Index: LeahiRt/LeahiRtController.cpp =================================================================== diff -u -r64243101dff61b5c1a40b96ef33080236999acf6 -ra5781739bcbe58c754aff8861561495624bc5b67 --- LeahiRt/LeahiRtController.cpp (.../LeahiRtController.cpp) (revision 64243101dff61b5c1a40b96ef33080236999acf6) +++ LeahiRt/LeahiRtController.cpp (.../LeahiRtController.cpp) (revision a5781739bcbe58c754aff8861561495624bc5b67) @@ -29,14 +29,15 @@ _settings(configPath, QSettings::IniFormat), _canInterface(), _canThread(this), - _dispatcher(this) + _dispatcher(this), + _appServer(this) { loadMsgHandling(msgHandlingPath); _canInterface.init(_canThread); connect(&_canInterface, &Can::CanInterface::didFrameReceive, this, &LeahiRtController::onFrameReceive); connect(&_dispatcher, &Can::MessageDispatcher::didActionReceive, this, &LeahiRtController::onMessageReceive); - connect(&_agentInterface, &AgentInterface::didDisconnect, this, &LeahiRtController::onAgentDisconnect); + connect(&_agentInterface, &RtInterface::didDisconnect, this, &LeahiRtController::onAgentDisconnect); } /*! @@ -54,7 +55,7 @@ /*! * \brief LeahiRtController::connectToAgent - * \details Initialises the AgentInterface using the socket path and reconnect + * \details Initialises the RtInterface using the socket path and reconnect * interval from the settings file. */ void LeahiRtController::connectToAgent() @@ -65,6 +66,18 @@ } /*! + * \brief LeahiRtController::listenForApp + * \details Starts the local-socket server that the Luis application connects to, + * using the app socket path from the settings file. + * \return true if the server bound successfully, false otherwise. + */ +bool LeahiRtController::listenForApp() +{ + const QString appSocketPath = _settings.value("Socket/AppSocketName", "/tmp/leahi_app.sock").toString(); + return _appServer.listen(appSocketPath); +} + +/*! * \brief LeahiRtController::loadMsgHandling * \details Parses message handling INI and populates _msgHandling. * \note Unknown msg action values default to Drop; unknown topic strings default to ClinicalData. @@ -77,15 +90,15 @@ { QStringLiteral("send_delta"), MsgAction::SendDelta }, { QStringLiteral("drop"), MsgAction::Drop }, }; - static const QHash topicMap = { - { QStringLiteral("ClinicalData"), AgentMessage::MsgId::ClinicalData }, - { QStringLiteral("Diagnostic"), AgentMessage::MsgId::Diagnostic }, - { QStringLiteral("Ack"), AgentMessage::MsgId::Ack }, - { QStringLiteral("Alarms"), AgentMessage::MsgId::Alarms }, - { QStringLiteral("Audit"), AgentMessage::MsgId::Audit }, - { QStringLiteral("DeviceLogFile"), AgentMessage::MsgId::DeviceLogFile }, - { QStringLiteral("TreatmentLogFile"), AgentMessage::MsgId::TreatmentLogFile }, - { QStringLiteral("CloudSyncLogFile"), AgentMessage::MsgId::CloudSyncLogFile }, + static const QHash topicMap = { + { QStringLiteral("ClinicalData"), RtMessage::MsgId::ClinicalData }, + { QStringLiteral("Diagnostic"), RtMessage::MsgId::Diagnostic }, + { QStringLiteral("Ack"), RtMessage::MsgId::Ack }, + { QStringLiteral("Alarms"), RtMessage::MsgId::Alarms }, + { QStringLiteral("Audit"), RtMessage::MsgId::Audit }, + { QStringLiteral("DeviceLogFile"), RtMessage::MsgId::DeviceLogFile }, + { QStringLiteral("TreatmentLogFile"), RtMessage::MsgId::TreatmentLogFile }, + { QStringLiteral("CloudSyncLogFile"), RtMessage::MsgId::CloudSyncLogFile }, }; QSettings msgHandlingIni(msgHandlingPath, QSettings::IniFormat); @@ -109,7 +122,7 @@ MsgHandling msgHandling; msgHandling.action = actionMap.value(actionStr, MsgAction::Drop); - msgHandling.topic = topicMap.value(topicStr, AgentMessage::MsgId::ClinicalData); + msgHandling.topic = topicMap.value(topicStr, RtMessage::MsgId::ClinicalData); if (!actionMap.contains(actionStr)) { qWarning().noquote() << QString("LeahiRt: unknown message action \"%1\" for msgId=0x%2 — defaulting to drop") @@ -137,7 +150,7 @@ * \brief LeahiRtController::onMessageReceive * \details Applies the message handling policy from LeahiRtMsgHandling.ini: drops, * forwards unconditionally, or forwards only on payload change. Uses the - * section's topic to set the AgentMessage frame msg_id. + * section's topic to set the RtMessage frame msg_id. * \param msg - the reassembled message */ void LeahiRtController::onMessageReceive(const Can::Message &msg) @@ -167,7 +180,9 @@ QDateTime::currentDateTime(), QStringLiteral("test_device"), msg); - _agentInterface.send(it->topic, _txSequence++, payload); + const quint16 sequence = _txSequence++; + _agentInterface.send(it->topic, sequence, payload); + _appServer.send(it->topic, sequence, payload); received = true; cachedMsg = msg; }