Index: LeahiRt/LeahiRtController.h =================================================================== diff -u -r401d8ad0e5c070f9c6ecb41ed3ba25ba3d1c69a0 -r808df723cf9d1b0097796815e5229abfa18f2d8f --- LeahiRt/LeahiRtController.h (.../LeahiRtController.h) (revision 401d8ad0e5c070f9c6ecb41ed3ba25ba3d1c69a0) +++ LeahiRt/LeahiRtController.h (.../LeahiRtController.h) (revision 808df723cf9d1b0097796815e5229abfa18f2d8f) @@ -1,3 +1,15 @@ +/*! + * + * Copyright (c) 2024-2026 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file LeahiRtController.h + * \author (original) Stephen Quong + * \date (original) 24-May-2026 + * + */ #pragma once #include @@ -12,10 +24,17 @@ #include "AgentMessage.h" #include "CanInterface.h" #include "CanMessage.h" -#include "MessageBuilder.h" +#include "MessageDispatcher.h" using namespace Can; +/*! + * \brief Real-time CAN to cloud controller + * \details Owns the CAN→cloud pipeline. CanInterface receives frames, the + * MessageDispatcher reassembles them per CAN id, and completed messages + * are converted to protobuf and forwarded to the Connectivity Agent + * over the AgentInterface. + */ class LeahiRtController : public QObject { Q_OBJECT @@ -24,21 +43,44 @@ explicit LeahiRtController(const QString &configPath, QObject *parent = nullptr); ~LeahiRtController(); + /*! + * \brief connectToAgent + * \details Initialises the AgentInterface using the socket path and reconnect + * interval from the settings file. + */ void connectToAgent(); private: QSettings _settings; Can::CanInterface _canInterface; QThread _canThread; - Can::MessageBuilder _msgBuilder; - QMap _messages; + Can::MessageDispatcher _dispatcher; + QMap _msgCache; AgentInterface _agentInterface; QThread _agentThread; quint16 _txSequence = 0; Q_SIGNALS: + /*! + * \brief didCanMessageReceive + * \details Emitted when a complete CAN message has been reassembled. + * \param timestamp - time the message was completed + * \param msg - the completed message + */ void didCanMessageReceive(const QDateTime timestamp, const Can::Message msg); private Q_SLOTS: + /*! + * \brief onFrameReceive + * \details Unpacks a CAN frame and feeds it to the dispatcher for reassembly. + * \param frame - the received CAN frame + */ void onFrameReceive(const QCanBusFrame frame); + + /*! + * \brief onMessageReceive + * \details Converts a completed message to protobuf and forwards it to the Agent. + * \param msg - the reassembled message + */ + void onMessageReceive(const Can::Message &msg); };