Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,46 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Hannes Fritsche, ESZS, 2025-05-16
|
||||
#
|
||||
|
||||
SET(uas_gui_SRCS
|
||||
ppm_uas_gui_plugin.cpp
|
||||
ppm_uas_gui_plugin.h
|
||||
ppm_uas_edit_dialog.cpp
|
||||
ppm_uas_edit_dialog.h
|
||||
ppm_uas_list_dialog.cpp
|
||||
ppm_uas_list_dialog.h
|
||||
ppm_uas_list_model.cpp
|
||||
ppm_uas_list_model.h
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(uas_gui_SRCS
|
||||
ppm_uas_edit_dialog.ui
|
||||
ppm_uas_list_dialog.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY2(WS PpmUasGuiPlugin MODULE ${uas_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(PpmUasGuiPlugin
|
||||
AsbDataPluginInterface
|
||||
AsbHelper
|
||||
svcExmCommon
|
||||
nglwidgets
|
||||
NGLLogger
|
||||
LtsPrinting
|
||||
PpmCommon
|
||||
FlmDataPluginInterface
|
||||
PpmGuiParticipantsPluginInterface
|
||||
PpmGuiComboboxPluginInterface
|
||||
PpmGuiTemplatesPluginInterface
|
||||
PpmDataPluginInterface
|
||||
LtsDataView
|
||||
LtsWidgets
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
LtsUtilsGuiDds
|
||||
LtsUtilsSettings
|
||||
svcCoreClient # Core Ftc - for TLH
|
||||
)
|
||||
|
||||
@@ -0,0 +1,243 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Dialog for Editing UASs
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Fritsche, ESZS, 2025-07-01
|
||||
*/
|
||||
|
||||
#include "ppm_uas_edit_dialog.h"
|
||||
#include "ui_ppm_uas_edit_dialog.h"
|
||||
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <ParticipantManagement/ppm_ftc.h>
|
||||
#include <ParticipantManagement/logger.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
//FLM
|
||||
#include <FileManagement/flm_data_plugin_interface.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
UasEditDialog::UasEditDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_ui(new Ui::UasEditDialog)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->pbUnlink, &QPushButton::clicked, this, &UasEditDialog::onUnlinkClicked);
|
||||
}
|
||||
|
||||
UasEditDialog::~UasEditDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void UasEditDialog::init(LtsSession::LtsSession *session, const UAS &data)
|
||||
{
|
||||
if (!session)
|
||||
return;
|
||||
m_session = session;
|
||||
if(!m_session->getFtc<DataInterface>(m_ppmFtc))
|
||||
return;
|
||||
|
||||
m_data = data;
|
||||
|
||||
if ( m_session->exerciseId() > 0)
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-UAS-Linking-Edit"));
|
||||
else
|
||||
setOnlineHelpFilename(QStringLiteral("Administrator-UAS-List-Edit"));
|
||||
|
||||
|
||||
|
||||
if (!m_ppmFtc->isCreateModifyUasEnabled())
|
||||
m_ppmFtc->enableCreateModifyUas();
|
||||
|
||||
m_session->getDtc<ExerciseManagement::DataInterface>(m_exmDtc);
|
||||
m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc);
|
||||
m_session->getDtc<FileManagement::DataInterface>(m_flmDtc);
|
||||
|
||||
if (m_session->isExercisePartition())
|
||||
{
|
||||
m_ui->lblPort->hide();
|
||||
m_ui->lePort->hide();
|
||||
m_ui->lblHost->hide();
|
||||
m_ui->leHost->hide();
|
||||
m_ui->leIdentifier->setEnabled(false);
|
||||
m_ui->pbUnlink->hide();
|
||||
m_ui->udpRadioBtn->hide();
|
||||
m_ui->tcpRadioBtn->hide();
|
||||
m_ui->connectionModeLabel->hide();
|
||||
|
||||
connect(m_ui->cbParticpant, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &UasEditDialog::onUAVParticipantChanged);
|
||||
}
|
||||
fillData();
|
||||
|
||||
}
|
||||
|
||||
QString UasEditDialog::dialogIdentifier() const
|
||||
{
|
||||
return m_data.id() <= 0 ? tr("Add UAS") : tr("Edit UAS %1").arg(m_data.id());
|
||||
}
|
||||
|
||||
|
||||
void UasEditDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("UAS Edit"));
|
||||
}
|
||||
|
||||
bool UasEditDialog::apply()
|
||||
{
|
||||
return sendData();
|
||||
}
|
||||
|
||||
void UasEditDialog::onCreateModifyUasReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
m_requestHelper->requestReply(reply);
|
||||
if (m_data.id() <= 0)
|
||||
return;
|
||||
|
||||
const auto &newData = m_ppmDtc->uAS(m_data.id());
|
||||
m_data = newData;
|
||||
fillData();
|
||||
|
||||
}
|
||||
|
||||
void UasEditDialog::fillParticipantCbx()
|
||||
{
|
||||
QSignalBlocker s(m_ui->cbParticpant);
|
||||
m_ui->cbParticpant->clear();
|
||||
m_ui->cbParticpant->insertItem(0, QStringLiteral("-"));
|
||||
//find uas Types that are not deleted
|
||||
QMap<int, Participant> part_map;
|
||||
for (const auto &part : m_ppmDtc->participants())
|
||||
{
|
||||
if (m_ppmDtc->isTypeUas(part.typeId()) && !part.isDeleted())
|
||||
{
|
||||
part_map.insert(part.id(), part);
|
||||
}
|
||||
}
|
||||
//then filter out used
|
||||
|
||||
for (const auto &uav : m_ppmDtc->uASs())
|
||||
{
|
||||
if (uav.exerciseId() == m_session->exerciseId() && uav.participantId() != m_data.participantId())
|
||||
{
|
||||
part_map.remove(uav.participantId());
|
||||
}
|
||||
|
||||
}
|
||||
//next fill cbx with color
|
||||
for (const auto &uavPart : part_map)
|
||||
{
|
||||
QPixmap pix = QPixmap(10,10);
|
||||
pix.fill(QColor::fromRgb(m_ppmDtc->party(uavPart.partyId()).color()));
|
||||
m_ui->cbParticpant->insertItem(uavPart.id(), pix, m_ppmDtc->hierarchyFromParticipant(uavPart.id()), uavPart.id());
|
||||
}
|
||||
}
|
||||
|
||||
void UasEditDialog::fillData()
|
||||
{
|
||||
|
||||
if (m_session->isExercisePartition())
|
||||
{
|
||||
if (!m_ppmDtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "No PPM DTC; No Participant Assignmend";
|
||||
}
|
||||
else
|
||||
{
|
||||
fillParticipantCbx();
|
||||
if (m_data.participantId() > 0)
|
||||
{
|
||||
m_ui->cbParticpant->setCurrentIndex(m_ui->cbParticpant->findData(m_data.participantId()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
QSignalBlocker s(m_ui->cbParticpant);
|
||||
m_ui->cbParticpant->clear();
|
||||
if(m_data.participantId() == 0 || m_data.exerciseId() == 0)
|
||||
{
|
||||
m_ui->cbParticpant->insertItem(0, QStringLiteral("-"));
|
||||
}
|
||||
else if (m_data.exerciseId() != m_session->exerciseId())
|
||||
{
|
||||
// we assume, that the exercise id is set, because the participant id is set
|
||||
|
||||
m_ui->cbParticpant->insertItem(0, tr("Participant from exercise %1").arg(QString::fromStdString(m_exmDtc->exercise(m_data.exerciseId()).name())));
|
||||
}
|
||||
m_ui->cbParticpant->setEnabled(false);
|
||||
}
|
||||
|
||||
m_ui->leIdentifier->setText(QString::fromStdString(m_data.deviceIdentifier()));
|
||||
m_ui->leHost->setText(QString::fromStdString(m_data.hostname()));
|
||||
m_ui->lePort->setText(QString::number(m_data.hostport()));
|
||||
m_ui->pbUnlink->setEnabled(m_data.exerciseId() > 0);
|
||||
|
||||
m_ui->tcpRadioBtn->setChecked(m_data.useTcp());
|
||||
m_ui->udpRadioBtn->setChecked(!m_data.useTcp());
|
||||
|
||||
}
|
||||
|
||||
bool UasEditDialog::sendData()
|
||||
{
|
||||
CreateModifyUasRequest req;
|
||||
req.id(m_data.id());
|
||||
req.deviceIdentifier(m_ui->leIdentifier->text().toStdString());
|
||||
req.participantId(m_data.participantId());
|
||||
req.exerciseId(m_data.exerciseId());
|
||||
req.hostname(m_ui->leHost->text().toStdString());
|
||||
req.hostport(m_ui->lePort->text().toInt());
|
||||
req.useTcp(m_ui->tcpRadioBtn->isChecked());
|
||||
|
||||
m_requestHelper->addRequest([this, req]()
|
||||
{
|
||||
return m_ppmFtc->createModifyUasRequest(req, this);
|
||||
});
|
||||
|
||||
return m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
void UasEditDialog::onUnlinkClicked()
|
||||
{
|
||||
int ret = QMessageBox::warning(this, tr("Unlink UAS"),
|
||||
tr("Do you really want to unlink selected uas?"),
|
||||
QMessageBox::Yes | QMessageBox::Cancel);
|
||||
if(ret == QMessageBox::Yes)
|
||||
{
|
||||
m_data.exerciseId() = 0;
|
||||
m_data.participantId() = 0;
|
||||
sendData();
|
||||
}
|
||||
}
|
||||
|
||||
void UasEditDialog::onUAVParticipantChanged()
|
||||
{
|
||||
if (m_ui->cbParticpant->currentData().toInt() > 0)
|
||||
{
|
||||
m_data.exerciseId() = m_session->exerciseId();
|
||||
m_data.participantId() = m_ui->cbParticpant->currentData().toInt();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_data.exerciseId() = 0;
|
||||
m_data.participantId() = 0;
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace ParticipantManagement
|
||||
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Dialog for Editing UASs
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Fritsche, ESZS, 2025-07-01
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <ParticipantManagement/ppm_ftc.h>
|
||||
//EXM
|
||||
#include <ExerciseManagement/exm_data_plugin_interface.h>
|
||||
//FLM
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
#include <FileManagement/flm_dtc.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class UasEditDialog;
|
||||
}
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace LtsUtils
|
||||
{
|
||||
class RequestHelper;
|
||||
}
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Ftc;
|
||||
class Dtc;
|
||||
}
|
||||
|
||||
|
||||
class UasEditDialog
|
||||
: public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::CreateModifyUasReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
using BaseClass = LtsWidgets::LtsDialog;
|
||||
|
||||
public:
|
||||
UasEditDialog(QWidget *parent = nullptr);
|
||||
~UasEditDialog();
|
||||
|
||||
void init(LtsSession::LtsSession *session, const UAS &data = UAS());
|
||||
|
||||
QString dialogIdentifier() const;
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
bool apply() override;
|
||||
void onCreateModifyUasReply(const Core::FunctionReplyObject &reply) override;
|
||||
void fillParticipantCbx();
|
||||
void fillData();
|
||||
bool sendData();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onUnlinkClicked();
|
||||
void onUAVParticipantChanged();
|
||||
|
||||
private:
|
||||
Ui::UasEditDialog *m_ui;
|
||||
LtsSession::LtsSession *m_session {nullptr};
|
||||
std::shared_ptr<Interface::Ftc> m_ppmFtc;
|
||||
std::shared_ptr<Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_exmDtc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
std::shared_ptr<FileManagement::Interface::Dtc> m_flmDtc;
|
||||
UAS m_data;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
|
||||
};
|
||||
|
||||
} //ParticipantManagement
|
||||
@@ -0,0 +1,162 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>UasEditDialog</class>
|
||||
<widget class="QWidget" name="UasEditDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1128</width>
|
||||
<height>224</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Aes Danger Area Edit</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblIdentifier">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Identifier:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lblHost">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Host:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Participant</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="cbParticpant"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="leHost"/>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="pbUnlink">
|
||||
<property name="text">
|
||||
<string>Unlink</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="leIdentifier">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="lePort"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lblPort">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Port:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="connectionModeLabel">
|
||||
<property name="text">
|
||||
<string>Connection Mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="udpRadioBtn">
|
||||
<property name="text">
|
||||
<string>UDP</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="tcpRadioBtn">
|
||||
<property name="text">
|
||||
<string>TCP</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>leIdentifier</tabstop>
|
||||
<tabstop>leHost</tabstop>
|
||||
<tabstop>lePort</tabstop>
|
||||
<tabstop>cbParticpant</tabstop>
|
||||
<tabstop>pbUnlink</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for ParticipantManagement - UAS
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Fritsche, ESZS, 2025-05-16
|
||||
*/
|
||||
|
||||
#include "ppm_uas_gui_plugin.h"
|
||||
|
||||
#include <ParticipantManagement/ppm_operator_rights.h>
|
||||
|
||||
#include <Plugins/AdvancedSymbology/asb_data_plugin_interface.h>
|
||||
#include <Plugins/ExerciseManagement/exm_data_plugin_interface.h>
|
||||
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include "ppm_uas_list_dialog.h"
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
std::shared_ptr<GuiPluginBase::Interface> GuiPlugin::createGuiInterface(LtsSession::LtsSession *session)
|
||||
{
|
||||
return std::make_shared<InterfaceImpl>(session);
|
||||
}
|
||||
|
||||
InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session)
|
||||
: GuiPluginBase::Interface(session, getLogger("Plugins.Gui.Ppm.Uas"))
|
||||
, m_ppmDtc(nullptr)
|
||||
, m_ppmFtc(nullptr)
|
||||
, m_exmDtc(nullptr)
|
||||
{}
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
|
||||
LtsWidgets::PluginData pluginData;
|
||||
|
||||
pluginData.menuGroup = menuGroup();
|
||||
pluginData.layoutArea = LtsWidgets::LayoutArea::eDialogTab;
|
||||
if (m_session->exerciseId() > 0)
|
||||
pluginData.menuText = tr("UAS Linking");
|
||||
else
|
||||
pluginData.menuText = tr("UAS");
|
||||
pluginData.identifier = QStringLiteral("uasListDialog");
|
||||
pluginData.menuIcon = QIcon(QLatin1String("icon:uas_administration.svg"));
|
||||
pluginData.createWidgetFunc = [this](QWidget *parent) { return onUasListDialog(parent); };
|
||||
pluginData.operatorRight = OperatorRights::Uas::EditAndLinkUas;
|
||||
pluginData.exercisePart = LtsWidgets::ExercisePart::ePlanning;
|
||||
pluginData.exerciseStates = LtsWidgets::ExcState::eCreated | LtsWidgets::ExcState::eStarted | LtsWidgets::ExcState::ePaused;
|
||||
ret.append(pluginData);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString InterfaceImpl::menuGroup() const
|
||||
{
|
||||
return tr("Air Support");
|
||||
}
|
||||
|
||||
bool InterfaceImpl::fetchInterfaces()
|
||||
{
|
||||
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
return false;
|
||||
if (!m_session->getFtc<ParticipantManagement::DataInterface>(m_ppmFtc))
|
||||
return false;
|
||||
if (!m_session->getDtc<ExerciseManagement::DataInterface>(m_exmDtc))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void InterfaceImpl::clearInterfaces()
|
||||
{
|
||||
m_ppmDtc = nullptr;
|
||||
m_ppmFtc = nullptr;
|
||||
m_exmDtc = nullptr;
|
||||
}
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onUasListDialog(QWidget *parent)
|
||||
{
|
||||
return LtsWidgets::initDialog(new UasListDialog(m_session, parent));
|
||||
}
|
||||
|
||||
} // namespace ParticipantManagement
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for ParticipantManagement - UAS
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Fritsche, ESZS, 2025-05-16
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ParticipantManagement/logger.h>
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_participants_gui_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
|
||||
namespace ExerciseManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:ppm.uas")
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return QStringLiteral("ParticipantManagement.GuiPlugin.uas"); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return (partition == IDL::PartitionType::Global || partition == IDL::PartitionType::Exercise);
|
||||
}
|
||||
}; // class GuiPlugin
|
||||
|
||||
class InterfaceImpl final : public QObject, public ForeignGuiParticipantsInterface, public GuiPluginBase::Interface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
bool fetchInterfaces() override;
|
||||
void clearInterfaces() override;
|
||||
QString menuGroup() const override;
|
||||
|
||||
bool availableInPartition(IDL::PartitionType partition) const override { return (partition == IDL::PartitionType::Global || partition == IDL::PartitionType::Exercise); }
|
||||
|
||||
private:
|
||||
LtsWidgets::LtsDialog *onUasListDialog(QWidget *parent);
|
||||
|
||||
private:
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Ftc> m_ppmFtc;
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_exmDtc;
|
||||
|
||||
}; // class InterfaceImpl
|
||||
|
||||
} // namespace ParticipantManagement
|
||||
@@ -0,0 +1,155 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Dialog for Showning, Adding, Editing and Removing UASs
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Fritsche, ESZS, 2025-06-27
|
||||
*/
|
||||
|
||||
#include "ppm_uas_list_dialog.h"
|
||||
#include "Uas/ui_ppm_uas_list_dialog.h"
|
||||
|
||||
#include "ppm_uas_list_model.h"
|
||||
#include "ppm_uas_edit_dialog.h"
|
||||
|
||||
#include <Services/ParticipantManagement/ppm_dtc.h>
|
||||
|
||||
#include <ParticipantManagement/logger.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
UasListDialog::UasListDialog(LtsSession::LtsSession *session, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_ppmDtc(nullptr)
|
||||
, m_ppmFtc(nullptr)
|
||||
, m_session(session)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::UasListDialog)
|
||||
, m_logger(getLogger("UasListDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
if (m_session->exerciseId() == 0 )
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &UasListDialog::onAddClicked);
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &UasListDialog::onRemoveClicked);
|
||||
}
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &UasListDialog::onEditClicked);
|
||||
|
||||
connect(m_ui->ldvUas, &LtsDataView::LtsDataView::selectionChanged, this, &UasListDialog::onSelectionChanged);
|
||||
|
||||
if ( m_session->exerciseId() > 0)
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-UAS-Linking"));
|
||||
else
|
||||
setOnlineHelpFilename(QStringLiteral("Administrator-UAS-List"));
|
||||
|
||||
enaDisa();
|
||||
}
|
||||
|
||||
UasListDialog::~UasListDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool UasListDialog::init()
|
||||
{
|
||||
// interfaces
|
||||
if (!m_session->getDtc<DataInterface>(m_ppmDtc) || !m_session->getFtc<DataInterface>(m_ppmFtc))
|
||||
return false;
|
||||
|
||||
// uas model
|
||||
m_uasListModel = new UasListModel(this);
|
||||
m_uasListModel->initModel(m_session);
|
||||
m_ui->ldvUas->setModel(m_uasListModel);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void UasListDialog::onRemoveUasReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
m_requestHelper->requestReply(reply);
|
||||
}
|
||||
|
||||
void UasListDialog::retranslate()
|
||||
{
|
||||
if ( m_session->exerciseId() > 0)
|
||||
translate(m_ui, tr("UAS Linking"));
|
||||
else
|
||||
translate(m_ui, tr("UAS"));
|
||||
}
|
||||
|
||||
void UasListDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
//LtsColumnOrganiser
|
||||
m_ui->ldvUas->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
void UasListDialog::enaDisa()
|
||||
{
|
||||
QModelIndex currentIndex = m_ui->ldvUas->currentIndex();
|
||||
const auto &uasData = m_uasListModel->uasData(m_ui->ldvUas->currentIndex());
|
||||
bool isEditable = true;
|
||||
if (m_session->isExercisePartition() && uasData.exerciseId() > 0)
|
||||
{
|
||||
isEditable = (uasData.exerciseId() == m_session->exerciseId());
|
||||
}
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, currentIndex.isValid() && isEditable);
|
||||
if (m_session->exerciseId() == 0)
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, currentIndex.isValid());
|
||||
}
|
||||
|
||||
void UasListDialog::onAddClicked()
|
||||
{
|
||||
UasEditDialog *dialog = new UasEditDialog(this);
|
||||
|
||||
dialog->init(m_session);
|
||||
|
||||
addDialog(dialog, menuGroup(), dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void UasListDialog::onEditClicked()
|
||||
{
|
||||
if (!m_uasListModel)
|
||||
return;
|
||||
|
||||
UasEditDialog *dialog = new UasEditDialog(this);
|
||||
|
||||
dialog->init(m_session, m_uasListModel->uasData(m_ui->ldvUas->currentIndex()));
|
||||
|
||||
addDialog(dialog, menuGroup(), dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void UasListDialog::onRemoveClicked()
|
||||
{
|
||||
if (!m_uasListModel)
|
||||
return;
|
||||
|
||||
int idToRemove =m_uasListModel->uasData(m_ui->ldvUas->currentIndex()).id();
|
||||
const RemoveUasRequest req(idToRemove);
|
||||
m_requestHelper->addRequest([this, req]()
|
||||
{
|
||||
return m_ppmFtc->removeUasRequest(req, this);
|
||||
});
|
||||
|
||||
m_requestHelper->startRequests();
|
||||
|
||||
}
|
||||
|
||||
void UasListDialog::onSelectionChanged(const QItemSelection &, const QItemSelection &)
|
||||
{
|
||||
enaDisa();
|
||||
}
|
||||
|
||||
|
||||
|
||||
} //namespace ParticipantManagement
|
||||
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Dialog for Showning, Adding, Editing and Removing UASs
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Fritsche, ESZS, 2025-06-27
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <Services/ParticipantManagement/ppm_ftc.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class UasListDialog;
|
||||
}
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
namespace ExerciseManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
|
||||
class UasListModel;
|
||||
|
||||
class UasListDialog : public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::RemoveUasReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
using BaseClass = LtsWidgets::LtsDialog;
|
||||
|
||||
public:
|
||||
UasListDialog(LtsSession::LtsSession *session, QWidget *parent = nullptr);
|
||||
~UasListDialog();
|
||||
|
||||
bool init();
|
||||
|
||||
private:
|
||||
void onRemoveUasReply(const Core::FunctionReplyObject &reply) override;
|
||||
void retranslate() override;
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
void enaDisa();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onAddClicked();
|
||||
void onEditClicked();
|
||||
void onRemoveClicked();
|
||||
void onSelectionChanged(const QItemSelection &, const QItemSelection &);
|
||||
|
||||
private:
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Ftc> m_ppmFtc;
|
||||
|
||||
LtsSession::LtsSession *m_session{nullptr};
|
||||
|
||||
UasListModel *m_uasListModel{nullptr};
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
Ui::UasListDialog *m_ui;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
} //ParticipantManagement
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>UasListDialog</class>
|
||||
<widget class="QWidget" name="UasListDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>743</width>
|
||||
<height>472</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">setwindowtitle in source</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="LtsDataView::LtsDataView" name="ldvUas" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,146 @@
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for MarkerManangement - Marker Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
|
||||
#include "ppm_uas_list_model.h"
|
||||
#include "LtsSession/lts_session.h"
|
||||
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <ProjectDataManagement/pdm_translation.h>
|
||||
#include <ExerciseManagement/exm_data_plugin_interface.h>
|
||||
#include <ExerciseManagement/exm_dtc.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <QBuffer>
|
||||
#include <QMimeData>
|
||||
#include <QSet>
|
||||
#include <QTimer>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
//---------------------------------
|
||||
// MarkerManagementDialogModel
|
||||
//---------------------------------
|
||||
UasListModel::UasListModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<UAS>({tr("UAV ID"),
|
||||
tr("Identifier"),
|
||||
tr("State"),
|
||||
tr("Hostname"),
|
||||
tr("Hostport"),
|
||||
tr("Linked Participant")
|
||||
},
|
||||
parent)
|
||||
, m_logger(getLogger("UasListModel"))
|
||||
{}
|
||||
|
||||
|
||||
bool UasListModel::initModel(LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!session)
|
||||
return false;
|
||||
if (!session->getDtc<DataInterface>(m_ppmDtc) || !session->getDtc<ExerciseManagement::DataInterface>(m_exmDtc))
|
||||
return false;
|
||||
|
||||
m_exerciseId = session->exerciseId();
|
||||
|
||||
if (!m_ppmDtc->isUASEnabled())
|
||||
m_ppmDtc->enableUAS();
|
||||
|
||||
m_ppmDtc->waitForHistoricalDataUAS(500);
|
||||
|
||||
m_ppmDtc->uASs([this](const UAS &uas){onUasChanged(uas, DataModification::eAdded);});
|
||||
|
||||
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::uASChanged,
|
||||
this, &UasListModel::onUasChanged);
|
||||
|
||||
if (!m_exmDtc->isExerciseEnabled())
|
||||
m_exmDtc->enableExercise();
|
||||
|
||||
m_exmDtc->waitForHistoricalDataExercise(500);
|
||||
|
||||
DEBUG_LOG(m_logger) << "UasListModel initialised for exercise " << m_exerciseId;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant UasListModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
const int row = index.row();
|
||||
const ParticipantManagement::UAS &uas = getRowData(row);
|
||||
|
||||
if (role != Qt::DisplayRole ||
|
||||
!indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case ColUavId:
|
||||
return uas.id();
|
||||
case ColIdentifier:
|
||||
return QString::fromStdString(uas.deviceIdentifier());
|
||||
case ColUavState:
|
||||
return ProjectDataManagement::toString(uas.uasState());
|
||||
case ColHostname:
|
||||
return QString::fromStdString(uas.hostname());
|
||||
case ColHostport:
|
||||
return uas.hostport();
|
||||
case ColParticipant:
|
||||
{
|
||||
if(uas.participantId() == 0 ||
|
||||
uas.exerciseId() == 0)
|
||||
return QStringLiteral("-");
|
||||
|
||||
// we assume, that the exercise id is set, because the participant id is set
|
||||
if (uas.exerciseId() != m_exerciseId)
|
||||
return tr("Participant from exercise %1").arg(QString::fromStdString(m_exmDtc->exercise(uas.exerciseId()).name()));
|
||||
|
||||
// uas.exerciseId() == m_exerciseId
|
||||
return m_ppmDtc->hierarchyFromParticipant(uas.participantId());
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
UAS UasListModel::uasData(const QModelIndex &index)
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return UAS();
|
||||
|
||||
return getRowData(index.row());
|
||||
}
|
||||
|
||||
void UasListModel::onUasChanged(const UAS &data, const DataModification modType)
|
||||
{
|
||||
int row = findRowForId(data.id());
|
||||
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
removeRow(row);
|
||||
|
||||
return;
|
||||
}
|
||||
case DataModification::eModified:
|
||||
case DataModification::eAdded:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "DataModification::eModified and eAdded: ";
|
||||
|
||||
if (row < 0)
|
||||
insertRow(data);
|
||||
else
|
||||
setRowData(row, data);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ParticipantManagement
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for MarkerManangement - Marker Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <ParticipantManagement/logger.h>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
|
||||
namespace ExerciseManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
// --------------------------------------------------------
|
||||
// UasListModel
|
||||
// --------------------------------------------------------
|
||||
class UasListModel : public LtsWidgets::LtsAbstractTableModel<UAS>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
ColUavId,
|
||||
ColIdentifier,
|
||||
ColUavState,
|
||||
ColHostname,
|
||||
ColHostport,
|
||||
ColParticipant
|
||||
};
|
||||
explicit UasListModel(QObject *parent = nullptr);
|
||||
|
||||
bool initModel(LtsSession::LtsSession *session);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::UserRole) const override final;
|
||||
UAS uasData(const QModelIndex &index);
|
||||
|
||||
private slots:
|
||||
void onUasChanged(const ParticipantManagement::UAS &data,
|
||||
const DataModification modType);
|
||||
private:
|
||||
int32_t m_exerciseId { 0 };
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_exmDtc;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user