Index: drydemo.pro.user =================================================================== diff -u -rc8da96049610870d3a8c9c00edc04f80ae62085f -r1cfa9a2d55e3bf954e5d02f12b73d3a8deda9e5c --- drydemo.pro.user (.../drydemo.pro.user) (revision c8da96049610870d3a8c9c00edc04f80ae62085f) +++ drydemo.pro.user (.../drydemo.pro.user) (revision 1cfa9a2d55e3bf954e5d02f12b73d3a8deda9e5c) @@ -1,6 +1,6 @@ - + EnvironmentId Index: drydemoxmlstates.scxml =================================================================== diff -u -rc8da96049610870d3a8c9c00edc04f80ae62085f -r1cfa9a2d55e3bf954e5d02f12b73d3a8deda9e5c --- drydemoxmlstates.scxml (.../drydemoxmlstates.scxml) (revision c8da96049610870d3a8c9c00edc04f80ae62085f) +++ drydemoxmlstates.scxml (.../drydemoxmlstates.scxml) (revision 1cfa9a2d55e3bf954e5d02f12b73d3a8deda9e5c) @@ -2,19 +2,24 @@ - + - + + + + - - + - + + + + Index: sources/ApplicationController.cpp =================================================================== diff -u -r584874a724b2d3e8c98247d3b0e42d6a34ce9478 -r1cfa9a2d55e3bf954e5d02f12b73d3a8deda9e5c --- sources/ApplicationController.cpp (.../ApplicationController.cpp) (revision 584874a724b2d3e8c98247d3b0e42d6a34ce9478) +++ sources/ApplicationController.cpp (.../ApplicationController.cpp) (revision 1cfa9a2d55e3bf954e5d02f12b73d3a8deda9e5c) @@ -82,7 +82,6 @@ void ApplicationController::doUnhandledMsgAppController(const QVariantList &msg) { - qDebug() << "Test Slot" << msg; emit didUnhandledMsgAppController(msg); } // disabled coco end Index: sources/StateController.cpp =================================================================== diff -u -r584874a724b2d3e8c98247d3b0e42d6a34ce9478 -r1cfa9a2d55e3bf954e5d02f12b73d3a8deda9e5c --- sources/StateController.cpp (.../StateController.cpp) (revision 584874a724b2d3e8c98247d3b0e42d6a34ce9478) +++ sources/StateController.cpp (.../StateController.cpp) (revision 1cfa9a2d55e3bf954e5d02f12b73d3a8deda9e5c) @@ -7,7 +7,12 @@ void StateController::init() { connect(&_ApplicationController, SIGNAL(didUnhandledMsgAppController(const QVariantList &)), - this , SLOT(onStateControllerUnhandledMsgReceived(const QVariantList &))); + this , SLOT(onStateControllerUnhandledMsgReceived(const QVariantList &))); + + _dryDemo.connectToState("Idle" , this, &StateController::onIdleStateChange ); + _dryDemo.connectToState("Treatment" , this, &StateController::onTreatmentStateChange ); + _dryDemo.connectToState("Disinfect" , this, &StateController::onDisinfectStateChange ); + } void StateController::quit() @@ -20,28 +25,77 @@ { qDebug() << "Message With new" << msg[0]; + quint16 receivedMsgID = msg[0].toUInt(); + + if (!_dryDemo.isRunning()) { _dryDemo.start(); // TODO why cannot start the state machine somewhere else? } - switch(msg[0].toUInt()) + qDebug() << "Active states" << _dryDemo.activeStateNames(); + + switch(receivedMsgID) { - case 2500: // TODO enum for this - qDebug() << "Right here"; - _dryDemo.connectToState("Idle", _dryDemo.onEntry([&]() { - qDebug() << "In onEntry" << _dryDemo.activeStateNames();})); + case 0x2500: // TODO enum for this + //qDebug() << "Right here"; + //_dryDemo.connectToState("Idle", _dryDemo.onEntry([&]() { + // qDebug() << "In onEntry" << _dryDemo.activeStateNames();})); + //qDebug() << "New state" << _dryDemo.activeStateNames(); - qDebug() << "New state" << _dryDemo.activeStateNames(); + //QVariantList list; + //list.append(static_cast(0x2A00)); + //list.append(Can_Id::eChlid_HD_UI); + //list.append(68); + //list.append(34.56); + //emit _ApplicationController.didActionTransmit(list); + break; + case 0x2700: + if ( _dryDemo.activeStateNames()[0] == "Idle" ) { + qDebug() << "Current active"; + _dryDemo.submitEvent("Tx_Start_Rqst"); + } - QVariantList list; - list.append(static_cast(0x2A00)); - list.append(Can_Id::eChlid_HD_UI); - list.append(68); - list.append(34.56); - emit _ApplicationController.didActionTransmit(list); - break; + qDebug() << "Active state in 0x2700" << _dryDemo.activeStateNames()[0]; + + if (_dryDemo.activeStateNames()[0] == "Treatment") + { + qDebug() << "Active state in treatment" << _dryDemo.activeStateNames()[0]; + _dryDemo.submitEvent("Transition_back_2_idle"); + } + break; } - qDebug() << "Msg Received" << msg; + //qDebug() << "Msg Received" << msg; // TODO remove } +// ---------------------- Private methods ------------------ // +void StateController::onIdleStateChange(bool active) +{ + if (active) { + REMOVE_THIS++; + qDebug() << "Idle from function" << REMOVE_THIS << active; + + if (REMOVE_THIS == 2) { + _dryDemo.submitEvent("Disinfect_Rqst"); + } + } +} + +void StateController::onTreatmentStateChange(bool active) +{ + qDebug() << "Calling treatment function"; + if (active) { + qDebug() << "Treatment active"; + } + else { + qDebug() << "Treatment inactive"; + } +} + +void StateController::onDisinfectStateChange(bool active) +{ + if (active) { + qDebug() << "Disinfect active"; + } +} + Index: sources/StateController.h =================================================================== diff -u -r584874a724b2d3e8c98247d3b0e42d6a34ce9478 -r1cfa9a2d55e3bf954e5d02f12b73d3a8deda9e5c --- sources/StateController.h (.../StateController.h) (revision 584874a724b2d3e8c98247d3b0e42d6a34ce9478) +++ sources/StateController.h (.../StateController.h) (revision 1cfa9a2d55e3bf954e5d02f12b73d3a8deda9e5c) @@ -18,12 +18,21 @@ SINGLETON(StateController) public: - void init(); + void init(); // TODO these in slots void quit(); public slots: void onStateControllerUnhandledMsgReceived(const QVariantList &msg); private: drydemoXMLstates _dryDemo; + QString _previoustStateName; + + quint16 REMOVE_THIS = 0; + + void buildRespondMessage(); + + void onIdleStateChange(bool active); + void onTreatmentStateChange(bool active); + void onDisinfectStateChange(bool active); }; Index: sources/canbus/MessageBuilder.cpp =================================================================== diff -u -r6abfb957108b171a8a5ab6770ad9b463235c210b -r1cfa9a2d55e3bf954e5d02f12b73d3a8deda9e5c --- sources/canbus/MessageBuilder.cpp (.../MessageBuilder.cpp) (revision 6abfb957108b171a8a5ab6770ad9b463235c210b) +++ sources/canbus/MessageBuilder.cpp (.../MessageBuilder.cpp) (revision 1cfa9a2d55e3bf954e5d02f12b73d3a8deda9e5c) @@ -151,7 +151,6 @@ } vPayload += len; vPayload += vData.mid(0, len); // Adding required Data - qDebug() << "Payload added" << vPayload; return true; } Index: sources/canbus/MessageDispatcher.cpp =================================================================== diff -u -r584874a724b2d3e8c98247d3b0e42d6a34ce9478 -r1cfa9a2d55e3bf954e5d02f12b73d3a8deda9e5c --- sources/canbus/MessageDispatcher.cpp (.../MessageDispatcher.cpp) (revision 584874a724b2d3e8c98247d3b0e42d6a34ce9478) +++ sources/canbus/MessageDispatcher.cpp (.../MessageDispatcher.cpp) (revision 1cfa9a2d55e3bf954e5d02f12b73d3a8deda9e5c) @@ -165,13 +165,12 @@ // disabled coco end _messageList[vCan_Id].append(Message()); } - qDebug() << "5" <<__FUNCTION__; // build the message and check. if (! buildMessage(vCan_Id, vPayload)) { return; } Message mMessage = _messageList[vCan_Id].last(); - qDebug() << "6" <<__FUNCTION__; + //qDebug() << "6" <<__FUNCTION__; // TODO : must be moved to a MessageModel class if (mMessage.isComplete()) { @@ -522,6 +521,5 @@ void MessageDispatcher::doUnhandledMsgReady(const QVariantList &msg) { - qDebug() << "In interp"; emit didUnhandledMsgDispatcher(msg); } Index: sources/canbus/MessageInterpreter.cpp =================================================================== diff -u -r584874a724b2d3e8c98247d3b0e42d6a34ce9478 -r1cfa9a2d55e3bf954e5d02f12b73d3a8deda9e5c --- sources/canbus/MessageInterpreter.cpp (.../MessageInterpreter.cpp) (revision 584874a724b2d3e8c98247d3b0e42d6a34ce9478) +++ sources/canbus/MessageInterpreter.cpp (.../MessageInterpreter.cpp) (revision 1cfa9a2d55e3bf954e5d02f12b73d3a8deda9e5c) @@ -320,7 +320,7 @@ else { Q_UNUSED (vData ); printUnhandled (vMessage ); - qDebug() << "1" <<__FUNCTION__; + //qDebug() << "1" <<__FUNCTION__; } return ok; } @@ -435,7 +435,6 @@ QString logString = QString("%1,").arg(id,4,16); QVariantList logVariant; logVariant.append(id); - qDebug() << "ID" << logString; if (_messageList.contains(id)) { ok = true;