- NGL_ADD_LIBRARY2: 87 CMakeLists.txt konvertiert für Export-Header Generierung - 44 Export-Header Include-Pfade korrigiert (_export.h) - 81 DDS-Stub-Header generiert (*_dtc.h, *_fts.h, *_dts.h, *_ftc.h) - INGLLogger: Duplikat gelöscht, m_logger Member entfernt, variadische Makros - Q_FUNC_INFO Redefinition behoben (Qt6 definiert bereits) - FATAL_LOG Makro hinzugefügt - InfrastructureManagement DDS-Stubs (ism.hpp, ism_enums.hpp, ism_ftc.h) - FilterManagement DDS-Stubs (flt_ftc.h, flt_dts.h) - AreaEffectSimulation DDS-Stubs (aes.hpp, aes_enums.hpp) - SymbolAppearance Klasse vollständig definiert mit content() Methode - BuildingComponentFilter Klasse definiert mit Copy-Konstruktor - Ftc Factory: nullptr Return (abstract class) - AesFilter Klasse in aes.hpp hinzugefügt - Dtc Klasse in ppm.hpp mit participantChanged Signal - AesType Enum: alle 15 At* Werte definiert - AesEffectState_def: EsReceived hinzugefügt - DataModification Enum: eAdded/eModified/eRemoved - function_reply_object.h → core_types.h Include-Pfad (72 Dateien) - Enum-Class-Streaming Template-Operator in INGLLogger.h - ism_mounting_point.h: QImage → QtGui/QImage, QGuiApplication/QScreen - ism_data_plugin_interface.h: QSet Include, Include-Reihenfolge - QRegExp → QRegularExpression in tpm_js_parser.cpp - .underlying() Aufrufe zu direktem Enum-Vergleich korrigiert - Include-Pfade: aes.hpp in symbol_appearance_settings_impl.h und aes_display_filter_impl.h Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
301 lines
8.2 KiB
C++
Executable File
301 lines
8.2 KiB
C++
Executable File
|
|
|
|
|
|
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
|
#include <ParticipantManagement/ppm_translation.h>
|
|
#include <Plugins/AssetManagement/asm_data_plugin_interface.h>
|
|
#include <SAAs/Common/saa_utils.h>
|
|
#include <ngltools/ngltools_dtg.h>
|
|
|
|
#include "saa_dialog_model.h"
|
|
|
|
namespace SAAInterfaceAdapterAdler
|
|
{
|
|
|
|
using namespace SAAUtils;
|
|
SaaDialogModel::SaaDialogModel(QObject *parent)
|
|
: LtsWidgets::LtsAbstractTableModel<AssetManagement::Asset>({tr("Id"), tr("Name"), tr("scenario is running"), tr("Used by Party")}, parent)
|
|
, m_ppmDtc(nullptr)
|
|
{
|
|
TRACE_LOG() << Q_FUNC_INFO << " START";
|
|
TRACE_LOG() << Q_FUNC_INFO << " END";
|
|
}
|
|
|
|
SaaDialogModel::~SaaDialogModel()
|
|
{
|
|
stopPing();
|
|
TRACE_LOG() << Q_FUNC_INFO << " START";
|
|
TRACE_LOG() << Q_FUNC_INFO << " END";
|
|
}
|
|
|
|
bool SaaDialogModel::initModel(LtsSession::LtsSession *session)
|
|
{
|
|
TRACE_LOG() << Q_FUNC_INFO << " START";
|
|
m_session = session;
|
|
|
|
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
|
{
|
|
ERROR_LOG() << " ppmDtc not set!!! " << m_logger.getLoggerName();
|
|
return false;
|
|
}
|
|
if (!m_session->getDtc<AssetManagement::DataInterface>(m_asmDtc))
|
|
{
|
|
ERROR_LOG() << " asmDtc not set!!! " << m_logger.getLoggerName();
|
|
return false;
|
|
}
|
|
|
|
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::partyChanged, this, &SaaDialogModel::onPartyDataChanged);
|
|
connect(m_asmDtc.get(), &AssetManagement::Interface::Dtc::assetChanged, this, &SaaDialogModel::slotAssetChanged);
|
|
m_asmDtc->assets(
|
|
[this](const AssetManagement::Asset &asset)
|
|
{
|
|
if (asset.id() <= 1 || asset.assetTypeId() != AssetManagement::AssetType_def::AdlerSAA)
|
|
return;
|
|
AsmAssetProps asmProps(QString::fromStdString(asset.properties()));
|
|
if (asmProps.hasExerciseId() && asmProps.exId != m_session->exerciseId())
|
|
return;
|
|
|
|
|
|
PingItem pi;
|
|
pi.assetId = asset.id();
|
|
pi.process = new QProcess(this);
|
|
pi.host = asmProps.host;
|
|
pi.port = asmProps.port;
|
|
m_saaPingItems.insert(asset.id(), pi);
|
|
|
|
|
|
onDataChanged(asset, DataModification::eAdded);
|
|
});
|
|
|
|
TRACE_LOG() << Q_FUNC_INFO << " END";
|
|
return true;
|
|
}
|
|
|
|
void SaaDialogModel::pingAllSaa()
|
|
{
|
|
DEBUG_LOG() << "====> pingAllSaa: saaList count: " << m_saaPingItems.count();
|
|
|
|
if (m_saaPingItems.isEmpty())
|
|
return;
|
|
|
|
|
|
for (auto &pi : m_saaPingItems)
|
|
{
|
|
|
|
if (pi.process)
|
|
{
|
|
pi.process->kill();
|
|
pi.process->deleteLater();
|
|
pi.process = nullptr;
|
|
}
|
|
|
|
pi.process = new QProcess(this);
|
|
|
|
connect(pi.process,
|
|
QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
|
this,
|
|
[this, &pi](int exitCode, QProcess::ExitStatus)
|
|
{
|
|
ParticipantManagement::Party party;
|
|
getPartyWithAssetId(pi.assetId, party);
|
|
DEBUG_LOG() << " ping assetId: " << pi.assetId << " reacheable ? " << (exitCode == 0) << " Szenar ? " << (party.id() > 0) << " Ip: " << pi.host
|
|
<< " PortNumb: " << pi.port;
|
|
pi.reachable = (exitCode == 0);
|
|
pi.process->kill();
|
|
pi.process->deleteLater();
|
|
pi.process = nullptr;
|
|
});
|
|
|
|
QStringList args = {QStringLiteral("-z"), QStringLiteral("-w"), QStringLiteral("1"), pi.host, QString::number(pi.port)};
|
|
|
|
pi.process->start(QStringLiteral("nc"), args);
|
|
}
|
|
|
|
updateView();
|
|
}
|
|
|
|
void SaaDialogModel::saaConnected(int assetId, bool state)
|
|
{
|
|
PingItem &saaItem = m_saaPingItems[assetId];
|
|
saaItem.connected = state;
|
|
}
|
|
|
|
void SaaDialogModel::stopPing()
|
|
{
|
|
WARNING_LOG() << ">> stop ping saa...";
|
|
for (auto &pi : m_saaPingItems)
|
|
{
|
|
|
|
if (pi.process)
|
|
{
|
|
WARNING_LOG() << ">> kill process saaId: " << pi.assetId;
|
|
pi.process->kill();
|
|
pi.process->deleteLater();
|
|
pi.process = nullptr;
|
|
}
|
|
}
|
|
m_saaPingItems.clear();
|
|
}
|
|
|
|
void SaaDialogModel::updateView()
|
|
{
|
|
beginResetModel();
|
|
endResetModel();
|
|
}
|
|
|
|
void SaaDialogModel::onPartyDataChanged(const ParticipantManagement::Party &data, DataModification modType)
|
|
{
|
|
Q_UNUSED(modType)
|
|
DEBUG_LOG() << ">>> SAA Dialog Party Data Changed: " << data.id() << " properties: " << data.properties();
|
|
update();
|
|
}
|
|
|
|
bool SaaDialogModel::isFiltered(const AssetManagement::Asset &data, DataModification modType) const
|
|
{
|
|
|
|
if (data.id() <= 1 || data.assetTypeId() != AssetManagement::AssetType_def::AdlerSAA)
|
|
return true;
|
|
|
|
|
|
AsmAssetProps asmProps(QString::fromStdString(data.properties()));
|
|
if (asmProps.hasExerciseId() && asmProps.exId != m_session->exerciseId())
|
|
return true;
|
|
return LtsWidgets::LtsAbstractTableModel<AssetManagement::Asset>::isFiltered(data, modType);
|
|
}
|
|
|
|
void SaaDialogModel::slotAssetChanged(const AssetManagement::Asset &data, DataModification modType)
|
|
{
|
|
|
|
if (data.id() <= 1 || data.assetTypeId() != AssetManagement::AssetType_def::AdlerSAA)
|
|
return;
|
|
AsmAssetProps asmProps(QString::fromStdString(data.properties()));
|
|
if (asmProps.hasExerciseId() && asmProps.exId != m_session->exerciseId())
|
|
return;
|
|
|
|
switch (modType)
|
|
{
|
|
case DataModification::eAdded:
|
|
{
|
|
onDataChanged(data, DataModification::eAdded);
|
|
PingItem pi;
|
|
pi.assetId = data.id();
|
|
pi.process = new QProcess(this);
|
|
pi.host = asmProps.host;
|
|
pi.port = asmProps.port;
|
|
m_saaPingItems.insert(data.id(), pi);
|
|
}
|
|
break;
|
|
case DataModification::eModified:
|
|
{
|
|
onDataChanged(data, DataModification::eModified);
|
|
PingItem pi = m_saaPingItems.take(data.id());
|
|
if (pi.process != nullptr && pi.process->state() != QProcess::NotRunning)
|
|
{
|
|
pi.process->kill();
|
|
pi.process->deleteLater();
|
|
}
|
|
pi.process = nullptr;
|
|
|
|
pi.assetId = data.id();
|
|
pi.host = asmProps.host;
|
|
pi.port = asmProps.port;
|
|
pi.connected = false;
|
|
pi.reachable = false;
|
|
pi.process = new QProcess(this);
|
|
m_saaPingItems.insert(data.id(), pi);
|
|
}
|
|
break;
|
|
case DataModification::eRemoved:
|
|
onDataChanged(data, DataModification::eRemoved);
|
|
|
|
auto pi = m_saaPingItems.take(data.id());
|
|
if (pi.process != nullptr && pi.process->state() != QProcess::NotRunning)
|
|
{
|
|
pi.process->kill();
|
|
pi.process->deleteLater();
|
|
}
|
|
pi.process = nullptr;
|
|
break;
|
|
}
|
|
}
|
|
|
|
void SaaDialogModel::getPartyWithAssetId(int assetId, ParticipantManagement::Party &party) const
|
|
{
|
|
const auto &partys = m_ppmDtc->partys();
|
|
for (const auto &p : partys)
|
|
{
|
|
SaaProps saaprops(QString::fromStdString(p.properties()));
|
|
if (!saaprops.hasAsset())
|
|
continue;
|
|
if (saaprops.assetId == assetId)
|
|
{
|
|
party = p;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
QVariant SaaDialogModel::data(const QModelIndex &index, int role) const
|
|
{
|
|
if (!indexIsValid(index))
|
|
return {};
|
|
|
|
const AssetManagement::Asset &asset = m_vecData.at(index.row());
|
|
const AsmAssetProps assetProps(QString::fromStdString(asset.properties()));
|
|
|
|
|
|
ParticipantManagement::Party party;
|
|
if (asset.assetTypeId() == AssetManagement::AssetType_def::AdlerSAA && assetProps.hasExerciseId())
|
|
getPartyWithAssetId(asset.id(), party);
|
|
|
|
if (role == Qt::DisplayRole)
|
|
{
|
|
switch (index.column())
|
|
{
|
|
case Id:
|
|
return asset.id();
|
|
case Name:
|
|
return QString::fromStdString(asset.name());
|
|
case IsUseByParty:
|
|
return party.id() > 0 ? ParticipantManagement::trPartyName(party.name()) : QStringLiteral("--");
|
|
default:
|
|
return {};
|
|
}
|
|
}
|
|
else if (role == Qt::DecorationRole)
|
|
{
|
|
if (index.column() != Connected)
|
|
return {};
|
|
|
|
|
|
|
|
|
|
|
|
static const QIcon green(QLatin1String("icon:green_light.svg"));
|
|
static const QIcon red(QLatin1String("icon:red_light.svg"));
|
|
static const QIcon yellow(QLatin1String("icon:yellow_light.svg"));
|
|
static const QIcon gray(QLatin1String("icon:gray_light.svg"));
|
|
const bool reacheable = m_saaPingItems.value(asset.id()).reachable;
|
|
switch (index.column())
|
|
{
|
|
case Connected:
|
|
{
|
|
const bool szenar = (party.id() > 0);
|
|
if (szenar && reacheable)
|
|
return green;
|
|
if (szenar && !reacheable)
|
|
return red;
|
|
if (!szenar && reacheable)
|
|
return yellow;
|
|
|
|
return gray;
|
|
}
|
|
default:
|
|
return {};
|
|
}
|
|
}
|
|
return {};
|
|
}
|
|
|
|
}
|