Adds immediate migration results in progress
This commit is contained in:
2102 files changed
+17482
-15071
No files matched your search
+27
-28
@@ -29,15 +29,14 @@
|
||||
//-----------------------------------------------------------------------------------------------------------------------
|
||||
namespace ExerciseEventManagement
|
||||
{
|
||||
EemTests::EemTests(QObject *parent)
|
||||
: QObject(parent)
|
||||
{}
|
||||
EemTests::EemTests(QObject *parent) : QObject(parent),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------
|
||||
bool EemTests::init(int domainId, int exerciseId, int testId)
|
||||
{
|
||||
bool bRet = true;
|
||||
DEBUG_LOG() << "init begin";
|
||||
DEBUG_LOG(m_logger) << "init begin";
|
||||
|
||||
m_testId = testId;
|
||||
|
||||
@@ -63,7 +62,7 @@ bool EemTests::init(int domainId, int exerciseId, int testId)
|
||||
m_bldDts = Buildings::Interface::Dts::create(m_ddsConnector42);
|
||||
bRet &= m_bldDts->enableBuildingState();
|
||||
|
||||
DEBUG_LOG() << "bRet: " << bRet;
|
||||
DEBUG_LOG(m_logger) << "bRet: " << bRet;
|
||||
|
||||
return bRet;
|
||||
}
|
||||
@@ -71,7 +70,7 @@ bool EemTests::init(int domainId, int exerciseId, int testId)
|
||||
//-----------------------------------------------------------------------------------------------------------------------
|
||||
void EemTests::startTest()
|
||||
{
|
||||
INFO_LOG() << "startTest m_testId = " << m_testId;
|
||||
INFO_LOG(m_logger) << "startTest m_testId = " << m_testId;
|
||||
|
||||
if (m_testId == 1) // publish dynamicParticipantData
|
||||
{
|
||||
@@ -134,7 +133,7 @@ void EemTests::startTest()
|
||||
|
||||
if (m_testId <= 0 || m_testId > 6)
|
||||
{
|
||||
ERROR_LOG() << "Unknown test case: " << m_testId;
|
||||
ERROR_LOG(m_logger) << "Unknown test case: " << m_testId;
|
||||
failExit();
|
||||
}
|
||||
|
||||
@@ -166,10 +165,10 @@ void EemTests::tryCreateDynamicParticipantData(int participantId, ProjectDataMan
|
||||
dp.stateHistory().push_back(si);
|
||||
dp.sampleTime(esTime);
|
||||
|
||||
DEBUG_LOG() << "Publishing DynamicParticipantData for participant " << participantId ;
|
||||
DEBUG_LOG(m_logger) << "Publishing DynamicParticipantData for participant " << participantId ;
|
||||
if (!m_ppmDts->publish(dp))
|
||||
{
|
||||
ERROR_LOG() << "Error requesting create DynamicParticipantData";
|
||||
ERROR_LOG(m_logger) << "Error requesting create DynamicParticipantData";
|
||||
failExit();
|
||||
}
|
||||
}
|
||||
@@ -191,10 +190,10 @@ void EemTests::trySendFireEvent()
|
||||
|
||||
gearAssigment.gears(gears);
|
||||
|
||||
DEBUG_LOG() << "Publish EquipmentGearAssigment";
|
||||
DEBUG_LOG(m_logger) << "Publish EquipmentGearAssigment";
|
||||
if (!m_tabDts->publish(gearAssigment))
|
||||
{
|
||||
ERROR_LOG() << "Error while publishing EquipmentGearAssigment";
|
||||
ERROR_LOG(m_logger) << "Error while publishing EquipmentGearAssigment";
|
||||
failExit();
|
||||
}
|
||||
|
||||
@@ -212,10 +211,10 @@ void EemTests::trySendFireEvent()
|
||||
|
||||
gearChargeState.charge(vGearCharge);
|
||||
|
||||
DEBUG_LOG() << "Publish EquipmentGearChargeState";
|
||||
DEBUG_LOG(m_logger) << "Publish EquipmentGearChargeState";
|
||||
if (!m_tabDts->publish(gearChargeState))
|
||||
{
|
||||
ERROR_LOG() << "Error while publishing EquipmentGearChargeState";
|
||||
ERROR_LOG(m_logger) << "Error while publishing EquipmentGearChargeState";
|
||||
failExit();
|
||||
}
|
||||
|
||||
@@ -231,10 +230,10 @@ void EemTests::trySendFireEvent()
|
||||
gearEvent.chargeAmount(200);
|
||||
gearEvent.charge(gc);
|
||||
|
||||
DEBUG_LOG() << "Publish EquipmentGearEvent";
|
||||
DEBUG_LOG(m_logger) << "Publish EquipmentGearEvent";
|
||||
if (!m_tabDts->publish(gearEvent))
|
||||
{
|
||||
ERROR_LOG() << "Error while publishing EquipmentGearEvent";
|
||||
ERROR_LOG(m_logger) << "Error while publishing EquipmentGearEvent";
|
||||
failExit();
|
||||
}
|
||||
|
||||
@@ -246,10 +245,10 @@ void EemTests::trySendFireEvent()
|
||||
gearEvent.chargeAmount(100);
|
||||
gearEvent.charge(gc);
|
||||
|
||||
DEBUG_LOG() << "Publish EquipmentGearEvent";
|
||||
DEBUG_LOG(m_logger) << "Publish EquipmentGearEvent";
|
||||
if (!m_tabDts->publish(gearEvent))
|
||||
{
|
||||
ERROR_LOG() << "Error while publishing EquipmentGearEvent";
|
||||
ERROR_LOG(m_logger) << "Error while publishing EquipmentGearEvent";
|
||||
failExit();
|
||||
}
|
||||
|
||||
@@ -257,12 +256,12 @@ void EemTests::trySendFireEvent()
|
||||
|
||||
const QMap<qint64, ExerciseEventManagement::Event> events = m_dtc->events();
|
||||
|
||||
DEBUG_LOG() << "events: " << events.size();
|
||||
DEBUG_LOG(m_logger) << "events: " << events.size();
|
||||
|
||||
int noEvents = 0;
|
||||
for(const ExerciseEventManagement::Event &e : events)
|
||||
{
|
||||
INFO_LOG() << "eventId: " << e.id() << ", eventType: " << e.eventTypeId().underlying();
|
||||
INFO_LOG(m_logger) << "eventId: " << e.id() << ", eventType: " << e.eventTypeId().underlying();
|
||||
if (e.eventTypeId() == ProjectDataManagement::EventType_def::WeaponAssignment ||
|
||||
e.eventTypeId() == ProjectDataManagement::EventType_def::FireEvent)
|
||||
noEvents ++;
|
||||
@@ -270,7 +269,7 @@ void EemTests::trySendFireEvent()
|
||||
|
||||
if (noEvents != 5)
|
||||
{
|
||||
ERROR_LOG() << "Error number of events (" << QString::number(noEvents) << ") not as expected (5)";
|
||||
ERROR_LOG(m_logger) << "Error number of events (" << QString::number(noEvents) << ") not as expected (5)";
|
||||
failExit();
|
||||
}
|
||||
|
||||
@@ -306,7 +305,7 @@ void EemTests::trySendBiteMessage()
|
||||
|
||||
if (!m_tabDts->publish(bite))
|
||||
{
|
||||
ERROR_LOG() << "Error while publishing EquipmentBite";
|
||||
ERROR_LOG(m_logger) << "Error while publishing EquipmentBite";
|
||||
failExit();
|
||||
}
|
||||
|
||||
@@ -331,7 +330,7 @@ void EemTests::trySendBuildingState()
|
||||
|
||||
if (!m_bldDts->publish(bState))
|
||||
{
|
||||
ERROR_LOG() << "Error while publishing building state";
|
||||
ERROR_LOG(m_logger) << "Error while publishing building state";
|
||||
failExit();
|
||||
}
|
||||
|
||||
@@ -358,10 +357,10 @@ void EemTests::tryCreateIed(qint64 time)
|
||||
const rti::core::int64 esTime = static_cast<rti::core::int64>(time);
|
||||
ied.sampleTime(esTime);
|
||||
|
||||
DEBUG_LOG() << "Publishing Ied " ;
|
||||
DEBUG_LOG(m_logger) << "Publishing Ied " ;
|
||||
if (!m_gimDts->publish(ied))
|
||||
{
|
||||
ERROR_LOG() << "Error requesting publish Ied";
|
||||
ERROR_LOG(m_logger) << "Error requesting publish Ied";
|
||||
failExit();
|
||||
}
|
||||
}
|
||||
@@ -371,12 +370,12 @@ void EemTests::checkEvents(const ProjectDataManagement::EventType &et, int expec
|
||||
{
|
||||
const QMap<qint64, ExerciseEventManagement::Event> events = m_dtc->events();
|
||||
|
||||
DEBUG_LOG() << "All published events: " << events.size();
|
||||
DEBUG_LOG(m_logger) << "All published events: " << events.size();
|
||||
int noEvents = 0;
|
||||
|
||||
for (const ExerciseEventManagement::Event &e : events)
|
||||
{
|
||||
INFO_LOG() << "eventId: " << e.id() << ", eventType: " << e.eventTypeId().underlying();
|
||||
INFO_LOG(m_logger) << "eventId: " << e.id() << ", eventType: " << e.eventTypeId().underlying();
|
||||
if (e.eventTypeId() == et)
|
||||
{
|
||||
QJsonObject prop = LtsUtils::JsonObject::fromJson(e.properties());
|
||||
@@ -389,11 +388,11 @@ void EemTests::checkEvents(const ProjectDataManagement::EventType &et, int expec
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_LOG() << "No events: " << noEvents;
|
||||
DEBUG_LOG(m_logger) << "No events: " << noEvents;
|
||||
|
||||
if (noEvents != expected)
|
||||
{
|
||||
ERROR_LOG() << "Error number of events (" << QString::number(noEvents) << ") not as expected (" << QString::number(expected) << ")";
|
||||
ERROR_LOG(m_logger) << "Error number of events (" << QString::number(noEvents) << ") not as expected (" << QString::number(expected) << ")";
|
||||
failExit();
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -47,6 +47,7 @@ protected Q_SLOTS:
|
||||
void failExit();
|
||||
void ExitSuccess();
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector42;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dts> m_ppmDts;
|
||||
std::shared_ptr<TrainingAreaBase::Interface::Dts> m_tabDts;
|
||||
|
||||
+7
-8
@@ -18,11 +18,10 @@
|
||||
namespace ExerciseEventManagement
|
||||
{
|
||||
|
||||
WebSocketHandler::WebSocketHandler(QObject *parent)
|
||||
: QObject(parent)
|
||||
WebSocketHandler::WebSocketHandler(QObject *parent) : QObject(parent)
|
||||
, m_webSocketServer(new QWebSocketServer(QStringLiteral("AVS-Server"), QWebSocketServer::NonSecureMode, this))
|
||||
, m_timer(new QTimer())
|
||||
{
|
||||
, m_timer(new QTimer()),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
connect(m_timer, &QTimer::timeout,
|
||||
this, &WebSocketHandler::onSendMessage);
|
||||
|
||||
@@ -44,7 +43,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;
|
||||
}
|
||||
// inform calling process via stdout about the port/url
|
||||
@@ -61,7 +60,7 @@ bool WebSocketHandler::sendTelegram(const QString &jsonStr)
|
||||
if (!isConnected())
|
||||
return false;
|
||||
|
||||
ERROR_LOG() << "jsonStr" << jsonStr;
|
||||
ERROR_LOG(m_logger) << "jsonStr" << jsonStr;
|
||||
|
||||
bool bOk = false;
|
||||
for (QWebSocket *ws : std::as_const(m_webSockets))
|
||||
@@ -79,7 +78,7 @@ void WebSocketHandler::onNewConnection()
|
||||
QWebSocket *ws = m_webSocketServer->nextPendingConnection();
|
||||
if (!ws)
|
||||
return;
|
||||
INFO_LOG() << "New websocket connection from " << ws->peerAddress().toString() << ":" << ws->peerPort();
|
||||
INFO_LOG(m_logger) << "New websocket connection from " << ws->peerAddress().toString() << ":" << ws->peerPort();
|
||||
|
||||
connect(ws, &QWebSocket::disconnected,
|
||||
this, &WebSocketHandler::onWebSocketDisconnected);
|
||||
@@ -91,7 +90,7 @@ void WebSocketHandler::onNewConnection()
|
||||
|
||||
void WebSocketHandler::onSendMessage()
|
||||
{
|
||||
ERROR_LOG() << "Send message: ";
|
||||
ERROR_LOG(m_logger) << "Send message: ";
|
||||
|
||||
QJsonObject obj;
|
||||
|
||||
|
||||
+1
@@ -40,6 +40,7 @@ private Q_SLOTS:
|
||||
void onWebSocketDisconnected();
|
||||
void onSendMessage();
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
QWebSocketServer *m_webSocketServer;
|
||||
QSet<QWebSocket *> m_webSockets;
|
||||
QTimer *m_timer;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace ExerciseEventManagement
|
||||
DdsHandler::DdsHandler(int domainId, int partitionId, IDL::PartitionType partitionType)
|
||||
: m_ddsConnector(std::make_shared<DDSConnector::DdsConnector>(domainId, partitionType, partitionId))
|
||||
{
|
||||
DEBUG_LOG() << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
DEBUG_LOG(m_logger) << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
}
|
||||
|
||||
DdsHandler::~DdsHandler()
|
||||
@@ -25,11 +25,11 @@ DdsHandler::~DdsHandler()
|
||||
|
||||
bool DdsHandler::init(const QStringList &qosFileList)
|
||||
{
|
||||
TRACE_LOG() << " START, this=" << this;
|
||||
TRACE_LOG(m_logger) << " START, this=" << this;
|
||||
|
||||
if (!m_ddsConnector->init(qosFileList))
|
||||
{
|
||||
ERROR_LOG() << "Error initializing dds connections - aborting";
|
||||
ERROR_LOG(m_logger) << "Error initializing dds connections - aborting";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -45,12 +45,12 @@ bool DdsHandler::init(const QStringList &qosFileList)
|
||||
m_ddsDts = ExerciseEventManagement::Interface::Dts::create(m_ddsConnector);
|
||||
|
||||
bool bRet = m_ddsDts->enableAll();
|
||||
INFO_LOG() << "Dts initialised";
|
||||
INFO_LOG(m_logger) << "Dts initialised";
|
||||
|
||||
// Subsribe for InfrastructureManagement::MainStructureElement
|
||||
m_dtcIsm = InfrastructureManagement::Interface::Dtc::create(m_ddsConnector);
|
||||
|
||||
TRACE_LOG() << " END, this=" << this;
|
||||
TRACE_LOG(m_logger) << " END, this=" << this;
|
||||
return bRet;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ public:
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> dtcIsm() const { return m_dtcIsm;} ///< Pointer to DTC InfrastructureManagement interface object
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<ExerciseEventManagement::Interface::Dts> m_ddsDts;
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_dtcIsm; ///< Pointer to DTC InfrastructureManagement interface object
|
||||
|
||||
+29
-30
@@ -30,12 +30,11 @@ using namespace ExerciseEventManagement;
|
||||
HandlerDynamicParticipantData::HandlerDynamicParticipantData(MainHandler *mainHandler,
|
||||
const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DbHandler> &db,
|
||||
const std::shared_ptr<WebSocketEventServer> &eventServer)
|
||||
: m_ddsHandler(ddsHandler)
|
||||
const std::shared_ptr<WebSocketEventServer> &eventServer) : m_ddsHandler(ddsHandler)
|
||||
, m_dbHandler(db)
|
||||
, m_eventServer(eventServer)
|
||||
, m_mainHandler(mainHandler)
|
||||
{
|
||||
, m_mainHandler(mainHandler),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
} // end of ctor()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -46,13 +45,13 @@ HandlerDynamicParticipantData::~HandlerDynamicParticipantData()
|
||||
//-----------------------------------------------------------------------------
|
||||
bool HandlerDynamicParticipantData::init()
|
||||
{
|
||||
INFO_LOG() << "start init() DTC ParticipantManagement ";
|
||||
INFO_LOG(m_logger) << "start init() DTC ParticipantManagement ";
|
||||
|
||||
// DTC ParticipantManagement
|
||||
m_ppmDtc = ParticipantManagement::Interface::Dtc::create(m_ddsHandler->ddsConnector());
|
||||
if (m_ppmDtc == nullptr)
|
||||
{
|
||||
ERROR_LOG() << "Could not create DTC ParticipantManagement";
|
||||
ERROR_LOG(m_logger) << "Could not create DTC ParticipantManagement";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -79,7 +78,7 @@ bool HandlerDynamicParticipantData::init()
|
||||
!m_ppmDtc->enableBite() ||
|
||||
!m_ppmDtc->enableParticipantPosition())
|
||||
{
|
||||
ERROR_LOG() << "init() DTC ParticipantManagement failed";
|
||||
ERROR_LOG(m_logger) << "init() DTC ParticipantManagement failed";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -87,7 +86,7 @@ bool HandlerDynamicParticipantData::init()
|
||||
|
||||
if (m_bldDtc == nullptr)
|
||||
{
|
||||
ERROR_LOG() << "Could not create DTC Buildings";
|
||||
ERROR_LOG(m_logger) << "Could not create DTC Buildings";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -96,7 +95,7 @@ bool HandlerDynamicParticipantData::init()
|
||||
|
||||
if (!m_bldDtc->enableBuildingState())
|
||||
{
|
||||
ERROR_LOG() << "Enable buildingState failed";
|
||||
ERROR_LOG(m_logger) << "Enable buildingState failed";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -143,7 +142,7 @@ void HandlerDynamicParticipantData::onAesItemViewChanged(const AreaEffectSimulat
|
||||
void HandlerDynamicParticipantData::tryCreateHitEvent(Database::EemEvent eData,
|
||||
const ParticipantManagement::StateInformation &stateInfo)
|
||||
{
|
||||
DEBUG_LOG() << "tryCreateHitEvent";
|
||||
DEBUG_LOG(m_logger) << "tryCreateHitEvent";
|
||||
// special values - ignore
|
||||
const ProjectDataManagement::VulnerabilityState vulnState = stateInfo.vulnerabilityState();
|
||||
if (vulnState == ProjectDataManagement::VulnerabilityState_def::VulnerabilityBitsChanged ||
|
||||
@@ -198,7 +197,7 @@ void HandlerDynamicParticipantData::tryCreateHitEvent(Database::EemEvent eData,
|
||||
}
|
||||
if (eData.eventTypeId == ProjectDataManagement::EventType::HitEffectSimulation)
|
||||
{
|
||||
DEBUG_LOG() << "Event HitEffectSimulation from originatorId = " << stateInfo.originatorId();
|
||||
DEBUG_LOG(m_logger) << "Event HitEffectSimulation from originatorId = " << stateInfo.originatorId();
|
||||
obj[QStringLiteral("AesId")] = stateInfo.originatorId();
|
||||
obj[QStringLiteral("AesType")] = m_itemViews.value(stateInfo.originatorId()).underlying();
|
||||
AreaEffectSimulation::AesItem aesItem;
|
||||
@@ -211,7 +210,7 @@ void HandlerDynamicParticipantData::tryCreateHitEvent(Database::EemEvent eData,
|
||||
if (stateInfo.sanitationProceduresTaken() == 0 && stateInfo.originatorChargeTypeId() == 0) //qualification
|
||||
return;
|
||||
|
||||
DEBUG_LOG() << "Event sanitation ";
|
||||
DEBUG_LOG(m_logger) << "Event sanitation ";
|
||||
|
||||
obj[QStringLiteral("Vitality")] = stateInfo.vitality();
|
||||
obj[QStringLiteral("SanitationResult")] = stateInfo.sanitationResult().underlying();
|
||||
@@ -224,7 +223,7 @@ void HandlerDynamicParticipantData::tryCreateHitEvent(Database::EemEvent eData,
|
||||
eData.sampleTime = stateInfo.stateTime();
|
||||
|
||||
if (!m_dbHandler->db()->insert(eData))
|
||||
ERROR_LOG() << "Error while inserting event data for participant: " << eData.participantId;
|
||||
ERROR_LOG(m_logger) << "Error while inserting event data for participant: " << eData.participantId;
|
||||
else
|
||||
publishData(eData);
|
||||
}
|
||||
@@ -236,7 +235,7 @@ void HandlerDynamicParticipantData::onDynamicParticipantDataChanged(const Partic
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
|
||||
DEBUG_LOG() << "onDynamicParticipantDataChanged()"
|
||||
DEBUG_LOG(m_logger) << "onDynamicParticipantDataChanged()"
|
||||
<< ", participantId: " << data.participantId()
|
||||
<< ", size stateHistory: " << data.stateHistory().size();
|
||||
|
||||
@@ -257,7 +256,7 @@ void HandlerDynamicParticipantData::onDynamicParticipantDataChanged(const Partic
|
||||
itParticipant = m_partMap.find(data.participantId());
|
||||
if (itParticipant == m_partMap.end())
|
||||
{
|
||||
ERROR_LOG() << "Participant does not exist: participantId: " << data.participantId();
|
||||
ERROR_LOG(m_logger) << "Participant does not exist: participantId: " << data.participantId();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -300,7 +299,7 @@ void HandlerDynamicParticipantData::onDynamicParticipantDataChanged(const Partic
|
||||
{
|
||||
if (gearIsKnown(gi))
|
||||
continue;
|
||||
DEBUG_LOG() << "Found new gear " << gi << " for participant " << data.participantId();
|
||||
DEBUG_LOG(m_logger) << "Found new gear " << gi << " for participant " << data.participantId();
|
||||
QJsonObject obj;
|
||||
obj[QStringLiteral("GearId")] = QJsonValue(gi.gearId());
|
||||
obj[QStringLiteral("GearTypeId")] = QJsonValue(gi.gearTypeId());
|
||||
@@ -310,7 +309,7 @@ void HandlerDynamicParticipantData::onDynamicParticipantDataChanged(const Partic
|
||||
eData.eventTypeId = ProjectDataManagement::EventType_def::WeaponAssignment;
|
||||
eData.id = 0;
|
||||
if (!m_dbHandler->db()->insert(eData))
|
||||
ERROR_LOG() << "Error while inserting event data for participant: " << data.participantId();
|
||||
ERROR_LOG(m_logger) << "Error while inserting event data for participant: " << data.participantId();
|
||||
else
|
||||
publishData(eData);
|
||||
}
|
||||
@@ -335,7 +334,7 @@ void HandlerDynamicParticipantData::onDynamicParticipantDataChanged(const Partic
|
||||
eData.sampleTime = mani.manipulationTime();
|
||||
eData.id = 0;
|
||||
if (!m_dbHandler->db()->insert(eData))
|
||||
ERROR_LOG() << "Error while inserting event data for participant: " << data.participantId();
|
||||
ERROR_LOG(m_logger) << "Error while inserting event data for participant: " << data.participantId();
|
||||
else
|
||||
publishData(eData);
|
||||
}
|
||||
@@ -360,7 +359,7 @@ void HandlerDynamicParticipantData::onParticipantGearEventChanged(const Particip
|
||||
itParticipant = m_partMap.find(data.participantId());
|
||||
if (itParticipant == m_partMap.end())
|
||||
{
|
||||
ERROR_LOG() << "Participant does not exist: participantId: " << data.participantId();
|
||||
ERROR_LOG(m_logger) << "Participant does not exist: participantId: " << data.participantId();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -389,9 +388,9 @@ void HandlerDynamicParticipantData::onParticipantGearEventChanged(const Particip
|
||||
eData.properties = QString::fromUtf8(QJsonDocument(obj).toJson(QJsonDocument::Compact));
|
||||
eData.id = 0;
|
||||
|
||||
DEBUG_LOG() << "create fire event for participant " << data.participantId();
|
||||
DEBUG_LOG(m_logger) << "create fire event for participant " << data.participantId();
|
||||
if (!m_dbHandler->db()->insert(eData))
|
||||
ERROR_LOG() << "Error while inserting event data for participant: " << data.participantId();
|
||||
ERROR_LOG(m_logger) << "Error while inserting event data for participant: " << data.participantId();
|
||||
else
|
||||
publishData(eData);
|
||||
}
|
||||
@@ -403,9 +402,9 @@ void HandlerDynamicParticipantData::onParticipantChanged(const ParticipantManage
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified:
|
||||
DEBUG_LOG() << "added/modified";
|
||||
DEBUG_LOG(m_logger) << "added/modified";
|
||||
m_partMap.insert(data.id(), data);
|
||||
DEBUG_LOG() << "data.participantId: " << data.id()
|
||||
DEBUG_LOG(m_logger) << "data.participantId: " << data.id()
|
||||
<< ", data.partyId: " << data.partyId()
|
||||
<< ". data.equipmentNumber: " << data.equipmentNumber();
|
||||
break;
|
||||
@@ -423,7 +422,7 @@ void HandlerDynamicParticipantData::onParticipantPositionChanged(const Participa
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified:
|
||||
m_partPosMap.insert(data.participantId(), data);
|
||||
DEBUG_LOG() << "data.participantId: " << data.participantId()
|
||||
DEBUG_LOG(m_logger) << "data.participantId: " << data.participantId()
|
||||
<< ", position lat: " << data.pos().lat()
|
||||
<< ", position lon: " << data.pos().lon();
|
||||
break;
|
||||
@@ -481,7 +480,7 @@ void HandlerDynamicParticipantData::onBiteChanged(const ParticipantManagement::B
|
||||
}
|
||||
|
||||
if (!m_dbHandler->db()->insert(eData))
|
||||
ERROR_LOG() << "Error while inserting event data for participantId: " << data.participantId();
|
||||
ERROR_LOG(m_logger) << "Error while inserting event data for participantId: " << data.participantId();
|
||||
else
|
||||
publishData(eData);
|
||||
}
|
||||
@@ -544,7 +543,7 @@ void HandlerDynamicParticipantData::onBuildingStateChanged(const Buildings::Buil
|
||||
eData.properties = QString::fromUtf8(QJsonDocument(obj).toJson(QJsonDocument::Compact));
|
||||
|
||||
if (!m_dbHandler->db()->insert(eData))
|
||||
ERROR_LOG() << "Error while inserting event data for building ";
|
||||
ERROR_LOG(m_logger) << "Error while inserting event data for building ";
|
||||
else
|
||||
publishData(eData);
|
||||
}
|
||||
@@ -557,7 +556,7 @@ void HandlerDynamicParticipantData::publishData(const Database::EemEvent &data)
|
||||
ExerciseEventManagement::Event ddsData = toDdsData(data);
|
||||
|
||||
if (!m_ddsHandler->dts()->publish(ddsData))
|
||||
ERROR_LOG() << "Error publishing event-data to dds";
|
||||
ERROR_LOG(m_logger) << "Error publishing event-data to dds";
|
||||
|
||||
// take data from dds-bus after 10s, we need just to make sure the recording service got it
|
||||
m_mainHandler->addEventIdToRemove(ddsData.id());
|
||||
@@ -580,7 +579,7 @@ ExerciseEventManagement::Event HandlerDynamicParticipantData::toDdsData(const Da
|
||||
if (data.eventTypeId == ProjectDataManagement::EventType_def::HitBuilding)
|
||||
{
|
||||
int mainStructureElementId = LtsUtils::JsonObject::fromJson(ddsData.properties()).valueOr<int>(QStringLiteral("MainStructureElementId"), 0);
|
||||
DEBUG_LOG() << "MainStructureElementId=" << mainStructureElementId;
|
||||
DEBUG_LOG(m_logger) << "MainStructureElementId=" << mainStructureElementId;
|
||||
ddsData.position(m_mainStructureElements.value(mainStructureElementId).geoPosition());
|
||||
}
|
||||
|
||||
@@ -592,7 +591,7 @@ ExerciseEventManagement::Event HandlerDynamicParticipantData::toDdsData(const Da
|
||||
// ///////////////////////////////////
|
||||
void HandlerDynamicParticipantData::onMainStructureElementChanged(const InfrastructureManagement::MainStructureElement &data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG() << "onMainStructureElementChanged";
|
||||
DEBUG_LOG(m_logger) << "onMainStructureElementChanged";
|
||||
if (modType != DataModification::eAdded &&
|
||||
modType != DataModification::eModified)
|
||||
{
|
||||
@@ -601,7 +600,7 @@ void HandlerDynamicParticipantData::onMainStructureElementChanged(const Infrastr
|
||||
}
|
||||
|
||||
m_mainStructureElements.insert(data.id(), data);
|
||||
DEBUG_LOG() << "Got MainStructureElement: " << data;
|
||||
DEBUG_LOG(m_logger) << "Got MainStructureElement: " << data;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
+2
@@ -68,6 +68,8 @@ private Q_SLOTS:
|
||||
void onMainStructureElementChanged(const InfrastructureManagement::MainStructureElement &data, DataModification modType);
|
||||
|
||||
private: // methoden
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void publishData(const Database::EemEvent &data);
|
||||
ExerciseEventManagement::Event toDdsData(const Database::EemEvent &data);
|
||||
|
||||
|
||||
+9
-10
@@ -28,13 +28,12 @@ using namespace ExerciseEventManagement;
|
||||
HandlerEquipmentErrorRegistration::HandlerEquipmentErrorRegistration(MainHandler *mainHandler,
|
||||
const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DbHandler> &db,
|
||||
const std::shared_ptr<WebSocketEventServer> &eventServer)
|
||||
: m_mainHandler(mainHandler)
|
||||
const std::shared_ptr<WebSocketEventServer> &eventServer) : m_mainHandler(mainHandler)
|
||||
, m_ddsHandler(ddsHandler)
|
||||
, m_dbHandler(db)
|
||||
, m_eventServer(eventServer)
|
||||
, m_ossDtc(nullptr)
|
||||
{
|
||||
, m_ossDtc(nullptr),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -45,14 +44,14 @@ HandlerEquipmentErrorRegistration::~HandlerEquipmentErrorRegistration()
|
||||
|
||||
bool HandlerEquipmentErrorRegistration::init()
|
||||
{
|
||||
INFO_LOG() << "start init() DTC OcSituationServer ";
|
||||
INFO_LOG(m_logger) << "start init() DTC OcSituationServer ";
|
||||
|
||||
|
||||
// DTC OcSituationServer
|
||||
m_ossDtc = OcSituationServer::Interface::Dtc::create(m_ddsHandler->ddsConnector());
|
||||
if (m_ossDtc == nullptr)
|
||||
{
|
||||
ERROR_LOG() << "Could not create DTC OcSituationServer";
|
||||
ERROR_LOG(m_logger) << "Could not create DTC OcSituationServer";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -62,7 +61,7 @@ bool HandlerEquipmentErrorRegistration::init()
|
||||
|
||||
if (!m_ossDtc->enableEquipmentErrorRegistration())
|
||||
{
|
||||
ERROR_LOG() << "init() DTC OcSituationServer failed";
|
||||
ERROR_LOG(m_logger) << "init() DTC OcSituationServer failed";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -74,7 +73,7 @@ bool HandlerEquipmentErrorRegistration::init()
|
||||
//-----------------------------------------------------------------------------
|
||||
void HandlerEquipmentErrorRegistration::onEquipmentErrorRegistrationChanged(const OcSituationServer::EquipmentErrorRegistration &data, DataModification modType)
|
||||
{
|
||||
INFO_LOG() << "onEquipmentErrorRegistrationChanged()"
|
||||
INFO_LOG(m_logger) << "onEquipmentErrorRegistrationChanged()"
|
||||
<< ", equipmentNr: " << data.equipmentNumber()
|
||||
<< ", text: " << QString::fromStdString(data.text());
|
||||
|
||||
@@ -94,7 +93,7 @@ void HandlerEquipmentErrorRegistration::onEquipmentErrorRegistrationChanged(cons
|
||||
eData.properties = QString::fromUtf8(QJsonDocument(obj).toJson(QJsonDocument::Compact));
|
||||
|
||||
if (!m_dbHandler->db()->insert(eData))
|
||||
ERROR_LOG() << "Error while inserting event into database";
|
||||
ERROR_LOG(m_logger) << "Error while inserting event into database";
|
||||
else
|
||||
publishData(eData);
|
||||
|
||||
@@ -108,7 +107,7 @@ void HandlerEquipmentErrorRegistration::publishData(const Database::EemEvent &da
|
||||
ExerciseEventManagement::Event ddsData = toDdsData(data);
|
||||
|
||||
if (!m_ddsHandler->dts()->publish(ddsData))
|
||||
ERROR_LOG() << "Error publishing event-data to dds";
|
||||
ERROR_LOG(m_logger) << "Error publishing event-data to dds";
|
||||
|
||||
// take data from dds-bus after 10s, we need just to make sure the recording service got it
|
||||
m_mainHandler->addEventIdToRemove(ddsData.id());
|
||||
|
||||
+2
@@ -56,6 +56,8 @@ private Q_SLOTS:
|
||||
void onEquipmentErrorRegistrationChanged(const OcSituationServer::EquipmentErrorRegistration &data, DataModification modType);
|
||||
|
||||
private: // methoden
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void publishData(const Database::EemEvent &data);
|
||||
ExerciseEventManagement::Event toDdsData(const Database::EemEvent &data);
|
||||
|
||||
|
||||
+23
-24
@@ -22,12 +22,11 @@ using namespace ExerciseEventManagement;
|
||||
HandlerParticipantEvent::HandlerParticipantEvent(MainHandler *mainHandler,
|
||||
const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DbHandler> &db,
|
||||
const std::shared_ptr<WebSocketEventServer> &eventServer)
|
||||
: m_ddsHandler(ddsHandler)
|
||||
const std::shared_ptr<WebSocketEventServer> &eventServer) : m_ddsHandler(ddsHandler)
|
||||
, m_dbHandler(db)
|
||||
, m_eventServer(eventServer)
|
||||
, m_mainHandler(mainHandler)
|
||||
{
|
||||
, m_mainHandler(mainHandler),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -38,13 +37,13 @@ HandlerParticipantEvent::~HandlerParticipantEvent()
|
||||
|
||||
bool HandlerParticipantEvent::init()
|
||||
{
|
||||
INFO_LOG() << "start init() DTC CentralEffectSimulation ";
|
||||
INFO_LOG(m_logger) << "start init() DTC CentralEffectSimulation ";
|
||||
|
||||
// DTC CentralEffectSimulation
|
||||
m_cesDtc = CentralEffectSimulation::Interface::Dtc::create(m_ddsHandler->ddsConnector());
|
||||
if (!m_cesDtc)
|
||||
{
|
||||
ERROR_LOG() << "Could not create DTC CentralEffectSimulation";
|
||||
ERROR_LOG(m_logger) << "Could not create DTC CentralEffectSimulation";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -54,7 +53,7 @@ bool HandlerParticipantEvent::init()
|
||||
|
||||
if (!m_cesDtc->enableParticipantEvent() )
|
||||
{
|
||||
ERROR_LOG() << "init() DTC CentralEffectSimulation failed";
|
||||
ERROR_LOG(m_logger) << "init() DTC CentralEffectSimulation failed";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -62,7 +61,7 @@ bool HandlerParticipantEvent::init()
|
||||
m_pdmDtc = ProjectDataManagement::Interface::Dtc::create(m_ddsHandler->ddsConnector());
|
||||
if (!m_pdmDtc)
|
||||
{
|
||||
ERROR_LOG() << "Could not create DTC ProjectDataManagement";
|
||||
ERROR_LOG(m_logger) << "Could not create DTC ProjectDataManagement";
|
||||
return false;
|
||||
}
|
||||
m_pdmDtc->enableChargeType();
|
||||
@@ -84,7 +83,7 @@ bool HandlerParticipantEvent::init()
|
||||
|
||||
void HandlerParticipantEvent::onAesItemViewChanged(const AreaEffectSimulation::AesItemView &data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG() << "AesItemId: " << data.aesItemId() << ", effectState: " << data.effectStateId();
|
||||
DEBUG_LOG(m_logger) << "AesItemId: " << data.aesItemId() << ", effectState: " << data.effectStateId();
|
||||
|
||||
Database::EemEvent eData = m_aesMap[data.id()];
|
||||
eData.sampleTime = data.effectStart();
|
||||
@@ -96,7 +95,7 @@ void HandlerParticipantEvent::onAesItemViewChanged(const AreaEffectSimulation::A
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
m_itemViews.insert(data.aesItemId(), data.aesTypeId());
|
||||
DEBUG_LOG() << "eAdded: AesItemId: " << data.aesItemId() << ", effectState: " << data.effectStateId();
|
||||
DEBUG_LOG(m_logger) << "eAdded: AesItemId: " << data.aesItemId() << ", effectState: " << data.effectStateId();
|
||||
m_aesEffectState.insert(data.aesItemId(), data.effectStateId());
|
||||
|
||||
if (data.aesTypeId() == AreaEffectSimulation::AesType_def::AtBorderline)
|
||||
@@ -115,7 +114,7 @@ void HandlerParticipantEvent::onAesItemViewChanged(const AreaEffectSimulation::A
|
||||
data.boundingBoxBottomLeft().lat(), 0.0);
|
||||
|
||||
if (!m_dbHandler->db()->insert(eData))
|
||||
ERROR_LOG() << "Error while inserting event data from AES ";
|
||||
ERROR_LOG(m_logger) << "Error while inserting event data from AES ";
|
||||
else
|
||||
publishData(eData);
|
||||
}
|
||||
@@ -124,22 +123,22 @@ void HandlerParticipantEvent::onAesItemViewChanged(const AreaEffectSimulation::A
|
||||
{
|
||||
AreaEffectSimulation::AesEffectState effectState = m_aesEffectState.value(data.aesItemId());
|
||||
|
||||
DEBUG_LOG() << "eModified: AesItemId: " << data.aesItemId() << ", effectState: " << data.effectStateId();
|
||||
DEBUG_LOG() << "effectState: " << effectState;
|
||||
DEBUG_LOG(m_logger) << "eModified: AesItemId: " << data.aesItemId() << ", effectState: " << data.effectStateId();
|
||||
DEBUG_LOG(m_logger) << "effectState: " << effectState;
|
||||
|
||||
// insert event only once
|
||||
if (effectState != AreaEffectSimulation::AesEffectState::EsPrepared &&
|
||||
(effectState == AreaEffectSimulation::AesEffectState_def::EsActivated && data.effectStateId() != AreaEffectSimulation::AesEffectState_def::EsExpired))
|
||||
return;
|
||||
|
||||
INFO_LOG() << "new/update event: aesId: " << data.aesItemId();
|
||||
INFO_LOG(m_logger) << "new/update event: aesId: " << data.aesItemId();
|
||||
|
||||
m_aesEffectState.insert(data.aesItemId(), data.effectStateId());
|
||||
m_itemViews.insert(data.aesItemId(), data.aesTypeId());
|
||||
eData.position = LtsUtils::QPoint3D(data.boundingBoxBottomLeft().lon(),
|
||||
data.boundingBoxBottomLeft().lat(), 0.0);
|
||||
|
||||
INFO_LOG() << "aesType: " << data.aesTypeId();
|
||||
INFO_LOG(m_logger) << "aesType: " << data.aesTypeId();
|
||||
|
||||
switch (data.aesTypeId().underlying())
|
||||
{
|
||||
@@ -181,7 +180,7 @@ void HandlerParticipantEvent::onAesItemViewChanged(const AreaEffectSimulation::A
|
||||
// No ExerciseEvent for AesType
|
||||
default:
|
||||
{
|
||||
INFO_LOG() << "No ExerciseEvent for AesType:" << data.aesTypeId().underlying();
|
||||
INFO_LOG(m_logger) << "No ExerciseEvent for AesType:" << data.aesTypeId().underlying();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -212,7 +211,7 @@ void HandlerParticipantEvent::onAesItemViewChanged(const AreaEffectSimulation::A
|
||||
{
|
||||
if (!m_dbHandler->db()->insert(eData))
|
||||
{
|
||||
ERROR_LOG() << "Error while inserting event data from AES ";
|
||||
ERROR_LOG(m_logger) << "Error while inserting event data from AES ";
|
||||
break;
|
||||
}
|
||||
m_aesMap.insert(data.id(), eData);
|
||||
@@ -221,7 +220,7 @@ void HandlerParticipantEvent::onAesItemViewChanged(const AreaEffectSimulation::A
|
||||
{
|
||||
if (!m_dbHandler->db()->update(eData))
|
||||
{
|
||||
ERROR_LOG() << "Error while updating event data from AES ";
|
||||
ERROR_LOG(m_logger) << "Error while updating event data from AES ";
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -290,7 +289,7 @@ void HandlerParticipantEvent::onExplosionSingleChanged(const AreaEffectSimulatio
|
||||
{
|
||||
if (!m_dbHandler->db()->insert(eData))
|
||||
{
|
||||
ERROR_LOG() << "Error while inserting event data from AES ";
|
||||
ERROR_LOG(m_logger) << "Error while inserting event data from AES ";
|
||||
break;
|
||||
}
|
||||
m_aesMap.insert(data.id(), eData);
|
||||
@@ -299,7 +298,7 @@ void HandlerParticipantEvent::onExplosionSingleChanged(const AreaEffectSimulatio
|
||||
{
|
||||
if (!m_dbHandler->db()->update(eData))
|
||||
{
|
||||
ERROR_LOG() << "Error while updating event data from AES ";
|
||||
ERROR_LOG(m_logger) << "Error while updating event data from AES ";
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -307,7 +306,7 @@ void HandlerParticipantEvent::onExplosionSingleChanged(const AreaEffectSimulatio
|
||||
break;
|
||||
}
|
||||
default:
|
||||
DEBUG_LOG() << "Nothing to do";
|
||||
DEBUG_LOG(m_logger) << "Nothing to do";
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -323,7 +322,7 @@ void HandlerParticipantEvent::onParticipantEventChanged(const CentralEffectSimul
|
||||
eData.partyId = data.partyId();
|
||||
eData.sampleTime = data.eventTime();
|
||||
eData.position = LtsUtils::QPoint3D(data.position().lon(), data.position().lat(), data.position().z());
|
||||
DEBUG_LOG() << " onParticipantEventChanged "
|
||||
DEBUG_LOG(m_logger) << " onParticipantEventChanged "
|
||||
<< " position=" << data.position()
|
||||
<< " eData.position=" << eData.position;
|
||||
|
||||
@@ -397,7 +396,7 @@ void HandlerParticipantEvent::onParticipantEventChanged(const CentralEffectSimul
|
||||
|
||||
|
||||
if (!m_dbHandler->db()->insert(eData))
|
||||
ERROR_LOG() << "Error while inserting event data from CES ";
|
||||
ERROR_LOG(m_logger) << "Error while inserting event data from CES ";
|
||||
else
|
||||
publishData(eData);
|
||||
|
||||
@@ -412,7 +411,7 @@ void HandlerParticipantEvent::publishData(const Database::EemEvent &data)
|
||||
ExerciseEventManagement::Event ddsData = toDdsData(data);
|
||||
|
||||
if (!m_ddsHandler->dts()->publish(ddsData))
|
||||
ERROR_LOG() << "Error publishing event-data to dds";
|
||||
ERROR_LOG(m_logger) << "Error publishing event-data to dds";
|
||||
|
||||
// take data from dds-bus after 10s, we need just to make sure the recording service got it
|
||||
m_mainHandler->addEventIdToRemove(ddsData.id());
|
||||
|
||||
+2
@@ -47,6 +47,8 @@ private Q_SLOTS:
|
||||
void onExplosionSingleChanged(const AreaEffectSimulation::ExplosionSingle &data, DataModification modType);
|
||||
|
||||
private: // methoden
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void publishData(const Database::EemEvent &data);
|
||||
ExerciseEventManagement::Event toDdsData(const Database::EemEvent &data);
|
||||
|
||||
|
||||
+10
-11
@@ -24,13 +24,12 @@
|
||||
namespace ExerciseEventManagement
|
||||
{
|
||||
|
||||
MainHandler::MainHandler()
|
||||
: m_almService(nullptr)
|
||||
MainHandler::MainHandler() : m_almService(nullptr)
|
||||
, m_fltService(nullptr)
|
||||
, m_mrkService(nullptr)
|
||||
, m_evlService(nullptr)
|
||||
, m_removeTimer(new QTimer(this))
|
||||
{
|
||||
, m_removeTimer(new QTimer(this)),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
connect(m_removeTimer, &QTimer::timeout, this, &MainHandler::onRemoveKeys);
|
||||
m_removeTimer->setInterval(5000);
|
||||
m_removeTimer->setSingleShot(false);
|
||||
@@ -64,12 +63,12 @@ bool MainHandler::init(int domainId, int exerciseId)
|
||||
bool bRet = initInternal(domainId, exerciseId);
|
||||
if (bRet)
|
||||
{
|
||||
INFO_LOG() << "svcExerciseEventManagement successfully initialized";
|
||||
INFO_LOG(m_logger) << "svcExerciseEventManagement successfully initialized";
|
||||
m_ddsHandler->setRunningState(Core::RunningState::Running);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG() << "Error initializing svcExerciseEventManagement...";
|
||||
ERROR_LOG(m_logger) << "Error initializing svcExerciseEventManagement...";
|
||||
if (m_ddsHandler)
|
||||
m_ddsHandler->setRunningState(Core::RunningState::StartingError);
|
||||
}
|
||||
@@ -143,27 +142,27 @@ bool MainHandler::loadFromDatabase()
|
||||
{
|
||||
if (!m_webSocketEventServer || !m_webSocketEventServer->listen(Settings::getWebSocketServerPortRange(1)))
|
||||
{
|
||||
ERROR_LOG() << "Can not initialize WebSocket Event server";
|
||||
ERROR_LOG(m_logger) << "Can not initialize WebSocket Event server";
|
||||
return false;
|
||||
}
|
||||
m_ddsHandler->addPortToPacemaker(m_webSocketEventServer->listenPort(), Core::PortType::WebSocketServer);
|
||||
|
||||
if (!m_handlerEerEvent || !m_handlerEerEvent->init())
|
||||
{
|
||||
ERROR_LOG() << "Can not initialize EquipmentErrorRegistration handler";
|
||||
ERROR_LOG(m_logger) << "Can not initialize EquipmentErrorRegistration handler";
|
||||
return false;
|
||||
}
|
||||
if (!m_dynPartData || !m_dynPartData->init())
|
||||
{
|
||||
ERROR_LOG() << "Can not initialize Participant Data handler";
|
||||
ERROR_LOG(m_logger) << "Can not initialize Participant Data handler";
|
||||
return false;
|
||||
}
|
||||
if (!m_handlerPartEvent || !m_handlerPartEvent->init())
|
||||
{
|
||||
ERROR_LOG() << "Can not initialize Participant Event handler";
|
||||
ERROR_LOG(m_logger) << "Can not initialize Participant Event handler";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG() << "loadFromDatabase successfully finished";
|
||||
DEBUG_LOG(m_logger) << "loadFromDatabase successfully finished";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ public:
|
||||
void addEventIdToRemove(qint64 id);
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool initInternal(int domainId, int exerciseId);
|
||||
void onRemoveKeys();
|
||||
bool loadFromDatabase();
|
||||
|
||||
+47
-48
@@ -53,8 +53,7 @@ WebSocketAvs::WebSocketAvs(MainHandler *mainHandler,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
int exerciseId,
|
||||
QObject *parent)
|
||||
: QObject(parent)
|
||||
QObject *parent) : QObject(parent)
|
||||
, m_ddsHandler(ddsHandler)
|
||||
, m_dbHandler(db)
|
||||
, m_eventServer(eventServer)
|
||||
@@ -66,8 +65,8 @@ WebSocketAvs::WebSocketAvs(MainHandler *mainHandler,
|
||||
, m_cleanupTimer(new QTimer(this))
|
||||
, m_exerciseId(exerciseId)
|
||||
, m_lastUpdate(0)
|
||||
, m_bWebSocketDisconnectedWarnedOnce(false)
|
||||
{
|
||||
, m_bWebSocketDisconnectedWarnedOnce(false),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
connect(m_wsReconnectTimer, &QTimer::timeout,
|
||||
this, &WebSocketAvs::openWebSocket);
|
||||
|
||||
@@ -77,12 +76,12 @@ WebSocketAvs::WebSocketAvs(MainHandler *mainHandler,
|
||||
//if there is a positive time start it
|
||||
//if not: don't do it!
|
||||
int cleanupTimeout = Settings::getCleanupTimeout();
|
||||
INFO_LOG() << "cleanup Timer Interval: " << cleanupTimeout;
|
||||
INFO_LOG(m_logger) << "cleanup Timer Interval: " << cleanupTimeout;
|
||||
if (cleanupTimeout > 0)
|
||||
{
|
||||
m_cleanupTimer->setInterval(cleanupTimeout);
|
||||
m_cleanupTimer->start();
|
||||
INFO_LOG() << "Started cleanup Timer with Interval: " << cleanupTimeout;
|
||||
INFO_LOG(m_logger) << "Started cleanup Timer with Interval: " << cleanupTimeout;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -93,14 +92,14 @@ WebSocketAvs::~WebSocketAvs()
|
||||
|
||||
void WebSocketAvs::init()
|
||||
{
|
||||
DEBUG_LOG() << "WebSocketAvs::init";
|
||||
DEBUG_LOG(m_logger) << "WebSocketAvs::init";
|
||||
m_wsReconnectTimer->start(1000);
|
||||
//onCleanUpDbInternal();
|
||||
}
|
||||
|
||||
void WebSocketAvs::setWsUrl(const QString &url)
|
||||
{
|
||||
DEBUG_LOG() << "Url: " << url;
|
||||
DEBUG_LOG(m_logger) << "Url: " << url;
|
||||
m_wsUrl = url;
|
||||
}
|
||||
|
||||
@@ -128,7 +127,7 @@ AvsData WebSocketAvs::jsonObjectToAvsData(const QJsonObject &obj)
|
||||
break;
|
||||
default:
|
||||
eventType = ProjectDataManagement::EventType::Unknown;
|
||||
ERROR_LOG() << "Unknown avsEventType: " << avsEventType;
|
||||
ERROR_LOG(m_logger) << "Unknown avsEventType: " << avsEventType;
|
||||
break;
|
||||
}
|
||||
data.eventType = eventType.underlying();
|
||||
@@ -188,7 +187,7 @@ ExerciseEventManagement::Event WebSocketAvs::avsDataToEvent(const AvsData &data)
|
||||
|
||||
void WebSocketAvs::onTextMessageReceived(const QString &message)
|
||||
{
|
||||
INFO_LOG() << "Got message from AVS control process: " << message;
|
||||
INFO_LOG(m_logger) << "Got message from AVS control process: " << message;
|
||||
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(message.toUtf8()));
|
||||
const QJsonObject obj = doc.object();
|
||||
@@ -202,41 +201,41 @@ void WebSocketAvs::handleAvsData(const AvsData &data, const bool &lastRangeClose
|
||||
{
|
||||
QString streamName = data.streamName;
|
||||
|
||||
DEBUG_LOG() << "handleAvsData for stream: " << streamName;
|
||||
DEBUG_LOG(m_logger) << "handleAvsData for stream: " << streamName;
|
||||
|
||||
auto it = m_avsDataMap.find(streamName);
|
||||
|
||||
// existing stream ..........................................................
|
||||
if (it != m_avsDataMap.end())
|
||||
{
|
||||
DEBUG_LOG() << "handleAvsData for stream 1: " << streamName;
|
||||
DEBUG_LOG(m_logger) << "handleAvsData for stream 1: " << streamName;
|
||||
AvsData &avsData = m_avsDataMap[streamName];
|
||||
if ( (avsData.endTime == -1) && (data.endTime == -1))
|
||||
{
|
||||
DEBUG_LOG() << "kein Publish (avsData.endTime == -1) && (data.endTime == -1)";
|
||||
DEBUG_LOG(m_logger) << "kein Publish (avsData.endTime == -1) && (data.endTime == -1)";
|
||||
return;
|
||||
}
|
||||
if ( (data.endTime == -1) && (data.eventType == ProjectDataManagement::EventType::RadioCnr))
|
||||
{
|
||||
DEBUG_LOG() << "kein Publish (avsData.endTime == -1) && RadioCnr";
|
||||
DEBUG_LOG(m_logger) << "kein Publish (avsData.endTime == -1) && RadioCnr";
|
||||
return;
|
||||
}
|
||||
|
||||
if (avsData.eventTime != data.eventTime) // new range -> close old range
|
||||
{
|
||||
DEBUG_LOG() << "handleAvsData for stream 2: " << streamName;
|
||||
DEBUG_LOG(m_logger) << "handleAvsData for stream 2: " << streamName;
|
||||
if (avsData.eventTime == -1) // missing end time -> set artificial end time
|
||||
{
|
||||
WARNING_LOG() << "Missing end time for stream: " << streamName << " -> setting artificial end time: " << avsData.eventTime + 1000;
|
||||
WARNING_LOG(m_logger) << "Missing end time for stream: " << streamName << " -> setting artificial end time: " << avsData.eventTime + 1000;
|
||||
avsData.eventTime = avsData.eventTime + 1000;
|
||||
publishData(streamName);
|
||||
}
|
||||
DEBUG_LOG() << "handleAvsData for stream remove: " << streamName;
|
||||
DEBUG_LOG(m_logger) << "handleAvsData for stream remove: " << streamName;
|
||||
m_avsDataMap.remove(streamName);
|
||||
}
|
||||
else // update range
|
||||
{
|
||||
DEBUG_LOG() << "handleAvsData update range publish" << streamName;
|
||||
DEBUG_LOG(m_logger) << "handleAvsData update range publish" << streamName;
|
||||
|
||||
avsData.endTime = data.endTime;
|
||||
publishData(streamName);
|
||||
@@ -247,20 +246,20 @@ void WebSocketAvs::handleAvsData(const AvsData &data, const bool &lastRangeClose
|
||||
}
|
||||
|
||||
// new range ................................................................
|
||||
DEBUG_LOG() << "m_avsDataMap.insert(streamName";
|
||||
DEBUG_LOG(m_logger) << "m_avsDataMap.insert(streamName";
|
||||
m_avsDataMap.insert(streamName, data);
|
||||
AvsData &avsData = m_avsDataMap[streamName];
|
||||
if (!lastRangeClosed)
|
||||
{
|
||||
DEBUG_LOG() << "!lastRangeClosed";
|
||||
DEBUG_LOG(m_logger) << "!lastRangeClosed";
|
||||
avsData.endTime = -1;
|
||||
}
|
||||
else if (avsData.endTime == -1) // range is closed but end time is missing
|
||||
{
|
||||
DEBUG_LOG() << "avsData.endTime == -1";
|
||||
DEBUG_LOG(m_logger) << "avsData.endTime == -1";
|
||||
avsData.endTime = avsData.eventTime + 1000; // -> set artificial end time
|
||||
}
|
||||
DEBUG_LOG() << "publishData";
|
||||
DEBUG_LOG(m_logger) << "publishData";
|
||||
avsData.id = publishData(streamName);
|
||||
// if (lastRangeClosed)
|
||||
// m_avsDataMap.remove(streamName);
|
||||
@@ -268,7 +267,7 @@ void WebSocketAvs::handleAvsData(const AvsData &data, const bool &lastRangeClose
|
||||
// // new stream ...............................................................
|
||||
// if (it == m_avsDataMap.end())
|
||||
// {
|
||||
// DEBUG_LOG() << "received event on new stream: " << streamName;
|
||||
// DEBUG_LOG(m_logger) << "received event on new stream: " << streamName;
|
||||
// AvsData avsData = data;
|
||||
// if (!lastRangeClosed) // waiting for end time
|
||||
// avsData.endTime = -1;
|
||||
@@ -288,12 +287,12 @@ void WebSocketAvs::handleAvsData(const AvsData &data, const bool &lastRangeClose
|
||||
|
||||
// if (avsData.eventTime != data.eventTime) // same stream, different time -> new event received
|
||||
// {
|
||||
// DEBUG_LOG() << "new event on stream: " << streamName;
|
||||
// DEBUG_LOG(m_logger) << "new event on stream: " << streamName;
|
||||
|
||||
// // close old event ........................................................
|
||||
// if (avsData.endTime == -1) // last event on the same stream was not closed
|
||||
// {
|
||||
// WARNING_LOG() << "Missing end time for stream: " << streamName << ". Setting artificial end time.";
|
||||
// WARNING_LOG(m_logger) << "Missing end time for stream: " << streamName << ". Setting artificial end time.";
|
||||
// avsData.endTime = avsData.eventTime + 1000;
|
||||
// publishData(streamName);
|
||||
// }
|
||||
@@ -311,7 +310,7 @@ void WebSocketAvs::handleAvsData(const AvsData &data, const bool &lastRangeClose
|
||||
// else // same event
|
||||
// {
|
||||
// avsData.endTime = data.endTime;
|
||||
// DEBUG_LOG() << "received new end time: " << data.endTime << " for stream: " << streamName;
|
||||
// DEBUG_LOG(m_logger) << "received new end time: " << data.endTime << " for stream: " << streamName;
|
||||
// if (lastRangeClosed)
|
||||
// {
|
||||
// publishData(streamName);
|
||||
@@ -322,10 +321,10 @@ void WebSocketAvs::handleAvsData(const AvsData &data, const bool &lastRangeClose
|
||||
|
||||
int WebSocketAvs::publishData(const QString &streamName)
|
||||
{
|
||||
DEBUG_LOG() << "WebSocketAvs::publishData";
|
||||
DEBUG_LOG(m_logger) << "WebSocketAvs::publishData";
|
||||
if (streamName.isEmpty())
|
||||
{
|
||||
WARNING_LOG() << "Ignoring empty stream name";
|
||||
WARNING_LOG(m_logger) << "Ignoring empty stream name";
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -355,7 +354,7 @@ int WebSocketAvs::publishData(const QString &streamName)
|
||||
{
|
||||
if (isAlreadyInDb)
|
||||
{
|
||||
WARNING_LOG() << "Ignoring existing event at " << dbData.sampleTime;
|
||||
WARNING_LOG(m_logger) << "Ignoring existing event at " << dbData.sampleTime;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -364,17 +363,17 @@ int WebSocketAvs::publishData(const QString &streamName)
|
||||
if (dbData.id > 0)
|
||||
{
|
||||
if (!m_dbHandler->db()->update(dbData))
|
||||
ERROR_LOG() << "Error while updating dbData with id : " << data.id;
|
||||
ERROR_LOG(m_logger) << "Error while updating dbData with id : " << data.id;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_dbHandler->db()->insert(dbData))
|
||||
ERROR_LOG() << "Error while inserting avsData in db: streamName: " << data.streamName;
|
||||
ERROR_LOG(m_logger) << "Error while inserting avsData in db: streamName: " << data.streamName;
|
||||
ddsEvent.id(dbData.id);
|
||||
}
|
||||
|
||||
// publish data
|
||||
INFO_LOG() << "Publish data for stream: " << streamName << " and database id=" << dbData.id;
|
||||
INFO_LOG(m_logger) << "Publish data for stream: " << streamName << " and database id=" << dbData.id;
|
||||
m_eventServer->sendEvent(Database::toJson(dbData));
|
||||
m_ddsHandler->dts()->publish(ddsEvent);
|
||||
m_mainHandler->addEventIdToRemove(dbData.id); // take data from dds-bus after 10s, we need just to make sure the recording service got it
|
||||
@@ -385,7 +384,7 @@ int WebSocketAvs::publishData(const QString &streamName)
|
||||
|
||||
void WebSocketAvs::openWebSocket()
|
||||
{
|
||||
DEBUG_LOG() << "openWebSocket";
|
||||
DEBUG_LOG(m_logger) << "openWebSocket";
|
||||
closeWebSocket();
|
||||
m_wsSocket = new QWebSocket;
|
||||
connect(m_wsSocket, QOverload<QAbstractSocket::SocketError>::of(&QWebSocket::error),
|
||||
@@ -402,7 +401,7 @@ void WebSocketAvs::openWebSocket()
|
||||
|
||||
void WebSocketAvs::closeWebSocket()
|
||||
{
|
||||
DEBUG_LOG() << "closeWebSocket";
|
||||
DEBUG_LOG(m_logger) << "closeWebSocket";
|
||||
if (m_wsSocket)
|
||||
{
|
||||
m_wsSocket->disconnect(this);
|
||||
@@ -417,14 +416,14 @@ void WebSocketAvs::onWebSocketError(QAbstractSocket::SocketError error)
|
||||
{
|
||||
if (!m_wsSocket)
|
||||
return;
|
||||
WARNING_LOG() << "Error connecting to " << m_wsSocket->peerAddress().toString() << ": " << error;
|
||||
WARNING_LOG(m_logger) << "Error connecting to " << m_wsSocket->peerAddress().toString() << ": " << error;
|
||||
closeWebSocket();
|
||||
m_wsReconnectTimer->start(1000);
|
||||
}
|
||||
|
||||
void WebSocketAvs::onWebSocketConnected()
|
||||
{
|
||||
DEBUG_LOG() << "connected to via websockets";
|
||||
DEBUG_LOG(m_logger) << "connected to via websockets";
|
||||
m_wsReconnectTimer->stop();
|
||||
m_bWebSocketDisconnectedWarnedOnce = false;
|
||||
|
||||
@@ -433,11 +432,11 @@ void WebSocketAvs::onWebSocketConnected()
|
||||
|
||||
void WebSocketAvs::onWebSocketDisconnected()
|
||||
{
|
||||
DEBUG_LOG() << "WebSocketAvs::onWebSocketDisconnected()";
|
||||
DEBUG_LOG(m_logger) << "WebSocketAvs::onWebSocketDisconnected()";
|
||||
if (!m_bWebSocketDisconnectedWarnedOnce)
|
||||
{
|
||||
m_bWebSocketDisconnectedWarnedOnce = true;
|
||||
WARNING_LOG() << "Websocket to " << m_wsUrl << " closed - trying to reconnect in 1 sec";
|
||||
WARNING_LOG(m_logger) << "Websocket to " << m_wsUrl << " closed - trying to reconnect in 1 sec";
|
||||
}
|
||||
|
||||
closeWebSocket();
|
||||
@@ -446,7 +445,7 @@ void WebSocketAvs::onWebSocketDisconnected()
|
||||
|
||||
void WebSocketAvs::onSendExerciseId()
|
||||
{
|
||||
ERROR_LOG() << "Send exerciseId: ";
|
||||
ERROR_LOG(m_logger) << "Send exerciseId: ";
|
||||
|
||||
QJsonObject obj;
|
||||
|
||||
@@ -484,7 +483,7 @@ void WebSocketAvs::onCleanUpDbInternal()
|
||||
{
|
||||
ntpRangeSortLocal.insert(avItem.eventTime, avItem);
|
||||
}
|
||||
DEBUG_LOG() <<" Start with key: '" << stream << "' external = " << externalData.size() << " internal: " << ntpRangeSortLocal.size();
|
||||
DEBUG_LOG(m_logger) <<" Start with key: '" << stream << "' external = " << externalData.size() << " internal: " << ntpRangeSortLocal.size();
|
||||
QVector<qint64> itemsToRemoveFromInternal;
|
||||
QMap<qint64, AvsData> collection;
|
||||
QVector<AvsData> toAdd;
|
||||
@@ -512,7 +511,7 @@ void WebSocketAvs::onCleanUpDbInternal()
|
||||
if (m_ismDtc->getBuildingId(mountingPointId, mainStructureElementId))
|
||||
add.mainStructureElementId = mainStructureElementId;
|
||||
}
|
||||
DEBUG_LOG() << "need to add: " << add.eventType << " st: " << add.streamName << " mpi:" << add.mainStructureElementId;
|
||||
DEBUG_LOG(m_logger) << "need to add: " << add.eventType << " st: " << add.streamName << " mpi:" << add.mainStructureElementId;
|
||||
toAdd.append(add);
|
||||
collection.insert(add.eventTime, add);
|
||||
}
|
||||
@@ -595,11 +594,11 @@ void WebSocketAvs::onCleanUpDbInternal()
|
||||
dbDataAdd.id = 0;
|
||||
m_dbHandler->db()->insert(dbDataAdd);
|
||||
}
|
||||
DEBUG_LOG() << "DONE Sync wite remote DB "<< stream << " to Ignore" << toIgnore.size()<< " to Add" << toAdd.size() << " to Update:" << toUpdate.size()<< " to remove:" << itemsToRemoveFromInternal.size();
|
||||
DEBUG_LOG(m_logger) << "DONE Sync wite remote DB "<< stream << " to Ignore" << toIgnore.size()<< " to Add" << toAdd.size() << " to Update:" << toUpdate.size()<< " to remove:" << itemsToRemoveFromInternal.size();
|
||||
}
|
||||
m_cleanupTimer->start();
|
||||
m_lastUpdate = QDateTime::currentMSecsSinceEpoch()-2*60*1000;
|
||||
DEBUG_LOG() << "DONE Sync wite remote DB next check starts at: " << QDateTime::fromMSecsSinceEpoch(m_lastUpdate).toString();
|
||||
DEBUG_LOG(m_logger) << "DONE Sync wite remote DB next check starts at: " << QDateTime::fromMSecsSinceEpoch(m_lastUpdate).toString();
|
||||
}
|
||||
|
||||
QMap<QString, QVector<AvsData> > WebSocketAvs::getAllAvsData()
|
||||
@@ -616,11 +615,11 @@ QMap<QString, QVector<AvsData> > WebSocketAvs::getAllAvsData()
|
||||
QLatin1String(" WHERE context_id = :context"));
|
||||
if (m_lastUpdate > 0)
|
||||
stmt += QLatin1String(" and time_start_msec > ") + QString::number(m_lastUpdate);
|
||||
DEBUG_LOG() << "START Sync read remote DB at " << QDateTime::fromMSecsSinceEpoch(m_lastUpdate).toString();
|
||||
DEBUG_LOG(m_logger) << "START Sync read remote DB at " << QDateTime::fromMSecsSinceEpoch(m_lastUpdate).toString();
|
||||
NSqlQuery q(m_dbHandler->db()->database());
|
||||
if (!q.prepare(stmt))
|
||||
{
|
||||
WARNING_LOG() << "Could not prepare statement" << stmt << q.lastError().text() << q.lastError().databaseText();
|
||||
WARNING_LOG(m_logger) << "Could not prepare statement" << stmt << q.lastError().text() << q.lastError().databaseText();
|
||||
return retu;
|
||||
} // if
|
||||
q.setForwardOnly(true);
|
||||
@@ -632,7 +631,7 @@ QMap<QString, QVector<AvsData> > WebSocketAvs::getAllAvsData()
|
||||
|
||||
if (!q.exec())
|
||||
{
|
||||
DEBUG_LOG() << "Could not execute" << stmt << q.lastError().text() << q.lastError().databaseText();
|
||||
DEBUG_LOG(m_logger) << "Could not execute" << stmt << q.lastError().text() << q.lastError().databaseText();
|
||||
return retu;
|
||||
} // if
|
||||
|
||||
@@ -678,7 +677,7 @@ QMap<QString, QVector<AvsData>> WebSocketAvs::getAllInternalDbData()
|
||||
|
||||
// m_dbHandler->db()->select(dataVec);
|
||||
//qCritical() << "END select reading internal db ";
|
||||
DEBUG_LOG() << "START Sync read local DB at " << QDateTime::fromMSecsSinceEpoch(m_lastUpdate).toString();
|
||||
DEBUG_LOG(m_logger) << "START Sync read local DB at " << QDateTime::fromMSecsSinceEpoch(m_lastUpdate).toString();
|
||||
int j = 0;
|
||||
for (const auto &dataI : std::as_const(dataVec))
|
||||
{
|
||||
@@ -687,7 +686,7 @@ QMap<QString, QVector<AvsData>> WebSocketAvs::getAllInternalDbData()
|
||||
QJsonDocument job = QJsonDocument::fromJson(dataI.properties.toUtf8());
|
||||
if(!job.isObject())
|
||||
{
|
||||
WARNING_LOG() << "ERROR Parsing Json";
|
||||
WARNING_LOG(m_logger) << "ERROR Parsing Json";
|
||||
}
|
||||
|
||||
QJsonObject obj = job.object();
|
||||
|
||||
@@ -86,11 +86,13 @@ private Q_SLOTS:
|
||||
QMap<QString, QVector<AvsData>> getAllInternalDbData();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
AvsData jsonObjectToAvsData(const QJsonObject &obj);
|
||||
Database::EemEvent avsDataToEemEvent(const AvsData &data);
|
||||
ExerciseEventManagement::Event avsDataToEvent(const AvsData &data);
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler; ///< Pointer to DDS handler
|
||||
std::shared_ptr<DbHandler> m_dbHandler;
|
||||
std::shared_ptr<WebSocketEventServer> m_eventServer;
|
||||
|
||||
+13
-14
@@ -22,12 +22,11 @@
|
||||
|
||||
namespace ExerciseEventManagement
|
||||
{
|
||||
WebSocketEventServer::WebSocketEventServer(const QSqlDatabase &db, QObject *parent)
|
||||
: QObject(parent)
|
||||
WebSocketEventServer::WebSocketEventServer(const QSqlDatabase &db, QObject *parent) : QObject(parent)
|
||||
, m_wsServer(nullptr)
|
||||
, m_cleanupTimer(new QTimer(this))
|
||||
, m_db(db)
|
||||
{
|
||||
, m_db(db),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
m_cleanupTimer->setInterval(10000); // clear every 10s
|
||||
connect(m_cleanupTimer, &QTimer::timeout, this, &WebSocketEventServer::onCleanupLiveHistory);
|
||||
}
|
||||
@@ -94,7 +93,7 @@ void WebSocketEventServer::onNewConnection()
|
||||
QWebSocket *ws = m_wsServer->nextPendingConnection();
|
||||
if (!ws)
|
||||
return;
|
||||
DEBUG_LOG() << "New incoming connection from "
|
||||
DEBUG_LOG(m_logger) << "New incoming connection from "
|
||||
<< ws->peerAddress().toString() << ":"
|
||||
<< ws->peerPort() << ", "
|
||||
<< ws->requestUrl().toString();
|
||||
@@ -115,7 +114,7 @@ void WebSocketEventServer::onNewConnection()
|
||||
historyDataRequested(m_db, ws, requestUrl);
|
||||
else
|
||||
{
|
||||
WARNING_LOG() << "Unknown request path: '" << requestPath << "' - closing";
|
||||
WARNING_LOG(m_logger) << "Unknown request path: '" << requestPath << "' - closing";
|
||||
ws->close();
|
||||
ws->deleteLater();
|
||||
}
|
||||
@@ -126,7 +125,7 @@ void WebSocketEventServer::onSocketDisconnected()
|
||||
QWebSocket *ws = qobject_cast<QWebSocket *>(sender());
|
||||
if (!ws)
|
||||
return;
|
||||
DEBUG_LOG() << "Disconnected from "
|
||||
DEBUG_LOG(m_logger) << "Disconnected from "
|
||||
<< ws->peerAddress().toString() << ":"
|
||||
<< ws->peerPort() << ", "
|
||||
<< ws->requestUrl().toString();
|
||||
@@ -150,7 +149,7 @@ void WebSocketEventServer::historyDataRequested(const QSqlDatabase &db, QWebSock
|
||||
const qint64 to = query.queryItemValue(QStringLiteral("to")).toLongLong();
|
||||
if (requestId == 0 || from <= 0 || to <= 0 || from > to)
|
||||
{
|
||||
WARNING_LOG() << "Unknown request: '" << requestUrl.toString() << "' - closing, "
|
||||
WARNING_LOG(m_logger) << "Unknown request: '" << requestUrl.toString() << "' - closing, "
|
||||
<< requestId << ", " << from << ", to " << to;
|
||||
ws->sendTextMessage(QStringLiteral("{}"));
|
||||
ws->close();
|
||||
@@ -184,7 +183,7 @@ void WebSocketEventServer::historyDataRequested(const QSqlDatabase &db, QWebSock
|
||||
if (query.hasQueryItem(QStringLiteral("filter")))
|
||||
{
|
||||
const QString filterString = query.queryItemValue(QStringLiteral("filter"));
|
||||
DEBUG_LOG() << "filter string: " << filterString;
|
||||
DEBUG_LOG(m_logger) << "filter string: " << filterString;
|
||||
const QJsonObject obj(QJsonDocument::fromJson(filterString.toUtf8()).object());
|
||||
if (obj.keys().size() == 1)
|
||||
{
|
||||
@@ -210,16 +209,16 @@ void WebSocketEventServer::historyDataRequested(const QSqlDatabase &db, QWebSock
|
||||
if (query.hasQueryItem(QStringLiteral("limit")))
|
||||
{
|
||||
const QString limitString = query.queryItemValue(QStringLiteral("limit"));
|
||||
DEBUG_LOG() << "limiting query to " << limitString << " events";
|
||||
DEBUG_LOG(m_logger) << "limiting query to " << limitString << " events";
|
||||
stmt += QStringLiteral(" LIMIT ") + limitString;
|
||||
}
|
||||
|
||||
DEBUG_LOG() << "stmt: " << stmt;
|
||||
DEBUG_LOG(m_logger) << "stmt: " << stmt;
|
||||
|
||||
NSqlQuery q(db);
|
||||
if (!q.exec(stmt))
|
||||
{
|
||||
ERROR_LOG() << "Error while selecting event-data: " << stmt << ", " << q.lastError().databaseText();
|
||||
ERROR_LOG(m_logger) << "Error while selecting event-data: " << stmt << ", " << q.lastError().databaseText();
|
||||
ws->sendTextMessage(QStringLiteral("{}"));
|
||||
ws->close();
|
||||
ws->deleteLater();
|
||||
@@ -246,7 +245,7 @@ void WebSocketEventServer::historyDataRequested(const QSqlDatabase &db, QWebSock
|
||||
events.append(Database::toJson(data));
|
||||
if (events.size() > 100)
|
||||
{
|
||||
INFO_LOG() << "Sending an answer with " << events.size() << " events for query " << stmt;
|
||||
INFO_LOG(m_logger) << "Sending an answer with " << events.size() << " events for query " << stmt;
|
||||
const QJsonDocument doc(events);
|
||||
ws->sendTextMessage(QString::fromUtf8(doc.toJson(QJsonDocument::Compact)));
|
||||
events = QJsonArray();
|
||||
@@ -254,7 +253,7 @@ void WebSocketEventServer::historyDataRequested(const QSqlDatabase &db, QWebSock
|
||||
}
|
||||
if (!events.isEmpty())
|
||||
{
|
||||
INFO_LOG() << "Sending an answer with " << events.size() << " events for query " << stmt;
|
||||
INFO_LOG(m_logger) << "Sending an answer with " << events.size() << " events for query " << stmt;
|
||||
const QJsonDocument doc(events);
|
||||
ws->sendTextMessage(QString::fromUtf8(doc.toJson(QJsonDocument::Compact)));
|
||||
}
|
||||
|
||||
+1
@@ -35,6 +35,7 @@ public:
|
||||
|
||||
void sendEvent(const QJsonObject &obj);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void onNewConnection();
|
||||
void onSocketDisconnected();
|
||||
void onCleanupLiveHistory();
|
||||
|
||||
Reference in new issue
Block a user