Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+30
@@ -0,0 +1,30 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
# Created by Patric Karwat, NLSE, 2018-03-07
|
||||
#
|
||||
|
||||
ADD_SUBDIRECTORY(Gui)
|
||||
ADD_SUBDIRECTORY(Data)
|
||||
|
||||
#
|
||||
# Gui Pairing Plugin Interface
|
||||
#
|
||||
ADD_INTERFACE_LIBRARY(TabocGuiPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/taboc_gui_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../
|
||||
GuiPluginInterface
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Data Plugin Interface
|
||||
#
|
||||
ADD_INTERFACE_LIBRARY(TabocDataPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/taboc_data_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
DataPluginInterface
|
||||
svcTabocCommon
|
||||
)
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
# Created by Ptric KarwatD NLSE, 2018-03-07
|
||||
#
|
||||
|
||||
#
|
||||
# Data Plugin
|
||||
#
|
||||
NGL_ADD_LIBRARY(WS TabocDataPlugin MODULE taboc_data_plugin.cpp taboc_data_plugin.h)
|
||||
NGL_TARGET_LINK_LIBRARIES(TabocDataPlugin
|
||||
Qt5::Core
|
||||
TabocDataPluginInterface
|
||||
svcTabocClient
|
||||
NGLLogger
|
||||
LtsSessionDataDds
|
||||
)
|
||||
NGL_INSTALL_TARGET(TabocDataPlugin)
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Data Plugin for TrainingAreaBase
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-09-19
|
||||
*/
|
||||
|
||||
|
||||
#include "taboc_data_plugin.h"
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
#include <Proxies/TrainingAreaBaseOC/taboc_dtc.h>
|
||||
#include <Proxies/TrainingAreaBaseOC/taboc_ftc.h>
|
||||
|
||||
|
||||
namespace TrainingAreaBaseOC
|
||||
{
|
||||
std::shared_ptr<DataPluginBase::Interface> DataPlugin::createDataInterface(LtsSession::LtsSessionDataDds *session)
|
||||
{
|
||||
std::shared_ptr<Interface::Dtc> dtc;
|
||||
std::shared_ptr<Interface::Ftc> ftc;
|
||||
if (!session->createTopicClient(dtc, ftc))
|
||||
return std::shared_ptr<DataPluginBase::Interface>();
|
||||
|
||||
return std::make_shared<DataInterfaceImpl>(dtc, ftc);
|
||||
}
|
||||
|
||||
|
||||
DataInterfaceImpl::DataInterfaceImpl(const std::shared_ptr<TrainingAreaBaseOC::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<TrainingAreaBaseOC::Interface::Ftc> &ftc)
|
||||
: DataInterface()
|
||||
, m_dtc(dtc)
|
||||
, m_ftc(ftc)
|
||||
{}
|
||||
|
||||
|
||||
} // namespace TrainingAreaBaseOC
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Data Plugin for TrainingAreaBase
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-09-19
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <PluginInterfaces/data_plugin_interface.h>
|
||||
#include <Plugins/TrainingAreaBaseOC/taboc_data_plugin_interface.h>
|
||||
|
||||
|
||||
namespace TrainingAreaBaseOC
|
||||
{
|
||||
|
||||
class DataPlugin final : public QObject, public DataPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "data:3:taboc")
|
||||
Q_INTERFACES(DataPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
DataPlugin() = default;
|
||||
~DataPlugin() = default;
|
||||
|
||||
QString pluginName() const override { return QStringLiteral("TrainingAreaBaseOC"); }
|
||||
std::shared_ptr<DataPluginBase::Interface> createDataInterface(LtsSession::LtsSessionDataDds *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return partition == IDL::PartitionType::Exercise ||
|
||||
partition == IDL::PartitionType::Global;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class DataInterfaceImpl final : public DataInterface
|
||||
{
|
||||
public:
|
||||
DataInterfaceImpl(const std::shared_ptr<TrainingAreaBaseOC::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<TrainingAreaBaseOC::Interface::Ftc> &ftc);
|
||||
|
||||
std::shared_ptr<TrainingAreaBaseOC::Interface::Dtc> getDtc() override { return m_dtc; }
|
||||
std::shared_ptr<TrainingAreaBaseOC::Interface::Ftc> getFtc() override { return m_ftc; }
|
||||
|
||||
private:
|
||||
std::shared_ptr<TrainingAreaBaseOC::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<TrainingAreaBaseOC::Interface::Ftc> m_ftc;
|
||||
};
|
||||
|
||||
} // namespace TrainingAreaBaseOC
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
# Created by Dassow Philipp, SLST, 2017-09-19
|
||||
#
|
||||
|
||||
ADD_SUBDIRECTORY(OcTerminal)
|
||||
ADD_SUBDIRECTORY(SfmMessaging)
|
||||
@@ -0,0 +1,29 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
# Created by Dassow Philipp, SLST, 2017-09-19
|
||||
#
|
||||
|
||||
SET (taboc_gui_SRCS
|
||||
taboc_gui_plugin.h
|
||||
taboc_gui_plugin.cpp
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS TabocGuiPlugin MODULE ${taboc_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(TabocGuiPlugin
|
||||
PRIVATE
|
||||
svcTabocCommon
|
||||
PUBLIC
|
||||
LtsSession
|
||||
LtsNotification
|
||||
LtsUtilsSettings
|
||||
TabocGuiPluginInterface
|
||||
TabocDataPluginInterface
|
||||
PpmDataPluginInterface
|
||||
Qt5::Widgets
|
||||
Qt5::Network
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(TabocGuiPlugin)
|
||||
@@ -0,0 +1,214 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Notifcation plugin for TAB connection states
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-09-19
|
||||
*/
|
||||
|
||||
#include "taboc_gui_plugin.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsNotification/lts_notification.h>
|
||||
#include <TrainingAreaBaseOC/logger.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <LtsWidgets/lts_base_layout_widget.h> // as parent for message dialogs
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
namespace TrainingAreaBaseOC
|
||||
{
|
||||
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("Notification"))
|
||||
, m_dtc(nullptr)
|
||||
, m_ppmDtc(nullptr)
|
||||
, m_sitMapGuiIfc(nullptr)
|
||||
, m_notiPos(nullptr)
|
||||
, m_notiRadio(nullptr)
|
||||
, m_notiSfm(nullptr)
|
||||
{
|
||||
connect(m_session, &LtsSession::LtsSession::signalDoneInitializingSession, // workaround to only receive the signal once
|
||||
this, &InterfaceImpl::onInitDone);
|
||||
}
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
|
||||
LtsWidgets::PluginData plData;
|
||||
plData.menuGroup = menuGroup();
|
||||
plData.createInstant = LtsWidgets::CreateInstantType::CreateInstantAndDiscardAction;
|
||||
|
||||
//center to own postion:
|
||||
plData.directFunc = [this](const LtsWidgets::PluginData &)
|
||||
{
|
||||
m_notiPos = m_session->createNotification(QStringLiteral("tabOcCenterToPos"));
|
||||
m_notiPos->setIcon(QIcon(QLatin1String("icon:center_to_object.svg")));
|
||||
m_notiPos->setToolTip(tr("Center Map to Position"));
|
||||
m_notiPos->setAction([this]()
|
||||
{
|
||||
//do the map thing here
|
||||
int participantId = m_ppmDtc->participantIdByEquipmentNumber(m_dtc->specificsEquipment(1).equipmentNumber());
|
||||
if (participantId > 0)
|
||||
m_sitMapGuiIfc->centerMapToParticipant(participantId);
|
||||
}
|
||||
);
|
||||
|
||||
};
|
||||
ret.append(plData);
|
||||
|
||||
//Radio Connection:
|
||||
plData.directFunc = [this](const LtsWidgets::PluginData &)
|
||||
{
|
||||
m_notiRadio = m_session->createNotification(QStringLiteral("TabOcTetraConnection"));
|
||||
setDefaultToolTipRadio();
|
||||
m_notiRadio->setAction([this]()
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(m_session->baseLayout(), m_notiRadio->tooltip());
|
||||
});
|
||||
};
|
||||
ret.append(plData);
|
||||
|
||||
//Sfm Connection
|
||||
plData.directFunc = [this](const LtsWidgets::PluginData &)
|
||||
{
|
||||
m_notiSfm = m_session->createNotification(QStringLiteral("TabOcSfmConnection"));
|
||||
setDefaultToolTipSfm();
|
||||
m_notiSfm->setAction([this]()
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(m_session->baseLayout(), m_notiSfm->tooltip());
|
||||
});
|
||||
};
|
||||
ret.append(plData);
|
||||
|
||||
connect(m_dtc.get(), &TrainingAreaBaseOC::Interface::Dtc::technicalStateSfmChanged, this, &InterfaceImpl::onStatusSfmChanged);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool InterfaceImpl::fetchInterfaces()
|
||||
{
|
||||
if (!m_session->getDtc<TrainingAreaBaseOC::DataInterface>(m_dtc))
|
||||
return false;
|
||||
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
return false;
|
||||
if (!m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitMapGuiIfc))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void InterfaceImpl::clearInterfaces()
|
||||
{
|
||||
m_dtc = nullptr;
|
||||
m_ppmDtc = nullptr;
|
||||
m_sitMapGuiIfc = nullptr;
|
||||
}
|
||||
|
||||
void InterfaceImpl::onStatusSfmChanged(const TechnicalStateSfm &data, DataModification modType)
|
||||
{
|
||||
Q_UNUSED(modType)
|
||||
setRadioStatus(data.radioAvailable(), data.licensed());
|
||||
setSfmStatus(data.sfmConnected());
|
||||
|
||||
if (m_notiRadio != nullptr)
|
||||
m_notiRadio->setToolTip(data.licensed() ? tr("Licensed") : tr("Not Licensed")); //set licenced text
|
||||
}
|
||||
|
||||
void InterfaceImpl::setRadioStatus(bool isAvilable, bool isLicensed)
|
||||
{
|
||||
if (!m_notiRadio)
|
||||
return;
|
||||
|
||||
if (isAvilable && isLicensed)
|
||||
m_notiRadio->setIcon(QIcon(QStringLiteral("icon:network-wireless-green.svg")));
|
||||
else if (isAvilable)
|
||||
m_notiRadio->setIcon(QIcon(QStringLiteral("icon:network-wireless-yellow.svg")));
|
||||
else
|
||||
m_notiRadio->setIcon(QIcon(QStringLiteral("icon:network-wireless-red.svg")));
|
||||
}
|
||||
|
||||
void InterfaceImpl::setSfmStatus(bool isConnected)
|
||||
{
|
||||
if (!m_notiSfm)
|
||||
return;
|
||||
|
||||
if (isConnected)
|
||||
{
|
||||
m_notiSfm->setIcon(QIcon(QStringLiteral("icon:pu-green.svg")));
|
||||
m_notiSfm->setToolTip(tr("Connected to Sfm"));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_notiSfm->setIcon(QIcon(QStringLiteral("icon:pu-red.svg")));
|
||||
m_notiSfm->setToolTip(tr("No Sfm connection"));
|
||||
}
|
||||
}
|
||||
|
||||
void InterfaceImpl::setDefaultToolTipRadio()
|
||||
{
|
||||
m_notiRadio->setToolTip(tr("No Radio Connection"));
|
||||
}
|
||||
|
||||
void InterfaceImpl::setDefaultToolTipSfm()
|
||||
{
|
||||
m_notiSfm->setToolTip(tr("No Connection to Sfm"));
|
||||
m_notiSfm->setAction([this]()
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(m_session->baseLayout(), m_notiSfm->tooltip());
|
||||
});
|
||||
}
|
||||
|
||||
void InterfaceImpl::onInitDone()
|
||||
{
|
||||
disconnect(m_session, &LtsSession::LtsSession::signalDoneInitializingSession,
|
||||
this, nullptr); // workaround to only receive the signal once
|
||||
|
||||
if (appId() != LtsAppDescriptor::App::OC)
|
||||
return;
|
||||
|
||||
if (m_dtc)
|
||||
{
|
||||
TechnicalStateSfm currentState = m_dtc->technicalStateSfm(1);
|
||||
onStatusSfmChanged(currentState, DataModification());
|
||||
}
|
||||
|
||||
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::participantPositionChanged, this, &InterfaceImpl::onPositionChanged);
|
||||
connect(m_dtc.get(), &TrainingAreaBaseOC::Interface::Dtc::specificsEquipmentChanged, this, &InterfaceImpl::onSpecificsEquipmentChanged);
|
||||
|
||||
m_curParticipantId = m_ppmDtc->participantIdByEquipmentNumber(m_dtc->specificsEquipment(1).equipmentNumber());
|
||||
if (m_curParticipantId)
|
||||
onPositionChanged(m_ppmDtc->participantPosition(m_curParticipantId), DataModification::eAdded);
|
||||
|
||||
}
|
||||
|
||||
void InterfaceImpl::onPositionChanged(const ParticipantManagement::ParticipantPosition &data, DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
|
||||
if (m_curParticipantId <= 0)
|
||||
m_curParticipantId = m_ppmDtc->participantIdByEquipmentNumber(m_dtc->specificsEquipment(1).equipmentNumber());
|
||||
|
||||
if (data.participantId() == m_curParticipantId)
|
||||
{
|
||||
if (LtsUtils::OperatorSettings::getInstance()->value(QStringLiteral("ObserverController"), QStringLiteral("MovingMapToSelf"), false).toBool())
|
||||
m_sitMapGuiIfc->setCenterPoint(QPointF(data.pos().lon(), data.pos().lat())); // setCenterPoint, as the sitmapPlugin could still have an old position
|
||||
}
|
||||
}
|
||||
|
||||
void InterfaceImpl::onSpecificsEquipmentChanged(const TrainingAreaBaseOC::SpecificsEquipment &data, DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
m_curParticipantId = m_ppmDtc->participantIdByEquipmentNumber(data.equipmentNumber());
|
||||
}
|
||||
|
||||
} // namespace TrainingAreaBaseOC
|
||||
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Notifcation plugin for TAB connection states
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-09-19
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <Plugins/TrainingAreaBaseOC/taboc_data_plugin_interface.h>
|
||||
#include <Plugins/TrainingAreaBaseOC/taboc_gui_plugin_interface.h>
|
||||
#include <Proxies/TrainingAreaBaseOC/taboc_dtc.h>
|
||||
//sitmap
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
|
||||
namespace LtsNotification
|
||||
{
|
||||
class LtsNotification;
|
||||
}
|
||||
|
||||
namespace TrainingAreaBaseOC
|
||||
{
|
||||
|
||||
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:taboc")
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return ForeignGuiInterface::pluginName(); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return partition == IDL::PartitionType::Exercise || partition == IDL::PartitionType::Global;
|
||||
}
|
||||
};
|
||||
|
||||
class InterfaceImpl final : public QObject, public TrainingAreaBaseOC::ForeignGuiInterface, public GuiPluginBase::Interface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
|
||||
QString pluginName() { return ForeignGuiInterface::pluginName(); }
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
QString menuGroup() const override { return tr("Training Area Base OC"); }
|
||||
|
||||
bool fetchInterfaces() override;
|
||||
void clearInterfaces() override;
|
||||
|
||||
public slots:
|
||||
void onStatusSfmChanged(const TrainingAreaBaseOC::TechnicalStateSfm &data, DataModification modType);
|
||||
void onInitDone();
|
||||
void onPositionChanged(const ParticipantManagement::ParticipantPosition &data, DataModification modType);
|
||||
void onSpecificsEquipmentChanged(const TrainingAreaBaseOC::SpecificsEquipment &data, DataModification modType);
|
||||
|
||||
|
||||
private:
|
||||
void setRadioStatus(bool isAvilable, bool isLicensed);
|
||||
void setSfmStatus(bool isConnected);
|
||||
void setDefaultToolTipRadio();
|
||||
void setDefaultToolTipSfm();
|
||||
|
||||
std::shared_ptr<TrainingAreaBaseOC::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
|
||||
int m_curParticipantId = 0;
|
||||
|
||||
LtsNotification::LtsNotification *m_notiPos;
|
||||
LtsNotification::LtsNotification *m_notiRadio;
|
||||
LtsNotification::LtsNotification *m_notiSfm;
|
||||
};
|
||||
|
||||
} // namespace TrainingAreaBaseOC
|
||||
@@ -0,0 +1,39 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Christian Roeskens, NLSE, 2018-05-03
|
||||
#
|
||||
|
||||
SET(taboc_sfm_messaging_gui_SRCS
|
||||
taboc_sfm_messaging_gui_plugin.cpp
|
||||
taboc_sfm_messaging_gui_plugin.h
|
||||
taboc_sfm_messaging_dialog.cpp
|
||||
taboc_sfm_messaging_dialog.h
|
||||
taboc_sfm_messaging_model.cpp
|
||||
taboc_sfm_messaging_model.h
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(taboc_sfm_messaging_gui_SRCS
|
||||
taboc_sfm_messaging_dialog.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS TabOcSfmMessagingGuiPlugin MODULE ${taboc_sfm_messaging_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(TabOcSfmMessagingGuiPlugin
|
||||
svcTabocCommon
|
||||
TabocGuiPluginInterface
|
||||
TabocDataPluginInterface
|
||||
LtsWidgets
|
||||
LtsDataView
|
||||
LtsPrinting
|
||||
LtsNotification
|
||||
LtsSession
|
||||
LtsUtilsGuiDds
|
||||
LtsSessionData
|
||||
LtsUtilsSettings
|
||||
Qt5::Widgets
|
||||
NGLLogger
|
||||
ngltools
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(TabOcSfmMessagingGuiPlugin)
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for Messaging - Messaging Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Chrsitian Roeskens, NLSE, 2018-05-03
|
||||
*/
|
||||
|
||||
#include "taboc_sfm_messaging_dialog.h"
|
||||
#include "ui_taboc_sfm_messaging_dialog.h"
|
||||
|
||||
#include <LtsNotification/lts_notification.h>
|
||||
#include <LtsSession/lts_session_manager.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace TrainingAreaBaseOC
|
||||
{
|
||||
|
||||
SfmMessagesDialog::SfmMessagesDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_model(nullptr)
|
||||
, m_dtc(nullptr)
|
||||
, m_ui(new Ui::SfmMessagesDialog)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_logger(getLogger("MessagingDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->widget->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &SfmMessagesDialog::onPrint);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::No, this, &SfmMessagesDialog::onClear);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::No)->setText(tr("Clear"));
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("OC-TNE_Messages"));
|
||||
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
SfmMessagesDialog::~SfmMessagesDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void SfmMessagesDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("SFM Messages") );
|
||||
}
|
||||
|
||||
bool SfmMessagesDialog::init(const std::shared_ptr<TrainingAreaBaseOC::Interface::Dtc> &dtc, LtsNotification::LtsNotification *notiSfmMsg, qint64 lastClearTime)
|
||||
{
|
||||
if (!dtc || !notiSfmMsg)
|
||||
return false;
|
||||
|
||||
m_dtc = dtc;
|
||||
m_notiSfmMsg = notiSfmMsg;
|
||||
|
||||
m_notiSfmMsg->setCount(0);
|
||||
|
||||
m_model = new MessagingModel(this);
|
||||
m_model->initModel(m_dtc, lastClearTime);
|
||||
m_ui->widget->setModel(m_model);
|
||||
m_ui->widget->setSortIndicator(0, Qt::AscendingOrder);
|
||||
return true;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void SfmMessagesDialog::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView() );
|
||||
}
|
||||
|
||||
void SfmMessagesDialog::onClear()
|
||||
{
|
||||
m_model->clearModel();
|
||||
emit clearedModel();
|
||||
}
|
||||
|
||||
} // namespace TrainingAreaBaseOC
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for Messaging - Messaging Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Chrsitian Roeskens, NLSE, 2018-05-03
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "taboc_sfm_messaging_model.h"
|
||||
|
||||
#include <TrainingAreaBaseOC/taboc_dtc.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class SfmMessagesDialog;
|
||||
}
|
||||
namespace TrainingAreaBaseOC
|
||||
{
|
||||
|
||||
class SfmMessagesDialog : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SfmMessagesDialog(QWidget *parent = nullptr);
|
||||
~SfmMessagesDialog();
|
||||
bool init(const std::shared_ptr<TrainingAreaBaseOC::Interface::Dtc> &dtc, LtsNotification::LtsNotification *notiSfmMsg, qint64 lastClearTime);
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void onPrint();
|
||||
void onClear();
|
||||
signals:
|
||||
void clearedModel();
|
||||
|
||||
private:
|
||||
QString m_menuGroup;
|
||||
MessagingModel *m_model;
|
||||
std::shared_ptr<TrainingAreaBaseOC::Interface::Dtc> m_dtc;
|
||||
|
||||
LtsSession::LtsSession *m_session;
|
||||
Ui::SfmMessagesDialog *m_ui;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
LtsNotification::LtsNotification *m_notiSfmMsg;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
} // namespace TrainingAreaBaseOC
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SfmMessagesDialog</class>
|
||||
<widget class="QWidget" name="SfmMessagesDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>455</width>
|
||||
<height>341</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">MessagingView</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="LtsDataView::LtsDataView" name="widget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>250</height>
|
||||
</size>
|
||||
</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>
|
||||
+170
@@ -0,0 +1,170 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for Messaging
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Chrsitian Roeskens, NLSE, 2018-05-03
|
||||
*/
|
||||
|
||||
#include "taboc_sfm_messaging_gui_plugin.h"
|
||||
#include "taboc_sfm_messaging_dialog.h"
|
||||
#include "taboc_sfm_messaging_model.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <TrainingAreaBaseOC/logger.h>
|
||||
#include <LtsNotification/lts_notification.h>
|
||||
#include <LtsWidgets/lts_dialog.h> // for noti actions..
|
||||
#include <LtsWidgets/lts_splash.h>
|
||||
#include <QTimer>
|
||||
|
||||
namespace TrainingAreaBaseOC
|
||||
{
|
||||
|
||||
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("SfmMessages"))
|
||||
, m_dtc(nullptr)
|
||||
, m_unread(0)
|
||||
, m_unreadCounterIsLocked(false)
|
||||
, m_lastClearTime(0)
|
||||
, m_notiSfmMsg(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
InterfaceImpl::~InterfaceImpl()
|
||||
{
|
||||
delete m_notiSfmMsg;
|
||||
}
|
||||
|
||||
|
||||
bool InterfaceImpl::fetchInterfaces()
|
||||
{
|
||||
if (!m_session->getDtc<TrainingAreaBaseOC::DataInterface>(m_dtc))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void InterfaceImpl::clearInterfaces()
|
||||
{
|
||||
m_dtc = nullptr;
|
||||
}
|
||||
|
||||
|
||||
void InterfaceImpl::initializeMessaging()
|
||||
{
|
||||
connect(m_dtc.get(), &TrainingAreaBaseOC::Interface::Dtc::freeTextChanged,
|
||||
this, QOverload<const TrainingAreaBaseOC::FreeText &, DataModification>::of(&InterfaceImpl::handleNewData)
|
||||
, Qt::UniqueConnection);
|
||||
|
||||
connect(m_dtc.get(), &TrainingAreaBaseOC::Interface::Dtc::shortMessageChanged,
|
||||
this, QOverload<const TrainingAreaBaseOC::ShortMessage &, DataModification>::of(&InterfaceImpl::handleNewData)
|
||||
, Qt::UniqueConnection);
|
||||
|
||||
m_unread = m_dtc->freeTexts().size() + m_dtc->shortMessages().size();
|
||||
|
||||
updateUnreadCount();
|
||||
}
|
||||
|
||||
void InterfaceImpl::handleNewData(const FreeText &data, DataModification modType)
|
||||
{
|
||||
if (modType != DataModification::eAdded || m_unreadCounterIsLocked)
|
||||
return;
|
||||
if (data.timeStamp() < (QDateTime::currentMSecsSinceEpoch() - (60 * 60 * 1000 * 1))
|
||||
|| data.timeStamp() < m_lastClearTime) //only last 1 hour
|
||||
return;
|
||||
++m_unread;
|
||||
updateUnreadCount();
|
||||
}
|
||||
|
||||
void InterfaceImpl::handleNewData(const ShortMessage &data, DataModification modType)
|
||||
{
|
||||
if (modType != DataModification::eAdded || m_unreadCounterIsLocked)
|
||||
return;
|
||||
if (data.timeStamp() < (QDateTime::currentMSecsSinceEpoch() - (60 * 60 * 1000 * 1))
|
||||
|| data.timeStamp() < m_lastClearTime) //only last 1 hour
|
||||
return;
|
||||
++m_unread;
|
||||
updateUnreadCount();
|
||||
}
|
||||
|
||||
|
||||
void InterfaceImpl::updateUnreadCount()
|
||||
{
|
||||
if (!m_unreadCounterIsLocked)
|
||||
{
|
||||
if (m_notiSfmMsg == nullptr)
|
||||
return;
|
||||
|
||||
m_notiSfmMsg->setCount(m_unread);
|
||||
m_notiSfmMsg->setToolTip(tr("Sfm Messages: %n unread message(s)", "", m_unread));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
|
||||
if (m_notiSfmMsg == nullptr)
|
||||
{
|
||||
m_notiSfmMsg = m_session->createNotification(QStringLiteral("TabOcSfmMessages"));
|
||||
|
||||
m_notiSfmMsg->setIcon(QIcon(QStringLiteral("icon:oc_messages.svg")));
|
||||
m_notiSfmMsg->setToolTip(tr("No unread messages"));
|
||||
m_notiSfmMsg->setAction([this]()
|
||||
{
|
||||
m_session->addWidget(onShowSfmMessages(nullptr), menuGroup(), QStringLiteral("sfmMessages"), LtsWidgets::LayoutArea::eDialogTab); // TODO: PlData und das hier verbinden..
|
||||
});
|
||||
}
|
||||
|
||||
LtsWidgets::PluginData plData;
|
||||
plData.menuGroup = tr("Messaging");
|
||||
plData.menuText = tr("SFM Messages");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:messages_inbox.svg"));
|
||||
plData.identifier = QStringLiteral("sfmMessages");
|
||||
plData.visibleInMenu = false;
|
||||
// plData.operatorRight = OperatorRights::MessagesShow;
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eSpecial;
|
||||
plData.createWidgetFunc = [this](QWidget * parent)
|
||||
{
|
||||
return onShowSfmMessages(parent);
|
||||
};
|
||||
ret.append(plData);
|
||||
|
||||
initializeMessaging();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void InterfaceImpl::resetAndLockUnreadCount()
|
||||
{
|
||||
m_unreadCounterIsLocked = true;
|
||||
m_unread = 0;
|
||||
}
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowSfmMessages(QWidget *parent)
|
||||
{
|
||||
SfmMessagesDialog *dialog = new SfmMessagesDialog(parent);
|
||||
|
||||
connect(dialog, &SfmMessagesDialog::signalFocused, this, &InterfaceImpl::resetAndLockUnreadCount);
|
||||
connect(dialog, &SfmMessagesDialog::clearedModel, this, &InterfaceImpl::resetAndLockUnreadCount);
|
||||
connect(dialog, &SfmMessagesDialog::signalHide, this, [this] () { m_unreadCounterIsLocked = false; } );
|
||||
connect(dialog, &SfmMessagesDialog::destroyed, this, [this] () { m_unreadCounterIsLocked = false; } );
|
||||
connect(dialog, &SfmMessagesDialog::clearedModel, this, [this]{
|
||||
m_lastClearTime = QDateTime::currentMSecsSinceEpoch();
|
||||
});
|
||||
dialog->init(m_dtc, m_notiSfmMsg, m_lastClearTime);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
} // namespace TrainingAreaBaseOC
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for Messaging
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Chrsitian Roeskens, NLSE, 2018-05-03
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/TrainingAreaBaseOC/taboc_data_plugin_interface.h>
|
||||
#include <Plugins/TrainingAreaBaseOC/taboc_gui_plugin_interface.h>
|
||||
#include <Proxies/TrainingAreaBaseOC/taboc_dtc.h>
|
||||
#include <Proxies/TrainingAreaBaseOC/taboc_ftc.h>
|
||||
|
||||
namespace LtsNotification
|
||||
{
|
||||
class LtsNotification;
|
||||
}
|
||||
|
||||
namespace TrainingAreaBaseOC
|
||||
{
|
||||
|
||||
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:taboc.sfm")
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return QStringLiteral("TrainingAreaBaseOcSfmMessagesGui"); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return (partition == IDL::PartitionType::Exercise);
|
||||
}
|
||||
};
|
||||
|
||||
class InterfaceImpl final : public QObject, public GuiPluginBase::Interface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
~InterfaceImpl();
|
||||
|
||||
bool fetchInterfaces() override;
|
||||
void clearInterfaces() override;
|
||||
QString menuGroup() const override { return tr("Training Area Base OC"); }
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
void initializeMessaging();
|
||||
void messageChanged();
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return (partition == IDL::PartitionType::Exercise);
|
||||
}
|
||||
|
||||
private:
|
||||
void resetAndLockUnreadCount();
|
||||
void updateUnreadCount();
|
||||
|
||||
void handleNewData(const TrainingAreaBaseOC::FreeText &data, DataModification modType);
|
||||
void handleNewData(const TrainingAreaBaseOC::ShortMessage &data, DataModification modType);
|
||||
|
||||
LtsWidgets::LtsDialog *onShowSfmMessages(QWidget *parent);
|
||||
|
||||
std::shared_ptr<TrainingAreaBaseOC::Interface::Dtc> m_dtc;
|
||||
int m_unread;
|
||||
bool m_unreadCounterIsLocked;
|
||||
qint64 m_lastClearTime;
|
||||
LtsNotification::LtsNotification *m_notiSfmMsg;
|
||||
};
|
||||
|
||||
} // namespace TrainingAreaBaseOC
|
||||
+253
@@ -0,0 +1,253 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for Messaging - Messaging Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Chrsitian Roeskens, NLSE, 2018-05-03
|
||||
*/
|
||||
|
||||
#include "taboc_sfm_messaging_model.h"
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <QtGui/QFont>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
namespace TrainingAreaBaseOC
|
||||
{
|
||||
//---------------------------------
|
||||
// Messaging
|
||||
//---------------------------------
|
||||
MessagingModel::MessagingModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<Entry>({tr("Time"), tr("Message")}, parent)
|
||||
, m_dtc(nullptr)
|
||||
, m_operatorId(0)
|
||||
, m_lastClearTime(0)
|
||||
, m_logger(getLogger("MessagingModel"))
|
||||
{}
|
||||
|
||||
|
||||
bool MessagingModel::initModel(const std::shared_ptr<TrainingAreaBaseOC::Interface::Dtc> &dtc, qint64 lastClearTime)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
m_lastClearTime = lastClearTime;
|
||||
connect(m_dtc.get(), &Interface::Dtc::freeTextChanged, this,
|
||||
[this](const TrainingAreaBaseOC::FreeText & data, DataModification modType) { insertData(data, modType);});
|
||||
|
||||
connect(m_dtc.get(), &Interface::Dtc::shortMessageChanged, this,
|
||||
[this](const TrainingAreaBaseOC::ShortMessage & data, DataModification modType) { insertData(data, modType);});
|
||||
|
||||
// init Model
|
||||
m_dtc->freeTexts([this](const TrainingAreaBaseOC::FreeText & data) { insertData(data); });
|
||||
m_dtc->shortMessages([this](const TrainingAreaBaseOC::ShortMessage & data) { insertData(data); });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void MessagingModel::insertData(const TrainingAreaBaseOC::FreeText &data, DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
|
||||
if (dontAdd(data.timeStamp()))
|
||||
return;
|
||||
|
||||
QString text = QString::fromStdString(data.text().c_str());
|
||||
if (text.size() > 1)
|
||||
text.chop(1);
|
||||
QString msg = tr("Text: %1").arg(text);
|
||||
|
||||
insertRow({QDateTime::fromMSecsSinceEpoch(data.timeStamp()), msg});
|
||||
}
|
||||
|
||||
void MessagingModel::insertData(const TrainingAreaBaseOC::ShortMessage &data, DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
|
||||
if (dontAdd(data.timeStamp()))
|
||||
return;
|
||||
|
||||
/*
|
||||
QString msg = tr("Type: %1 VGB: %2 VBA: %3")
|
||||
.arg(textTypeToString(static_cast<TextType>(data.textType())))
|
||||
.arg(data.indexVbg())
|
||||
.arg(data.indexVba());
|
||||
}
|
||||
*/
|
||||
QString msg = tr("Type: %1 - %2")
|
||||
.arg(textTypeToString(static_cast<TextType>(data.textType())),
|
||||
vbgVbaIndexToText(data.textType(), data.indexVbg()));
|
||||
|
||||
insertRow({QDateTime::fromMSecsSinceEpoch(data.timeStamp()), msg});
|
||||
}
|
||||
|
||||
|
||||
bool MessagingModel::dontAdd(qint64 timeToCheck)
|
||||
{
|
||||
qint64 checktime = m_lastClearTime;
|
||||
if (checktime == 0)
|
||||
{
|
||||
checktime = QDateTime::currentMSecsSinceEpoch()-10000;
|
||||
}
|
||||
|
||||
if (timeToCheck < (QDateTime::currentMSecsSinceEpoch() - (60 * 60 * 1000 * 1)))
|
||||
return true;
|
||||
|
||||
if(timeToCheck < checktime)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
QString MessagingModel::textTypeToString(TextType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case TextType::test : return tr("Test");
|
||||
case TextType::UnderFire : return tr("UnderFire");
|
||||
case TextType::Injury : return tr("Injury");
|
||||
case TextType::Manipulation : return tr("Manipulation");
|
||||
case TextType::Kill : return tr("Kill");
|
||||
case TextType::State : return tr("State");
|
||||
case TextType::Error : return tr("Error");
|
||||
case TextType::Activation : return tr("Activation");
|
||||
case TextType::Messages : return tr("Messages");
|
||||
case TextType::AcousticOutputOnly : return tr("AcousticOutputOnly");
|
||||
case TextType::ClearDisplay : return tr("ClearDisplay");
|
||||
}
|
||||
return tr("Unknown (%1)").arg(int(type));
|
||||
}
|
||||
|
||||
QString MessagingModel::vbgVbaIndexToText(int type, int vbg)
|
||||
{
|
||||
|
||||
QString defaultError = tr("Unknown Message: (%1)").arg(vbg);
|
||||
switch (type)
|
||||
{
|
||||
case 5:
|
||||
{
|
||||
switch (vbg)
|
||||
{
|
||||
case 1:
|
||||
return tr("Active Equipment");
|
||||
case 3:
|
||||
return tr("Active Player Unit");
|
||||
case 4:
|
||||
return tr("Active Equipment");
|
||||
case 5:
|
||||
return tr("Connection Setup to Player Unit");
|
||||
case 6:
|
||||
return tr("Active Radio Communication");
|
||||
case 7:
|
||||
return tr("Ready for Action");
|
||||
default:
|
||||
return defaultError;
|
||||
} // vbg5
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
QString ret = tr("Error:") + QLatin1Char(' ');
|
||||
switch (vbg)
|
||||
{
|
||||
case 10:
|
||||
return ret + tr("Configuration");
|
||||
case 11:
|
||||
return ret + tr("No Radio Communication");
|
||||
case 12:
|
||||
return ret + tr("Login");
|
||||
case 13:
|
||||
return ret + tr("Licensing");
|
||||
case 20:
|
||||
return ret + tr("Player Unit");
|
||||
case 21:
|
||||
return ret + tr("Voltage Player Unit");
|
||||
case 40:
|
||||
return ret + tr("Effect Display");
|
||||
case 50:
|
||||
return ret + tr("Mine Sensor System");
|
||||
case 60:
|
||||
return ret + tr("Tactical Engagement Simulator"); //AGDUS
|
||||
case 70:
|
||||
return ret + tr("Special Sensor System");
|
||||
case 80:
|
||||
return ret + tr("Disply Unit");
|
||||
case 90:
|
||||
{
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
bool enableB = ps->value(QStringLiteral("aes"),
|
||||
QStringLiteral("enableBiologicalContamination")).toBool();
|
||||
bool enableC = ps->value(QStringLiteral("aes"),
|
||||
QStringLiteral("enableChemicalContamination")).toBool();
|
||||
bool enableN = ps->value(QStringLiteral("aes"),
|
||||
QStringLiteral("enableNuclearContaminations")).toBool();
|
||||
|
||||
if (!enableB && !enableC && enableN)
|
||||
return ret + tr("N Protection Sensor System");
|
||||
else if (enableB && !enableC && enableN)
|
||||
return ret + tr("NB Protection Sensor System");
|
||||
else if (!enableB && enableC && enableN)
|
||||
return ret + tr("NC Protection Sensor System");
|
||||
else if (enableB && !enableC && !enableN)
|
||||
return ret + tr("B Protection Sensor System");
|
||||
else if (enableB && enableC && !enableN)
|
||||
return ret + tr("BC Protection Sensor System");
|
||||
else if (!enableB && enableC && !enableN)
|
||||
return ret + tr("C Protection Sensor System");
|
||||
else
|
||||
return ret + tr("NBC Protection Sensor System");
|
||||
}
|
||||
default:
|
||||
return defaultError;
|
||||
}
|
||||
}
|
||||
case 8:
|
||||
{
|
||||
return tr("Active Pos");
|
||||
}
|
||||
|
||||
default:
|
||||
return defaultError;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
QVariant MessagingModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const Entry &data = m_vecData.at(index.row());
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case 0:
|
||||
return data.m_date;
|
||||
case 1:
|
||||
return data.m_msg;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void MessagingModel::clearModel()
|
||||
{
|
||||
ERROR_LOG(m_logger) << QDateTime::currentMSecsSinceEpoch();
|
||||
m_lastClearTime = QDateTime::currentMSecsSinceEpoch();
|
||||
ERROR_LOG(m_logger) << m_lastClearTime;
|
||||
|
||||
clear();
|
||||
}
|
||||
|
||||
} // namespace TrainingAreaBaseOC
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for Messaging - Messaging Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Chrsitian Roeskens, NLSE, 2018-05-03
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <TrainingAreaBaseOC/taboc_dtc.h>
|
||||
#include <TrainingAreaBaseOC/logger.h>
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <QDateTime>
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace TrainingAreaBaseOC
|
||||
{
|
||||
|
||||
struct Entry
|
||||
{
|
||||
Entry() = default;
|
||||
Entry(const QDateTime &date, const QString &msg) : m_date(date), m_msg(msg) {}
|
||||
|
||||
QDateTime m_date;
|
||||
QString m_msg;
|
||||
};
|
||||
|
||||
enum class TextType
|
||||
{
|
||||
test = 0,
|
||||
UnderFire = 1,
|
||||
Injury = 2,
|
||||
Manipulation = 3,
|
||||
Kill = 4,
|
||||
State = 5,
|
||||
Error = 6,
|
||||
Activation = 7,
|
||||
Messages = 8,
|
||||
AcousticOutputOnly = 9,
|
||||
ClearDisplay = 255,
|
||||
};
|
||||
|
||||
|
||||
// --------------------------------------------------------
|
||||
// MessagingModel
|
||||
// --------------------------------------------------------
|
||||
class MessagingModel final : public LtsWidgets::LtsAbstractTableModel<Entry>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MessagingModel(QObject *parent = nullptr);
|
||||
|
||||
bool initModel(const std::shared_ptr<TrainingAreaBaseOC::Interface::Dtc> &dtc, qint64 lastClearTime);
|
||||
|
||||
QVariant data(const QModelIndex &, int) const override;
|
||||
|
||||
public slots:
|
||||
void clearModel();
|
||||
|
||||
private:
|
||||
void insertData(const TrainingAreaBaseOC::FreeText &data, DataModification modType = DataModification::eAdded);
|
||||
void insertData(const TrainingAreaBaseOC::ShortMessage &data, DataModification modType = DataModification::eAdded);
|
||||
bool dontAdd(qint64 timeToCheck);
|
||||
static QString textTypeToString(TrainingAreaBaseOC::TextType type);
|
||||
static QString vbgVbaIndexToText(int type, int vbg);
|
||||
|
||||
std::shared_ptr<TrainingAreaBaseOC::Interface::Dtc> m_dtc;
|
||||
int m_operatorId;
|
||||
qint64 m_lastClearTime;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
} //namespace TrainingAreaBaseOC
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for TrainingAreaBase (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-09-19
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <PluginInterfaces/data_plugin_interface.h>
|
||||
#include <Proxies/TrainingAreaBaseOC/taboc_dtc.h>
|
||||
#include <Proxies/TrainingAreaBaseOC/taboc_ftc.h>
|
||||
|
||||
namespace TrainingAreaBaseOC
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
class Ftc;
|
||||
}
|
||||
}
|
||||
|
||||
namespace TrainingAreaBaseOC
|
||||
{
|
||||
/**
|
||||
* @brief The DataInterface class provides the Topics Clients only for the GUI Plugins
|
||||
*/
|
||||
class DataInterface : public DataPluginBase::Interface
|
||||
{
|
||||
public:
|
||||
using DataPluginBase::Interface::Interface;
|
||||
|
||||
virtual std::shared_ptr<TrainingAreaBaseOC::Interface::Dtc> getDtc() = 0;
|
||||
virtual std::shared_ptr<TrainingAreaBaseOC::Interface::Ftc> getFtc() = 0;
|
||||
};
|
||||
|
||||
} // namespace TrainingAreaBaseOC
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
*
|
||||
* Notifcation plugin for TAB connection states
|
||||
*
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Dassow Philipp, SLST, 2017-09-19
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
class QObject;
|
||||
|
||||
namespace TrainingAreaBaseOC
|
||||
{
|
||||
class ForeignGuiInterface
|
||||
{
|
||||
public:
|
||||
ForeignGuiInterface() = default;
|
||||
virtual ~ForeignGuiInterface() = default;
|
||||
|
||||
static QString pluginName() { return QStringLiteral("TrainingAreaBaseOCGuiPlugin"); }
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user