#pragma once #include #include #include "main.h" #include "MessageGlobals.h" #include "drydemoxmlstates.h" #define _StateController StateController::I() // TODO check illegal state transition class StateController : public QObject { Q_OBJECT SINGLETON(StateController) public: void init(); // TODO move these in slots void quit(); public slots: void doStateControllerUnhandledMsgReceived(const QVariantList &msg); protected: void timerEvent(QTimerEvent *) override; private: #define DEFAULT_TIMEOUT_S 10 #define TRANSITION_EVENT_INDEX 0 #define RESP_MSG_START_INDEX 3 #define IS_TIMER_INDEX 0 #define IS_WAIT_NEEDED_INDEX 1 #define NEXT_AUTO_TRANSITION_INDEX 2 #define COUNT_DOWN_TIMER_INDEX 6 #define UI_MSG_BB_PAYLOAD_ID 0x63 #define QOBJECT_TIMER_TIMEOUT_MS 1000 #define PROGRESS_TIME_BC_INTERVAL_MS 1000 #define NUM_OF_COUNTS_TIMER_BC_EMIT (PROGRESS_TIME_BC_INTERVAL_MS / QOBJECT_TIMER_TIMEOUT_MS) #define NUM_OF_COUNTS_TO_BC_MSG 3 enum User_Command_ID { CMD_NONE = -1, CMD_TX_PARAMS = 0 , CMD_WATER_SAMPLE, CMD_CONSUMABLES, CMD_DISPOSABLES, CMD_SYSTEM_PRIME, CMD_BP_HR, CMD_ULTRAFILTRATION, CMD_CONNECTION, CMD_START_TX, CMD_END_TX, CMD_DISINFECTION, }; QHash > _dryDemoCmds; quint16 _index; quint16 _broadcastMsgCount; quint16 _timerBroadcastCount; User_Command_ID _dryDemoCurrentCmd; drydemoXMLstates _dryDemo; void initMessagesHashTable(); void transitionApplicationToStandBy(); void resetVariables(); void onIdleStateChange(bool active); void onTreatmentParamsStateChange(bool active); void onWaterSampleStateChange(bool active); void onConsumablesStateChange(bool active); void onDisposablesStateChange(bool active); void onSystemPrimeStateChange(bool active); void onBPHRStateChange(bool active); void onUltrafiltrationStateChange(bool active); void onConnectionStateChange(bool active); void onStartTreatmentStateChange(bool active); void onEndTreatmentStateChange(bool active); void onDisinfectStateChange(bool active); };