Index: sources/StateController.cpp =================================================================== diff -u -rc5b453debecfb1b22e40f073537077792fad4ab1 -rce5cfa527a7f05d77a42a05c859d5de4571de84f --- sources/StateController.cpp (.../StateController.cpp) (revision c5b453debecfb1b22e40f073537077792fad4ab1) +++ sources/StateController.cpp (.../StateController.cpp) (revision ce5cfa527a7f05d77a42a05c859d5de4571de84f) @@ -7,7 +7,7 @@ void StateController::init() { - startTimer(1000); + startTimer(QOBJECT_TIMER_TIMEOUT_MS); connect(&_ApplicationController, SIGNAL(didUnhandledMsgAppController(const QVariantList &)), this , SLOT(doStateControllerUnhandledMsgReceived(const QVariantList &))); @@ -24,10 +24,10 @@ _dryDemo.connectToState("End_Tx" , this, &StateController::onEndTreatmentStateChange ); _dryDemo.connectToState("Disinfect" , this, &StateController::onDisinfectStateChange ); - _index = 0; - _broadcastMsgCount = 0; + _dryDemoCurrentCmd = CMD_NONE; + resetVariables(); initMessagesHashTable(); // Todo move this? } @@ -84,8 +84,7 @@ 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) { + if (IDParam.value == UI_MSG_BB_PAYLOAD_ID) { int cmdIndex = 4; Types::U32 cmdParam; GetValue(msg[1].toByteArray(), cmdIndex, cmdParam); @@ -96,7 +95,7 @@ QVariantList closeMsg; closeMsg.append(static_cast(ID_HD_UI_CONFIRM_RQST)); closeMsg.append(Can_Id::eChlid_HD_UI); - closeMsg.append(0x63); + closeMsg.append(UI_MSG_BB_PAYLOAD_ID); closeMsg.append(1); closeMsg.append(0); emit _ApplicationController.didActionTransmit(closeMsg); @@ -191,29 +190,38 @@ { int listSize = _dryDemoCmds[_dryDemoCurrentCmd].size(); - qDebug() << "Index" << _index << listSize; + //qDebug() << "Index" << _index << listSize; if ((listSize > 1) && (_index < listSize)) { - bool isTimer = _dryDemoCmds[_dryDemoCurrentCmd][_index][IS_TIMER_INDEX].toBool(); + //bool isTimer = _dryDemoCmds[_dryDemoCurrentCmd][_index][IS_TIMER_INDEX].toBool(); + + if (_dryDemoCmds[_dryDemoCurrentCmd][_index][IS_TIMER_INDEX].toBool()) { + if((++_timerBroadcastCount >= NUM_OF_COUNTS_TIMER_BC_EMIT) && + (_dryDemoCmds[_dryDemoCurrentCmd][_index][COUNT_DOWN_TIMER_INDEX].toUInt() != 0)) { + + //} + //qDebug() << "Index 222" << _dryDemoCmds[_dryDemoCurrentCmd][_index]; - if(isTimer && (_dryDemoCmds[_dryDemoCurrentCmd][_index][COUNT_DOWN_TIMER_INDEX].toUInt() != 0)) { + //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++; + _timerBroadcastCount = 0; } } + } else { + emit _ApplicationController.didActionTransmit(_dryDemoCmds[_dryDemoCurrentCmd][_index].mid(RESP_MSG_START_INDEX)); + _broadcastMsgCount++; 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 ) { + if (_broadcastMsgCount > NUM_OF_COUNTS_TO_BC_MSG) { int nextCmd = _dryDemoCmds[_dryDemoCurrentCmd][_index][NEXT_AUTO_TRANSITION_INDEX].toInt(); User_Command_ID nextCmdEnum = static_cast(nextCmd); qDebug() << "NONE" << nextCmd << nextCmdEnum; @@ -240,7 +248,7 @@ 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(Can_Id::eChlid_HD_Sync); temp.append(MODE_TPAR); temp.append(0); _dryDemoCmds[CMD_TX_PARAMS].append(temp); @@ -250,7 +258,7 @@ 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(Can_Id::eChlid_HD_Sync); temp.append(MODE_PRET); temp.append(0); _dryDemoCmds[CMD_WATER_SAMPLE].append(temp); @@ -260,18 +268,9 @@ 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); + 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 @@ -307,7 +306,7 @@ 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(Can_Id::eChlid_HD_Sync); temp.append(MODE_PRET); temp.append(0); _dryDemoCmds[CMD_CONSUMABLES].append(temp); @@ -373,7 +372,7 @@ 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(Can_Id::eChlid_HD_Sync); temp.append(1); temp.append(0); temp.append(3); @@ -412,7 +411,7 @@ 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(Can_Id::eChlid_HD_Sync); temp.append(MODE_PRET); temp.append(0); _dryDemoCmds[CMD_DISPOSABLES].append(temp); @@ -488,7 +487,7 @@ 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(Can_Id::eChlid_HD_Sync); temp.append(MODE_PRET); temp.append(0); _dryDemoCmds[CMD_SYSTEM_PRIME].append(temp); @@ -811,17 +810,17 @@ 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(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)); @@ -836,7 +835,7 @@ 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(Can_Id::eChlid_HD_Sync); temp.append(MODE_PRET); temp.append(0); _dryDemoCmds[CMD_BP_HR].append(temp); @@ -856,22 +855,22 @@ 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(Can_Id::eChlid_HD_Sync); 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(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)); @@ -886,7 +885,7 @@ 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(Can_Id::eChlid_HD_Sync); temp.append(MODE_PRET); temp.append(0); _dryDemoCmds[CMD_START_TX].append(temp); @@ -906,8 +905,7 @@ void StateController::transitionApplicationToStandBy() { - _index = 0; - _broadcastMsgCount = 0; + resetVariables(); _dryDemoCmds[CMD_WATER_SAMPLE][1][IS_WAIT_NEEDED_INDEX] = true; _dryDemoCmds[CMD_WATER_SAMPLE][2][COUNT_DOWN_TIMER_INDEX] = DEFAULT_TIMEOUT_S; @@ -925,6 +923,13 @@ emit _ApplicationController.didActionTransmit(list); } +void StateController::resetVariables() +{ + _index = 0; + _broadcastMsgCount = 0; + _timerBroadcastCount = 0; +} + // ----------- State transition methods ---------------- // void StateController::onIdleStateChange(bool active)