Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+35
@@ -0,0 +1,35 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Mike Wille, SLSE, 2016-09-06
|
||||
#
|
||||
|
||||
#
|
||||
# Data Plugin
|
||||
#
|
||||
SET(alarm_common_gui_SRCS
|
||||
alm_history_alarm_model.cpp
|
||||
alm_history_alarm_model.h
|
||||
alm_config_alarm_model.cpp
|
||||
alm_config_alarm_model.h
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY2(WS AlmCommon SHARED ${alarm_common_gui_SRCS} )
|
||||
NGL_TARGET_LINK_LIBRARIES(AlmCommon
|
||||
PRIVATE
|
||||
Qt5::Widgets
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
LtsCoordTrans
|
||||
NGLLogger
|
||||
PUBLIC
|
||||
Qt5::Core
|
||||
nglwidgets
|
||||
svcPpmCommon
|
||||
svcAlmCommon
|
||||
svcAesCommon
|
||||
advancedSymbology
|
||||
advancedSymbologyGui
|
||||
ngltools
|
||||
)
|
||||
@@ -0,0 +1,171 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AlarmManagement - AlarmManagement Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10.05
|
||||
*/
|
||||
|
||||
#include "alm_config_alarm_model.h"
|
||||
#include <AlarmManagement/alm_translation.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <ProjectDataManagement/pdm_to_string.h>
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
//---------------------------------
|
||||
// AlarmManagementModel
|
||||
//---------------------------------
|
||||
ConfigAlarmModel::ConfigAlarmModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<AlarmManagement::AlarmConfig>(
|
||||
{
|
||||
tr("Id"),
|
||||
tr("Equip. No."),
|
||||
tr("Designator"),
|
||||
tr("Tact. Identifier"),
|
||||
tr("Vulnerability State"),
|
||||
tr("Event Type"),
|
||||
tr("Message Window"),
|
||||
tr("Set Marker")
|
||||
},
|
||||
parent)
|
||||
, m_dtc(nullptr)
|
||||
, m_ppmDtc(nullptr)
|
||||
, m_alarmHistoryModel(nullptr)
|
||||
, m_global(false)
|
||||
, m_logger(getLogger("ConfigAlarmModel"))
|
||||
{}
|
||||
|
||||
|
||||
bool ConfigAlarmModel::initModel(const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
AlarmHistoryModel *alarmHistoryModel,
|
||||
bool global)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_alarmHistoryModel = alarmHistoryModel;
|
||||
m_global = global;
|
||||
|
||||
// insert Model
|
||||
const QMap<qint32, AlarmManagement::AlarmConfig> alarmConfigs = m_dtc->alarmConfigs();
|
||||
INFO_LOG(m_logger) << "initModel - #AlarmConfig: " << alarmConfigs.size();
|
||||
|
||||
connect(m_dtc.get(), &Interface::Dtc::alarmConfigChanged,
|
||||
this, &ConfigAlarmModel::onAlarmConfigChanged);
|
||||
|
||||
m_dtc->enableAlarmConfig();
|
||||
auto cb = [this] (const AlarmManagement::AlarmConfig &d)
|
||||
{
|
||||
onAlarmConfigChanged(d, DataModification::eAdded);
|
||||
};
|
||||
m_dtc->alarmConfigs(cb);
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant ConfigAlarmModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "AlarmManagementModel::data";
|
||||
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const AlarmManagement::AlarmConfig &alarmConfig = m_vecData.at(index.row());
|
||||
if (alarmConfig.global() != m_global)
|
||||
return QVariant();
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case Id:
|
||||
return alarmConfig.id();
|
||||
case EquipmentNumber:
|
||||
{
|
||||
const int equipmentNumber = m_alarmHistoryModel->participantId2EquipNo(alarmConfig.participantId());
|
||||
if (equipmentNumber == 0)
|
||||
return tr("All");
|
||||
return equipmentNumber;
|
||||
}
|
||||
case Designator:
|
||||
return m_alarmHistoryModel->getDesignator(alarmConfig.participantId());
|
||||
case TactIdentifier:
|
||||
return m_alarmHistoryModel->getTactIdentifier(alarmConfig.participantId());
|
||||
case VulnerabilityState:
|
||||
{
|
||||
QString vulnerabilityState = tr("All Types");
|
||||
if (alarmConfig.vulnerabilityState()>=0){
|
||||
ParticipantManagement::TypeClass typeClass =
|
||||
m_ppmDtc->type(m_ppmDtc->participant(alarmConfig.participantId()).typeId()).typeClass();
|
||||
|
||||
const ProjectDataManagement::VulnerabilityClass vc = typeClass == ParticipantManagement::TypeClass::Human ?
|
||||
ProjectDataManagement::VulnerabilityClass_def::SoldierInjuries :
|
||||
ProjectDataManagement::VulnerabilityClass_def::VehicleDamages;
|
||||
ProjectDataManagement::VulnerabilityState vs = static_cast<ProjectDataManagement::VulnerabilityState_def::type>(alarmConfig.vulnerabilityState());
|
||||
vulnerabilityState = ProjectDataManagement::toString(vs, vc);
|
||||
}
|
||||
return vulnerabilityState;
|
||||
}
|
||||
|
||||
case EventType:
|
||||
return ProjectDataManagement::toString(alarmConfig.eventTypeId());
|
||||
case MessageWindow:
|
||||
return alarmConfig.messageWindow() ? tr("Yes") : tr("No");
|
||||
case SetMarker:
|
||||
return alarmConfig.setMarker() ? tr("Yes") : tr("No");
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
void ConfigAlarmModel::onAlarmConfigChanged(const AlarmManagement::AlarmConfig &data,
|
||||
const DataModification modType)
|
||||
{
|
||||
const int id = data.id();
|
||||
if (data.global() != m_global)
|
||||
return;
|
||||
|
||||
int row = findRowForId(id);
|
||||
|
||||
const int eventTypeId = data.eventTypeId().underlying();
|
||||
const bool messageWindow = data.messageWindow();
|
||||
const bool setMarker = data.setMarker();
|
||||
DEBUG_LOG(m_logger) << "onAlarmConfigChanged: " << eventTypeId << " messageWindow=" << messageWindow
|
||||
<< "setMarker"<<setMarker;
|
||||
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
// removed
|
||||
DEBUG_LOG(m_logger) << "AlarmConfig was removed: " << id;
|
||||
AlarmManagement::AlarmConfig data1 = data;
|
||||
data1.messageWindow(false);
|
||||
data1.setMarker(false);
|
||||
setRowData(row, data1);
|
||||
removeRow(row);
|
||||
return;
|
||||
}
|
||||
case DataModification::eModified:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "DataModification::eModified: ";
|
||||
if (row < 0)
|
||||
{
|
||||
// created
|
||||
return;
|
||||
}
|
||||
if (m_alarmHistoryModel->participantId2EquipNo(data.participantId()) > 0)
|
||||
setRowData(row, data);
|
||||
break;
|
||||
}
|
||||
case DataModification::eAdded:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "DataModification::eAdded";
|
||||
insertRow(data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace AlarmManagement
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for Messaging - Messaging Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10.05
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Common/almcommon_export.h>
|
||||
#include <AlarmManagement/alm_dtc.h>
|
||||
#include <AlarmManagement/logger.h>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include "alm_history_alarm_model.h"
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
// --------------------------------------------------------
|
||||
// AlarmManagementModel
|
||||
// --------------------------------------------------------
|
||||
class ALMCOMMON_EXPORT ConfigAlarmModel final : public LtsWidgets::LtsAbstractTableModel<AlarmManagement::AlarmConfig>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
Id,
|
||||
EquipmentNumber,
|
||||
Designator,
|
||||
TactIdentifier,
|
||||
VulnerabilityState,
|
||||
EventType,
|
||||
MessageWindow,
|
||||
SetMarker
|
||||
};
|
||||
|
||||
explicit ConfigAlarmModel(QObject *parent = nullptr);
|
||||
|
||||
bool initModel(const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
AlarmHistoryModel *alarmHistoryModel,
|
||||
bool global);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
private slots:
|
||||
void onAlarmConfigChanged(const AlarmManagement::AlarmConfig &data,
|
||||
const DataModification modType);
|
||||
private:
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
AlarmHistoryModel *m_alarmHistoryModel;
|
||||
bool m_global;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
} //namespace AlarmManagement
|
||||
@@ -0,0 +1,325 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AlarmManagement - AlarmManagement Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10.05
|
||||
*/
|
||||
|
||||
#include "alm_history_alarm_model.h"
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <AlarmManagement/alm_translation.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <ProjectDataManagement/pdm_translation.h>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonParseError>
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
//---------------------------------
|
||||
// AlarmHistoryModel
|
||||
//---------------------------------
|
||||
AlarmHistoryModel::AlarmHistoryModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<NotificationEx>(
|
||||
{
|
||||
tr("Id"),
|
||||
tr("Date"),
|
||||
tr("Incident"),
|
||||
tr("Equip. No."),
|
||||
tr("Hierarchie"),
|
||||
tr("Participant Id"),
|
||||
tr("Position"),
|
||||
tr("Aes Id"),
|
||||
tr("Aes Name"),
|
||||
},
|
||||
parent)
|
||||
, m_dtc(nullptr)
|
||||
, m_ppmDtc(nullptr)
|
||||
, m_logger(getLogger("AlarmHistoryModel"))
|
||||
{}
|
||||
|
||||
|
||||
bool AlarmHistoryModel::initModel(const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &aesDtc)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_aesDtc = aesDtc;
|
||||
|
||||
// insert Model
|
||||
|
||||
connect(m_dtc.get(), &Interface::Dtc::notificationChanged,
|
||||
this, &AlarmHistoryModel::onNotificationChanged);
|
||||
|
||||
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::participantChanged,
|
||||
this, &AlarmHistoryModel::onParticipantChanged);
|
||||
|
||||
m_ppmDtc->enableParticipant();
|
||||
m_dtc->enableNotification();
|
||||
|
||||
// Player in Referenzmap eintragen
|
||||
const auto cbParticipants = [this](const ParticipantManagement::Participant & participant)
|
||||
{
|
||||
onParticipantChanged(participant, DataModification::eAdded);
|
||||
};
|
||||
m_ppmDtc->participants(cbParticipants);
|
||||
//***************************************************************
|
||||
//** Get AES-Names
|
||||
//***************************************************************
|
||||
|
||||
// Get AesNames for all AesItems
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::borderlineChanged,
|
||||
this, &AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::dangerAreaChanged,
|
||||
this, &AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::nContaminationChanged,
|
||||
this, &AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::bCContaminationChanged,
|
||||
this, &AlarmHistoryModel::onBCContaminationChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::mineAreaChanged,
|
||||
this, &AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::functionalAreaChanged,
|
||||
this, &AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::boobyTrapChanged,
|
||||
this, &AlarmHistoryModel::onBoobyTrapChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::offRouteMineChanged,
|
||||
this, &AlarmHistoryModel::onOffRouteMineChanged);
|
||||
|
||||
|
||||
auto cbAesItem = [this](const AreaEffectSimulation::AesItem & item)
|
||||
{
|
||||
onAesItemChanged(item, DataModification::eAdded);
|
||||
};
|
||||
m_aesDtc->borderlines(cbAesItem);
|
||||
m_aesDtc->dangerAreas(cbAesItem);
|
||||
m_aesDtc->nContaminations(cbAesItem);
|
||||
m_aesDtc->mineAreas(cbAesItem);
|
||||
m_aesDtc->functionalAreas(cbAesItem);
|
||||
m_aesDtc->boobyTraps(cbAesItem);
|
||||
m_aesDtc->offRouteMines(cbAesItem);
|
||||
|
||||
return true;
|
||||
} // end of initModel
|
||||
|
||||
|
||||
QVariant AlarmHistoryModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
if ((role != Qt::DisplayRole) && (role != Qt::UserRole) && (role != Qt::BackgroundRole))
|
||||
return QVariant();
|
||||
|
||||
const NotificationEx ¬ificationEx = m_vecData.at(index.row());
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (notificationEx.eventType() == ProjectDataManagement::EventType_def::EmergencyCall)
|
||||
return QColor(Qt::red);
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case Id:
|
||||
return notificationEx.id();
|
||||
case Date:
|
||||
return QDateTime::fromMSecsSinceEpoch(notificationEx.time());
|
||||
case EquipmentNumber:
|
||||
if (notificationEx.equipmentNumber)
|
||||
return notificationEx.equipmentNumber;
|
||||
break;
|
||||
case Incident:
|
||||
return ProjectDataManagement::toString(notificationEx.eventTypeId);
|
||||
case Hierarchie:
|
||||
return m_ppmDtc->hierarchyFromParticipant(notificationEx.participantId);
|
||||
case ParticipantId:
|
||||
return notificationEx.participantId;
|
||||
case Position:
|
||||
if (role == Qt::DisplayRole)
|
||||
return LtsCoordTrans::mgrsFromGeographic(notificationEx.position().lon(), notificationEx.position().lat());
|
||||
else if (role == Qt::UserRole)
|
||||
return QPointF(notificationEx.position().lon(), notificationEx.position().lat());
|
||||
break;
|
||||
case AesId:
|
||||
return notificationEx.aesId;
|
||||
case AesName:
|
||||
// Direct Hits do not contain aesId
|
||||
return m_aesNameMap.value(notificationEx.aesId, tr("-"));
|
||||
}
|
||||
return QVariant();
|
||||
} // end of data
|
||||
|
||||
|
||||
bool AlarmHistoryModel::isFiltered(const NotificationEx &data, DataModification modType) const
|
||||
{
|
||||
Q_UNUSED(modType);
|
||||
if (data.operatorId() == 0)
|
||||
return false;
|
||||
return data.operatorId() != LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
}
|
||||
|
||||
void AlarmHistoryModel::onNotificationChanged(const AlarmManagement::Notification &data,
|
||||
const DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
|
||||
NotificationEx notification(data);
|
||||
const QByteArray properties = QByteArray::fromRawData(data.properties().c_str(), data.properties().size());
|
||||
const QJsonDocument propertieJsonDoc = QJsonDocument::fromJson(properties);
|
||||
const QJsonObject propertieJsonObj = propertieJsonDoc.object();
|
||||
|
||||
notification.equipmentNumber = data.equipmentNumber();
|
||||
if (data.participantId().is_set())
|
||||
notification.participantId = data.participantId().get();
|
||||
notification.eventTypeId = data.eventType();
|
||||
if (data.aesId().is_set())
|
||||
notification.aesId = data.aesId().get();
|
||||
const int global = propertieJsonObj[QStringLiteral("Global")].toInt();
|
||||
const int friendlyFire = propertieJsonObj[QStringLiteral("FriendlyFire")].toInt();
|
||||
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION
|
||||
<< " notification:" << data
|
||||
<< ", Global: " << global
|
||||
<< ", FriendlyFire: " << friendlyFire;
|
||||
|
||||
onDataChanged(notification, modType);
|
||||
} // end of onWindowChanged
|
||||
|
||||
void AlarmHistoryModel::onParticipantChanged(const ParticipantManagement::Participant &participant,
|
||||
const DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
QString designator = QString::fromStdString(participant.designator());
|
||||
m_idDesignatorMap.insert(participant.id(), designator);
|
||||
|
||||
const int equipNo = participant.equipmentNumber().is_set() ? participant.equipmentNumber().get() : 0;
|
||||
m_partId2EquipNoMap.insert(participant.id(), equipNo);
|
||||
|
||||
QString tacticalIdentifier = QString::fromStdString(participant.tacticalIdentifier());
|
||||
m_idTactIdentifierMap.insert(participant.id(), tacticalIdentifier);
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " id=" << participant.id()
|
||||
<< " designator=" << designator
|
||||
<< " tacticalIdentifier=" << tacticalIdentifier;
|
||||
} // end of onParticipantChanged
|
||||
|
||||
int AlarmHistoryModel::participantId2EquipNo(const int participantId) const
|
||||
{
|
||||
int ret = m_partId2EquipNoMap.value(participantId, 0);
|
||||
INFO_LOG(m_logger) << "participantId2EquipNo participantId=" << participantId
|
||||
<< " EquipmentNumber=" << ret;
|
||||
return ret;
|
||||
} // end of participantId2EquipNo()
|
||||
|
||||
QString AlarmHistoryModel::getDesignator(const int participantId) const
|
||||
{
|
||||
QString designator = m_idDesignatorMap.value(participantId);
|
||||
DEBUG_LOG(m_logger) << "m_idDesignatorMap.value(participantId)=" << designator;
|
||||
|
||||
return designator;
|
||||
}
|
||||
|
||||
QString AlarmHistoryModel::getTactIdentifier(const int participantId) const
|
||||
{
|
||||
QString tactIdentifier = m_idTactIdentifierMap.value(participantId);
|
||||
DEBUG_LOG(m_logger) << "m_idTactIdentifierMap.value(participantId)=" << tactIdentifier;
|
||||
|
||||
return tactIdentifier;
|
||||
}
|
||||
|
||||
void AlarmHistoryModel::onBCContaminationChanged(const AreaEffectSimulation::BCContamination &data,
|
||||
const DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
int id = data.id();
|
||||
QString name = QString::fromStdString(data.name());
|
||||
m_aesNameMap[id] = name;
|
||||
DEBUG_LOG(m_logger) << "onBCContaminationChanged: " << data
|
||||
<< " Name=" << name
|
||||
<< " id=" << id;
|
||||
}
|
||||
|
||||
void AlarmHistoryModel::onBoobyTrapChanged(const AreaEffectSimulation::BoobyTrap &data,
|
||||
const DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
int id = data.id();
|
||||
QString name = QString::fromStdString(data.name());
|
||||
m_aesNameMap[id] = name;
|
||||
DEBUG_LOG(m_logger) << "BoobyTrap: " << data
|
||||
<< " Name=" << name
|
||||
<< " id=" << id;
|
||||
}
|
||||
|
||||
void AlarmHistoryModel::onOffRouteMineChanged(const AreaEffectSimulation::OffRouteMine &data,
|
||||
const DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
int id = data.id();
|
||||
QString name = QString::fromStdString(data.name());
|
||||
m_aesNameMap[id] = name;
|
||||
DEBUG_LOG(m_logger) << "OffRouteMine: " << data
|
||||
<< " Name=" << name
|
||||
<< " id=" << id;
|
||||
}
|
||||
|
||||
void AlarmHistoryModel::onAesItemChanged(const AreaEffectSimulation::AesItem &item,
|
||||
const DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
QString name = QString::fromStdString(item.name());
|
||||
int id = item.id();
|
||||
m_aesNameMap[id] = name;
|
||||
DEBUG_LOG(m_logger) << "AreaEffectSimulation::AesItem onAesItemChanged: " << item
|
||||
<< " Name=" << name
|
||||
<< " id=" << item.id();
|
||||
} // end of onAesItemChanged
|
||||
|
||||
//
|
||||
// AlarmHistoryProxyModel
|
||||
//
|
||||
void AlarmHistoryProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
|
||||
{
|
||||
m_sourceModel = qobject_cast<AlarmHistoryModel*>(sourceModel);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
|
||||
}
|
||||
|
||||
bool AlarmHistoryProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
{
|
||||
if (!m_sourceModel ||
|
||||
source_left.column() != source_right.column() ||
|
||||
!source_left.isValid() ||
|
||||
!source_right.isValid())
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
const auto &dataLeft = m_sourceModel->m_vecData.at(source_left.row());
|
||||
const auto dataRight = m_sourceModel->m_vecData.at(source_right.row());
|
||||
switch (source_left.column())
|
||||
{
|
||||
case AlarmHistoryModel::Date:
|
||||
return dataLeft.time() < dataRight.time();
|
||||
|
||||
case AlarmHistoryModel::Id:
|
||||
case AlarmHistoryModel::Incident:
|
||||
case AlarmHistoryModel::EquipmentNumber:
|
||||
case AlarmHistoryModel::Hierarchie:
|
||||
case AlarmHistoryModel::ParticipantId:
|
||||
case AlarmHistoryModel::Position:
|
||||
case AlarmHistoryModel::AesId:
|
||||
case AlarmHistoryModel::AesName:
|
||||
break;
|
||||
}
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
}
|
||||
} // namespace AlarmManagement
|
||||
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for Messaging - Messaging Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10.05
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Common/almcommon_export.h>
|
||||
#include <AlarmManagement/alm_dtc.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <AreaEffectSimulation/aes_dtc.h>
|
||||
#include <AlarmManagement/logger.h>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
// --------------------------------------------------------
|
||||
// AlarmHistoryModel
|
||||
// --------------------------------------------------------
|
||||
struct NotificationEx : public AlarmManagement::Notification
|
||||
{
|
||||
int equipmentNumber = 0;
|
||||
int participantId = 0;
|
||||
int aesId = 0;
|
||||
ProjectDataManagement::EventType eventTypeId = ProjectDataManagement::EventType::Unknown;
|
||||
|
||||
NotificationEx() = default;
|
||||
explicit NotificationEx(const AlarmManagement::Notification &n)
|
||||
: AlarmManagement::Notification(n)
|
||||
{}
|
||||
};
|
||||
|
||||
class ALMCOMMON_EXPORT AlarmHistoryModel final : public LtsWidgets::LtsAbstractTableModel<NotificationEx>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
enum Columns
|
||||
{
|
||||
Id,
|
||||
Date,
|
||||
Incident,
|
||||
EquipmentNumber,
|
||||
Hierarchie,
|
||||
ParticipantId,
|
||||
Position,
|
||||
AesId,
|
||||
AesName
|
||||
};
|
||||
|
||||
explicit AlarmHistoryModel(QObject *parent = nullptr);
|
||||
|
||||
bool initModel(const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &aesDtc);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
/**
|
||||
* Get equipment number for the given participant
|
||||
* @param participantId participant id to get the equipment number for
|
||||
* @return equipment number or 0 in case of failure
|
||||
*/
|
||||
int participantId2EquipNo(const int participantId) const;
|
||||
QString getDesignator(const int participantId) const;
|
||||
QString getTactIdentifier(const int participantId) const;
|
||||
|
||||
protected:
|
||||
bool isFiltered(const NotificationEx &data, DataModification modType) const override;
|
||||
private slots:
|
||||
void onNotificationChanged(const AlarmManagement::Notification &data,
|
||||
const DataModification modType);
|
||||
void onParticipantChanged(const ParticipantManagement::Participant &participant,
|
||||
const DataModification modType);
|
||||
void onAesItemChanged(const AreaEffectSimulation::AesItem &item,
|
||||
const DataModification modType);
|
||||
void onBCContaminationChanged(const AreaEffectSimulation::BCContamination &data,
|
||||
const DataModification modType);
|
||||
void onBoobyTrapChanged(const AreaEffectSimulation::BoobyTrap &data,
|
||||
const DataModification modType);
|
||||
void onOffRouteMineChanged(const AreaEffectSimulation::OffRouteMine &data,
|
||||
const DataModification modType);
|
||||
|
||||
private:
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
|
||||
|
||||
QMap<int, int> m_partId2EquipNoMap; ///< Reference map participant (player) to equipment number (participantId, equipmentNo)
|
||||
QHash<int, QString> m_idDesignatorMap;
|
||||
QHash<int, QString> m_idTactIdentifierMap;
|
||||
QHash<int, QString> m_aesNameMap; // key = aesId, name = aesName
|
||||
|
||||
friend class AlarmHistoryProxyModel;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
class ALMCOMMON_EXPORT AlarmHistoryProxyModel final : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||
protected:
|
||||
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
|
||||
private:
|
||||
AlarmHistoryModel *m_sourceModel = nullptr;
|
||||
};
|
||||
} //namespace AlarmManagement
|
||||
Reference in new issue
Block a user