Adds immediate migration results in progress

This commit is contained in:
torsten committed 2026-08-19 11:18:24 +02:00
1 parent 8453e104c5
commit 3bb6e89496
2102 files changed
+17482 -15071

No files matched your search

@@ -36,6 +36,8 @@ private Q_SLOTS:
void onAirSupportImpact(AreaEffectSimulation::AirSupportImpactModifyRequest asi, int equipmentNumber);
private:
NGL::INGLLogger &m_logger;
NgsHandler *m_ngsHandler;
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_dtcAes;
std::shared_ptr<AreaEffectSimulation::Interface::Ftc> m_ftcAes;
@@ -9,11 +9,10 @@
namespace HighLevelArchitecture
{
DdsHandler::DdsHandler(int domainId, int exerciseId)
: m_ddsConnector(new DDSConnector::DdsConnector(domainId, IDL::PartitionType::Exercise, exerciseId))
, m_exerciseHasHlaConnection(false)
{
DEBUG_LOG() << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
DdsHandler::DdsHandler(int domainId, int exerciseId) : m_ddsConnector(new DDSConnector::DdsConnector(domainId, IDL::PartitionType::Exercise, exerciseId))
, m_exerciseHasHlaConnection(false),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
DEBUG_LOG(m_logger) << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
}
DdsHandler::~DdsHandler()
@@ -27,7 +26,7 @@ bool DdsHandler::init(const QStringList &qosFileList)
{
if (!m_ddsConnector->init(qosFileList))
{
ERROR_LOG() << "Error initializing dds connections - aborting";
ERROR_LOG(m_logger) << "Error initializing dds connections - aborting";
return false;
}
@@ -32,8 +32,10 @@ public:
Q_SIGNALS:
void exerciseHlaStateChanged(bool bHlaEnabled);
private:
NGL::INGLLogger &m_logger;
void onExerciseChanged(const ExerciseManagement::Exercise &ex, DataModification modType);
private:
NGL::INGLLogger &m_logger;
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
std::shared_ptr<Core::Pacemaker> m_pacemaker;
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_dtcExm;
@@ -13,10 +13,9 @@
namespace HighLevelArchitecture
{
MainHandler::MainHandler(QObject *parent)
: QObject(parent)
, m_exerciseId(0)
{}
MainHandler::MainHandler(QObject *parent) : QObject(parent)
, m_exerciseId(0),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
MainHandler::~MainHandler()
{
@@ -31,7 +30,7 @@ bool MainHandler::init(int domainId, int exerciseId)
m_ddsHandler = std::make_shared<DdsHandler>(domainId, exerciseId);
if (!m_ddsHandler->init())
{
ERROR_LOG() << "Could not init DDS handler";
ERROR_LOG(m_logger) << "Could not init DDS handler";
return false;
}
connect(m_ddsHandler.get(), &DdsHandler::exerciseHlaStateChanged,
@@ -26,6 +26,7 @@ public:
private Q_SLOTS:
void onExerciseHlaStateChanged(bool bHlaEnabled);
private:
NGL::INGLLogger &m_logger;
std::shared_ptr<DdsHandler> m_ddsHandler;
std::shared_ptr<NgsHandler> m_ngsHandler;
std::shared_ptr<WebSocketHandler> m_wsHandler;
@@ -127,8 +127,7 @@ static inline rpr2::SpatialStruct spatialStructFromWorldLocation(const rpr2::Wor
NgsConnector::NgsConnector(const QString &fedName, NgsHandler *ngsHandler)
: m_ngsHandler(ngsHandler)
NgsConnector::NgsConnector(const QString &fedName, NgsHandler *ngsHandler) : m_ngsHandler(ngsHandler)
, m_fedName(fedName)
, m_swadmin(&ngs::SimulatedWorldAPI::getSimulatedWorldAdmin())
, m_master(nullptr)
@@ -144,8 +143,8 @@ NgsConnector::NgsConnector(const QString &fedName, NgsHandler *ngsHandler)
, m_iaWeaponFireCallback(new ObserverWeaponFireCBNotifier())
, m_bInitialized(false)
, m_bCanPublishData(false)
, m_timer(new QTimer(this))
{
, m_timer(new QTimer(this)),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
connect(m_timer, &QTimer::timeout,
this, &NgsConnector::go);
connect(m_playerCallback, &PlayerCallback::firstTick,
@@ -212,7 +211,7 @@ bool NgsConnector::initialize(ngs::IObserver::ProtocolType protocol, const QStri
}
catch (const ngs::NGSSimWorldException &e)
{
ERROR_LOG() << "caught exception during init (getIFederationMaster): " << e.print();
ERROR_LOG(m_logger) << "caught exception during init (getIFederationMaster): " << e.print();
return false;
}
@@ -227,7 +226,7 @@ bool NgsConnector::initialize(ngs::IObserver::ProtocolType protocol, const QStri
}
catch (const NGSException &e)
{
ERROR_LOG() << "caught exception during init (createFederation): " << e.print();
ERROR_LOG(m_logger) << "caught exception during init (createFederation): " << e.print();
return false;
}
player = &m_swadmin->getIPlayer(m_fedName.toStdString(), playerName.toStdString(), *m_playerCallback, Settings::swConfFileName().toLatin1().data(), Settings::fomIdentifier().toStdString(), Settings::rtiIdentifier().toStdString());
@@ -277,22 +276,22 @@ void NgsConnector::subscribeAtNgs()
m_enitityNumberCounter = 1;
m_eventCount = 1;
INFO_LOG() << "Subscribe at NGS - Human Objects";
INFO_LOG(m_logger) << "Subscribe at NGS - Human Objects";
rpr2::IObserverHumanObjClass &humanObjClass = m_somPlayer->getObserverHumanObjClass(*m_humanCallback);
humanObjClass.subscribeAllAttributes();
humanObjClass.subscribe();
INFO_LOG() << "Subscribe at NGS - GroundVehicle Objects";
INFO_LOG(m_logger) << "Subscribe at NGS - GroundVehicle Objects";
rpr2::IObserverGroundVehicleObjClass &groundVehicleObjClass = m_somPlayer->getObserverGroundVehicleObjClass(*m_groundVehicleCallback);
groundVehicleObjClass.subscribeAllAttributes();
groundVehicleObjClass.subscribe();
INFO_LOG() << "Subscribe at NGS - LongBowApache Objects";
INFO_LOG(m_logger) << "Subscribe at NGS - LongBowApache Objects";
rpr2::IObserverLongBowApacheObjClass &longBowApacheObjClass = m_somPlayer->getObserverLongBowApacheObjClass(*m_longBowApacheCallback);
longBowApacheObjClass.subscribeAllAttributes();
longBowApacheObjClass.subscribe();
INFO_LOG() << "Subscribe at NGS - Designator Objects";
INFO_LOG(m_logger) << "Subscribe at NGS - Designator Objects";
rpr2::IObserverDesignatorObjClass &designatorObjClass = m_somPlayer->getObserverDesignatorObjClass(*m_designatorCallback);
designatorObjClass.subscribeAllAttributes();
designatorObjClass.subscribe();
@@ -321,35 +320,35 @@ void NgsConnector::unsubscribeFromNgs()
if (m_somPlayer)
{
INFO_LOG() << "Unsubscribe at NGS - Human Objects";
INFO_LOG(m_logger) << "Unsubscribe at NGS - Human Objects";
rpr2::IObserverHumanObjClass &humanObjClass = m_somPlayer->getObserverHumanObjClass(*m_humanCallback);
humanObjClass.unsubscribe();
INFO_LOG() << "Unsubscribe at NGS - GroundVehicle Objects";
INFO_LOG(m_logger) << "Unsubscribe at NGS - GroundVehicle Objects";
rpr2::IObserverGroundVehicleObjClass &groundVehicleObjClass = m_somPlayer->getObserverGroundVehicleObjClass(*m_groundVehicleCallback);
groundVehicleObjClass.unsubscribe();
INFO_LOG() << "Unsubscribe at NGS - LongBowApache Objects";
INFO_LOG(m_logger) << "Unsubscribe at NGS - LongBowApache Objects";
rpr2::IObserverLongBowApacheObjClass &longBowApacheObjClass = m_somPlayer->getObserverLongBowApacheObjClass(*m_longBowApacheCallback);
longBowApacheObjClass.unsubscribe();
INFO_LOG() << "Unsubscribe at NGS - Designator Objects";
INFO_LOG(m_logger) << "Unsubscribe at NGS - Designator Objects";
rpr2::IObserverDesignatorObjClass &designatorObjectClass = m_somPlayer->getObserverDesignatorObjClass(*m_designatorCallback);
designatorObjectClass.unsubscribe();
INFO_LOG() << "Unsubscribe at NGS - Engagement Reply Interaction";
INFO_LOG(m_logger) << "Unsubscribe at NGS - Engagement Reply Interaction";
rpr2::IObserverEngagementReplyIntClass &enr = m_somPlayer->getObserverEngagementReplyIntClass(*m_iaEngagementReplyCallback);
enr.unsubscribe();
INFO_LOG() << "Unsubscribe at NGS - Event Report Interaction";
INFO_LOG(m_logger) << "Unsubscribe at NGS - Event Report Interaction";
rpr2::IObserverEventReportIntClass &evr = m_somPlayer->getObserverEventReportIntClass(*m_iaEventReportCallback);
evr.unsubscribe();
INFO_LOG() << "Unsubscribe at NGS - Munition Detonation Interaction";
INFO_LOG(m_logger) << "Unsubscribe at NGS - Munition Detonation Interaction";
rpr2::IObserverMunitionDetonationIntClass &md = m_somPlayer->getObserverMunitionDetonationIntClass(*m_iaMunitionDetonationCallback);
md.unsubscribe();
INFO_LOG() << "Unsubscribe at NGS - Weapon Fire Interaction";
INFO_LOG(m_logger) << "Unsubscribe at NGS - Weapon Fire Interaction";
rpr2::IObserverWeaponFireIntClass &wf = m_somPlayer->getObserverWeaponFireIntClass(*m_iaWeaponFireCallback);
wf.unsubscribe();
}
@@ -515,7 +514,7 @@ bool NgsConnector::sendData(int eqNo, const QByteArray& data, int requestIdentif
vds.NumberOfLongLongs__A__Padding__A__DatumValue.resize(data.size() / 8 + 1);
vds.DatumLengthInBits = 8 * data.size();
TRACE_LOG() << "--> Data. Receiver: " << eqNo << ", ReqID: " << requestIdentifier << ", Data: " << data;
TRACE_LOG(m_logger) << "--> Data. Receiver: " << eqNo << ", ReqID: " << requestIdentifier << ", Data: " << data;
for (unsigned int i=0; i< vds.NumberOfLongLongs__A__Padding__A__DatumValue.size(); ++i)
{
@@ -682,11 +681,11 @@ void NgsConnector::go()
}
catch (const NGSException &ex)
{
ERROR_LOG() << "NGS Exception caught in Event Loop" << ex.print();
ERROR_LOG(m_logger) << "NGS Exception caught in Event Loop" << ex.print();
}
catch (const std::exception &e)
{
ERROR_LOG() << "Standard Exception caught in Event Loop: " << e.what();
ERROR_LOG(m_logger) << "Standard Exception caught in Event Loop: " << e.what();
}
catch (...)
{
@@ -1499,7 +1498,7 @@ void NgsConnector::onNewMunitionDetonation(const rpr2::IObserverMunitionDetonati
const auto &objectIdentifier = interaction.getEventIdentifier().IssuingObjectIdentifier;
int eqId = getEquipmentNoByRTIObjectId(objectIdentifier.ID);
DEBUG_LOG() << "Engagement Reply, Issuer: " << eqId;
DEBUG_LOG(m_logger) << "Engagement Reply, Issuer: " << eqId;
if (m_playerMap.contains(eqId) || objectIdentifier.ID == std::to_string(IdentifierStruct(0).toInt64()))
return;
@@ -232,6 +232,7 @@ signals:
void laserDesignation(const TrainingAreaBase::LaserDesignation &event);
protected:
NGL::INGLLogger &m_logger;
void subscribeAtNgs();
void unsubscribeFromNgs();
@@ -14,10 +14,9 @@
namespace HighLevelArchitecture
{
NgsHandler::NgsHandler(QObject *parent)
: QObject(parent)
, m_ddsHandler(nullptr)
{}
NgsHandler::NgsHandler(QObject *parent) : QObject(parent)
, m_ddsHandler(nullptr),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
NgsHandler::~NgsHandler()
{
@@ -39,7 +38,7 @@ bool NgsHandler::init(const std::shared_ptr<DdsHandler> &ddsHandler)
ngs::IObserver::ProtocolType protocol = Settings::hlaProtocol();
INFO_LOG() << "Protocol = " << protToStr.value(protocol, QStringLiteral("UNKNOWN"));
INFO_LOG(m_logger) << "Protocol = " << protToStr.value(protocol, QStringLiteral("UNKNOWN"));
m_ngsConnector =
@@ -61,9 +60,9 @@ void NgsHandler::onFirstTickFinished()
m_ppmHandler = std::make_shared<PpmHandler>(this);
m_aesHandler = std::make_shared<AesHandler>(this);
if (!m_ppmHandler->init())
ERROR_LOG() << "Could not init ppm handler - not able to publish participants to HLA";
ERROR_LOG(m_logger) << "Could not init ppm handler - not able to publish participants to HLA";
if (!m_aesHandler->init())
ERROR_LOG() << "Could not init ppm handler - not able to publish area effect simulations to HLA";
ERROR_LOG(m_logger) << "Could not init ppm handler - not able to publish area effect simulations to HLA";
connect(m_ppmHandler.get(), &PpmHandler::externalEquipmentNumberAdded,
this, &NgsHandler::externalEquipmentNumberAdded);
@@ -89,11 +88,11 @@ void NgsHandler::initSocketReaders()
sr->start();
connect(sr, &SocketReader::newData, this, &NgsHandler::onNewSocketReaderData);
m_socketReaders.append(sr);
INFO_LOG() << "SocketReader with ID " << sd.hlaRequestIdentifier << " connected";
INFO_LOG(m_logger) << "SocketReader with ID " << sd.hlaRequestIdentifier << " connected";
}
else
{
ERROR_LOG() << "Could not initialize SocketReader " << sd.hlaRequestIdentifier;
ERROR_LOG(m_logger) << "Could not initialize SocketReader " << sd.hlaRequestIdentifier;
}
}
}
@@ -49,6 +49,7 @@ private slots:
private:
NGL::INGLLogger &m_logger;
void initSocketReaders();
void deInitSocketReaders();
@@ -82,7 +82,7 @@ bool PpmHandler::init()
m_dtsTab->enableEquipmentGearAssignment())
)
{
ERROR_LOG() << "Enabling TAB DTS Data-Topics failed.";
ERROR_LOG(m_logger) << "Enabling TAB DTS Data-Topics failed.";
return false;
}
@@ -172,7 +172,7 @@ void PpmHandler::onDynamicParticipantDataChanged(const ParticipantManagement::Dy
int equipmentNo = getEquipmentNo(data.participantId());
if (equipmentNo == 0)
{
ERROR_LOG() << "Could not find EquipmentNo for Participant " << data.participantId() << ". Cannot send Dynamic Participant Data Modification to HLA.";
ERROR_LOG(m_logger) << "Could not find EquipmentNo for Participant " << data.participantId() << ". Cannot send Dynamic Participant Data Modification to HLA.";
return;
}
@@ -235,7 +235,7 @@ void PpmHandler::onDynamicParticipantDataChanged(const ParticipantManagement::Dy
void PpmHandler::onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType)
{
DEBUG_LOG() << "onParticipantChanged: " << data;
DEBUG_LOG(m_logger) << "onParticipantChanged: " << data;
switch (modType)
{
case DataModification::eAdded:
@@ -314,7 +314,7 @@ void PpmHandler::onParticipantChanged(const ParticipantManagement::Participant &
void PpmHandler::onParticipantPositionChanged(const ParticipantManagement::ParticipantPosition &data, DataModification modType)
{
DEBUG_LOG() << "onParticipantPositionChanged: " << data;
DEBUG_LOG(m_logger) << "onParticipantPositionChanged: " << data;
switch (modType)
{
case DataModification::eAdded:
@@ -404,7 +404,7 @@ void PpmHandler::onChargeTypeChanged(const ProjectDataManagement::ChargeType &da
void PpmHandler::startPublishToNgs()
{
INFO_LOG() << "Recreating all players from scratch due to structure / exercise change";
INFO_LOG(m_logger) << "Recreating all players from scratch due to structure / exercise change";
m_createdParticipantIds.clear();
@@ -413,7 +413,7 @@ void PpmHandler::startPublishToNgs()
INFO_LOG() << "(Re)Adding all players, size: " << m_partData.size();
INFO_LOG(m_logger) << "(Re)Adding all players, size: " << m_partData.size();
for (const ParticipantManagement::Participant &participant : std::as_const(m_partData))
createParticipant(participant);
@@ -474,7 +474,7 @@ rpr2::DetonationResultCodeEnum8::ET PpmHandler::rpr2DetonationResultFromPercenta
void PpmHandler::participantVulnerabilityStateRequest(const TrainingAreaBase::TetraIcd::DemandVulnerabilityStateChange &request)
{
DEBUG_LOG() << "Participant Vulnerability State Request";
DEBUG_LOG(m_logger) << "Participant Vulnerability State Request";
rpr2::DetonationResultCodeEnum8::ET resCode = rpr2DetonationResultFromVulnerabilityState(request.reqestedState);
m_ngsHandler->ngsConnector()->sendMunitionDetonation(request.header.equipmentNumber,
@@ -503,7 +503,7 @@ void PpmHandler::createParticipant(const ParticipantManagement::Participant &par
if (!m_ngsHandler->ngsConnector()->canPublishData())
{
WARNING_LOG() << "Can not publish data ... :(";
WARNING_LOG(m_logger) << "Can not publish data ... :(";
return;
}
@@ -90,6 +90,7 @@ public slots:
void participantCesHitInformationRequest(const TrainingAreaBase::TetraIcd::CesHitInformation &request);
private:
NGL::INGLLogger &m_logger;
void createParticipant(const ParticipantManagement::Participant &participant);
bool createHuman(const ParticipantManagement::Participant &participant);
bool createGroundVehicle(const ParticipantManagement::Participant &participant);
@@ -113,6 +114,7 @@ private:
static rpr2::DetonationResultCodeEnum8::ET rpr2DetonationResultFromPercentage(int percentage);
private:
NGL::INGLLogger &m_logger;
NgsHandler *m_ngsHandler;
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_dtcPpm;
std::shared_ptr<ParticipantManagement::Interface::Ftc> m_ftcPpm;
@@ -22,6 +22,6 @@ void ObserverActionRequestCBNotifier::newActionRequestIntInstance(const rpr2::IO
void ObserverActionRequestCBNotifier::deleteInterface()
{
DEBUG_LOG() << "Delete Interface";
DEBUG_LOG(m_logger) << "Delete Interface";
}
@@ -25,6 +25,8 @@ public:
void deleteInterface() override;
protected:
NGL::INGLLogger &m_logger;
signals:
void newActionRequest(const rpr2::IObserverActionRequestIntInstance &interaction);
@@ -22,6 +22,6 @@ void ObserverDataCBNotifier::newDataIntInstance(const rpr2::IObserverDataIntInst
void ObserverDataCBNotifier::deleteInterface()
{
DEBUG_LOG() << "Delete Interface";
DEBUG_LOG(m_logger) << "Delete Interface";
}
@@ -25,6 +25,8 @@ public:
void deleteInterface() override;
protected:
NGL::INGLLogger &m_logger;
signals:
void newData(const rpr2::IObserverDataIntInstance &interaction);
@@ -23,6 +23,6 @@ void ObserverEngagementReplyCBNotifier::newEngagementReplyIntInstance(const rpr2
void ObserverEngagementReplyCBNotifier::deleteInterface()
{
DEBUG_LOG() << "Delete Interface";
DEBUG_LOG(m_logger) << "Delete Interface";
}
@@ -25,6 +25,8 @@ public:
void deleteInterface() override;
protected:
NGL::INGLLogger &m_logger;
signals:
void newEngagementReply(const rpr2::IObserverEngagementReplyIntInstance &interaction);
};
@@ -22,6 +22,6 @@ void ObserverEventReportCBNotifier::newEventReportIntInstance(const rpr2::IObser
void ObserverEventReportCBNotifier::deleteInterface()
{
DEBUG_LOG() << "Delete Interface";
DEBUG_LOG(m_logger) << "Delete Interface";
}
@@ -25,6 +25,8 @@ public:
void deleteInterface() override;
protected:
NGL::INGLLogger &m_logger;
signals:
void newEventReport(const rpr2::IObserverEventReportIntInstance &interaction);
};
@@ -17,6 +17,6 @@ void ObserverMunitionDetonationCBNotifier::newMunitionDetonationIntInstance(cons
void ObserverMunitionDetonationCBNotifier::deleteInterface()
{
DEBUG_LOG() << "Delete Interface";
DEBUG_LOG(m_logger) << "Delete Interface";
}
@@ -24,6 +24,8 @@ public:
void deleteInterface() override;
protected:
NGL::INGLLogger &m_logger;
signals:
void newMunitionDetonation(const rpr2::IObserverMunitionDetonationIntInstance &interaction);
};
@@ -23,6 +23,6 @@ void ObserverWeaponFireCBNotifier::newWeaponFireIntInstance(const rpr2::IObserve
void ObserverWeaponFireCBNotifier::deleteInterface()
{
DEBUG_LOG() << "Delete Interface";
DEBUG_LOG(m_logger) << "Delete Interface";
}
@@ -25,6 +25,8 @@ public:
void deleteInterface() override;
protected:
NGL::INGLLogger &m_logger;
signals:
void newWeaponFire(const rpr2::IObserverWeaponFireIntInstance &interaction);
};
@@ -25,7 +25,7 @@ public:
void deleteObjectInstance() override
{
DEBUG_LOG() << "deleteObjectInstance";
DEBUG_LOG(m_logger) << "deleteObjectInstance";
if (m_pCB && m_pIObject)
m_pCB->deleteObjectInstance(*m_pIObject);
delete this;
@@ -12,17 +12,16 @@
namespace HighLevelArchitecture {
SocketReader::SocketReader(QObject *parent)
: QThread(parent)
SocketReader::SocketReader(QObject *parent) : QThread(parent)
, m_socket(new QTcpSocket(this))
, m_hlaRequestIdentifier(0)
.getNGLLogger("SocketReader"))
{
.getNGLLogger("SocketReader")),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
}
bool SocketReader::init(const QString &host, quint16 port, int hlaRequestIdentifier)
{
DEBUG_LOG() << "SR " << hlaRequestIdentifier << ": Trying to establish connection to " << host << ":" << port;
DEBUG_LOG(m_logger) << "SR " << hlaRequestIdentifier << ": Trying to establish connection to " << host << ":" << port;
m_hlaRequestIdentifier = hlaRequestIdentifier;
connect(m_socket, SIGNAL(readyRead()), this, SLOT(onReadyRead()));
@@ -49,9 +48,9 @@ void SocketReader::onReadyRead()
DEBUG_LOG() << "SR "<< m_hlaRequestIdentifier << ": Data received, transmitting";
DEBUG_LOG(m_logger) << "SR "<< m_hlaRequestIdentifier << ": Data received, transmitting";
QByteArray ba(m_socket->readAll());
TRACE_LOG() << "SR "<< m_hlaRequestIdentifier << ": Data contents: " << ba.constData();
TRACE_LOG(m_logger) << "SR "<< m_hlaRequestIdentifier << ": Data contents: " << ba.constData();
emit newData(ba, m_hlaRequestIdentifier);
}
@@ -75,7 +74,7 @@ void SocketReader::onSocketError(const QAbstractSocket::SocketError &error)
}
}
ERROR_LOG() << "SR "<< m_hlaRequestIdentifier << ": Socket Error: " << errorValue;
ERROR_LOG(m_logger) << "SR "<< m_hlaRequestIdentifier << ": Socket Error: " << errorValue;
}
}
@@ -26,6 +26,7 @@ signals:
void newData(const QByteArray &content, int id);
protected:
NGL::INGLLogger &m_logger;
QTcpSocket *m_socket;
int m_hlaRequestIdentifier;
private slots:
@@ -15,12 +15,11 @@
namespace HighLevelArchitecture
{
WebSocketHandler::WebSocketHandler(int exerciseId, MainHandler *mainHandler, QObject *parent)
: QObject(parent)
WebSocketHandler::WebSocketHandler(int exerciseId, MainHandler *mainHandler, QObject *parent) : QObject(parent)
, m_webSocketServer(new QWebSocketServer(QStringLiteral("WLS"), QWebSocketServer::NonSecureMode, this))
, m_mainHandler(mainHandler)
, m_exerciseId(exerciseId)
{}
, m_exerciseId(exerciseId),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
WebSocketHandler::~WebSocketHandler()
{
@@ -32,7 +31,7 @@ bool WebSocketHandler::init(quint16 listenPort)
{
if (!m_webSocketServer->listen(QHostAddress::Any, listenPort))
{
WARNING_LOG() << "Can not listen on port " << listenPort << " - aborting";
WARNING_LOG(m_logger) << "Can not listen on port " << listenPort << " - aborting";
return false;
}
connect(m_webSocketServer, &QWebSocketServer::newConnection,
@@ -51,7 +50,7 @@ bool WebSocketHandler::sendTelegramInternal(const TrainingAreaBase::TetraIcd::Tr
const QString jsonStr = QString::fromUtf8(QJsonDocument(obj).toJson(QJsonDocument::Compact));
DEBUG_LOG() << "jsonStr: " << jsonStr;
DEBUG_LOG(m_logger) << "jsonStr: " << jsonStr;
bool bOk = false;
for (auto wsw : std::as_const(m_webSockets))
@@ -68,12 +67,12 @@ void WebSocketHandler::sendHlaConnectionState()
TrainingAreaBase::TetraIcd::ProxyConnectionState connState;
connState.connectedToSystem = m_mainHandler->isConnectedToHla();
sendTelegram(&connState, m_exerciseId);
DEBUG_LOG() << "sendHlaConnectionState, isConnected: " << connState.connectedToSystem;
DEBUG_LOG(m_logger) << "sendHlaConnectionState, isConnected: " << connState.connectedToSystem;
}
void WebSocketHandler::sendParticipantConnectionStates()
{
DEBUG_LOG() << "sendParticipantConnectionStates";
DEBUG_LOG(m_logger) << "sendParticipantConnectionStates";
TrainingAreaBase::TetraIcd::WlsParticipantsConnectionState partConnState;
partConnState.equipmentNumber = -1;
partConnState.dataCommunicationPossible = false;
@@ -81,7 +80,7 @@ void WebSocketHandler::sendParticipantConnectionStates()
if (!m_mainHandler->isConnectedToHla())
{
INFO_LOG() << "We are (not) yet connected to HLA - don't send participant connection states";
INFO_LOG(m_logger) << "We are (not) yet connected to HLA - don't send participant connection states";
return;
}
const auto externalEquipmentNumbers = m_mainHandler->ngsHandler()->ppmHandler()->externalEquipmentNumbers();
@@ -117,7 +116,7 @@ void WebSocketHandler::onNewConnection()
QWebSocket *ws = m_webSocketServer->nextPendingConnection();
if (!ws)
return;
DEBUG_LOG() << "New websocket connection from " << ws->peerAddress().toString() << ":" << ws->peerPort();
DEBUG_LOG(m_logger) << "New websocket connection from " << ws->peerAddress().toString() << ":" << ws->peerPort();
auto wsw = std::make_shared<WebSocketWrapper>(ws);
connect(wsw.get(), &WebSocketWrapper::textMessageReceived,
@@ -132,11 +131,11 @@ void WebSocketHandler::onTextMessageReceived(const QByteArray &baJson)
{
using namespace TrainingAreaBase::TetraIcd;
TRACE_LOG() << "WebSocketHandler::onTextMessageReceived: " << baJson;
TRACE_LOG(m_logger) << "WebSocketHandler::onTextMessageReceived: " << baJson;
WebSocketWrapper *wsw = qobject_cast<WebSocketWrapper *>(sender());
if (!wsw)
{
ERROR_LOG() << "Internal error - sender is no WebSocketWrapper";
ERROR_LOG(m_logger) << "Internal error - sender is no WebSocketWrapper";
return;
}
@@ -156,7 +155,7 @@ void WebSocketHandler::onTextMessageReceived(const QByteArray &baJson)
const QJsonValue typeId = obj.value(QStringLiteral("typeId"));
if (!typeId.isDouble())
{
ERROR_LOG() << "Can not read type id: " << baJson;
ERROR_LOG(m_logger) << "Can not read type id: " << baJson;
return;
}
const QJsonObject data = obj.value(QStringLiteral("data")).toObject();
@@ -185,14 +184,14 @@ void WebSocketHandler::onTextMessageReceived(const QByteArray &baJson)
emit vulnerabilityStateRequest(DemandVulnerabilityStateChange::fromJson(data));
break;
default:
WARNING_LOG() << "Handler for telegram Id " << typeId.toInt()
WARNING_LOG(m_logger) << "Handler for telegram Id " << typeId.toInt()
<< " not yet implemented (" << baJson << ")";
return;
}
}
catch (const std::exception &e)
{
WARNING_LOG() << "Could not parse json: " << e.what() << " (" << baJson << ")";
WARNING_LOG(m_logger) << "Could not parse json: " << e.what() << " (" << baJson << ")";
return;
}
}
@@ -54,6 +54,7 @@ public Q_SLOTS:
void onExternalEquipmentNumberRemoved(int equipNo);
private:
NGL::INGLLogger &m_logger;
void sendDataCommunicationState(int equipNo, bool bIsAvailable);
bool sendTelegramInternal(const TrainingAreaBase::TetraIcd::TrainingAreaTelegram *data,
const QString &type, int exerciseId);
@@ -62,6 +63,7 @@ private Q_SLOTS:
void onWebSocketDisconnected();
void onTextMessageReceived(const QByteArray &baJson);
private:
NGL::INGLLogger &m_logger;
QWebSocketServer *m_webSocketServer;
QVector<std::shared_ptr<WebSocketWrapper>> m_webSockets;
MainHandler *m_mainHandler;
@@ -85,6 +87,7 @@ Q_SIGNALS:
private Q_SLOTS:
void onTextMessageReceived(const QString &data);
private:
NGL::INGLLogger &m_logger;
QWebSocket *m_webSocket;
int m_exerciseId;
};
@@ -79,9 +79,9 @@ AesHandler::AesHandler(NgsHandler *ngsHandler)
void AesHandler::onMineAreaModifyReply(const Core::FunctionReplyObject &replyObject)
{
if (replyObject.error())
WARNING_LOG() << "ModifyReply: " << replyObject();
WARNING_LOG(m_logger) << "ModifyReply: " << replyObject();
else
DEBUG_LOG() << "ModifyReply: " << replyObject();
DEBUG_LOG(m_logger) << "ModifyReply: " << replyObject();
m_requestHelper->requestReply(replyObject);
}
@@ -176,7 +176,7 @@ void AesHandler::onAesItemViewChanged(const AesItemView &data, DataModification
for (const auto &pos : data.form())
formString << ParticipantPosition(pos).toString();
DEBUG_LOG() << "\n##############################"
DEBUG_LOG(m_logger) << "\n##############################"
<< "\n##### AesItemViewChanged #####"
<< "\n##############################"
<< "\nid: " << data.id()
@@ -196,7 +196,7 @@ void AesHandler::onAesItemViewChanged(const AesItemView &data, DataModification
data.effectStateId() == AesEffectState::EsExpired ||
data.effectStateId() == AesEffectState::EsRemoved)
{
DEBUG_LOG() << "Item view with id " << data.aesItemId() << " removed";
DEBUG_LOG(m_logger) << "Item view with id " << data.aesItemId() << " removed";
m_aesItemViews.remove(data.aesItemId());
m_takenIndicesForAesItem.remove(data.aesItemId());
m_ngsHandler->ngsConnector()->setItemForm(data.aesItemId());
@@ -205,7 +205,7 @@ void AesHandler::onAesItemViewChanged(const AesItemView &data, DataModification
else if (data.effectStateId() == AesEffectState::EsPrepared &&
data.aesTypeId() == AesType_def::AtExplosionAreaSingleExplosions)
{
DEBUG_LOG() << "Item view with id " << data.aesItemId() << " added";
DEBUG_LOG(m_logger) << "Item view with id " << data.aesItemId() << " added";
m_aesItemViews.insert(data.aesItemId(), data);
m_takenIndicesForAesItem.insert(data.aesItemId(), QVector<int32_t>());
}
@@ -213,7 +213,7 @@ void AesHandler::onAesItemViewChanged(const AesItemView &data, DataModification
else if (data.aesTypeId() == AesType_def::AtBCContamination)
{
m_ngsHandler->ngsConnector()->setItemForm(data.aesItemId(), data.aesTypeId().underlying(), data.form());
DEBUG_LOG() << "Item view with id " << data.aesItemId() << " directly updated in ngsConnector";
DEBUG_LOG(m_logger) << "Item view with id " << data.aesItemId() << " directly updated in ngsConnector";
}
}
@@ -229,7 +229,7 @@ void AesHandler::onTriggeredImpactsChanged(const TriggeredImpacts &data, DataMod
}
bitfield.append(QStringLiteral("]"));
DEBUG_LOG() << "\n#####################################"
DEBUG_LOG(m_logger) << "\n#####################################"
<< "\n##### triggered impacts changed #####"
<< "\n#####################################"
<< "\nid: " << data.id()
@@ -349,7 +349,7 @@ void AesHandler::onAesExplosionSingleChanged(const ExplosionSingle &data, DataMo
DEBUG_LOG() << "\n####################################"
DEBUG_LOG(m_logger) << "\n####################################"
<< "\n##### single explosion changed #####"
<< "\n####################################"
<< "\nid: " << data.id()
@@ -387,7 +387,7 @@ void AesHandler::onAesMineAreaChanged(const MineArea &data, DataModification mod
{
Q_UNUSED(modType);
DEBUG_LOG() << "\n#############################"
DEBUG_LOG(m_logger) << "\n#############################"
<< "\n##### mine area changed #####"
<< "\n#############################"
<< "\nid: " << data.id()
@@ -410,7 +410,7 @@ void AesHandler::onAesMineCorridorChanged(const MineCorridor &data, DataModifica
{
Q_UNUSED(modType);
DEBUG_LOG() << "\n#################################"
DEBUG_LOG(m_logger) << "\n#################################"
<< "\n##### mine corridor changed #####"
<< "\n#################################"
<< "\nid: " << data.id()
@@ -435,7 +435,7 @@ void AesHandler::onAesNContaminationChanged(const NContamination &data, DataModi
Q_UNUSED(modType);
m_ngsHandler->ngsConnector()->guezNuclearAgent(data);
DEBUG_LOG() << "\n####################################"
DEBUG_LOG(m_logger) << "\n####################################"
<< "\n##### n contamination changed #####"
<< "\n####################################"
<< "\nid: " << data.id()
@@ -458,7 +458,7 @@ void AesHandler::onAesBCContaminationChanged(const BCContamination &data, DataMo
Q_UNUSED(modType);
m_ngsHandler->ngsConnector()->guezChemicalAgent(data);
DEBUG_LOG() << "\n####################################"
DEBUG_LOG(m_logger) << "\n####################################"
<< "\n##### bc contamination changed #####"
<< "\n####################################"
<< "\nid: " << data.id()
@@ -563,7 +563,7 @@ void AesHandler::onAesRemoveItem(qint64 identifierInt)
AesType type = m_dtcAes->aesItemIdFromExternalId(identifierInt, aesItemId);
Core::RemoveElementRequest req(aesItemId);
DEBUG_LOG() << "Remove Item for " << aesItemId << " requested. Type: " << type;
DEBUG_LOG(m_logger) << "Remove Item for " << aesItemId << " requested. Type: " << type;
switch (type.underlying())
{
@@ -647,11 +647,11 @@ void AesHandler::onAesActivationTimeChanged(qint64 identifierInt, qint64 msecsSi
}
case AreaEffectSimulation::AesType_def::AtMineArea:
{
DEBUG_LOG() << "onAesActivationTimeChanged / MineArea";
DEBUG_LOG(m_logger) << "onAesActivationTimeChanged / MineArea";
MineAreaModifyRequest *req = static_cast<MineAreaModifyRequest*>(m_pendingRequests.value(aesItemId));
if (!req)
{
DEBUG_LOG() << "onAesActivationTimeChanged / MineArea - Request NOT found";
DEBUG_LOG(m_logger) << "onAesActivationTimeChanged / MineArea - Request NOT found";
AreaEffectSimulation::MineArea item = m_dtcAes->mineArea(aesItemId);
if ((item.effectStart().is_set() && item.effectStart().get() == msecsSinceEpoch) || !isModifiable(item))
return;
@@ -958,7 +958,7 @@ void AesHandler::onAesPointsDataChanged(qint64 identifierInt, const std::vector<
int aesItemId = 0;
AesType type = m_dtcAes->aesItemIdFromExternalId(identifierInt, aesItemId);
DEBUG_LOG() << "Points Data changed for Aes Item ID: " << aesItemId << ". Type: " << type;
DEBUG_LOG(m_logger) << "Points Data changed for Aes Item ID: " << aesItemId << ". Type: " << type;
switch (type.underlying())
{
@@ -980,7 +980,7 @@ void AesHandler::onAesPointsDataChanged(qint64 identifierInt, const std::vector<
std::vector<Core::GeoPosition2D> segments;
if (!getCorridorSegment(pos, segments, width))
{
ERROR_LOG() << "Could not calculate Mine Area from given Points Data!";
ERROR_LOG(m_logger) << "Could not calculate Mine Area from given Points Data!";
return;
}
req->segments(segments);
@@ -1003,7 +1003,7 @@ void AesHandler::onAesPointsDataChanged(qint64 identifierInt, const std::vector<
std::vector<Core::GeoPosition2D> segments;
if (!getCorridorSegment(pos, segments, width))
{
ERROR_LOG() << "Could not calculate Mine Area from given Points Data!";
ERROR_LOG(m_logger) << "Could not calculate Mine Area from given Points Data!";
return;
}
req->segments(segments);
@@ -87,6 +87,7 @@ private Q_SLOTS:
#endif
private:
NGL::INGLLogger &m_logger;
template <typename T>
void onSendRequest(const T &item);
template <typename T>
@@ -94,6 +95,7 @@ private:
static bool isModifiable(const AreaEffectSimulation::AesItem &item);
private:
NGL::INGLLogger &m_logger;
NgsHandler *m_ngsHandler;
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_dtcAes;
std::shared_ptr<AreaEffectSimulation::Interface::Ftc> m_ftcAes;
@@ -9,11 +9,10 @@
namespace HighLevelArchitecture
{
DdsHandler::DdsHandler(int domainId, int exerciseId)
: m_ddsConnector(new DDSConnector::DdsConnector(domainId, IDL::PartitionType::Exercise, exerciseId))
, m_hlaIsActive(false)
{
DEBUG_LOG() << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
DdsHandler::DdsHandler(int domainId, int exerciseId) : m_ddsConnector(new DDSConnector::DdsConnector(domainId, IDL::PartitionType::Exercise, exerciseId))
, m_hlaIsActive(false),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
DEBUG_LOG(m_logger) << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
}
DdsHandler::~DdsHandler()
@@ -27,7 +26,7 @@ bool DdsHandler::init(const QStringList &qosFileList)
{
if (!m_ddsConnector->init(qosFileList))
{
ERROR_LOG() << "Error initializing dds connections - aborting";
ERROR_LOG(m_logger) << "Error initializing dds connections - aborting";
return false;
}
@@ -33,8 +33,10 @@ public:
Q_SIGNALS:
void exerciseHlaStateChanged(bool bHlaEnabled);
private:
NGL::INGLLogger &m_logger;
void onExerciseChanged(const ExerciseManagement::Exercise &ex, DataModification modType);
private:
NGL::INGLLogger &m_logger;
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
std::shared_ptr<Core::Pacemaker> m_pacemaker;
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_dtcExm;
@@ -15,10 +15,9 @@
namespace HighLevelArchitecture
{
MainHandler::MainHandler(QObject *parent)
: QObject(parent)
, m_exerciseId(0)
{}
MainHandler::MainHandler(QObject *parent) : QObject(parent)
, m_exerciseId(0),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
MainHandler::~MainHandler()
{
@@ -34,7 +33,7 @@ bool MainHandler::init(int domainId, int exerciseId)
m_ddsHandler = std::make_shared<DdsHandler>(domainId, exerciseId);
if (!m_ddsHandler->init())
{
ERROR_LOG() << "Could not init DDS handler";
ERROR_LOG(m_logger) << "Could not init DDS handler";
return false;
}
connect(m_ddsHandler.get(), &DdsHandler::exerciseHlaStateChanged,
@@ -26,6 +26,7 @@ public:
private Q_SLOTS:
void onExerciseHlaStateChanged(bool bHlaEnabled);
private:
NGL::INGLLogger &m_logger;
std::shared_ptr<DdsHandler> m_ddsHandler;
std::shared_ptr<NgsHandler> m_ngsHandler;
std::shared_ptr<WebSocketHandler> m_wsHandler;
@@ -134,8 +134,7 @@ static inline rpr2::EnvironmentObjectTypeStruct dummyEOS()
NgsConnector::NgsConnector(const QString &fedName, NgsHandler *ngsHandler)
: m_ngsHandler(ngsHandler)
NgsConnector::NgsConnector(const QString &fedName, NgsHandler *ngsHandler) : m_ngsHandler(ngsHandler)
, m_fedName(fedName)
, m_swadmin(&ngs::SimulatedWorldAPI::getSimulatedWorldAdmin())
, m_master(nullptr)
@@ -154,8 +153,8 @@ NgsConnector::NgsConnector(const QString &fedName, NgsHandler *ngsHandler)
, m_requestBiteReportCallback(new ObserverGuezRequestBiteReportCBNotifier())
, m_bInitialized(false)
, m_bCanPublishData(false)
, m_timer(new QTimer(this))
{
, m_timer(new QTimer(this)),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
connect(m_timer, &QTimer::timeout,
this, &NgsConnector::go);
connect(m_playerCallback, &PlayerCallback::firstTick,
@@ -234,7 +233,7 @@ bool NgsConnector::initialize(ngs::IObserver::ProtocolType protocol, const QStri
}
catch (const ngs::NGSSimWorldException &e)
{
ERROR_LOG() << "caught exception during init (getIFederationMaster): " << e.print();
ERROR_LOG(m_logger) << "caught exception during init (getIFederationMaster): " << e.print();
return false;
}
@@ -249,7 +248,7 @@ bool NgsConnector::initialize(ngs::IObserver::ProtocolType protocol, const QStri
}
catch (const NGSException &e)
{
ERROR_LOG() << "caught exception during init (createFederation): " << e.print();
ERROR_LOG(m_logger) << "caught exception during init (createFederation): " << e.print();
return false;
}
player = &m_swadmin->getIPlayer(m_fedName.toStdString(), playerName.toStdString(), *m_playerCallback, Settings::swConfFileName().toLatin1().data(), Settings::fomIdentifier().toStdString(), Settings::rtiIdentifier().toStdString());
@@ -299,27 +298,27 @@ void NgsConnector::subscribeAtNgs()
m_enitityNumberCounter = 1;
m_eventCount = 1;
INFO_LOG() << "Subscribe at NGS - Guez Human Objects";
INFO_LOG(m_logger) << "Subscribe at NGS - Guez Human Objects";
rpr2::IObserverGuezHumanObjClass &humanObjClass = m_somPlayer->getObserverGuezHumanObjClass(*m_humanCallback);
humanObjClass.subscribeAllAttributes();
humanObjClass.subscribe();
INFO_LOG() << "Subscribe at NGS - Guez ObserverController Objects";
INFO_LOG(m_logger) << "Subscribe at NGS - Guez ObserverController Objects";
rpr2::IObserverGuezObserverControllerObjClass &observerControllerObjClass = m_somPlayer->getObserverGuezObserverControllerObjClass(*m_observerControllerCallback);
observerControllerObjClass.subscribeAllAttributes();
observerControllerObjClass.subscribe();
INFO_LOG() << "Subscribe at NGS - Guez GroundVehicle Objects";
INFO_LOG(m_logger) << "Subscribe at NGS - Guez GroundVehicle Objects";
rpr2::IObserverGuezGroundVehicleObjClass &groundVehicleObjClass = m_somPlayer->getObserverGuezGroundVehicleObjClass(*m_groundVehicleCallback);
groundVehicleObjClass.subscribeAllAttributes();
groundVehicleObjClass.subscribe();
INFO_LOG() << "Subscribe at NGS - Guez MineField Objects";
INFO_LOG(m_logger) << "Subscribe at NGS - Guez MineField Objects";
rpr2::IObserverGuezMineFieldObjClass &minefieldObjClass = m_somPlayer->getObserverGuezMineFieldObjClass(*m_minefieldCallback);
minefieldObjClass.subscribeAllAttributes();
minefieldObjClass.subscribe();
INFO_LOG() << "Subscribe at NGS - Guez MineField Breach Objects";
INFO_LOG(m_logger) << "Subscribe at NGS - Guez MineField Breach Objects";
rpr2::IObserverGuezMineFieldBreachObjClass &minefieldBreachObjClass = m_somPlayer->getObserverGuezMineFieldBreachObjClass(*m_minefieldBreachCallback);
minefieldBreachObjClass.subscribeAllAttributes();
minefieldBreachObjClass.subscribe();
@@ -355,23 +354,23 @@ void NgsConnector::unsubscribeFromNgs()
if (m_somPlayer)
{
INFO_LOG() << "Unsubscribe at NGS - Guez Human Objects";
INFO_LOG(m_logger) << "Unsubscribe at NGS - Guez Human Objects";
rpr2::IObserverGuezHumanObjClass &humanObjClass = m_somPlayer->getObserverGuezHumanObjClass(*m_humanCallback);
humanObjClass.unsubscribe();
INFO_LOG() << "Unsubscribe at NGS - Guez ObserverController Objects";
INFO_LOG(m_logger) << "Unsubscribe at NGS - Guez ObserverController Objects";
rpr2::IObserverGuezObserverControllerObjClass &observerControllerObjClass = m_somPlayer->getObserverGuezObserverControllerObjClass(*m_observerControllerCallback);
observerControllerObjClass.unsubscribe();
INFO_LOG() << "Unsubscribe at NGS - Guez GroundVehicle Objects";
INFO_LOG(m_logger) << "Unsubscribe at NGS - Guez GroundVehicle Objects";
rpr2::IObserverGuezGroundVehicleObjClass &groundVehicleObjClass = m_somPlayer->getObserverGuezGroundVehicleObjClass(*m_groundVehicleCallback);
groundVehicleObjClass.unsubscribe();
INFO_LOG() << "Unsubscribe at NGS - Guez MineField Objects";
INFO_LOG(m_logger) << "Unsubscribe at NGS - Guez MineField Objects";
rpr2::IObserverGuezMineFieldObjClass &minefieldObjClass = m_somPlayer->getObserverGuezMineFieldObjClass(*m_minefieldCallback);
minefieldObjClass.unsubscribe();
INFO_LOG() << "Unsubscribe at NGS - Guez MineField Breach Objects";
INFO_LOG(m_logger) << "Unsubscribe at NGS - Guez MineField Breach Objects";
rpr2::IObserverGuezMineFieldBreachObjClass &minefieldBreachObjClass = m_somPlayer->getObserverGuezMineFieldBreachObjClass(*m_minefieldBreachCallback);
minefieldBreachObjClass.unsubscribe();
}
@@ -1097,11 +1096,11 @@ void NgsConnector::go()
}
catch (const NGSException &ex)
{
ERROR_LOG() << "NGS Exception caught in Event Loop" << ex.print();
ERROR_LOG(m_logger) << "NGS Exception caught in Event Loop" << ex.print();
}
catch (const std::exception &e)
{
ERROR_LOG() << "Standard Exception caught in Event Loop: " << e.what();
ERROR_LOG(m_logger) << "Standard Exception caught in Event Loop: " << e.what();
}
catch (...)
{
@@ -284,6 +284,7 @@ signals:
void newMinefieldBreach(AreaEffectSimulation::MineCorridorModifyRequest &mc);
protected:
NGL::INGLLogger &m_logger;
void subscribeAtNgs();
void unsubscribeFromNgs();
@@ -12,10 +12,9 @@
namespace HighLevelArchitecture
{
NgsHandler::NgsHandler(QObject *parent)
: QObject(parent)
, m_ddsHandler(nullptr)
{}
NgsHandler::NgsHandler(QObject *parent) : QObject(parent)
, m_ddsHandler(nullptr),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
NgsHandler::~NgsHandler()
{
@@ -37,7 +36,7 @@ bool NgsHandler::init(const std::shared_ptr<DdsHandler> &ddsHandler)
ngs::IObserver::ProtocolType protocol = Settings::hlaProtocol();
INFO_LOG() << "Protocol = " << protToStr.value(protocol, QStringLiteral("UNKNOWN"));
INFO_LOG(m_logger) << "Protocol = " << protToStr.value(protocol, QStringLiteral("UNKNOWN"));
m_ngsConnector =
@@ -59,9 +58,9 @@ void NgsHandler::onFirstTickFinished()
m_ppmHandler = std::make_shared<PpmHandler>(this);
m_aesHandler = std::make_shared<AesHandler>(this);
if (!m_ppmHandler->init())
ERROR_LOG() << "Could not init ppm handler - not able to publish participants to HLA";
ERROR_LOG(m_logger) << "Could not init ppm handler - not able to publish participants to HLA";
if (!m_aesHandler->init())
ERROR_LOG() << "Could not init ppm handler - not able to publish area effect simulations to HLA";
ERROR_LOG(m_logger) << "Could not init ppm handler - not able to publish area effect simulations to HLA";
emit firstTickFinished();
@@ -42,6 +42,7 @@ Q_SIGNALS:
private slots:
void onFirstTickFinished();
private:
NGL::INGLLogger &m_logger;
std::shared_ptr<DdsHandler> m_ddsHandler;
std::shared_ptr<PpmHandler> m_ppmHandler;
std::shared_ptr<AesHandler> m_aesHandler;
@@ -81,7 +81,7 @@ bool PpmHandler::init()
m_dtsTab->enableEquipmentBite())
)
{
ERROR_LOG() << "Enabling TAB DTS Data-Topics failed.";
ERROR_LOG(m_logger) << "Enabling TAB DTS Data-Topics failed.";
return false;
}
@@ -176,7 +176,7 @@ void PpmHandler::onDynamicParticipantDataChanged(const ParticipantManagement::Dy
int equipmentNo = getEquipmentNo(data.participantId());
if (equipmentNo == 0)
{
ERROR_LOG() << "Could not find EquipmentNo for Participant " << data.participantId() << ". Cannot send Dynamic Participant Data Modification to HLA.";
ERROR_LOG(m_logger) << "Could not find EquipmentNo for Participant " << data.participantId() << ". Cannot send Dynamic Participant Data Modification to HLA.";
return;
}
@@ -255,7 +255,7 @@ void PpmHandler::onDynamicParticipantDataChanged(const ParticipantManagement::Dy
void PpmHandler::onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType)
{
DEBUG_LOG() << "onParticipantChanged: " << data;
DEBUG_LOG(m_logger) << "onParticipantChanged: " << data;
switch (modType)
{
case DataModification::eAdded:
@@ -337,7 +337,7 @@ void PpmHandler::onParticipantChanged(const ParticipantManagement::Participant &
void PpmHandler::onParticipantPositionChanged(const ParticipantManagement::ParticipantPosition &data, DataModification modType)
{
DEBUG_LOG() << "onParticipantPositionChanged: " << data;
DEBUG_LOG(m_logger) << "onParticipantPositionChanged: " << data;
switch (modType)
{
case DataModification::eAdded:
@@ -446,7 +446,7 @@ void PpmHandler::onEquipmentBiteChanged(const TrainingAreaBase::EquipmentBite &d
void PpmHandler::startPublishToNgs()
{
INFO_LOG() << "Recreating all players from scratch due to structure / exercise change";
INFO_LOG(m_logger) << "Recreating all players from scratch due to structure / exercise change";
m_createdParticipantIds.clear();
@@ -455,7 +455,7 @@ void PpmHandler::startPublishToNgs()
INFO_LOG() << "(Re)Adding all players, size: " << m_partData.size();
INFO_LOG(m_logger) << "(Re)Adding all players, size: " << m_partData.size();
for (const ParticipantManagement::Participant &participant : std::as_const(m_partData))
createParticipant(participant);
@@ -479,7 +479,7 @@ void PpmHandler::createParticipant(const ParticipantManagement::Participant &par
if (!m_ngsHandler->ngsConnector()->canPublishData())
{
WARNING_LOG() << "Can not publish data ... :(";
WARNING_LOG(m_logger) << "Can not publish data ... :(";
return;
}
@@ -1002,7 +1002,7 @@ bool PpmHandler::onExconInit(int eqNo, rpr2::ResetPlayerEnum8::ET rp, rpr2::Acti
bool PpmHandler::onBiteReport(const TrainingAreaBase::EquipmentBite &report)
{
DEBUG_LOG() << "Attempting to Forward Bite Report to DDS. dtsTab: " << m_dtsTab << ", report for EqId: " << report.equipmentNumber();
DEBUG_LOG(m_logger) << "Attempting to Forward Bite Report to DDS. dtsTab: " << m_dtsTab << ", report for EqId: " << report.equipmentNumber();
if (!m_dtsTab)
return false;
return m_dtsTab->publish(report);
@@ -89,6 +89,7 @@ public slots:
void participantBiteRequest(const TrainingAreaBase::TetraIcd::DemandBite &request);
private:
NGL::INGLLogger &m_logger;
void createParticipant(const ParticipantManagement::Participant &participant);
bool createHuman(const ParticipantManagement::Participant &participant);
bool createGroundVehicle(const ParticipantManagement::Participant &participant);
@@ -110,6 +111,7 @@ private:
TypeStruct getTypestruct(int typeId);
private:
NGL::INGLLogger &m_logger;
NgsHandler *m_ngsHandler;
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_dtcPpm;
std::shared_ptr<ParticipantManagement::Interface::Ftc> m_ftcPpm;
@@ -17,6 +17,6 @@ void ObserverGuezBiteReportCBNotifier::newGuezBiteReportIntInstance(const rpr2::
void ObserverGuezBiteReportCBNotifier::deleteInterface()
{
DEBUG_LOG() << "Delete Interface";
DEBUG_LOG(m_logger) << "Delete Interface";
}
@@ -23,6 +23,8 @@ public:
void deleteInterface() override;
protected:
NGL::INGLLogger &m_logger;
signals:
void newGuezBiteReport(const rpr2::IObserverGuezBiteReportIntInstance &action);
};
@@ -17,6 +17,6 @@ void ObserverGuezExconEngagementCBNotifier::newGuezExconEngagementIntInstance(co
void ObserverGuezExconEngagementCBNotifier::deleteInterface()
{
DEBUG_LOG() << "Delete Interface";
DEBUG_LOG(m_logger) << "Delete Interface";
}
@@ -23,6 +23,8 @@ public:
void deleteInterface() override;
protected:
NGL::INGLLogger &m_logger;
signals:
void newGuezExconEngagement(const rpr2::IObserverGuezExconEngagementIntInstance &action);
};
@@ -18,6 +18,6 @@ void ObserverGuezHitCBNotifier::newGuezHitIntInstance(const rpr2::IObserverGuezH
void ObserverGuezHitCBNotifier::deleteInterface()
{
DEBUG_LOG() << "Delete Interface";
DEBUG_LOG(m_logger) << "Delete Interface";
}
@@ -23,6 +23,8 @@ public:
void deleteInterface() override;
protected:
NGL::INGLLogger &m_logger;
signals:
void newGuezHit(const rpr2::IObserverGuezHitIntInstance &interaction);
};
@@ -17,6 +17,6 @@ void ObserverGuezInitCBNotifier::newGuezInitIntInstance(const rpr2::IObserverGue
void ObserverGuezInitCBNotifier::deleteInterface()
{
DEBUG_LOG() << "Delete Interface";
DEBUG_LOG(m_logger) << "Delete Interface";
}
@@ -23,6 +23,8 @@ public:
void deleteInterface() override;
protected:
NGL::INGLLogger &m_logger;
signals:
void newGuezInit(const rpr2::IObserverGuezInitIntInstance &action);
};
@@ -17,6 +17,6 @@ void ObserverGuezRequestBiteReportCBNotifier::newGuezRequestBiteReportIntInstanc
void ObserverGuezRequestBiteReportCBNotifier::deleteInterface()
{
DEBUG_LOG() << "Delete Interface";
DEBUG_LOG(m_logger) << "Delete Interface";
}
@@ -23,6 +23,8 @@ public:
void deleteInterface() override;
protected:
NGL::INGLLogger &m_logger;
signals:
void newGuezRequestBiteReport(const rpr2::IObserverGuezRequestBiteReportIntInstance &action);
};
@@ -17,6 +17,6 @@ void ObserverMunitionDetonationCBNotifier::newMunitionDetonationIntInstance(cons
void ObserverMunitionDetonationCBNotifier::deleteInterface()
{
DEBUG_LOG() << "Delete Interface";
DEBUG_LOG(m_logger) << "Delete Interface";
}
@@ -24,6 +24,8 @@ public:
void deleteInterface() override;
protected:
NGL::INGLLogger &m_logger;
signals:
void newMunitionDetonation(const rpr2::IObserverMunitionDetonationIntInstance &interaction);
};
@@ -23,6 +23,6 @@ void ObserverWeaponFireCBNotifier::newWeaponFireIntInstance(const rpr2::IObserve
void ObserverWeaponFireCBNotifier::deleteInterface()
{
DEBUG_LOG() << "Delete Interface";
DEBUG_LOG(m_logger) << "Delete Interface";
}
@@ -25,6 +25,8 @@ public:
void deleteInterface() override;
protected:
NGL::INGLLogger &m_logger;
signals:
void newWeaponFire(const rpr2::IObserverWeaponFireIntInstance &interaction);
};
@@ -25,7 +25,7 @@ public:
void deleteObjectInstance() override
{
DEBUG_LOG() << "deleteObjectInstance";
DEBUG_LOG(m_logger) << "deleteObjectInstance";
if (m_pCB && m_pIObject)
m_pCB->deleteObjectInstance(*m_pIObject);
delete this;
@@ -15,12 +15,11 @@
namespace HighLevelArchitecture
{
WebSocketHandler::WebSocketHandler(int exerciseId, MainHandler *mainHandler, QObject *parent)
: QObject(parent)
WebSocketHandler::WebSocketHandler(int exerciseId, MainHandler *mainHandler, QObject *parent) : QObject(parent)
, m_webSocketServer(new QWebSocketServer(QStringLiteral("WLS"), QWebSocketServer::NonSecureMode, this))
, m_mainHandler(mainHandler)
, m_exerciseId(exerciseId)
{}
, m_exerciseId(exerciseId),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
WebSocketHandler::~WebSocketHandler()
{
@@ -32,7 +31,7 @@ bool WebSocketHandler::init(quint16 listenPort)
{
if (!m_webSocketServer->listen(QHostAddress::Any, listenPort))
{
WARNING_LOG() << "Can not listen on port " << listenPort << " - aborting";
WARNING_LOG(m_logger) << "Can not listen on port " << listenPort << " - aborting";
return false;
}
connect(m_webSocketServer, &QWebSocketServer::newConnection,
@@ -51,7 +50,7 @@ bool WebSocketHandler::sendTelegramInternal(const TrainingAreaBase::TetraIcd::Tr
const QString jsonStr = QString::fromUtf8(QJsonDocument(obj).toJson(QJsonDocument::Compact));
DEBUG_LOG() << "jsonStr: " << jsonStr;
DEBUG_LOG(m_logger) << "jsonStr: " << jsonStr;
bool bOk = false;
for (const auto &wsw : std::as_const(m_webSockets))
@@ -68,12 +67,12 @@ void WebSocketHandler::sendHlaConnectionState()
TrainingAreaBase::TetraIcd::ProxyConnectionState connState;
connState.connectedToSystem = m_mainHandler->isConnectedToHla();
sendTelegram(&connState, m_exerciseId);
DEBUG_LOG() << "sendHlaConnectionState, isConnected: " << connState.connectedToSystem;
DEBUG_LOG(m_logger) << "sendHlaConnectionState, isConnected: " << connState.connectedToSystem;
}
void WebSocketHandler::sendParticipantConnectionStates()
{
DEBUG_LOG() << "sendParticipantConnectionStates";
DEBUG_LOG(m_logger) << "sendParticipantConnectionStates";
TrainingAreaBase::TetraIcd::WlsParticipantsConnectionState partConnState;
partConnState.equipmentNumber = -1;
partConnState.dataCommunicationPossible = false;
@@ -81,7 +80,7 @@ void WebSocketHandler::sendParticipantConnectionStates()
if (!m_mainHandler->isConnectedToHla())
{
INFO_LOG() << "We are (not) yet connected to HLA - don't send participant connection states";
INFO_LOG(m_logger) << "We are (not) yet connected to HLA - don't send participant connection states";
return;
}
const auto externalEquipmentNumbers = m_mainHandler->ngsHandler()->ppmHandler()->externalEquipmentNumbers();
@@ -117,7 +116,7 @@ void WebSocketHandler::onNewConnection()
QWebSocket *ws = m_webSocketServer->nextPendingConnection();
if (!ws)
return;
DEBUG_LOG() << "New websocket connection from " << ws->peerAddress().toString() << ":" << ws->peerPort();
DEBUG_LOG(m_logger) << "New websocket connection from " << ws->peerAddress().toString() << ":" << ws->peerPort();
auto wsw = std::make_shared<WebSocketWrapper>(ws);
connect(wsw.get(), &WebSocketWrapper::textMessageReceived,
@@ -132,11 +131,11 @@ void WebSocketHandler::onTextMessageReceived(const QByteArray &baJson)
{
using namespace TrainingAreaBase::TetraIcd;
TRACE_LOG() << "WebSocketHandler::onTextMessageReceived: " << baJson;
TRACE_LOG(m_logger) << "WebSocketHandler::onTextMessageReceived: " << baJson;
WebSocketWrapper *wsw = qobject_cast<WebSocketWrapper *>(sender());
if (!wsw)
{
ERROR_LOG() << "Internal error - sender is no WebSocketWrapper";
ERROR_LOG(m_logger) << "Internal error - sender is no WebSocketWrapper";
return;
}
@@ -156,7 +155,7 @@ void WebSocketHandler::onTextMessageReceived(const QByteArray &baJson)
const QJsonValue typeId = obj.value(QStringLiteral("typeId"));
if (!typeId.isDouble())
{
ERROR_LOG() << "Can not read type id: " << baJson;
ERROR_LOG(m_logger) << "Can not read type id: " << baJson;
return;
}
const QJsonObject data = obj.value(QStringLiteral("data")).toObject();
@@ -185,14 +184,14 @@ void WebSocketHandler::onTextMessageReceived(const QByteArray &baJson)
emit vulnerabilityStateRequest(DemandVulnerabilityStateChange::fromJson(data));
break;
default:
WARNING_LOG() << "Handler for telegram Id " << typeId.toInt()
WARNING_LOG(m_logger) << "Handler for telegram Id " << typeId.toInt()
<< " not yet implemented (" << baJson << ")";
return;
}
}
catch (const std::exception &e)
{
WARNING_LOG() << "Could not parse json: " << e.what() << " (" << baJson << ")";
WARNING_LOG(m_logger) << "Could not parse json: " << e.what() << " (" << baJson << ")";
return;
}
}
@@ -53,6 +53,7 @@ public Q_SLOTS:
void onExternalEquipmentNumberRemoved(int equipNo);
private:
NGL::INGLLogger &m_logger;
void sendDataCommunicationState(int equipNo, bool bIsAvailable);
bool sendTelegramInternal(const TrainingAreaBase::TetraIcd::TrainingAreaTelegram *data,
const QString &type, int exerciseId);
@@ -61,6 +62,7 @@ private Q_SLOTS:
void onWebSocketDisconnected();
void onTextMessageReceived(const QByteArray &baJson);
private:
NGL::INGLLogger &m_logger;
QWebSocketServer *m_webSocketServer;
QVector<std::shared_ptr<WebSocketWrapper>> m_webSockets;
MainHandler *m_mainHandler;
@@ -84,6 +86,7 @@ Q_SIGNALS:
private Q_SLOTS:
void onTextMessageReceived(const QString &data);
private:
NGL::INGLLogger &m_logger;
QWebSocket *m_webSocket;
int m_exerciseId;
};
@@ -15,10 +15,9 @@
namespace HighLevelArchitecture
{
MainHandler::MainHandler(QObject *parent)
: QObject(parent)
, m_exerciseId(0)
{}
MainHandler::MainHandler(QObject *parent) : QObject(parent)
, m_exerciseId(0),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
MainHandler::~MainHandler()
{
@@ -50,7 +49,7 @@ bool MainHandler::init(int exerciseId)
int port = 23456;
if (!m_wsInterface->init(port))
{
ERROR_LOG() << Q_FUNC_INFO
ERROR_LOG(m_logger) << Q_FUNC_INFO
<< " WsInterface::init failed on port: " << port;
return false;
}
@@ -27,6 +27,7 @@ public:
private Q_SLOTS:
private:
NGL::INGLLogger &m_logger;
std::shared_ptr<NgsHandler> m_ngsHandler;
std::shared_ptr<WsInterface> m_wsInterface;
int m_exerciseId;
@@ -130,8 +130,7 @@ static inline rpr2::EnvironmentObjectTypeStruct dummyEOS()
NgsConnector::NgsConnector(const QString &fedName, NgsHandler *ngsHandler)
: m_ngsHandler(ngsHandler)
NgsConnector::NgsConnector(const QString &fedName, NgsHandler *ngsHandler) : m_ngsHandler(ngsHandler)
, m_fedName(fedName)
, m_swadmin(&ngs::SimulatedWorldAPI::getSimulatedWorldAdmin())
, m_master(nullptr)
@@ -150,8 +149,8 @@ NgsConnector::NgsConnector(const QString &fedName, NgsHandler *ngsHandler)
, m_requestBiteReportCallback(new ObserverGuezRequestBiteReportCBNotifier())
, m_bInitialized(false)
, m_bCanPublishData(false)
, m_timer(new QTimer(this))
{
, m_timer(new QTimer(this)),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
connect(m_timer, &QTimer::timeout,
this, &NgsConnector::go);
connect(m_playerCallback, &PlayerCallback::firstTick,
@@ -230,7 +229,7 @@ bool NgsConnector::initialize(ngs::IObserver::ProtocolType protocol, const QStri
}
catch (const ngs::NGSSimWorldException &e)
{
ERROR_LOG() << "caught exception during init (getIFederationMaster): " << e.print();
ERROR_LOG(m_logger) << "caught exception during init (getIFederationMaster): " << e.print();
return false;
}
@@ -245,7 +244,7 @@ bool NgsConnector::initialize(ngs::IObserver::ProtocolType protocol, const QStri
}
catch (const NGSException &e)
{
ERROR_LOG() << "caught exception during init (createFederation): " << e.print();
ERROR_LOG(m_logger) << "caught exception during init (createFederation): " << e.print();
return false;
}
player = &m_swadmin->getIPlayer(m_fedName.toStdString(), playerName.toStdString(), *m_playerCallback, Settings::swConfFileName().toLatin1().data(), Settings::fomIdentifier().toStdString(), Settings::rtiIdentifier().toStdString());
@@ -295,27 +294,27 @@ void NgsConnector::subscribeAtNgs()
m_enitityNumberCounter = 1;
m_eventCount = 1;
INFO_LOG() << "Subscribe at NGS - Guez Human Objects";
INFO_LOG(m_logger) << "Subscribe at NGS - Guez Human Objects";
rpr2::IObserverGuezHumanObjClass &humanObjClass = m_somPlayer->getObserverGuezHumanObjClass(*m_humanCallback);
humanObjClass.subscribeAllAttributes();
humanObjClass.subscribe();
INFO_LOG() << "Subscribe at NGS - Guez ObserverController Objects";
INFO_LOG(m_logger) << "Subscribe at NGS - Guez ObserverController Objects";
rpr2::IObserverGuezObserverControllerObjClass &observerControllerObjClass = m_somPlayer->getObserverGuezObserverControllerObjClass(*m_observerControllerCallback);
observerControllerObjClass.subscribeAllAttributes();
observerControllerObjClass.subscribe();
INFO_LOG() << "Subscribe at NGS - Guez GroundVehicle Objects";
INFO_LOG(m_logger) << "Subscribe at NGS - Guez GroundVehicle Objects";
rpr2::IObserverGuezGroundVehicleObjClass &groundVehicleObjClass = m_somPlayer->getObserverGuezGroundVehicleObjClass(*m_groundVehicleCallback);
groundVehicleObjClass.subscribeAllAttributes();
groundVehicleObjClass.subscribe();
INFO_LOG() << "Subscribe at NGS - Guez MineField Objects";
INFO_LOG(m_logger) << "Subscribe at NGS - Guez MineField Objects";
rpr2::IObserverGuezMineFieldObjClass &minefieldObjClass = m_somPlayer->getObserverGuezMineFieldObjClass(*m_minefieldCallback);
minefieldObjClass.subscribeAllAttributes();
minefieldObjClass.subscribe();
INFO_LOG() << "Subscribe at NGS - Guez MineField Breach Objects";
INFO_LOG(m_logger) << "Subscribe at NGS - Guez MineField Breach Objects";
rpr2::IObserverGuezMineFieldBreachObjClass &minefieldBreachObjClass = m_somPlayer->getObserverGuezMineFieldBreachObjClass(*m_minefieldBreachCallback);
minefieldBreachObjClass.subscribeAllAttributes();
minefieldBreachObjClass.subscribe();
@@ -351,23 +350,23 @@ void NgsConnector::unsubscribeFromNgs()
if (m_somPlayer)
{
INFO_LOG() << "Unsubscribe at NGS - Guez Human Objects";
INFO_LOG(m_logger) << "Unsubscribe at NGS - Guez Human Objects";
rpr2::IObserverGuezHumanObjClass &humanObjClass = m_somPlayer->getObserverGuezHumanObjClass(*m_humanCallback);
humanObjClass.unsubscribe();
INFO_LOG() << "Unsubscribe at NGS - Guez ObserverController Objects";
INFO_LOG(m_logger) << "Unsubscribe at NGS - Guez ObserverController Objects";
rpr2::IObserverGuezObserverControllerObjClass &observerControllerObjClass = m_somPlayer->getObserverGuezObserverControllerObjClass(*m_observerControllerCallback);
observerControllerObjClass.unsubscribe();
INFO_LOG() << "Unsubscribe at NGS - Guez GroundVehicle Objects";
INFO_LOG(m_logger) << "Unsubscribe at NGS - Guez GroundVehicle Objects";
rpr2::IObserverGuezGroundVehicleObjClass &groundVehicleObjClass = m_somPlayer->getObserverGuezGroundVehicleObjClass(*m_groundVehicleCallback);
groundVehicleObjClass.unsubscribe();
INFO_LOG() << "Unsubscribe at NGS - Guez MineField Objects";
INFO_LOG(m_logger) << "Unsubscribe at NGS - Guez MineField Objects";
rpr2::IObserverGuezMineFieldObjClass &minefieldObjClass = m_somPlayer->getObserverGuezMineFieldObjClass(*m_minefieldCallback);
minefieldObjClass.unsubscribe();
INFO_LOG() << "Unsubscribe at NGS - Guez MineField Breach Objects";
INFO_LOG(m_logger) << "Unsubscribe at NGS - Guez MineField Breach Objects";
rpr2::IObserverGuezMineFieldBreachObjClass &minefieldBreachObjClass = m_somPlayer->getObserverGuezMineFieldBreachObjClass(*m_minefieldBreachCallback);
minefieldBreachObjClass.unsubscribe();
}
@@ -777,11 +776,11 @@ void NgsConnector::go()
}
catch (const NGSException &ex)
{
ERROR_LOG() << "NGS Exception caught in Event Loop" << ex.print();
ERROR_LOG(m_logger) << "NGS Exception caught in Event Loop" << ex.print();
}
catch (const std::exception &e)
{
ERROR_LOG() << "Standard Exception caught in Event Loop: " << e.what();
ERROR_LOG(m_logger) << "Standard Exception caught in Event Loop: " << e.what();
}
catch (...)
{
@@ -283,6 +283,7 @@ signals:
void newMinefieldBreach(AreaEffectSimulation::MineCorridorModifyRequest &mc);
protected:
NGL::INGLLogger &m_logger;
void subscribeAtNgs();
void unsubscribeFromNgs();
@@ -17,9 +17,8 @@
namespace HighLevelArchitecture
{
NgsHandler::NgsHandler(QObject *parent)
: QObject(parent)
{}
NgsHandler::NgsHandler(QObject *parent) : QObject(parent),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
NgsHandler::~NgsHandler()
{
@@ -36,7 +35,7 @@ bool NgsHandler::init()
if (myVec < myVec2)
{
INFO_LOG() << "Protocol = ";
INFO_LOG(m_logger) << "Protocol = ";
}
@@ -50,7 +49,7 @@ bool NgsHandler::init()
ngs::IObserver::ProtocolType protocol = Settings::hlaProtocol();
INFO_LOG() << "Protocol = " << protToStr.value(protocol, QStringLiteral("UNKNOWN"));
INFO_LOG(m_logger) << "Protocol = " << protToStr.value(protocol, QStringLiteral("UNKNOWN"));
m_ngsConnector =
@@ -37,6 +37,7 @@ Q_SIGNALS:
private slots:
void onFirstTickFinished();
private:
NGL::INGLLogger &m_logger;
std::shared_ptr<NgsConnector> m_ngsConnector;
};
}
@@ -19,26 +19,25 @@ namespace HighLevelArchitecture
WsInterface::WsInterface(std::shared_ptr<NgsHandler> ngsHandler, QObject *parent)
: QObject(parent)
WsInterface::WsInterface(std::shared_ptr<NgsHandler> ngsHandler, QObject *parent) : QObject(parent)
, m_wsServer(new QWebSocketServer(QStringLiteral("GNA"), QWebSocketServer::NonSecureMode, this))
, m_ngsHandler(ngsHandler)
.getNGLLogger("HlaTestTool.WsInterface"))
{
TRACE_LOG() << Q_FUNC_INFO << " START";
TRACE_LOG() << Q_FUNC_INFO << " END";
.getNGLLogger("HlaTestTool.WsInterface")),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
}
WsInterface::~WsInterface()
{
TRACE_LOG() << Q_FUNC_INFO << " START";
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
for (auto client : std::as_const(m_clients))
{
client->disconnect(this);
client->close();
}
qDeleteAll(m_clients);
TRACE_LOG() << Q_FUNC_INFO << " END";
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
}
bool WsInterface::init(quint16 listenPort)
@@ -50,14 +49,14 @@ bool WsInterface::init(quint16 listenPort)
if (!m_wsServer->listen(QHostAddress::Any, listenPort))
{
WARNING_LOG() << "Cannot listen on port " << listenPort << " - aborting";
WARNING_LOG(m_logger) << "Cannot listen on port " << listenPort << " - aborting";
return false;
}
DEBUG_LOG() << "Listening on port " << listenPort;
DEBUG_LOG(m_logger) << "Listening on port " << listenPort;
connect(m_wsServer, &QWebSocketServer::newConnection,
this, &WsInterface::onNewConnection);
TRACE_LOG() << Q_FUNC_INFO << " END, listenPort=" << listenPort;
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END, listenPort=" << listenPort;
return true;
}
@@ -79,19 +78,19 @@ void WsInterface::onNewConnection()
void WsInterface::onWebSocketDisconnected()
{
TRACE_LOG() << Q_FUNC_INFO << " START";
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
QWebSocket *ws = qobject_cast<QWebSocket *>(sender());
if (!ws)
return;
NOTICE_LOG(m_logger) << "Websocket connection closed, ptr: " << ws;
m_clients.remove(ws);
ws->deleteLater();
TRACE_LOG() << Q_FUNC_INFO << " END";
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
}
void WsInterface::onError(QAbstractSocket::SocketError error)
{
ERROR_LOG() << Q_FUNC_INFO << " Error occured, QAbstractSocket::SocketError = " << error;
ERROR_LOG(m_logger) << Q_FUNC_INFO << " Error occured, QAbstractSocket::SocketError = " << error;
}
void WsInterface::onTextMessageReceived(const QString &msg)
@@ -100,15 +99,15 @@ void WsInterface::onTextMessageReceived(const QString &msg)
if (msg.isEmpty())
{
ERROR_LOG() << "Empty message received";
ERROR_LOG(m_logger) << "Empty message received";
return;
}
DEBUG_LOG() << "incoming telegram: " << msg;
DEBUG_LOG(m_logger) << "incoming telegram: " << msg;
const QByteArray baJson = msg.toUtf8();
processMessage(baJson);
DEBUG_LOG() << Q_FUNC_INFO << " END";
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " END";
}
void WsInterface::processMessage(const QByteArray baJson)
@@ -120,7 +119,7 @@ void WsInterface::processMessage(const QByteArray baJson)
if (parseError.error != QJsonParseError::NoError)
{
ERROR_LOG() << "Could not parse JSON "
ERROR_LOG(m_logger) << "Could not parse JSON "
<< ". Reason: "
<< parseError.errorString()
<< "; baJson: '"
@@ -156,7 +155,7 @@ void WsInterface::processMessage(const QByteArray baJson)
}
catch (const JsonException &ex)
{
ERROR_LOG() << "Could not parse json telegram: "
ERROR_LOG(m_logger) << "Could not parse json telegram: "
<< ", error: " << ex.what();
}
break;
@@ -176,7 +175,7 @@ void WsInterface::processMessage(const QByteArray baJson)
}
catch (const JsonException &ex)
{
ERROR_LOG() << "Could not parse json telegram: "
ERROR_LOG(m_logger) << "Could not parse json telegram: "
<< ", error: " << ex.what();
return;
}
@@ -206,7 +205,7 @@ void WsInterface::processMessage(const QByteArray baJson)
}
catch (const JsonException &ex)
{
ERROR_LOG() << "Could not parse json telegram: "
ERROR_LOG(m_logger) << "Could not parse json telegram: "
<< ", error: " << ex.what();
return;
}
@@ -219,7 +218,7 @@ void WsInterface::processMessage(const QByteArray baJson)
default:
{
ERROR_LOG() << "Telegram with typeId '" << typeId << "' not handled in switch"
ERROR_LOG(m_logger) << "Telegram with typeId '" << typeId << "' not handled in switch"
<< ", doc= " << doc.toJson(QJsonDocument::Compact) << "<<<";
}
}
@@ -33,6 +33,8 @@ public:
signals:
private:
NGL::INGLLogger &m_logger;
QWebSocketServer *m_wsServer;
QSet<QWebSocket *> m_clients;