/*! * * Copyright (c) 2019-2020 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 ApplicationController.h * \author (last) Peter Lucia * \date (last) 15-Oct-2020 * \author (original) Behrouz NematiPour * \date (original) 26-Aug-2020 * */ #pragma once // Qt #include // Project #include "main.h" // Doxygen : don't remove #include "MModel.h" #include "GuiGlobals.h" #include "ApplicationPost.h" #include "MessageGlobals.h" // define #define _ApplicationController ApplicationController::I() // forward declarations class tst_initializations; // namespace using namespace Gui; using namespace Can; /*! * \brief The ApplicationController class * \details Singleton class which is the main gateway of all signal/slots. * This class is the main 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 main state machine will decide on the state of the device what needs to be done. * \note States are like [Idle, Run on Battery, Fault, FW connection lost] and such */ class ApplicationController : public QObject { Q_OBJECT // Singleton SINGLETON(ApplicationController) // friends friend class ::tst_initializations; ApplicationPost *_applicationPost = nullptr; QThread *_thread = nullptr; bool _init = false; public slots: bool init(); bool init(QThread &vThread); private slots: void quit(); private: void initConnections(); void initThread(QThread &vThread); void quitThread(); void keepAlive(); void createFakeSequencedLongMessage (QVariantList &vData, const int vFakeDataLen); void createFakeSeqAtBeginLongMessage(QVariantList &vData, const int vFakeDataLen); void saveNewTreatment(QJsonObject obj); private slots: // Should be private for thread safety and is connected internally. void onActionReceive (GuiActionType vAction, const QVariantList &vData); // UI <= HD/DG void onActionTransmit(GuiActionType vAction, const QVariantList &vData); // UI => HD/DG void onMainTimerTimeout(); void onUSBDriveMount (); void onUSBDriveUmount(); void onUSBDriveRemove(); void onSDCardStateChange(bool vIsReady, bool vIsReadOnly); void onExportLog (); void onExport (); void onFailedTransmit(Sequence seq); signals: void didActionReceive (GuiActionType vAction, const QVariantList &vData); // UI <= HD/DG void didActionTransmit(GuiActionType vAction, const QVariantList &vData); // UI => HD/DG void didFailedTransmit(Sequence seq); void didUSBDriveMount (); void didUSBDriveUmount(); void didUSBDriveRemove(); void didSDCardStateChange(bool vIsReady, bool vIsReadOnly); void didExport (); // ---- Signal/Slots ADJUST_TRANSMT_MODEL_BRIDGE_DEFINITIONS ACTION_RECEIVE_MODEL_BRIDGE_DEFINITIONS };