Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+102
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Class which adds single mounting points to the current schedule by id
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 2017-04-06
|
||||
*/
|
||||
|
||||
#include "ism_dds_selector.h"
|
||||
|
||||
#include <LtsUtilsCore/dds_vector.h>
|
||||
#include <Plugins/InfrastructureManagement/Shared/ism_mounting_point.h>
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <QApplication>
|
||||
|
||||
using namespace InfrastructureManagement;
|
||||
|
||||
DdsSelector::DdsSelector(const std::shared_ptr<Interface::Dtc> &dtc, const std::shared_ptr<Interface::Ftc> &ftc, const std::shared_ptr<ForeignDataInterface> &ismDataIfc, LtsUtils::RequestHelper *requestHelper)
|
||||
: MountingPointSelector(dtc, ftc, ismDataIfc, requestHelper, getLogger(QStringLiteral("DdsSelector")))
|
||||
{
|
||||
}
|
||||
|
||||
void DdsSelector::addMountingPoints(const QVector<int32_t> &mountingPointIds, const QMap<int32_t, MountingPointState> &states, QWidget *parentWidget)
|
||||
{
|
||||
if (mountingPointIds.isEmpty())
|
||||
return;
|
||||
|
||||
Q_UNUSED(states)
|
||||
|
||||
std::vector<MountingPointPlan> modifyVec;
|
||||
modifyVec.reserve(mountingPointIds.size());
|
||||
|
||||
MainSchedule mainSchedule = m_ismDataIfc->mainSchedule(m_ismDataIfc->scheduleId());
|
||||
|
||||
MountingPointState mps = m_ismDataIfc->mountingPoint(mountingPointIds.first()).aimState();
|
||||
bool override = false;
|
||||
for (int32_t currentMountingPointId : mountingPointIds)
|
||||
{
|
||||
MountingPoint mountingPoint = m_ismDataIfc->mountingPoint(currentMountingPointId);
|
||||
|
||||
if (!mountingPoint.isValid())
|
||||
continue;
|
||||
|
||||
if (mountingPoint.aimState() == mps)
|
||||
continue;
|
||||
|
||||
LtsWidgets::Button resButton = LtsWidgets::LtsMessageDialog::showMessage(parentWidget,
|
||||
QApplication::translate("Ism::Selector", "Multiple selected components have different states.\nPlease select desired state"),
|
||||
QApplication::translate("Ism::Selector", "Inconsistent component state"),
|
||||
LtsWidgets::Behaviour::Modal,
|
||||
LtsWidgets::Button::Yes | LtsWidgets::Button::No | LtsWidgets::Button::Discard,
|
||||
{ {LtsWidgets::Button::Yes, QApplication::translate("Ism::Selector", "Equipped")},
|
||||
{LtsWidgets::Button::No, QApplication::translate("Ism::Selector", "Empty")},
|
||||
{LtsWidgets::Button::Discard, QApplication::translate("Ism::Selector", "Idle")}
|
||||
});
|
||||
switch(resButton)
|
||||
{
|
||||
case LtsWidgets::Button::Yes:
|
||||
mps = MountingPointState::Equipped;
|
||||
break;
|
||||
case LtsWidgets::Button::No:
|
||||
mps = MountingPointState::Empty;
|
||||
break;
|
||||
case LtsWidgets::Button::Discard:
|
||||
default:
|
||||
mps = MountingPointState::Idle;
|
||||
break;
|
||||
}
|
||||
override = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
for (int32_t currentMountingPointId : mountingPointIds)
|
||||
{
|
||||
MountingPoint mountingPoint = m_ismDataIfc->mountingPoint(currentMountingPointId);
|
||||
|
||||
if (!mountingPoint.isValid())
|
||||
continue;
|
||||
|
||||
MountingPointState aimState = override ? mps : mountingPoint.getNextMountingPointState(mountingPoint.aimState());
|
||||
|
||||
auto it = std::find_if(mainSchedule.elements().cbegin(), mainSchedule.elements().cend(), [currentMountingPointId](const MountingPointPlan &mpp){ return (mpp.structureElementId() == currentMountingPointId); });
|
||||
|
||||
if (it != mainSchedule.elements().cend())
|
||||
{
|
||||
if ((*it).mountingPointState() == aimState)
|
||||
continue;
|
||||
|
||||
MountingPointPlan mpp = (*it);
|
||||
mpp.mountingPointState() = aimState;
|
||||
modifyVec.push_back(mpp);
|
||||
}
|
||||
else if (aimState != MountingPointState::Idle)
|
||||
modifyVec.push_back(MountingPointPlan(currentMountingPointId,aimState));
|
||||
}
|
||||
|
||||
if (!modifyVec.empty())
|
||||
startModifyRequest(modifyVec);
|
||||
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Class which adds single mounting points to the current schedule by id
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 2017-04-06
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ism_selector.h"
|
||||
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
class DdsSelector
|
||||
: public MountingPointSelector
|
||||
{
|
||||
public:
|
||||
explicit DdsSelector(const std::shared_ptr<Interface::Dtc> &dtc, const std::shared_ptr<Interface::Ftc> &ftc, const std::shared_ptr<ForeignDataInterface> &ismDataIfc, LtsUtils::RequestHelper *requestHelper);
|
||||
|
||||
void addMountingPoints(const QVector<int32_t> &mountingPointIds, const QMap<int32_t, MountingPointState> &states, QWidget *parentWidget) override final;
|
||||
};
|
||||
|
||||
} // namespace InfrastructureManagement
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Abstract class which defines selection behavior when clicking on mounting points on the map
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 2017-04-05
|
||||
*/
|
||||
|
||||
#include "ism_selector.h"
|
||||
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
|
||||
MountingPointSelector::MountingPointSelector(const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ForeignDataInterface> &ismDataIfc,
|
||||
LtsUtils::RequestHelper *requestHelper,
|
||||
LOGGER_T logger)
|
||||
: m_ismDataIfc(ismDataIfc)
|
||||
, m_ftc(ftc)
|
||||
, m_dtc(dtc)
|
||||
, m_requestHelper(requestHelper)
|
||||
, m_logger(logger)
|
||||
{
|
||||
if (!m_ftc->enableMountingPointPlanModify())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable FT MountingPointPlanModify of ISM";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MountingPointSelector::onMountingPointPlanModifyReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
|
||||
if (replyObject.error())
|
||||
ERROR_LOG(m_logger) << "MountingPointPlansRemove error: "
|
||||
<< replyObject.str();
|
||||
else
|
||||
DEBUG_LOG(m_logger) << "MountingPointPlansRemove success";
|
||||
}
|
||||
|
||||
|
||||
void MountingPointSelector::startModifyRequest(const std::vector<MountingPointPlan> &data)
|
||||
{
|
||||
if (data.empty())
|
||||
return;
|
||||
MountingPointPlanModifyRequest req(m_ismDataIfc->scheduleId(), data);
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->mountingPointPlanModifyRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Lts/Plugins/InfrastructureManagement/Gui/ResourceManagement/MountingPointMapSelection/ism_selector.h
Executable
+47
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Abstract class which defines selection behavior when clicking on mounting points on the map
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 2017-04-05
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <InfrastructureManagement/ism_ftc.h>
|
||||
#include <InfrastructureManagement/logger.h>
|
||||
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
|
||||
#include <Plugins/InfrastructureManagement/ism_resource_management_gui_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
|
||||
namespace LtsUtils
|
||||
{
|
||||
class RequestHelper;
|
||||
}
|
||||
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
class MountingPointSelector
|
||||
: public Interface::Ftc::MountingPointPlanModifyReplyHandler
|
||||
{
|
||||
public:
|
||||
explicit MountingPointSelector(const std::shared_ptr<Interface::Dtc> &dtc, const std::shared_ptr<Interface::Ftc> &ftc, const std::shared_ptr<ForeignDataInterface> &ismDataIfc, LtsUtils::RequestHelper *requestHelper, LOGGER_T logger);
|
||||
virtual ~MountingPointSelector() = default;
|
||||
|
||||
virtual void addMountingPoints(const QVector<int32_t> &mountingPointIds, const QMap<int32_t, MountingPointState> &states, QWidget *parentWidget) = 0;
|
||||
|
||||
void onMountingPointPlanModifyReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
|
||||
protected: //methods
|
||||
void startModifyRequest(const std::vector<MountingPointPlan> &data);
|
||||
|
||||
protected: // attributes
|
||||
std::shared_ptr<ForeignDataInterface> m_ismDataIfc;
|
||||
std::shared_ptr<Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<Interface::Dtc> m_dtc;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
} // namespace InfrastructureManagement
|
||||
Reference in new issue
Block a user