Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,51 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Patric Karwat, SLSE, 2016-10-05
|
||||
#
|
||||
|
||||
SET(alm_emergency_call_gui_SRCS
|
||||
|
||||
alm_emergency_call_gui_plugin.cpp
|
||||
alm_emergency_call_gui_plugin.h
|
||||
alm_emergency_call_dialog.cpp
|
||||
alm_emergency_call_dialog.h
|
||||
alm_emergency_call_model.cpp
|
||||
alm_emergency_call_model.h
|
||||
alm_emergency_call_info_dialog.cpp
|
||||
alm_emergency_call_info_dialog.h
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(alm_emergency_call_gui_SRCS
|
||||
alm_emergency_call_dialog.ui
|
||||
alm_emergency_call_info_dialog.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS AlmEmergencyCallGuiPlugin MODULE ${alm_emergency_call_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(AlmEmergencyCallGuiPlugin
|
||||
LtsPrinting
|
||||
AlmCommon
|
||||
svcTabCommon
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
LtsUtilsSettings
|
||||
#AlmGuiPluginInterface
|
||||
AlmInfoGuiPluginInterface
|
||||
AlmDataPluginInterface
|
||||
OpmDataPluginInterface
|
||||
ExmDataPluginInterface
|
||||
#svcPdmCommon # pdm_enums.h in alm_dialog.cpp
|
||||
#svcPpmCommon
|
||||
GuiPluginInterface
|
||||
Qt5::Widgets
|
||||
LtsCoordTrans
|
||||
LtsWidgets
|
||||
LtsDataView
|
||||
SituationMapGuiPluginInterface
|
||||
NGLLogger
|
||||
LtsUtilsGuiDds
|
||||
LtsAppManager # get sessions to look on which one to open alarm history
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(AlmEmergencyCallGuiPlugin)
|
||||
+284
@@ -0,0 +1,284 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AlarmManagement (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Steve Kemayou, SLSE, 2023-05-26
|
||||
*/
|
||||
|
||||
#include "alm_emergency_call_dialog.h"
|
||||
#include "ui_alm_emergency_call_dialog.h"
|
||||
#include "AlarmManagement/Gui/EmergencyCalls/alm_emergency_call_model.h"
|
||||
#include <Services/AlarmManagement/alm_operator_rights.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <ExerciseManagement/exm_data_plugin_interface.h>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
|
||||
|
||||
EmergencyCallDialog::EmergencyCallDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_session(nullptr)
|
||||
, m_ui(new Ui::EmergencyCallDialog)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_logger(getLogger("EmergencyCallDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
|
||||
void EmergencyCallDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Emergency Call "));
|
||||
}
|
||||
|
||||
bool EmergencyCallDialog::init(const std::shared_ptr<AlarmManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
|
||||
LtsSession::LtsSession *session)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START ";
|
||||
if (!ftc || !dtc || !session){
|
||||
ERROR_LOG(m_logger)<<" init Emergency call dialog failed !!";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_ftc = ftc;
|
||||
m_dtc = dtc;
|
||||
m_opmDtc = opmDtc;
|
||||
m_session = session;
|
||||
m_dtc->enableAlmEmergencyCall();
|
||||
m_ftc->enableEmergencyCallAcknowledge();
|
||||
m_sitMapGuiIfc = sitMapGuiIfc;
|
||||
|
||||
|
||||
delete m_model;
|
||||
m_model = new AlarmManagement::EmergencyCallModel(this);
|
||||
m_model->initModel(m_dtc, opmDtc);
|
||||
|
||||
m_proxyModel = new EmergencyCallProxyModel(this);
|
||||
m_proxyModel->setSourceModel(m_model);
|
||||
m_ui->emergencyCallView->setModel(m_proxyModel);
|
||||
m_proxyModel->hideByExerciseStopped(m_session->exerciseState()!=LtsWidgets::ExcState::eStarted &&
|
||||
m_session->exerciseState() != LtsWidgets::ExcState::ePaused);
|
||||
m_ui->emergencyCallView->setSortingEnabled(true);
|
||||
m_ui->emergencyCallView->resizeSection(EmergencyCallModel::Columns::SAMPLE_TIME, 300);
|
||||
m_ui->emergencyCallView->resizeSection(EmergencyCallModel::Columns::POSITION, 300);
|
||||
m_ui->emergencyCallView->resizeSection(EmergencyCallModel::Columns::DELETED_TIMESTAMP, 300);
|
||||
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setText(tr("Acknowledge"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setText(tr("Center"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setIcon(QIcon(QStringLiteral("icon:center_to_object.svg")));
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &EmergencyCallDialog::onEditBtCliked);
|
||||
|
||||
const bool &hasOperatorRightEmergencyCall = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::EmergencyCall);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setVisible(hasOperatorRightEmergencyCall);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Show, this, &EmergencyCallDialog::onFindEmergencyOnMap);
|
||||
|
||||
|
||||
//cbx show expired
|
||||
QCheckBox *cbExpired = new QCheckBox(tr("Show expired"), m_ui->emergencyCallView);
|
||||
cbExpired->setProperty("const", true);
|
||||
m_ui->emergencyCallView->setCustomWidget(cbExpired);
|
||||
connect(cbExpired, &QCheckBox::toggled, this, &EmergencyCallDialog::onSetShowExpired);
|
||||
|
||||
connect(m_ui->emergencyCallView, &LtsDataView::LtsDataView::signalSelectionChanged, this, &EmergencyCallDialog::enaDisa);
|
||||
connect(m_ui->emergencyCallView, &LtsDataView::LtsDataView::doubleClicked, this, &EmergencyCallDialog::onEmergencyIndexDoubleClicked);
|
||||
enaDisa();
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->emergencyCallView->hideColumn(EmergencyCallModel::ID);
|
||||
m_ui->emergencyCallView->hideColumn(EmergencyCallModel::SAMPLE_TIME);
|
||||
m_ui->emergencyCallView->hideColumn(EmergencyCallModel::NAME);
|
||||
m_ui->emergencyCallView->hideColumn(EmergencyCallModel::EXPIRED);
|
||||
#endif
|
||||
|
||||
INFO_LOG(m_logger) << "EmergencyCallDialog::init done";
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief EmergencyCallDialog::enaDisa
|
||||
* enable 'acknowledge' button when selected has expired= false
|
||||
*/
|
||||
void EmergencyCallDialog::enaDisa()
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, false);
|
||||
|
||||
const AlmEmergencyCall &sos = getSelectedSOS();
|
||||
if (sos.id() <= 0)
|
||||
return;
|
||||
|
||||
if (!sos.expired())
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, true);
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, true);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief EmergencyCallDialog::getSelectedSOS
|
||||
* \return
|
||||
*/
|
||||
AlmEmergencyCall EmergencyCallDialog::getSelectedSOS()
|
||||
{
|
||||
QModelIndexList indexList = m_ui->emergencyCallView->selectedRows();
|
||||
if (indexList.isEmpty())
|
||||
return {};
|
||||
|
||||
return m_model->getRowData(indexList.front().row());
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* \brief EmergencyCallDialog::setAcknowledgeUi
|
||||
*/
|
||||
void EmergencyCallDialog::setAcknowledgeUi()
|
||||
{
|
||||
LtsWidgets::LtsFramelessDialog *popup = new LtsWidgets::LtsFramelessDialog(this, LtsWidgets::Behaviour::Popup);
|
||||
LtsWidgets::LtsDialogButtonBox *btnBox = new LtsWidgets::LtsDialogButtonBox(popup);
|
||||
btnBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(false);
|
||||
QVBoxLayout *lay = new QVBoxLayout(popup);
|
||||
QLineEdit *le = new QLineEdit(popup);
|
||||
QLabel *lblTxt = new QLabel(tr("Acknowledged by:"), popup);
|
||||
|
||||
connect(btnBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, popup, &LtsWidgets::LtsFramelessDialog::accept);
|
||||
|
||||
//check if total text count > than textMinSize
|
||||
connect(le, &QLineEdit::textChanged, this, [btnBox](const QString &text)
|
||||
{
|
||||
const int textMinSize = 5;
|
||||
btnBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(text.trimmed().size() >= textMinSize);
|
||||
});
|
||||
// on ok clicked acknowledge emergency
|
||||
connect(btnBox->getButton(LtsWidgets::DialogButton::Ok), &QPushButton::clicked, this, [this, le, popup]()
|
||||
{
|
||||
sendAcknowledgeEmergency(le->text());
|
||||
popup->accept();
|
||||
});
|
||||
|
||||
lay->addWidget(lblTxt);
|
||||
lay->addWidget(le);
|
||||
lay->addWidget(btnBox);
|
||||
popup->setLayout(lay);
|
||||
popup->setMinimumWidth(350);
|
||||
popup->show();
|
||||
le->setFocus();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief EmergencyCallDialog::onEditBtCliked
|
||||
*/
|
||||
void EmergencyCallDialog::onEditBtCliked()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
|
||||
const AlmEmergencyCall &sos = getSelectedSOS();
|
||||
if (sos.id() <= 0)
|
||||
return;
|
||||
setAcknowledgeUi();
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* \brief EmergencyCallDialog::setShowExpire
|
||||
*/
|
||||
void EmergencyCallDialog::onSetShowExpired(bool show)
|
||||
{
|
||||
if (m_proxyModel)
|
||||
m_proxyModel->setShowExpired(show);
|
||||
|
||||
// initialisation of class to display expired sos calls only if needed:
|
||||
if (!m_updateSOSGuard)
|
||||
m_updateSOSGuard = QSharedPointer<UpdateSOSGuard>(new UpdateSOSGuard(m_sitMapGuiIfc));
|
||||
m_updateSOSGuard->showExpiredSOS(show);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief EmergencyCallDialog::onFindEmergencyOnMap
|
||||
* \param position
|
||||
*/
|
||||
void EmergencyCallDialog::onFindEmergencyOnMap()
|
||||
{
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
|
||||
const AlmEmergencyCall &sos = getSelectedSOS();
|
||||
if (sos.id() <= 0)
|
||||
return;
|
||||
|
||||
m_sitMapGuiIfc->setCenterPoint(QPointF(sos.position().lon(), sos.position().lat()));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief EmergencyCallDialog::onEmergencyIndexDoubleClicked
|
||||
* \param index
|
||||
*/
|
||||
void EmergencyCallDialog::onEmergencyIndexDoubleClicked(const QModelIndex &index)
|
||||
{
|
||||
Q_UNUSED(index)
|
||||
emit openInfoDlg(getSelectedSOS().id());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief EmergencyCallDialog::onRemove
|
||||
* this method is use to acknowledge/quit the emergency call request
|
||||
*/
|
||||
void EmergencyCallDialog::sendAcknowledgeEmergency(const QString &comment)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
|
||||
const AlmEmergencyCall &sos = getSelectedSOS();
|
||||
if (sos.id() <= 0 || sos.expired())
|
||||
return;
|
||||
|
||||
EmergencyCallAcknowledgeRequest request;
|
||||
request.id(sos.id());
|
||||
request.issi(sos.issi());
|
||||
request.name(sos.name());
|
||||
request.timestamp(QDateTime::currentMSecsSinceEpoch());
|
||||
request.incomingTime(sos.incomingTime());
|
||||
request.expired(true);
|
||||
request.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
request.comment(comment.toStdString());
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
{
|
||||
return m_ftc->emergencyCallAcknowledgeRequest(request, this);
|
||||
});
|
||||
|
||||
enaDisa();
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
void EmergencyCallDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
//LtsColumnOrganiser
|
||||
m_ui->emergencyCallView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
EmergencyCallDialog::~EmergencyCallDialog()
|
||||
{
|
||||
// m_updateSOSGuard will be destroyed via QSharedPointer,
|
||||
// which hold it´s own shared_ptr/sitMapGuiIfc;
|
||||
// Therefore showExpiredEmergencyCalls(false) will be called
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
}// namespace AlarmManagement
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AlarmManagement (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Steve Kemayou, SLSE, 2023-05-26
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Services/AlarmManagement/alm_ftc.h>
|
||||
#include <Services/AlarmManagement/alm_dtc.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <AlarmManagement/logger.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include <QWidget>
|
||||
#include <QDebug>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class EmergencyCallDialog;
|
||||
}
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief The UpdateSOSGuard class
|
||||
*/
|
||||
class UpdateSOSGuard
|
||||
{
|
||||
public:
|
||||
explicit UpdateSOSGuard(const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc)
|
||||
: m_sitMapGuiIfc(sitMapGuiIfc)
|
||||
{}
|
||||
|
||||
~UpdateSOSGuard()
|
||||
{
|
||||
if (m_sitMapGuiIfc)
|
||||
m_sitMapGuiIfc->showExpiredEmergencyCalls(false);
|
||||
}
|
||||
void showExpiredSOS(bool visible)
|
||||
{
|
||||
if (m_sitMapGuiIfc)
|
||||
m_sitMapGuiIfc->showExpiredEmergencyCalls(visible);
|
||||
}
|
||||
private:
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
};
|
||||
|
||||
|
||||
class EmergencyCallModel;
|
||||
class EmergencyCallProxyModel;
|
||||
|
||||
class EmergencyCallDialog final : public LtsWidgets::LtsDialog
|
||||
, AlarmManagement::Interface::Ftc::EmergencyCallAcknowledgeReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EmergencyCallDialog(QWidget *parent = nullptr);
|
||||
~EmergencyCallDialog();
|
||||
|
||||
bool init(const std::shared_ptr<AlarmManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
|
||||
LtsSession::LtsSession *session);
|
||||
|
||||
void retranslate() override;
|
||||
void enaDisa();
|
||||
AlmEmergencyCall getSelectedSOS();
|
||||
|
||||
protected:
|
||||
void onEmergencyCallAcknowledgeReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void setAcknowledgeUi();
|
||||
private slots:
|
||||
void onEditBtCliked();
|
||||
void onSetShowExpired(bool show);
|
||||
void onFindEmergencyOnMap();
|
||||
void onEmergencyIndexDoubleClicked(const QModelIndex &index);
|
||||
signals:
|
||||
void openInfoDlg(int id);
|
||||
private:
|
||||
void sendAcknowledgeEmergency(const QString &comment);
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
private:
|
||||
EmergencyCallModel *m_model{nullptr};
|
||||
EmergencyCallProxyModel *m_proxyModel{nullptr};
|
||||
|
||||
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<AlarmManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
|
||||
LtsSession::LtsSession *m_session;
|
||||
|
||||
|
||||
Ui::EmergencyCallDialog *m_ui;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
LOGGER_T m_logger;
|
||||
|
||||
friend class UpdateSOSGuard;
|
||||
QSharedPointer<UpdateSOSGuard> m_updateSOSGuard;
|
||||
|
||||
};
|
||||
|
||||
}// namespace EmergencyCallDialog
|
||||
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>EmergencyCallDialog</class>
|
||||
<widget class="QWidget" name="EmergencyCallDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>406</width>
|
||||
<height>266</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="LtsDataView::LtsDataView" name="emergencyCallView" 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>
|
||||
+164
@@ -0,0 +1,164 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AlarmManagement (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Steve Kemayou, SLSE, 2023-05-26
|
||||
*/
|
||||
|
||||
|
||||
#include "alm_emergency_call_gui_plugin.h"
|
||||
#include <Services/AlarmManagement/alm_operator_rights.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <LtsAppManager/lts_app_manager.h>
|
||||
#include "alm_emergency_call_info_dialog.h"
|
||||
|
||||
#include <QDebug>
|
||||
namespace AlarmManagement
|
||||
{
|
||||
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.Interface"))
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_exmDtc(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
bool InterfaceImpl::fetchInterfaces()
|
||||
{
|
||||
if (!m_session->getDtc<AlarmManagement::DataInterface>(m_dtc))
|
||||
return false;
|
||||
if (!m_session->getFtc<AlarmManagement::DataInterface>(m_ftc))
|
||||
return false;
|
||||
if (!m_session->getDtc<OperatorManagement::DataInterface>(m_opmDtc))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "getDtc for OperatorManagement::DataInterface failed.";
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getDtc<ExerciseManagement::DataInterface>(m_exmDtc))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "getDtc for ExerciseManagement::DataInterface failed.";
|
||||
return false;
|
||||
}
|
||||
m_exmDtc->waitForHistoricalDataExercise();
|
||||
m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitmapGuIfc);
|
||||
|
||||
connect(m_dtc.get(), &AlarmManagement::Interface::Dtc::almEmergencyCallChanged,
|
||||
this, &InterfaceImpl::onEmergencyCallChanged, Qt::UniqueConnection);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void InterfaceImpl::clearInterfaces()
|
||||
{
|
||||
m_ftc = nullptr;
|
||||
m_dtc = nullptr;
|
||||
m_sitmapGuIfc = nullptr;
|
||||
}
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
LtsWidgets::PluginData plData;
|
||||
plData.menuGroup = menuGroup();
|
||||
|
||||
// Action 'EmergencyCall' anlegen
|
||||
plData.menuText = tr("Emergency Calls");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:emergency_call_enabled.svg"));
|
||||
plData.identifier = QLatin1String("almEmergencyCall");
|
||||
plData.layoutArea = LtsWidgets::LayoutArea::eDialogTab;
|
||||
plData.operatorRight = OperatorRights::ConfigGlobalDialog;
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eExecution;
|
||||
plData.createWidgetFunc = [this](QWidget * parent)
|
||||
{
|
||||
return slotShowEmergencyCallDialog(parent);;
|
||||
};
|
||||
ret.append(plData);
|
||||
|
||||
auto cb = [this](const AlmEmergencyCall &data)
|
||||
{
|
||||
if (data.id() <= 0 || data.expired())
|
||||
return;
|
||||
this->showEmergencyCallInfoWindow(data.id());
|
||||
};
|
||||
m_dtc->almEmergencyCalls(cb);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::slotShowEmergencyCallDialog(QWidget *parent)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "slotShowEmergencyCallDialog";
|
||||
|
||||
AlarmManagement::EmergencyCallDialog *emergencyDialog = new EmergencyCallDialog(parent);
|
||||
emergencyDialog->setOnlineHelpFilename(QStringLiteral("SOS_02"));
|
||||
connect(emergencyDialog, &AlarmManagement::EmergencyCallDialog::openInfoDlg, this, &InterfaceImpl::onOpenInfoDlg);
|
||||
return LtsWidgets::initDialog(emergencyDialog, m_ftc, m_dtc, m_sitmapGuIfc, m_opmDtc, m_session);
|
||||
}
|
||||
|
||||
void InterfaceImpl::showEmergencyCallInfoWindows(const QVector<int32_t> &entityIds)
|
||||
{
|
||||
for (auto id : entityIds)
|
||||
this->showEmergencyCallInfoWindow(id);
|
||||
}
|
||||
|
||||
void InterfaceImpl::onEmergencyCallChanged(const AlmEmergencyCall &data, DataModification modType)
|
||||
{
|
||||
if (modType != DataModification::eAdded)
|
||||
return;
|
||||
if (data.id() <= 0 || data.expired())
|
||||
return;
|
||||
|
||||
this->showEmergencyCallInfoWindow(data.id());
|
||||
}
|
||||
|
||||
void InterfaceImpl::onOpenInfoDlg(const int &id)
|
||||
{
|
||||
this->showEmergencyCallInfoWindow(id);
|
||||
}
|
||||
|
||||
void InterfaceImpl::showEmergencyCallInfoWindow(const int id)
|
||||
{
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> dtc;
|
||||
std::shared_ptr<AlarmManagement::Interface::Ftc> ftc;
|
||||
if (!m_session->getDtc<AlarmManagement::DataInterface>(dtc)
|
||||
|| !m_session->getFtc<AlarmManagement::DataInterface>(ftc))
|
||||
{
|
||||
new LtsWidgets::LtsMessageDialogNew(m_session->baseLayout(), tr("The Alarm Management is not available!"), tr("Cannot open Emergency Call Info Dialog"));
|
||||
return;
|
||||
}
|
||||
const QVector<LtsAppDescriptor::App> notValidApps {LtsAppDescriptor::App::PlanEditor,
|
||||
LtsAppDescriptor::App::Scripts,
|
||||
LtsAppDescriptor::App::Timeline,
|
||||
LtsAppDescriptor::App::BuildingViewer};
|
||||
|
||||
if (m_session->partitionType() == IDL::PartitionType::Replay
|
||||
|| m_session->exerciseState() == LtsWidgets::ExcState::eStopped
|
||||
|| notValidApps.contains(m_session->app()))
|
||||
return;
|
||||
|
||||
AlarmManagement::EmergencyCallInfoDialog *infoDialog = new EmergencyCallInfoDialog(id);
|
||||
infoDialog->setOnlineHelpFilename(QStringLiteral("SOS_01"));
|
||||
if (!infoDialog->init(ftc, dtc, m_sitmapGuIfc, m_opmDtc))
|
||||
{
|
||||
delete infoDialog;
|
||||
return;
|
||||
}
|
||||
m_session->addWidget(infoDialog, menuGroup(), infoDialog->emergencyIdentifier(), LtsWidgets::LayoutArea::eInfoTab);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace AlarmManagement
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AlarmManagement (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Steve Kemayou, SLSE, 2023-05-26
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "alm_emergency_call_dialog.h"
|
||||
#include <AlarmManagement/logger.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AlarmManagement/alm_gui_plugin_interface.h>
|
||||
#include <Plugins/AlarmManagement/alm_data_plugin_interface.h>
|
||||
#include <Plugins/AlarmManagement/alm_info_gui_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
//#include <Services/OperatorManagement/opm_dtc.h>
|
||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||
#include <ExerciseManagement/exm_data_plugin_interface.h>
|
||||
#include <ExerciseManagement/exm_dtc.h>
|
||||
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:alm.emergencycall")
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return QStringLiteral("AlmEmergencyCall"); }
|
||||
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::Replay;
|
||||
}
|
||||
};
|
||||
|
||||
class InterfaceImpl final
|
||||
: public QObject
|
||||
, public GuiPluginBase::Interface
|
||||
, public ForeignInfoGuiInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
bool fetchInterfaces() override;
|
||||
void clearInterfaces() override;
|
||||
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
QString menuGroup() const override { return tr("Alarm Management"); }
|
||||
|
||||
void showEmergencyCallInfoWindow(const int id) override;
|
||||
public slots:
|
||||
void showEmergencyCallInfoWindows(const QVector<int32_t> &entityIds) override final;
|
||||
void onEmergencyCallChanged(const AlarmManagement::AlmEmergencyCall &data, DataModification modType);
|
||||
void onOpenInfoDlg(const int &id);
|
||||
|
||||
private: // methods
|
||||
LtsWidgets::LtsDialog *slotShowEmergencyCallDialog(QWidget *parent);
|
||||
|
||||
private:
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<AlarmManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_exmDtc;
|
||||
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitmapGuIfc;
|
||||
|
||||
};
|
||||
|
||||
} // namespace AlarmManagement
|
||||
+268
@@ -0,0 +1,268 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AlarmManagement (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Steve Kemayou, SLSE, 2023-05-26
|
||||
*/
|
||||
|
||||
#include "alm_emergency_call_info_dialog.h"
|
||||
#include "ui_alm_emergency_call_info_dialog.h"
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <AlarmManagement/alm_operator_rights.h>
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
|
||||
QImage renderEmergencySymbol(bool expired = false)
|
||||
{
|
||||
int size = 64;
|
||||
QImage image(size, size, QImage::Format_ARGB32);
|
||||
image.fill(Qt::transparent);
|
||||
|
||||
QPainter painter(&image);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
QPen pen(Qt::white);
|
||||
pen.setWidth(3);
|
||||
painter.setPen(pen);
|
||||
|
||||
painter.setBrush( expired ? QBrush(Qt::gray) : QBrush(Qt::red));
|
||||
painter.drawEllipse(QPointF(image.rect().center()),
|
||||
image.rect().width() * 0.45,
|
||||
image.rect().height() * 0.45);
|
||||
|
||||
painter.setPen(QPen(Qt::white));
|
||||
|
||||
QFont font = painter.font();
|
||||
font.setBold(true);
|
||||
font.setPixelSize(26);
|
||||
painter.setFont(font);
|
||||
|
||||
QPointF pos(image.width() * 0.125,
|
||||
image.height() * 0.625);
|
||||
|
||||
painter.drawText(pos, QLatin1String("SOS"));
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief EmergencyCallInfoDialog::EmergencyCallInfoDialog
|
||||
* \param entryId
|
||||
* \param parent
|
||||
*/
|
||||
EmergencyCallInfoDialog::EmergencyCallInfoDialog(int entryId, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_logger(getLogger("EmergencyCallInfoDialog"))
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::EmergencyCallInfoDialog)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_emergency.id(entryId);
|
||||
}
|
||||
|
||||
EmergencyCallInfoDialog::~EmergencyCallInfoDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief EmergencyCallInfoDialog::init
|
||||
* \param ftc
|
||||
* \param dtc
|
||||
* \param sitMapGuiIfc
|
||||
* \return
|
||||
*/
|
||||
bool EmergencyCallInfoDialog::init(const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc>&opmDtc)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
if (!ftc || !dtc)
|
||||
{
|
||||
ERROR_LOG(m_logger)<<" init Emergency call Info dialog failed !!";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_opmDtc = opmDtc;
|
||||
m_sitMapGuiIfc = sitMapGuiIfc;
|
||||
|
||||
m_dtc->enableAlmEmergencyCall();
|
||||
m_ftc->enableEmergencyCallAcknowledge();
|
||||
|
||||
//center tp sos
|
||||
m_emergency = m_dtc->almEmergencyCall(m_emergency.id());
|
||||
setUiValues();
|
||||
|
||||
connect(m_dtc.get(), &AlarmManagement::Interface::Dtc::almEmergencyCallChanged, this, &EmergencyCallInfoDialog::onEmergencyCallChanged );
|
||||
connect(m_ui->pbAckEmergency, &QPushButton::clicked, this, &EmergencyCallInfoDialog::onPbAckEmergencyClicked );
|
||||
connect(m_ui->pbEmergencyCallFindOnMap, &QPushButton::clicked, this, &EmergencyCallInfoDialog::onFindEmergencyOnMap);
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief EmergencyCallInfoDialog::emergencyIdentifier
|
||||
* \return
|
||||
*/
|
||||
QString EmergencyCallInfoDialog::emergencyIdentifier() const
|
||||
{
|
||||
return QStringLiteral("emergency_") + QString::number(m_emergency.id());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief EmergencyCallInfoDialog::setUiValues
|
||||
* \return
|
||||
*/
|
||||
bool EmergencyCallInfoDialog::setUiValues()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
if (!m_dtc || !m_ftc || m_emergency.id() < 0)
|
||||
{
|
||||
ERROR_LOG(m_logger)<<" >> unabled to init EmergencyCallInfoDialog";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_ui->lblEquipNr->setText(QString::number(m_emergency.issi()));
|
||||
m_ui->lblIncomingTime->setText(DTG::toString(QDateTime::fromMSecsSinceEpoch(m_emergency.incomingTime())));//.toString(QStringLiteral("dd hhmmss Z MMMM yy")));
|
||||
m_ui->lblStatus->setText(m_emergency.expired() ? DTG::toString(QDateTime::fromMSecsSinceEpoch(m_emergency.deleted())) : QStringLiteral("--"));
|
||||
m_ui->lblComment->setText(QString::fromStdString(m_emergency.comment()));
|
||||
QString mgrs = LtsCoordTrans::mgrsFromGeographic(m_emergency.position().lon(), m_emergency.position().lat());
|
||||
m_ui->lblPosition->setText(mgrs);
|
||||
|
||||
// ack button
|
||||
const bool &hasOperatorRightEmergencyCall = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::EmergencyCall);
|
||||
m_ui->pbAckEmergency->setIcon(QIcon(QStringLiteral("icon:edit.svg")));
|
||||
m_ui->pbAckEmergency->setEnabled(m_emergency.expired() ? false : true);
|
||||
m_ui->pbAckEmergency->setVisible(hasOperatorRightEmergencyCall);
|
||||
|
||||
// render icon
|
||||
QPixmap iconPixmap = QPixmap::fromImage(renderEmergencySymbol(m_emergency.expired()));
|
||||
m_ui->lblIcon->setPixmap(iconPixmap);
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief EmergencyCallInfoDialog::onEmergencyCallChanged
|
||||
* \param data
|
||||
* \param modType
|
||||
*/
|
||||
void EmergencyCallInfoDialog::onEmergencyCallChanged(AlarmManagement::AlmEmergencyCall data, DataModification modType)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
if (data.id() != m_emergency.id() || data.id() == 0)
|
||||
return;
|
||||
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
m_ui->pbAckEmergency->setEnabled(false);
|
||||
m_ui->pbEmergencyCallFindOnMap->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
if (modType == DataModification::eModified)
|
||||
{
|
||||
m_emergency = data;
|
||||
setUiValues();
|
||||
}
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief EmergencyCallInfoDialog::onFindEmergencyOnMap
|
||||
* slot function to center map on specific object by it position
|
||||
*/
|
||||
void EmergencyCallInfoDialog::onFindEmergencyOnMap()
|
||||
{
|
||||
if (!m_sitMapGuiIfc || m_emergency.id() <= 0)
|
||||
return;
|
||||
m_sitMapGuiIfc->setCenterPoint(QPointF(m_emergency.position().lon(), m_emergency.position().lat()));
|
||||
}
|
||||
|
||||
void EmergencyCallInfoDialog::onPbAckEmergencyClicked()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
|
||||
LtsWidgets::LtsFramelessDialog *popup = new LtsWidgets::LtsFramelessDialog(this, LtsWidgets::Behaviour::Popup);
|
||||
LtsWidgets::LtsDialogButtonBox *btnBox = new LtsWidgets::LtsDialogButtonBox(popup);
|
||||
btnBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(false);
|
||||
QVBoxLayout *lay = new QVBoxLayout(popup);
|
||||
QLineEdit *le = new QLineEdit(popup);
|
||||
QLabel *lblTxt = new QLabel(tr("Acknowledged by:"), popup);
|
||||
|
||||
connect(btnBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, popup, &LtsWidgets::LtsFramelessDialog::accept);
|
||||
|
||||
//check if total text count > than textMinSize
|
||||
connect(le, &QLineEdit::textChanged, this, [btnBox](const QString &text)
|
||||
{
|
||||
const int textMinSize = 5;
|
||||
btnBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(text.trimmed().size() >= textMinSize);
|
||||
});
|
||||
|
||||
connect(btnBox->getButton(LtsWidgets::DialogButton::Ok), &QPushButton::clicked, this, [this, le, popup]()
|
||||
{
|
||||
const QString c = le->text().trimmed();
|
||||
sendAcknowledgeEmergencyCallRequest(c);
|
||||
popup->accept();
|
||||
});
|
||||
|
||||
lay->addWidget(lblTxt);
|
||||
lay->addWidget(le);
|
||||
lay->addWidget(btnBox);
|
||||
popup->setLayout(lay);
|
||||
popup->setMinimumWidth(350);
|
||||
popup->show();
|
||||
le->setFocus();
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief EmergencyCallInfoDialog::sendAcknowledgeEmergencyCallRequest
|
||||
* \param comment
|
||||
*/
|
||||
void EmergencyCallInfoDialog::sendAcknowledgeEmergencyCallRequest(const QString &comment)
|
||||
{
|
||||
if (m_emergency.id() <= 0)
|
||||
return ;
|
||||
|
||||
EmergencyCallAcknowledgeRequest request;
|
||||
request.id(m_emergency.id());
|
||||
request.name(m_emergency.name());
|
||||
request.issi(m_emergency.issi());
|
||||
request.timestamp(QDateTime::currentMSecsSinceEpoch());
|
||||
request.incomingTime(m_emergency.incomingTime());
|
||||
request.expired(true);
|
||||
request.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
request.comment(comment.toStdString());
|
||||
bool ret = m_requestHelper->startSingleRequest([this, request]()
|
||||
{
|
||||
return m_ftc->emergencyCallAcknowledgeRequest(request, this);
|
||||
});
|
||||
|
||||
if (ret)
|
||||
setUiValues();
|
||||
}
|
||||
|
||||
void EmergencyCallInfoDialog::retranslate()
|
||||
{
|
||||
m_emergency = m_dtc->almEmergencyCall(m_emergency.id());
|
||||
const QString lbName = tr("SOS_%1").arg(m_emergency.issi());
|
||||
translate(m_ui, lbName);
|
||||
}
|
||||
|
||||
|
||||
} // namespace AlarmManagement
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AlarmManagement (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Steve Kemayou, SLSE, 2023-05-26
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <Services/AlarmManagement/alm_ftc.h>
|
||||
#include <Services/AlarmManagement/alm_dtc.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <AlarmManagement/logger.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class EmergencyCallInfoDialog;
|
||||
}
|
||||
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
class EmergencyCallInfoDialog : public LtsWidgets::LtsDialog
|
||||
, protected AlarmManagement::Interface::Ftc::EmergencyCallAcknowledgeReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EmergencyCallInfoDialog(int entryId, QWidget *parent = nullptr);
|
||||
~EmergencyCallInfoDialog();
|
||||
bool init(const std::shared_ptr<AlarmManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc);
|
||||
QString emergencyIdentifier() const;
|
||||
|
||||
bool setUiValues();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onEmergencyCallChanged(AlmEmergencyCall data, DataModification modType);
|
||||
void onFindEmergencyOnMap();
|
||||
void onPbAckEmergencyClicked();
|
||||
|
||||
|
||||
protected:
|
||||
void onEmergencyCallAcknowledgeReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void sendAcknowledgeEmergencyCallRequest(const QString &comment);
|
||||
private:
|
||||
void retranslate() override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<AlarmManagement::Interface::Ftc> m_ftc;
|
||||
AlarmManagement::AlmEmergencyCall m_emergency;
|
||||
LOGGER_T m_logger;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
|
||||
|
||||
Ui::EmergencyCallInfoDialog *m_ui;
|
||||
};
|
||||
|
||||
} // namespace AlarmManagement
|
||||
+252
@@ -0,0 +1,252 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>EmergencyCallInfoDialog</class>
|
||||
<widget class="QWidget" name="EmergencyCallInfoDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>420</width>
|
||||
<height>556</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="verticalSpacing">
|
||||
<number>16</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbEquipNr">
|
||||
<property name="text">
|
||||
<string>Equip. No.:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>138</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="4">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<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>
|
||||
<widget class="QLabel" name="lblIcon">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbIncomingTime">
|
||||
<property name="text">
|
||||
<string>Incoming Time:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="3">
|
||||
<widget class="QLabel" name="lblIncomingTime">
|
||||
<property name="text">
|
||||
<string notr="true"><TIMESTAMP></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="3">
|
||||
<widget class="QLabel" name="lblEquipNr">
|
||||
<property name="text">
|
||||
<string notr="true"><EUIPNR></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="lblStatus">
|
||||
<property name="text">
|
||||
<string notr="true"><STATUS></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QToolButton" name="pbAckEmergency">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Acknowledge SOS</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLabel" name="lblPosition">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><POSITION></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QToolButton" name="pbEmergencyCallFindOnMap">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Find on Map</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/style/center_to_object.svg</normaloff>:/style/center_to_object.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>138</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbComment">
|
||||
<property name="text">
|
||||
<string>Acknowledged by:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbStatus">
|
||||
<property name="text">
|
||||
<string>Acknowledged:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbPosition">
|
||||
<property name="text">
|
||||
<string>Position:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" colspan="3">
|
||||
<widget class="QLabel" name="lblComment">
|
||||
<property name="text">
|
||||
<string notr="true"><COMMENT></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="4">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>358</width>
|
||||
<height>288</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsElidedLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>LtsWidgets/lts_elided_label.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+164
@@ -0,0 +1,164 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AlarmManagement (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Steve Kemayou, SLSE, 2023-05-26
|
||||
*/
|
||||
|
||||
#include "alm_emergency_call_model.h"
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
EmergencyCallModel::EmergencyCallModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<AlarmManagement::AlmEmergencyCall>(
|
||||
{
|
||||
tr("Id"),
|
||||
tr("Sample Time"),
|
||||
tr("Incoming Time"),
|
||||
tr("Name"),
|
||||
tr("Issi"),
|
||||
tr("Position"),
|
||||
tr("Expired"),
|
||||
tr("Operator"),
|
||||
tr("Deleted Timestamp"),
|
||||
tr("Comment"),
|
||||
}, parent)
|
||||
, m_dtc(nullptr)
|
||||
, m_logger(getLogger("EmergencyCallModel"))
|
||||
{}
|
||||
|
||||
QVariant EmergencyCallModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const AlarmManagement::AlmEmergencyCall &almEmergency = m_vecData.at(index.row());
|
||||
switch (index.column())
|
||||
{
|
||||
case Columns::ID:
|
||||
return almEmergency.id();
|
||||
case SAMPLE_TIME:
|
||||
return QDateTime::fromMSecsSinceEpoch(almEmergency.sampleTime());
|
||||
case INCOMING_TIME:
|
||||
return QDateTime::fromMSecsSinceEpoch(almEmergency.incomingTime());
|
||||
case NAME:
|
||||
return QString::fromStdString(almEmergency.name());
|
||||
case ISSI:
|
||||
return almEmergency.issi();
|
||||
case POSITION:
|
||||
{
|
||||
if (std::isnan(almEmergency.position().lat()))
|
||||
return tr("---");
|
||||
const QString mgrs = LtsCoordTrans::mgrsFromGeographic(almEmergency.position().lon(), almEmergency.position().lat());
|
||||
return mgrs;
|
||||
}
|
||||
case EXPIRED:
|
||||
return almEmergency.expired();
|
||||
case OPERATION_ID:
|
||||
{
|
||||
if (almEmergency.operatorId() == 0)
|
||||
return QStringLiteral("-");
|
||||
|
||||
return QString::fromStdString(m_opmDtc.get()->user(almEmergency.operatorId()).name());
|
||||
}
|
||||
case DELETED_TIMESTAMP:
|
||||
return QDateTime::fromMSecsSinceEpoch(almEmergency.deleted());
|
||||
case COMMENT:
|
||||
return QString::fromStdString(almEmergency.comment());
|
||||
default:
|
||||
break;
|
||||
} // switch
|
||||
return {};
|
||||
}
|
||||
|
||||
bool EmergencyCallModel::initModel(const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_opmDtc = opmDtc;
|
||||
|
||||
auto cb = [this](const AlarmManagement::AlmEmergencyCall & d)
|
||||
{
|
||||
onAlarmEmergencyCallChanged(d, DataModification::eAdded);
|
||||
};
|
||||
m_dtc->almEmergencyCalls(cb);
|
||||
connect(m_dtc.get(), &Interface::Dtc::almEmergencyCallChanged,
|
||||
this, &EmergencyCallModel::onAlarmEmergencyCallChanged);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void EmergencyCallModel::onAlarmEmergencyCallChanged(const AlarmManagement::AlmEmergencyCall &data, const DataModification modType)
|
||||
{
|
||||
const int id = data.id();
|
||||
int row = findRowForId(id);
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eModified:
|
||||
{
|
||||
if (row < 0)
|
||||
return;
|
||||
setRowData(row, data);
|
||||
break;
|
||||
}
|
||||
case DataModification::eAdded:
|
||||
insertRow(data);
|
||||
break;
|
||||
case DataModification::eRemoved:
|
||||
removeRow(row);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
///**************************
|
||||
/// EmergencyCallProxyModel
|
||||
///**************************
|
||||
|
||||
/*!
|
||||
* \brief EmergencyCallProxyModel::setSourceModel
|
||||
* \param sourceModel
|
||||
*/
|
||||
void EmergencyCallProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
|
||||
{
|
||||
m_sourceModel = qobject_cast<EmergencyCallModel*>(sourceModel);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
|
||||
}
|
||||
|
||||
void EmergencyCallProxyModel::hideByExerciseStopped(bool show)
|
||||
{
|
||||
if (m_hideByExerciseStopped == show)
|
||||
return;
|
||||
m_hideByExerciseStopped = show;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
void EmergencyCallProxyModel::setShowExpired(bool show)
|
||||
{
|
||||
if (m_showExpired == show)
|
||||
return;
|
||||
m_showExpired = show;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
bool EmergencyCallProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||
{
|
||||
Q_UNUSED(source_parent)
|
||||
return checkFilter(source_row);
|
||||
}
|
||||
|
||||
bool EmergencyCallProxyModel::checkFilter(int source_row) const
|
||||
{
|
||||
const auto sos = m_sourceModel->getRowData(source_row);
|
||||
if ((sos.expired() && !showExpired()) || (exerciseStopped() && !sos.expired()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace AlarmManagement
|
||||
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AlarmManagement (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Steve Kemayou, SLSE, 2023-05-26
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AlarmManagement/alm_dtc.h>
|
||||
#include <AlarmManagement/logger.h>
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
|
||||
class EmergencyCallModel : public LtsWidgets::LtsAbstractTableModel<AlarmManagement::AlmEmergencyCall>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
ID,
|
||||
SAMPLE_TIME,
|
||||
INCOMING_TIME,
|
||||
NAME,
|
||||
ISSI,
|
||||
POSITION,
|
||||
EXPIRED,
|
||||
OPERATION_ID,
|
||||
DELETED_TIMESTAMP,
|
||||
COMMENT
|
||||
};
|
||||
explicit EmergencyCallModel(QObject *parent = nullptr);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override final;
|
||||
bool initModel(const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc);
|
||||
|
||||
private slots:
|
||||
void onAlarmEmergencyCallChanged(const AlarmManagement::AlmEmergencyCall &data, const DataModification modType);
|
||||
private:
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
friend class EmergencyCallProxyModel;
|
||||
|
||||
};
|
||||
|
||||
|
||||
///**************************
|
||||
/// EmergencyCallProxyModel
|
||||
///**************************
|
||||
/*!
|
||||
* \brief The EmergencyCallProxyModel class
|
||||
*/
|
||||
class EmergencyCallProxyModel : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
bool showExpired() const { return m_showExpired; }
|
||||
bool exerciseStopped()const {return m_hideByExerciseStopped;}
|
||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||
void hideByExerciseStopped(bool show);
|
||||
|
||||
public slots:
|
||||
void setShowExpired(bool show);
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override final;
|
||||
|
||||
private:
|
||||
bool checkFilter(int source_row) const;
|
||||
|
||||
private:
|
||||
bool m_showExpired{false};
|
||||
bool m_hideByExerciseStopped{false};
|
||||
EmergencyCallModel *m_sourceModel{nullptr};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user