/*! * * 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 CloudConnectController.h * \author (original) Stephen Quong * \date (original) 24-May-2026 * */ #pragma once #include #include #include #include #include #include #include #include #include #include "CloudConnectClient.h" #include "CloudConnectFrame.h" #include "CanInterface.h" #include "CanMessage.h" #include "CloudConnectServer.h" #include "MessageDispatcher.h" using namespace Can; /*! * \brief CloudConnect controller */ class CloudConnectController : public QObject { Q_OBJECT public: explicit CloudConnectController(const QString &configPath, const QString &msgHandlingPath, QObject *parent = nullptr); ~CloudConnectController(); void connectToAgent(); bool listenForApp(); 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: /*! * \brief Send message handling policy for a CAN message. */ enum class MsgAction { Drop, SendAlways, SendDelta, }; /*! * \brief Message handling entry loaded from message handling INI. */ struct MsgHandling { MsgAction action = MsgAction::Drop; CloudConnectFrame::MsgId topic = CloudConnectFrame::MsgId::ClinicalData; }; void loadMsgHandling(const QString &msgHandlingPath); QSettings _settings; Can::CanInterface _canInterface; QThread _canThread; Can::MessageDispatcher _dispatcher; QMap> _msgCache; QHash _msgHandling; CloudConnectClient _agentInterface; QThread _agentThread; CloudConnectServer _appServer; quint16 _txSequence = 0; private Q_SLOTS: void onFrameReceive(const QCanBusFrame frame); void onMessageReceive(const Can::Message &msg); void onAgentDisconnect(); };