Apply clang-format to Lts/Common and DTC/enum headers
- Formatted all CodeGen module files (9 files) - Formatted LtsAppDescriptor module files - Formatted LtsAppManager/AppChooser files - Applied clang-format to all DTC and enum headers across modules - Removed coordTransTests from CommonUnitTestsPlaceholder (moved to tests/) Cosmetic changes only, no functional modifications. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
848 files changed
+89305
-100020
No files matched your search
Executable → Regular
+203
-215
@@ -1,334 +1,322 @@
|
||||
|
||||
|
||||
|
||||
#include <CentralEffectSimulation/ces_data_plugin_interface.h>
|
||||
#include <AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <CentralEffectSimulation/ces_operator_rights.h>
|
||||
|
||||
#include "mission_plan_dialog.h"
|
||||
|
||||
#include "ui_mission_plan_dialog.h"
|
||||
|
||||
#include <AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <CentralEffectSimulation/ces_data_plugin_interface.h>
|
||||
#include <CentralEffectSimulation/ces_operator_rights.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
|
||||
namespace CentralEffectSimulation
|
||||
{
|
||||
MissionPlanDialog::MissionPlanDialog(const QString &menuGroup, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_ppmDtc(nullptr)
|
||||
, m_ppmFtc(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_session(nullptr)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_ui(new Ui::MissionPlanDialog)
|
||||
MissionPlanDialog::MissionPlanDialog(const QString& menuGroup, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_ppmDtc(nullptr), m_ppmFtc(nullptr),
|
||||
m_requestHelper(new LtsUtils::RequestHelper(this)), m_session(nullptr), m_menuGroup(menuGroup),
|
||||
m_ui(new Ui::MissionPlanDialog)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_updateMissionTimer.setSingleShot(true);
|
||||
m_updateMissionTimer.setInterval(500);
|
||||
connect(&m_updateMissionTimer, &QTimer::timeout, this, &MissionPlanDialog::enaDisa);
|
||||
m_updateMissionTimer.setSingleShot(true);
|
||||
m_updateMissionTimer.setInterval(500);
|
||||
connect(&m_updateMissionTimer, &QTimer::timeout, this, &MissionPlanDialog::enaDisa);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-UAS-Mission"));
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-UAS-Mission"));
|
||||
}
|
||||
|
||||
MissionPlanDialog::~MissionPlanDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool MissionPlanDialog::init(LtsSession::LtsSession *session)
|
||||
bool MissionPlanDialog::init(LtsSession::LtsSession* session)
|
||||
{
|
||||
m_session = session;
|
||||
m_session = session;
|
||||
|
||||
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << " failed to get ppmDtc";
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getFtc<ParticipantManagement::DataInterface>(m_ppmFtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << " failed to get ppmFtc";
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << " failed to get ppmDtc";
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getFtc<ParticipantManagement::DataInterface>(m_ppmFtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << " failed to get ppmFtc";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_ppmDtc->enableUnitPosition();
|
||||
m_ppmDtc->waitForHistoricalDataUnitPosition(1000);
|
||||
m_ppmDtc->enableUnitPosition();
|
||||
m_ppmDtc->waitForHistoricalDataUnitPosition(1000);
|
||||
|
||||
delete m_missionPlanModel;
|
||||
m_missionPlanModel = new MissionPlanModel(this);
|
||||
m_missionPlanModel->initModel(m_ppmDtc, m_session->exerciseId());
|
||||
|
||||
delete m_missionPlanModel;
|
||||
m_missionPlanModel = new MissionPlanModel(this);
|
||||
m_missionPlanModel->initModel(m_ppmDtc, m_session->exerciseId());
|
||||
m_missionPlanProxyModel = new MissionPlanProxyModel(this);
|
||||
m_missionPlanProxyModel->setSourceModel(m_missionPlanModel);
|
||||
m_ui->participantsDataView->setModel(m_missionPlanProxyModel);
|
||||
|
||||
m_missionPlanProxyModel = new MissionPlanProxyModel(this);
|
||||
m_missionPlanProxyModel->setSourceModel(m_missionPlanModel);
|
||||
m_ui->participantsDataView->setModel(m_missionPlanProxyModel);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Load, this, &MissionPlanDialog::onLockModifications);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Load, false);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Load)->setText(tr("Lock"));
|
||||
m_buttonBox->setIcon(LtsWidgets::DialogButton::Load, QIcon(QStringLiteral("icon:drone_remote_connection.svg")));
|
||||
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Load)->hide();
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Save, this, &MissionPlanDialog::onUnlockModifications);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Save, false);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->setText(tr("Unlock"));
|
||||
m_buttonBox->setIcon(LtsWidgets::DialogButton::Save, QIcon(QStringLiteral("icon:drone_remote_connection.svg")));
|
||||
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->hide();
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Load, this, &MissionPlanDialog::onLockModifications);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Load, false);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Load)->setText(tr("Lock"));
|
||||
m_buttonBox->setIcon(LtsWidgets::DialogButton::Load, QIcon(QStringLiteral("icon:drone_remote_connection.svg")));
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &MissionPlanDialog::onAddMissionPlan);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, true);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Load)->hide();
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &MissionPlanDialog::onEditMissionPlan);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Save, this, &MissionPlanDialog::onUnlockModifications);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Save, false);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->setText(tr("Unlock"));
|
||||
m_buttonBox->setIcon(LtsWidgets::DialogButton::Save, QIcon(QStringLiteral("icon:drone_remote_connection.svg")));
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &MissionPlanDialog::onRemoveMissionPlanClicked);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->hide();
|
||||
|
||||
connect(m_ui->participantsDataView, &LtsDataView::LtsDataView::signalSelectionChanged, this, &MissionPlanDialog::enaDisa);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &MissionPlanDialog::onAddMissionPlan);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, true);
|
||||
|
||||
const bool &hasOperatorRightParticipantUAS = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::ParticipantMove);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setVisible(hasOperatorRightParticipantUAS);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Add)->setVisible(hasOperatorRightParticipantUAS);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &MissionPlanDialog::onEditMissionPlan);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
|
||||
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::missionPlanChanged,
|
||||
this, &MissionPlanDialog::onMissionPlanChanged);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &MissionPlanDialog::onRemoveMissionPlanClicked);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
connect(m_ui->participantsDataView, &LtsDataView::LtsDataView::doubleClicked, this, &MissionPlanDialog::onEditMissionPlan);
|
||||
connect(m_ui->participantsDataView, &LtsDataView::LtsDataView::signalSelectionChanged, this,
|
||||
&MissionPlanDialog::enaDisa);
|
||||
|
||||
return true;
|
||||
const bool& hasOperatorRightParticipantUAS =
|
||||
LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::ParticipantMove);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setVisible(hasOperatorRightParticipantUAS);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Add)->setVisible(hasOperatorRightParticipantUAS);
|
||||
|
||||
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::missionPlanChanged, this,
|
||||
&MissionPlanDialog::onMissionPlanChanged);
|
||||
|
||||
connect(m_ui->participantsDataView, &LtsDataView::LtsDataView::doubleClicked, this,
|
||||
&MissionPlanDialog::onEditMissionPlan);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MissionPlanDialog::onModifyMissionPlanReply(const Core::FunctionReplyObject &replyObject)
|
||||
void MissionPlanDialog::onModifyMissionPlanReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void MissionPlanDialog::onRemoveMissionPlanReply(const Core::FunctionReplyObject &replyObject)
|
||||
void MissionPlanDialog::onRemoveMissionPlanReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void MissionPlanDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("UAS Mission Plans"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setText(tr("Edit"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Remove)->setText(tr("Delete"));
|
||||
translate(m_ui, tr("UAS Mission Plans"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setText(tr("Edit"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Remove)->setText(tr("Delete"));
|
||||
}
|
||||
|
||||
bool MissionPlanDialog::removeMissionPlan(int32_t missionplanId)
|
||||
{
|
||||
if (missionplanId <= 0)
|
||||
return false;
|
||||
if (missionplanId <= 0)
|
||||
return false;
|
||||
|
||||
ParticipantManagement::RemoveMissionPlanRequest req(missionplanId);
|
||||
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ppmFtc->removeMissionPlanRequest(req, this);
|
||||
});
|
||||
return m_requestHelper->startRequests();
|
||||
ParticipantManagement::RemoveMissionPlanRequest req(missionplanId);
|
||||
|
||||
m_requestHelper->startSingleRequest([req, this]() { return m_ppmFtc->removeMissionPlanRequest(req, this); });
|
||||
return m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
MissionPlanDialog::WayPointsStatus MissionPlanDialog::wayPointCurrentStatus(const ParticipantManagement::MissionPlan &mp) const
|
||||
MissionPlanDialog::WayPointsStatus
|
||||
MissionPlanDialog::wayPointCurrentStatus(const ParticipantManagement::MissionPlan& mp) const
|
||||
{
|
||||
WayPointsStatus state = WayPointsStatus::Undefined;
|
||||
|
||||
if (mp.missionStart() > m_session->partitionTime())
|
||||
return WayPointsStatus::Prepared;
|
||||
else if (mp.itemsFulfilled() != static_cast<int32_t>(mp.items().size()))
|
||||
return WayPointsStatus::Active;
|
||||
else if (mp.itemsFulfilled() == static_cast<int32_t>(mp.items().size()))
|
||||
return WayPointsStatus::Expired;
|
||||
WayPointsStatus state = WayPointsStatus::Undefined;
|
||||
|
||||
|
||||
WARNING_LOG(m_logger)<<" -- Status Wegpunktkette Abgebrochen muss definiert werden";
|
||||
if (mp.missionStart() > m_session->partitionTime())
|
||||
return WayPointsStatus::Prepared;
|
||||
else if (mp.itemsFulfilled() != static_cast<int32_t>(mp.items().size()))
|
||||
return WayPointsStatus::Active;
|
||||
else if (mp.itemsFulfilled() == static_cast<int32_t>(mp.items().size()))
|
||||
return WayPointsStatus::Expired;
|
||||
|
||||
return state;
|
||||
WARNING_LOG(m_logger) << " -- Status Wegpunktkette Abgebrochen muss definiert werden";
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
bool MissionPlanDialog::canBeLocked() const
|
||||
{
|
||||
auto missionPlan = currentMissionPlan();
|
||||
if (missionPlan.id()<= 0)
|
||||
auto missionPlan = currentMissionPlan();
|
||||
if (missionPlan.id() <= 0)
|
||||
return false;
|
||||
|
||||
const auto wpStatus = wayPointCurrentStatus(missionPlan);
|
||||
const auto uas = m_ppmDtc->getUasByParticipantId(missionPlan.participantId(), m_session->exerciseId());
|
||||
|
||||
if (uas.uasState() == ProjectDataManagement::UasState_def::Manual || wpStatus == WayPointsStatus::Active)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
const auto wpStatus = wayPointCurrentStatus(missionPlan);
|
||||
const auto uas = m_ppmDtc->getUasByParticipantId(missionPlan.participantId(), m_session->exerciseId());
|
||||
|
||||
if (uas.uasState() == ProjectDataManagement::UasState_def::Manual
|
||||
|| wpStatus == WayPointsStatus::Active )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MissionPlanDialog::canBeUnlocked() const
|
||||
{
|
||||
auto missionPlan = currentMissionPlan();
|
||||
if (missionPlan.id()<= 0)
|
||||
auto missionPlan = currentMissionPlan();
|
||||
if (missionPlan.id() <= 0)
|
||||
return false;
|
||||
if (missionPlan.aborted())
|
||||
return false;
|
||||
|
||||
const auto wpStatus = wayPointCurrentStatus(missionPlan);
|
||||
const auto uas = m_ppmDtc->getUasByParticipantId(missionPlan.participantId(), m_session->exerciseId());
|
||||
|
||||
if (uas.uasState() == ProjectDataManagement::UasState_def::Manual || wpStatus != WayPointsStatus::Active)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
if (missionPlan.aborted())
|
||||
return false;
|
||||
|
||||
const auto wpStatus = wayPointCurrentStatus(missionPlan);
|
||||
const auto uas = m_ppmDtc->getUasByParticipantId(missionPlan.participantId(), m_session->exerciseId());
|
||||
|
||||
if ( uas.uasState() == ProjectDataManagement::UasState_def::Manual
|
||||
|| wpStatus != WayPointsStatus::Active)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
MissionPlanEdit *MissionPlanDialog::currentMissionPlanEditor() const
|
||||
MissionPlanEdit* MissionPlanDialog::currentMissionPlanEditor() const
|
||||
{
|
||||
QModelIndexList indexList = m_ui->participantsDataView->selectedRows();
|
||||
if (indexList.isEmpty())
|
||||
return nullptr;
|
||||
QModelIndexList indexList = m_ui->participantsDataView->selectedRows();
|
||||
if (indexList.isEmpty())
|
||||
return nullptr;
|
||||
|
||||
const ParticipantManagement::MissionPlan mp = m_missionPlanModel->getRowData(indexList.front().row());
|
||||
if (mp.id() < 0)
|
||||
return nullptr;
|
||||
const ParticipantManagement::MissionPlan mp = m_missionPlanModel->getRowData(indexList.front().row());
|
||||
if (mp.id() < 0)
|
||||
return nullptr;
|
||||
|
||||
return m_participantUasEditMap.value(mp.participantId(), nullptr);
|
||||
return m_participantUasEditMap.value(mp.participantId(), nullptr);
|
||||
}
|
||||
|
||||
ParticipantManagement::MissionPlan MissionPlanDialog::currentMissionPlan() const
|
||||
{
|
||||
QModelIndexList indexList = m_ui->participantsDataView->selectedRows();
|
||||
if (indexList.isEmpty())
|
||||
return {};
|
||||
QModelIndexList indexList = m_ui->participantsDataView->selectedRows();
|
||||
if (indexList.isEmpty())
|
||||
return {};
|
||||
|
||||
return m_missionPlanModel->getRowData(indexList.front().row());
|
||||
return m_missionPlanModel->getRowData(indexList.front().row());
|
||||
}
|
||||
|
||||
void MissionPlanDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->participantsDataView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->participantsDataView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
void MissionPlanDialog::enaDisa()
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Save, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Load, false);
|
||||
QModelIndexList indexList = m_ui->participantsDataView->selectedRows();
|
||||
bool bOk = !indexList.isEmpty();
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Save, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Load, false);
|
||||
QModelIndexList indexList = m_ui->participantsDataView->selectedRows();
|
||||
bool bOk = !indexList.isEmpty();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, bOk);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, bOk);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Save, bOk && canBeLocked());
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Load, bOk && canBeUnlocked());
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, bOk);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, bOk);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Save, bOk && canBeLocked());
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Load, bOk && canBeUnlocked());
|
||||
}
|
||||
|
||||
void MissionPlanDialog::onUnlockModifications()
|
||||
{
|
||||
auto dialog = currentMissionPlanEditor();
|
||||
if (!dialog)
|
||||
return;
|
||||
auto dialog = currentMissionPlanEditor();
|
||||
if (!dialog)
|
||||
return;
|
||||
|
||||
if (canBeUnlocked())
|
||||
dialog->setAllUiElementsEnabled(true);
|
||||
else
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Cannot unlock selected Mission Plan:\n mission plan still activ"));
|
||||
if (canBeUnlocked())
|
||||
dialog->setAllUiElementsEnabled(true);
|
||||
else
|
||||
LtsWidgets::LtsMessageDialog::showMessage(
|
||||
this, tr("Cannot unlock selected Mission Plan:\n mission plan still activ"));
|
||||
}
|
||||
|
||||
void MissionPlanDialog::onLockModifications()
|
||||
{
|
||||
auto dialog = currentMissionPlanEditor();
|
||||
if (!dialog)
|
||||
return;
|
||||
|
||||
if (canBeLocked())
|
||||
dialog->setAllUiElementsEnabled(false);
|
||||
else {
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Cannot Lock selected Mission Plan."));
|
||||
}
|
||||
auto dialog = currentMissionPlanEditor();
|
||||
if (!dialog)
|
||||
return;
|
||||
|
||||
if (canBeLocked())
|
||||
dialog->setAllUiElementsEnabled(false);
|
||||
else
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Cannot Lock selected Mission Plan."));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MissionPlanDialog::onAddMissionPlan()
|
||||
{
|
||||
static QString newMissionPlanIdentifier(QStringLiteral("NewMissionPlan"));
|
||||
static QString newMissionPlanIdentifier(QStringLiteral("NewMissionPlan"));
|
||||
|
||||
|
||||
const QModelIndexList indexList = m_ui->participantsDataView->selectedRows();
|
||||
if (indexList.isEmpty())
|
||||
{
|
||||
addDialog(LtsWidgets::initDialog(new MissionPlanEdit(this), 0, m_session),
|
||||
m_menuGroup, newMissionPlanIdentifier, LtsWidgets::LayoutArea::eDialogTab);
|
||||
return;
|
||||
}
|
||||
const QModelIndexList indexList = m_ui->participantsDataView->selectedRows();
|
||||
if (indexList.isEmpty())
|
||||
{
|
||||
addDialog(LtsWidgets::initDialog(new MissionPlanEdit(this), 0, m_session), m_menuGroup,
|
||||
newMissionPlanIdentifier, LtsWidgets::LayoutArea::eDialogTab);
|
||||
return;
|
||||
}
|
||||
|
||||
const ParticipantManagement::MissionPlan mp = m_missionPlanModel->getRowData(indexList.front().row());
|
||||
if (mp.id() <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
const ParticipantManagement::MissionPlan mp = m_missionPlanModel->getRowData(indexList.front().row());
|
||||
if (mp.id() <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
addDialog(LtsWidgets::initDialog(new MissionPlanEdit(this), mp.id(), m_session, true ),
|
||||
m_menuGroup, newMissionPlanIdentifier, LtsWidgets::LayoutArea::eDialogTab);
|
||||
addDialog(LtsWidgets::initDialog(new MissionPlanEdit(this), mp.id(), m_session, true), m_menuGroup,
|
||||
newMissionPlanIdentifier, LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void MissionPlanDialog::onRemoveMissionPlanClicked()
|
||||
{
|
||||
const QModelIndexList indexList = m_ui->participantsDataView->selectedRows();
|
||||
const bool isOne = (indexList.size() == 1);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, isOne);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
const QModelIndexList indexList = m_ui->participantsDataView->selectedRows();
|
||||
const bool isOne = (indexList.size() == 1);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, isOne);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
if (!isOne)
|
||||
return;
|
||||
const ParticipantManagement::MissionPlan mp = m_missionPlanModel->getRowData(indexList.front().row());
|
||||
if (!isOne)
|
||||
return;
|
||||
const ParticipantManagement::MissionPlan mp = m_missionPlanModel->getRowData(indexList.front().row());
|
||||
|
||||
delete m_participantUasEditMap.value(mp.id());
|
||||
m_participantUasEditMap.remove(mp.id());
|
||||
removeMissionPlan(mp.id());
|
||||
delete m_participantUasEditMap.value(mp.id());
|
||||
m_participantUasEditMap.remove(mp.id());
|
||||
removeMissionPlan(mp.id());
|
||||
}
|
||||
|
||||
void MissionPlanDialog::onEditMissionPlan()
|
||||
{
|
||||
QModelIndexList indexList = m_ui->participantsDataView->selectedRows();
|
||||
if (indexList.isEmpty())
|
||||
return;
|
||||
QModelIndexList indexList = m_ui->participantsDataView->selectedRows();
|
||||
if (indexList.isEmpty())
|
||||
return;
|
||||
|
||||
const ParticipantManagement::MissionPlan mp = m_missionPlanModel->getRowData(indexList.front().row());
|
||||
if (mp.id() <= 0)
|
||||
return;
|
||||
const ParticipantManagement::MissionPlan mp = m_missionPlanModel->getRowData(indexList.front().row());
|
||||
if (mp.id() <= 0)
|
||||
return;
|
||||
|
||||
const QString dialogIdentifier = QStringLiteral("Edit-MissionPlan_%1").arg(mp.id());
|
||||
|
||||
if (!m_participantUasEditMap.contains(mp.participantId()))
|
||||
{
|
||||
MissionPlanEdit *dialog = new MissionPlanEdit(this);
|
||||
m_participantUasEditMap.insert(mp.participantId(), dialog);
|
||||
connect(dialog, &MissionPlanEdit::editUasDialogClosed, this, &MissionPlanDialog::onEditDialogClosed);
|
||||
addDialog(LtsWidgets::initDialog(dialog, mp.id(), m_session)
|
||||
, m_menuGroup
|
||||
, dialogIdentifier
|
||||
, LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
else
|
||||
focusDialog(m_menuGroup, dialogIdentifier, LtsWidgets::LayoutArea::eDialogTab);
|
||||
const QString dialogIdentifier = QStringLiteral("Edit-MissionPlan_%1").arg(mp.id());
|
||||
|
||||
if (!m_participantUasEditMap.contains(mp.participantId()))
|
||||
{
|
||||
MissionPlanEdit* dialog = new MissionPlanEdit(this);
|
||||
m_participantUasEditMap.insert(mp.participantId(), dialog);
|
||||
connect(dialog, &MissionPlanEdit::editUasDialogClosed, this, &MissionPlanDialog::onEditDialogClosed);
|
||||
addDialog(LtsWidgets::initDialog(dialog, mp.id(), m_session), m_menuGroup, dialogIdentifier,
|
||||
LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
else
|
||||
focusDialog(m_menuGroup, dialogIdentifier, LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void MissionPlanDialog::onEditDialogClosed(const int participantId)
|
||||
{
|
||||
m_participantUasEditMap.remove(participantId);
|
||||
m_participantUasEditMap.remove(participantId);
|
||||
}
|
||||
|
||||
void MissionPlanDialog::onMissionPlanChanged(const ParticipantManagement::MissionPlan &data, const DataModification modType)
|
||||
void MissionPlanDialog::onMissionPlanChanged(const ParticipantManagement::MissionPlan& data,
|
||||
const DataModification modType)
|
||||
{
|
||||
Q_UNUSED(data)
|
||||
Q_UNUSED(modType)
|
||||
m_updateMissionTimer.start();
|
||||
Q_UNUSED(data)
|
||||
Q_UNUSED(modType)
|
||||
m_updateMissionTimer.start();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace CentralEffectSimulation
|
||||
Executable → Regular
+555
-614
File diff suppressed because it is too large.
Load diff
Executable → Regular
+116
-157
@@ -1,205 +1,164 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <ProjectDataManagement/pdm_translation.h>
|
||||
|
||||
#include "mission_plan_model.h"
|
||||
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <ProjectDataManagement/pdm_translation.h>
|
||||
|
||||
namespace CentralEffectSimulation
|
||||
{
|
||||
|
||||
|
||||
MissionPlanModel::MissionPlanModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<ParticipantManagement::MissionPlan>(
|
||||
{tr("Name"),
|
||||
tr("Mission Start"),
|
||||
tr("Actions [fulfilled / Count]"),
|
||||
tr("Fulfilled"),
|
||||
tr("Participant"),
|
||||
tr("UAS State"),
|
||||
tr("Current Mission"),
|
||||
tr("Aborted")},
|
||||
parent)
|
||||
, m_ppmDtc(nullptr)
|
||||
MissionPlanModel::MissionPlanModel(QObject* parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<ParticipantManagement::MissionPlan>(
|
||||
{tr("Name"), tr("Mission Start"), tr("Actions [fulfilled / Count]"), tr("Fulfilled"), tr("Participant"),
|
||||
tr("UAS State"), tr("Current Mission"), tr("Aborted")},
|
||||
parent),
|
||||
m_ppmDtc(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
QVariant MissionPlanModel::data(const QModelIndex &index, int role) const
|
||||
QVariant MissionPlanModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const ParticipantManagement::MissionPlan &mp = m_vecData.at(index.row());
|
||||
switch (index.column())
|
||||
{
|
||||
|
||||
case Columns::Name:
|
||||
return QString::fromStdString(mp.name());
|
||||
case Columns::MissionStart:
|
||||
return QDateTime::fromMSecsSinceEpoch(mp.missionStart());
|
||||
case Columns::Fulfilled:
|
||||
return QDateTime::fromMSecsSinceEpoch(mp.fulfilled());
|
||||
case Columns::ItemsCountAndFulfilled:
|
||||
{
|
||||
int actionsFulfilled = 0;
|
||||
int actionsCount = 0;
|
||||
for (const auto &item : mp.items())
|
||||
const ParticipantManagement::MissionPlan& mp = m_vecData.at(index.row());
|
||||
switch (index.column())
|
||||
{
|
||||
actionsFulfilled += item.actionsFulfilled();
|
||||
actionsCount += item.actions().size();
|
||||
|
||||
case Columns::Name:
|
||||
return QString::fromStdString(mp.name());
|
||||
case Columns::MissionStart:
|
||||
return QDateTime::fromMSecsSinceEpoch(mp.missionStart());
|
||||
case Columns::Fulfilled:
|
||||
return QDateTime::fromMSecsSinceEpoch(mp.fulfilled());
|
||||
case Columns::ItemsCountAndFulfilled: {
|
||||
int actionsFulfilled = 0;
|
||||
int actionsCount = 0;
|
||||
for (const auto& item : mp.items())
|
||||
{
|
||||
actionsFulfilled += item.actionsFulfilled();
|
||||
actionsCount += item.actions().size();
|
||||
}
|
||||
return QStringLiteral("%1/%2").arg(actionsFulfilled).arg(actionsCount);
|
||||
}
|
||||
case Columns::Participant: {
|
||||
const auto& participant = m_ppmDtc->participant(mp.participantId());
|
||||
return QString::number(mp.participantId());
|
||||
}
|
||||
case Columns::UasState: {
|
||||
const auto& uas = m_ppmDtc->getUasByParticipantId(mp.participantId(), m_exerciseId);
|
||||
return ProjectDataManagement::toString(uas.uasState());
|
||||
}
|
||||
case Columns::CurrentMission: {
|
||||
return currentJob2String(mp);
|
||||
}
|
||||
case Columns::Aborted: {
|
||||
return mp.aborted();
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QStringLiteral("%1/%2").arg(actionsFulfilled).arg(actionsCount);
|
||||
}
|
||||
case Columns::Participant:
|
||||
{
|
||||
const auto &participant = m_ppmDtc->participant(mp.participantId());
|
||||
return QString::number(mp.participantId());
|
||||
}
|
||||
case Columns::UasState:
|
||||
{
|
||||
const auto &uas = m_ppmDtc->getUasByParticipantId(mp.participantId(), m_exerciseId);
|
||||
return ProjectDataManagement::toString(uas.uasState());
|
||||
}
|
||||
case Columns::CurrentMission:
|
||||
{
|
||||
return currentJob2String(mp);
|
||||
}
|
||||
case Columns::Aborted:
|
||||
{
|
||||
return mp.aborted();
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool MissionPlanModel::initModel(const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc, int exerciseId)
|
||||
bool MissionPlanModel::initModel(const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc, int exerciseId)
|
||||
{
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_ppmDtc->enableMissionPlan(true);
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_ppmDtc->enableMissionPlan(true);
|
||||
|
||||
m_exerciseId = exerciseId;
|
||||
m_exerciseId = exerciseId;
|
||||
|
||||
if (!m_ppmDtc->isUASEnabled())
|
||||
m_ppmDtc->enableUAS();
|
||||
if (!m_ppmDtc->isUASEnabled())
|
||||
m_ppmDtc->enableUAS();
|
||||
|
||||
m_ppmDtc->waitForHistoricalDataUAS(1000);
|
||||
m_ppmDtc->waitForHistoricalDataUAS(1000);
|
||||
|
||||
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::missionPlanChanged,
|
||||
this, &MissionPlanModel::onMissionPlanChanged);
|
||||
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::missionPlanChanged, this,
|
||||
&MissionPlanModel::onMissionPlanChanged);
|
||||
|
||||
auto cb = [this](const ParticipantManagement::MissionPlan &msp)
|
||||
{
|
||||
onMissionPlanChanged(msp, DataModification::eAdded);
|
||||
};
|
||||
m_ppmDtc->missionPlans(cb);
|
||||
auto cb = [this](const ParticipantManagement::MissionPlan& msp) {
|
||||
onMissionPlanChanged(msp, DataModification::eAdded);
|
||||
};
|
||||
m_ppmDtc->missionPlans(cb);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
QString MissionPlanModel::currentJob2String(const ParticipantManagement::MissionPlan &missionPlan) const
|
||||
QString MissionPlanModel::currentJob2String(const ParticipantManagement::MissionPlan& missionPlan) const
|
||||
{
|
||||
|
||||
|
||||
ParticipantManagement::MissionAction currAction = m_ppmDtc->currentMissionAction(missionPlan.id());
|
||||
if (currAction.planId() == 0 ||
|
||||
static_cast<int>(missionPlan.items().size()) == missionPlan.itemsFulfilled())
|
||||
return tr(" Mission Complete ");
|
||||
|
||||
switch (currAction.actionType().underlying())
|
||||
{
|
||||
case ParticipantManagement::MissionActionType::MoveTo:
|
||||
{
|
||||
return tr("Move to WP %1").arg(currAction.itemNumber()+1);
|
||||
}
|
||||
case ParticipantManagement::MissionActionType::Loiter:
|
||||
{
|
||||
return tr("WP %1: Loiter %2 sec.").arg(currAction.itemNumber()+1).arg(currAction.duration());
|
||||
}
|
||||
case ParticipantManagement::MissionActionType::Attack:
|
||||
{
|
||||
return tr("WP %1: Drop Charge").arg(currAction.itemNumber()+1);
|
||||
}
|
||||
default:
|
||||
return tr("Unknown");
|
||||
}
|
||||
ParticipantManagement::MissionAction currAction = m_ppmDtc->currentMissionAction(missionPlan.id());
|
||||
if (currAction.planId() == 0 || static_cast<int>(missionPlan.items().size()) == missionPlan.itemsFulfilled())
|
||||
return tr(" Mission Complete ");
|
||||
|
||||
switch (currAction.actionType().underlying())
|
||||
{
|
||||
case ParticipantManagement::MissionActionType::MoveTo: {
|
||||
return tr("Move to WP %1").arg(currAction.itemNumber() + 1);
|
||||
}
|
||||
case ParticipantManagement::MissionActionType::Loiter: {
|
||||
return tr("WP %1: Loiter %2 sec.").arg(currAction.itemNumber() + 1).arg(currAction.duration());
|
||||
}
|
||||
case ParticipantManagement::MissionActionType::Attack: {
|
||||
return tr("WP %1: Drop Charge").arg(currAction.itemNumber() + 1);
|
||||
}
|
||||
default:
|
||||
return tr("Unknown");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MissionPlanModel::onMissionPlanChanged(const ParticipantManagement::MissionPlan &data, const DataModification modType)
|
||||
void MissionPlanModel::onMissionPlanChanged(const ParticipantManagement::MissionPlan& data,
|
||||
const DataModification modType)
|
||||
{
|
||||
const int id = data.id();
|
||||
int row = findRowForId(id);
|
||||
DEBUG_LOG(m_logger)<<"MISSION PLAN CHANGED id ( "<<data.id()<<" ) "<< modType;
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eModified:
|
||||
{
|
||||
if (row < 0)
|
||||
return;
|
||||
setRowData(row, data);
|
||||
break;
|
||||
}
|
||||
case DataModification::eAdded:
|
||||
{
|
||||
if (row != -1)
|
||||
return;
|
||||
else
|
||||
insertRow(data);
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved:
|
||||
removeRow(row);
|
||||
break;
|
||||
}
|
||||
const int id = data.id();
|
||||
int row = findRowForId(id);
|
||||
DEBUG_LOG(m_logger) << "MISSION PLAN CHANGED id ( " << data.id() << " ) " << modType;
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eModified: {
|
||||
if (row < 0)
|
||||
return;
|
||||
setRowData(row, data);
|
||||
break;
|
||||
}
|
||||
case DataModification::eAdded: {
|
||||
if (row != -1)
|
||||
return;
|
||||
else
|
||||
insertRow(data);
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved:
|
||||
removeRow(row);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void MissionPlanProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
|
||||
void MissionPlanProxyModel::setSourceModel(QAbstractItemModel* sourceModel)
|
||||
{
|
||||
m_sourceModel = qobject_cast<MissionPlanModel*>(sourceModel);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
|
||||
m_sourceModel = qobject_cast<MissionPlanModel*>(sourceModel);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MissionPlanProxyModel::setShowExpired(bool show)
|
||||
{
|
||||
m_showExpired = show;
|
||||
m_showExpired = show;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool MissionPlanProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||
bool MissionPlanProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
|
||||
{
|
||||
Q_UNUSED(sourceParent)
|
||||
return checkFilter(sourceRow);
|
||||
Q_UNUSED(sourceParent)
|
||||
return checkFilter(sourceRow);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool MissionPlanProxyModel::checkFilter(int sourceRow) const
|
||||
{
|
||||
Q_UNUSED(sourceRow)
|
||||
|
||||
return true;
|
||||
Q_UNUSED(sourceRow)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace CentralEffectSimulation
|
||||
Reference in new issue
Block a user