Index: LeahiRt/LeahiRtController.h =================================================================== diff -u -r088513e6ea7bad08b4fb7862127c726eabad18fd -rccc40a7e73e9ee5d2a5fb56f3f2bea4f8294900f --- LeahiRt/LeahiRtController.h (.../LeahiRtController.h) (revision 088513e6ea7bad08b4fb7862127c726eabad18fd) +++ LeahiRt/LeahiRtController.h (.../LeahiRtController.h) (revision ccc40a7e73e9ee5d2a5fb56f3f2bea4f8294900f) @@ -14,11 +14,13 @@ #include #include +#include #include #include #include #include #include +#include #include "AgentInterface.h" #include "AgentMessage.h" @@ -40,7 +42,7 @@ Q_OBJECT public: - explicit LeahiRtController(const QString &configPath, QObject *parent = nullptr); + explicit LeahiRtController(const QString &configPath, const QString &msgHandlingPath, QObject *parent = nullptr); ~LeahiRtController(); /*! @@ -51,11 +53,31 @@ void connectToAgent(); private: + /*! + * \brief Send message handling policy for a CAN message. + */ + enum class MsgAction { + Drop, ///< Discard the message; do not forward to the Agent. + SendAlways, ///< Forward unconditionally. + SendDelta, ///< Forward only when the payload has changed since the last send. + }; + + /*! + * \brief Message handling entry loaded from message handling INI. + */ + struct MsgHandling { + MsgAction action = MsgAction::Drop; + AgentMessage::MsgId topic = AgentMessage::MsgId::ClinicalData; + }; + + void loadMsgHandling(const QString &msgHandlingPath); + QSettings _settings; Can::CanInterface _canInterface; QThread _canThread; Can::MessageDispatcher _dispatcher; - QMap _msgCache; + QMap> _msgCache; + QHash _msgHandling; AgentInterface _agentInterface; QThread _agentThread; quint16 _txSequence = 0; @@ -79,8 +101,16 @@ /*! * \brief onMessageReceive - * \details Converts a completed message to protobuf and forwards it to the Agent. + * \details Applies the message handling policy: drops, forwards unconditionally, + * or forwards only on payload change, using the INI-configured topic. * \param msg - the reassembled message */ void onMessageReceive(const Can::Message &msg); + + /*! + * \brief onAgentDisconnect + * \details Resets the received flag on all cache entries so that send_delta + * messages are treated as new on the next connection. + */ + void onAgentDisconnect(); };