/*! * * Copyright (c) 2020-2024 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 GuiController.h * \author (last) Behrouz NematiPour * \date (last) 10-Sep-2023 * \author (original) Behrouz NematiPour * \date (original) 26-Aug-2020 * */ #pragma once // Qt #include // Project #include "main.h" // Doxygen : do not remove //#include "MModel.h" #include "MModelAutoGen.h" #include "GuiGlobalsAutoGen.h" #include "MessageGlobalsAutoGen.h" #include "DeviceGlobals.h" // define #define _GuiController GuiController::I() using namespace Can; // namespace namespace Gui { /*! * \brief The GuiController class * \details Singleton class which is the main gateway of all signal/slots through GUI. * This class is the Gui gate keeper for decisions and will decide if a message should pass through the other observers. * Currently (08/30/2020) is a bridge and will pass all the messages. * Later with implementation/help of the Gui state machine will decide on the state of the device what needs to be done. * This class contains the state of the GUI and it is the first interface between the GUI and the business logic by interfacing with ApplicationController. * Any Action that happens by the user on the screens needs to be passed to this class, which collaborates with the ApplicationController to validate the action * and decide on what needs to be done regarding re data transmitting/receiving and the current state of the UI Software application. * Messages to be transmitted from UI Application perspective to the entities on the CANBus will be passed by onActionTransmit * and will be decided to be passed down to by emitting the didActionTransmit() signal or needs to be handled by handleTransmit() * \note States are like [wait for user , user attention required , Time outs , ... ] */ class GuiController : public QObject { Q_OBJECT // singleton SINGLETON(GuiController) QThread *_thread = nullptr; bool _init = false; public slots: bool init(); bool init(QThread &vThread); void quit(); private: void initConnections(); void initThread(QThread &vThread); void quitThread(); bool handleTransmit(GuiActionType vAction, const QVariantList &vData); public slots: void doActionTransmit(GuiActionType vAction, const QVariantList &vData); // UI => TD/DD void doUSBDriveUmount (); // UI => OS void doExportLog (const GuiStringIndexMap &vExportList); // UI => OS void doExportService (const GuiStringIndexMap &vExportList); // UI => OS void doExportTreatment (const GuiStringIndexMap &vExportList); // UI => OS void doQuitApplication (); void doTreatmentRangesDone(bool vPass); private slots: // Should be private for thread safety and is connected internally. void onActionReceive (GuiActionType vAction, const QVariantList &vData); // UI <= HD/DG void onUSBDriveMount (); // OS => UI void onUSBDriveRemove(); // OS => UI void onUSBSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent); void onSDCardStateChange(bool vIsReady, bool vIsReadOnly); // OS => UI void onSDCardSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent); void onSDCardSpaceTooLow(quint8 vAvailablePercent); // OS => UI void onExport (); // OS => UI void onExportStat (quint32 vIndex, const QString &vFileName, quint8 vPercent); void onFailedTransmit(Sequence seq); void onPOSTPass (bool vPass); signals: void didActionReceive (GuiActionType vAction, const QVariantList &vData); // UI <= HD/DD void didActionTransmit(GuiActionType vAction, const QVariantList &vData); // UI => TD/DD void didUSBDriveMount (); void didUSBDriveUmount(); void didUSBDriveRemove(); void didUSBSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent); void didSDCardStateChange(bool vIsReady, bool vIsReadOnly); void didSDCardSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent); void didSDCardSpaceTooLow(quint8 vAvailablePercent); void didExportLog (const GuiStringIndexMap &vExportList); void didExportService (const GuiStringIndexMap &vExportList); void didExportTreatment (const GuiStringIndexMap &vExportList); void didExport (); void didExportStat (quint32 vIndex, const QString &vFileName, quint8 vPercent); void didPOSTPass (bool vPass); void didQuitApplication (); void didTreatmentRangesDone(bool vPass); // Device controller signal slots connection DEVICE_GUI_BRIDGE_DEFINITION_LIST // ---- Signal/Slots ADJUST_TRANSMT_MODEL_BRIDGE_DEFINITIONS_PUBLIC ACTION_RECEIVE_MODEL_BRIDGE_DEFINITIONS //ACTION_RECEIVE_PRIVATE_SLOT(UIPostFinalResultHDRequestData) }; }