#include "StateController.h" #include "ApplicationController.h" #include "types.h" StateController::StateController(QObject *parent) : QObject(parent) {} void StateController::init() { startTimer(1000); connect(&_ApplicationController, SIGNAL(didUnhandledMsgAppController(const QVariantList &)), this , SLOT(doStateControllerUnhandledMsgReceived(const QVariantList &))); _dryDemo.connectToState("Idle" , this, &StateController::onIdleStateChange ); _dryDemo.connectToState("Tx_Params" , this, &StateController::onTreatmentParamsStateChange ); _dryDemo.connectToState("Water_Sample" , this, &StateController::onWaterSampleStateChange ); _dryDemo.connectToState("Consumables" , this, &StateController::onConsumablesStateChange ); _dryDemo.connectToState("Disposables" , this, &StateController::onDisposablesStateChange ); _dryDemo.connectToState("System_Prime" , this, &StateController::onSystemPrimeStateChange ); _dryDemo.connectToState("BP_HR" , this, &StateController::onBPHRStateChange ); _dryDemo.connectToState("Ultrafiltraion" , this, &StateController::onUltrafiltrationStateChange ); _dryDemo.connectToState("Connection" , this, &StateController::onConnectionStateChange ); _dryDemo.connectToState("Start_Tx" , this, &StateController::onStartTreatmentStateChange ); _dryDemo.connectToState("End_Tx" , this, &StateController::onEndTreatmentStateChange ); _dryDemo.connectToState("Disinfect" , this, &StateController::onDisinfectStateChange ); _index = 0; _broadcastMsgCount = 0; _dryDemoCurrentCmd = CMD_NONE; initMessagesHashTable(); // Todo move this? } void StateController::quit() { // TODo fill up } void StateController::doStateControllerUnhandledMsgReceived(const QVariantList &msg) { if (!_dryDemo.isRunning()) { _dryDemo.start(); // TODO why cannot start the state machine somewhere else? } MessageID receivedMsgID = static_cast(msg[0].toUInt()); bool isCmdValid = false; QVariantList msgBack; switch(receivedMsgID) { case ID_UI_RQST_TX: isCmdValid = true; _dryDemoCurrentCmd = CMD_TX_PARAMS; break; case ID_UI_TX_PARAMS_RQST: msgBack.append(static_cast(ID_HD_NEW_PARAMS_RESP)); msgBack.append(Can_Id::eChlid_HD_UI); msgBack.append(1); msgBack.append(0); msgBack.append(275); msgBack.append(250); msgBack.append(60); msgBack.append(0); msgBack.append(100); msgBack.append(0); msgBack.append(0); msgBack.append(0); msgBack.append(0); msgBack.append(0); msgBack.append(250); msgBack.append(120); msgBack.append(100); msgBack.append(20); msgBack.append(0.000); msgBack.append(0.000); msgBack.append(36.00); emit _ApplicationController.didActionTransmit(msgBack); break; case ID_UI_CONFIRM_RESP: { int IDIndex = 0; Types::U32 IDParam; GetValue(msg[1].toByteArray(), IDIndex, IDParam); //qDebug() << "Msg Case" << receivedMsgID << msg[1].toByteArray() << IDParam.value; if (IDParam.value == 0x63) { int cmdIndex = 4; Types::U32 cmdParam; GetValue(msg[1].toByteArray(), cmdIndex, cmdParam); _dryDemoCurrentCmd = static_cast(cmdParam.value); isCmdValid = true; qDebug() << "Msg Case 2" << receivedMsgID << cmdParam.value << _dryDemoCurrentCmd <(ID_HD_UI_CONFIRM_RQST)); closeMsg.append(Can_Id::eChlid_HD_UI); closeMsg.append(0x63); closeMsg.append(1); closeMsg.append(0); emit _ApplicationController.didActionTransmit(closeMsg); } } break; case ID_UI_CONFIRM_TX_PARAMS: isCmdValid = true; _dryDemoCurrentCmd = CMD_WATER_SAMPLE; break; case ID_SAMPLE_WATER_RESULT: { isCmdValid = true; int resultIndex = 0; Types::U32 resultParam; GetValue(msg[1].toByteArray(), resultIndex, resultParam); qDebug() << "Sample reulsts" << resultParam.value; if ( resultParam.value == 1 ) { _dryDemoCurrentCmd = CMD_CONSUMABLES; } else { transitionApplicationToStandBy(); } } break; case ID_UI_CONSUMABLES_INSTALL: _dryDemoCmds[_dryDemoCurrentCmd][_index][IS_WAIT_NEEDED_INDEX] = false; break; case ID_UI_INTALLATION_CONFIRM: _dryDemoCmds[_dryDemoCurrentCmd][_index][IS_WAIT_NEEDED_INDEX] = false; _dryDemoCurrentCmd = CMD_SYSTEM_PRIME; isCmdValid = true; break; case ID_UI_PATIENT_CONNECTION_RQST: _dryDemoCmds[_dryDemoCurrentCmd][_index][IS_WAIT_NEEDED_INDEX] = false; _dryDemoCurrentCmd = CMD_BP_HR; isCmdValid = true; break; case ID_UI_SET_UF_VOLUME_RQST: { QVariantList msg; msg.append(static_cast(ID_HD_SET_UF_VOLUME_RESP)); msg.append(Can_Id::eChlid_HD_UI); msg.append(1); msg.append(0); msg.append(1.8); emit _ApplicationController.didActionTransmit(msg); _dryDemoCurrentCmd = CMD_CONNECTION; isCmdValid = true; } break; case ID_UI_PATIENT_CONNECTION_CONF_RQST: { QVariantList msg; msg.append(static_cast(ID_HD_PATINET_CONNECTION_CONF_RESP)); msg.append(Can_Id::eChlid_HD_UI); msg.append(1); msg.append(0); emit _ApplicationController.didActionTransmit(msg); _dryDemoCurrentCmd = CMD_START_TX; isCmdValid = true; } break; case ID_NONE: case ID_HD_OP_MODE: case ID_FILTER_FLUSH_TIME_BC: case ID_HD_UI_CONFIRM_RQST: case ID_PRE_TX_STATES_BC: case ID_HD_NEW_PARAMS_RESP: case ID_HD_SYS_SELF_TEST_TIME_BC: case ID_HD_DRY_SELF_TEST_TIME_BC: case ID_HD_PRIMING_TIME_BC: case ID_HD_SET_UF_VOLUME_RESP: case ID_HD_PATINET_CONNECTION_CONF_RESP: // Do nothing break; } if ((isCmdValid) && (_dryDemo.isRunning())) { isCmdValid = false; _dryDemo.submitEvent("Transition_back_2_idle"); } } void StateController::timerEvent(QTimerEvent *) { int listSize = _dryDemoCmds[_dryDemoCurrentCmd].size(); qDebug() << "Index" << _index << listSize; if ((listSize > 1) && (_index < listSize)) { bool isTimer = _dryDemoCmds[_dryDemoCurrentCmd][_index][IS_TIMER_INDEX].toBool(); //qDebug() << "Index 222" << _dryDemoCmds[_dryDemoCurrentCmd][_index]; if(isTimer && (_dryDemoCmds[_dryDemoCurrentCmd][_index][COUNT_DOWN_TIMER_INDEX].toUInt() != 0)) { _dryDemoCmds[_dryDemoCurrentCmd][_index][COUNT_DOWN_TIMER_INDEX] = _dryDemoCmds[_dryDemoCurrentCmd][_index][COUNT_DOWN_TIMER_INDEX].toUInt() - 1; qDebug() << "COUnters" << _dryDemoCmds[_dryDemoCurrentCmd][_index][COUNT_DOWN_TIMER_INDEX].toUInt(); emit _ApplicationController.didActionTransmit(_dryDemoCmds[_dryDemoCurrentCmd][_index].mid(RESP_MSG_START_INDEX)); if (_dryDemoCmds[_dryDemoCurrentCmd][_index][COUNT_DOWN_TIMER_INDEX].toUInt() == 0) { _dryDemoCmds[_dryDemoCurrentCmd][_index][IS_TIMER_INDEX] = false; _index++; } } else { if (!_dryDemoCmds[_dryDemoCurrentCmd][_index][IS_WAIT_NEEDED_INDEX].toBool()) { //qDebug() << "Nex Inedx" << _dryDemoCmds[_dryDemoCurrentCmd][_index]; emit _ApplicationController.didActionTransmit(_dryDemoCmds[_dryDemoCurrentCmd][_index].mid(RESP_MSG_START_INDEX)); _broadcastMsgCount++; if (_broadcastMsgCount > 4 ) { int nextCmd = _dryDemoCmds[_dryDemoCurrentCmd][_index][NEXT_AUTO_TRANSITION_INDEX].toInt(); User_Command_ID nextCmdEnum = static_cast(nextCmd); qDebug() << "NONE" << nextCmd << nextCmdEnum; if (nextCmdEnum != CMD_NONE) { qDebug() << "Current Enum" << _dryDemoCurrentCmd; _dryDemoCurrentCmd = nextCmdEnum; qDebug() << "New transiion" << nextCmdEnum << _dryDemoCurrentCmd << _index; _dryDemo.submitEvent("Transition_back_2_idle"); } _index++; _broadcastMsgCount = 0; } } } } } // ---------------------- Private methods ------------------ // void StateController::initMessagesHashTable() { QVariantList temp; temp.append("Transition_2_Tx_Parms"); temp.append(false); // wait for a trigger temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_HD_OP_MODE)); temp.append(Can_Id::eChlid_HD_UI); temp.append(MODE_TPAR); temp.append(0); _dryDemoCmds[CMD_TX_PARAMS].append(temp); temp.clear(); temp.append("Transition_2_Water_Sample"); temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_HD_OP_MODE)); temp.append(Can_Id::eChlid_HD_UI); temp.append(MODE_PRET); temp.append(0); _dryDemoCmds[CMD_WATER_SAMPLE].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_WATER_SAMPLE].append(temp); temp.clear(); temp.append(true); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_FILTER_FLUSH_TIME_BC)); temp.append(Can_Id::eChlid_DG_Sync); temp.append(DEFAULT_TIMEOUT_S); temp.append(DEFAULT_TIMEOUT_S); _dryDemoCmds[CMD_WATER_SAMPLE].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(0); temp.append(1); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_WATER_SAMPLE].append(temp); temp.clear(); temp.append("Transition_2_Consumables"); temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_HD_OP_MODE)); temp.append(Can_Id::eChlid_HD_UI); temp.append(MODE_PRET); temp.append(0); _dryDemoCmds[CMD_CONSUMABLES].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(true); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(1); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_CONSUMABLES].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(1); temp.append(0); temp.append(1); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_CONSUMABLES].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(1); temp.append(0); temp.append(2); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_CONSUMABLES].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_UI); temp.append(1); temp.append(0); temp.append(3); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_CONSUMABLES].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_DISPOSABLES)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(1); temp.append(0); temp.append(4); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_CONSUMABLES].append(temp); temp.clear(); temp.append("Transition_2_Disposables"); temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_HD_OP_MODE)); temp.append(Can_Id::eChlid_HD_UI); temp.append(MODE_PRET); temp.append(0); _dryDemoCmds[CMD_DISPOSABLES].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(2); temp.append(0); temp.append(0); temp.append(1); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_DISPOSABLES].append(temp); temp.clear(); temp.append(true); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_HD_SYS_SELF_TEST_TIME_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(DEFAULT_TIMEOUT_S); temp.append(DEFAULT_TIMEOUT_S); _dryDemoCmds[CMD_DISPOSABLES].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); // wait for the user temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(3); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_DISPOSABLES].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(true); // wait for the user temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(3); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_DISPOSABLES].append(temp); temp.clear(); temp.append("Transition_2_Sys_Prime"); temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_HD_OP_MODE)); temp.append(Can_Id::eChlid_HD_UI); temp.append(MODE_PRET); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(4); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(true); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_HD_DRY_SELF_TEST_TIME_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(DEFAULT_TIMEOUT_S); temp.append(DEFAULT_TIMEOUT_S); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(4); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(1); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(4); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(2); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(4); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(3); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(4); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(4); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(4); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(5); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(4); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(6); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(4); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(7); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(4); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(8); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(4); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(9); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(4); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(10); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(4); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(11); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(4); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(12); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(4); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(13); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(4); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(14); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(4); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(15); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(4); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(16); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(5); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(true); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_HD_PRIMING_TIME_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(DEFAULT_TIMEOUT_S); temp.append(DEFAULT_TIMEOUT_S); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(5); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(1); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(5); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(2); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(5); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(3); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(5); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(4); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(5); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(5); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(5); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(6); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(5); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(7); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(5); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(8); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(5); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(9); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(5); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(10); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(5); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(11); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(5); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(12); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); // wait temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(6); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(true); // wait temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(6); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); temp.clear(); temp.append("Transition_2_BP_HR"); temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_HD_OP_MODE)); temp.append(Can_Id::eChlid_HD_UI); temp.append(MODE_PRET); temp.append(0); _dryDemoCmds[CMD_BP_HR].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); // wait temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(7); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); _dryDemoCmds[CMD_BP_HR].append(temp); temp.clear(); temp.append("Transition_2_Patient_Connection"); temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_HD_OP_MODE)); temp.append(Can_Id::eChlid_HD_UI); temp.append(MODE_PRET); temp.append(0); _dryDemoCmds[CMD_CONNECTION].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); // wait temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(7); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(2); temp.append(0); temp.append(0); _dryDemoCmds[CMD_CONNECTION].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(true); // wait temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(7); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(2); temp.append(0); temp.append(0); _dryDemoCmds[CMD_CONNECTION].append(temp); temp.clear(); temp.append("Transition_2_Start_Tx"); temp.append(false); temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_HD_OP_MODE)); temp.append(Can_Id::eChlid_HD_UI); temp.append(MODE_PRET); temp.append(0); _dryDemoCmds[CMD_START_TX].append(temp); temp.clear(); temp.append(false); // this is the timer temp.append(false); // wait temp.append(static_cast(CMD_NONE)); // auto transition temp.append(static_cast(ID_PRE_TX_STATES_BC)); temp.append(Can_Id::eChlid_HD_Sync); temp.append(7); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(0); temp.append(3); temp.append(0); temp.append(0); _dryDemoCmds[CMD_START_TX].append(temp); temp.clear(); } void StateController::transitionApplicationToStandBy() { _index = 0; _broadcastMsgCount = 0; _dryDemoCmds[CMD_WATER_SAMPLE][1][IS_WAIT_NEEDED_INDEX] = true; _dryDemoCmds[CMD_WATER_SAMPLE][2][COUNT_DOWN_TIMER_INDEX] = DEFAULT_TIMEOUT_S; _dryDemoCmds[CMD_DISPOSABLES][2][COUNT_DOWN_TIMER_INDEX] = DEFAULT_TIMEOUT_S; _dryDemoCmds[CMD_DISPOSABLES][4][IS_WAIT_NEEDED_INDEX] = true; _dryDemoCmds[CMD_SYSTEM_PRIME][2][COUNT_DOWN_TIMER_INDEX] = DEFAULT_TIMEOUT_S; QVariantList list; list.append(static_cast(ID_HD_OP_MODE)); list.append(Can_Id::eChlid_HD_UI); list.append(MODE_STAN); list.append(0); emit _ApplicationController.didActionTransmit(list); } // ----------- State transition methods ---------------- // void StateController::onIdleStateChange(bool active) { if (active) { qDebug() << "Idle on entry"; if ((_dryDemoCmds.contains(_dryDemoCurrentCmd)) && (_dryDemoCurrentCmd != CMD_NONE)) { transitionApplicationToStandBy(); QString transitionEvent = _dryDemoCmds[_dryDemoCurrentCmd][_index][TRANSITION_EVENT_INDEX].toString(); qDebug() << "Event" << transitionEvent <<_dryDemoCurrentCmd << _index; _dryDemo.submitEvent(transitionEvent); } } else { qDebug() << "Exit"; QVariantList msg = _dryDemoCmds[_dryDemoCurrentCmd][_index].mid(RESP_MSG_START_INDEX); emit _ApplicationController.didActionTransmit(msg); _index++; } } void StateController::onTreatmentParamsStateChange(bool active) { if (active) { qDebug() << "In treatment params on entry"; //QVariantList msg = _dryDemoCmds[_dryDemoCurrentCmd][_index].mid(RESP_MSG_START_INDEX); //emit _ApplicationController.didActionTransmit(msg); } else { qDebug() << "In treatment params inactive"; } } void StateController::onWaterSampleStateChange(bool active) { if(active) { qDebug() << "Sample" << _index; QVariantList msg = _dryDemoCmds[_dryDemoCurrentCmd][_index].mid(RESP_MSG_START_INDEX); emit _ApplicationController.didActionTransmit(msg); _index++; } else { } } void StateController::onConsumablesStateChange(bool active) { if(active) { qDebug() << "Consumables" << _index; QVariantList msg = _dryDemoCmds[_dryDemoCurrentCmd][_index].mid(RESP_MSG_START_INDEX); emit _ApplicationController.didActionTransmit(msg); } } void StateController::onDisposablesStateChange(bool active) { if(active) { qDebug() << "disposables" << _index; QVariantList msg = _dryDemoCmds[_dryDemoCurrentCmd][_index].mid(RESP_MSG_START_INDEX); emit _ApplicationController.didActionTransmit(msg); _index++; } else { qDebug() << "exiting disposables"; } } void StateController::onSystemPrimeStateChange(bool active) { if (active) { qDebug() << "Prime active"; QVariantList msg = _dryDemoCmds[_dryDemoCurrentCmd][_index].mid(RESP_MSG_START_INDEX); emit _ApplicationController.didActionTransmit(msg); _index++; } } void StateController::onBPHRStateChange(bool active) { if (active) { qDebug() << "BP_HD active"; QVariantList msg = _dryDemoCmds[_dryDemoCurrentCmd][_index].mid(RESP_MSG_START_INDEX); emit _ApplicationController.didActionTransmit(msg); _index++; } } void StateController::onUltrafiltrationStateChange(bool active) { if (active) { qDebug() << "Ultrafiltraion active"; } } void StateController::onConnectionStateChange(bool active) { if(active) { qDebug() << "Connection active"; QVariantList msg = _dryDemoCmds[_dryDemoCurrentCmd][_index].mid(RESP_MSG_START_INDEX); emit _ApplicationController.didActionTransmit(msg); _index++; } } void StateController::onStartTreatmentStateChange(bool active) { if (active) { qDebug() << "Start Treatment active"; QVariantList msg = _dryDemoCmds[_dryDemoCurrentCmd][_index].mid(RESP_MSG_START_INDEX); emit _ApplicationController.didActionTransmit(msg); _index++; } } void StateController::onEndTreatmentStateChange(bool active) { if (active) { qDebug() << "Treatment end active"; } } void StateController::onDisinfectStateChange(bool active) { if (active) { qDebug() << "Disinfect active"; } }