Index: drydemo.pro =================================================================== diff -u -rc8da96049610870d3a8c9c00edc04f80ae62085f -r584874a724b2d3e8c98247d3b0e42d6a34ce9478 --- drydemo.pro (.../drydemo.pro) (revision c8da96049610870d3a8c9c00edc04f80ae62085f) +++ drydemo.pro (.../drydemo.pro) (revision 584874a724b2d3e8c98247d3b0e42d6a34ce9478) @@ -60,7 +60,6 @@ sources/model/settings \ HEADERS += \ - \ # common \ # Main sources/main.h \ sources/Threads.h \ @@ -69,34 +68,10 @@ \ # Controllers sources/ApplicationController.h \ sources/storage/Settings.h \ - \ # sources/storage/TreatmentLog.h # TODO is this needed? - \ # ---------- Models ---------- \ # ---------- States ---------- - sources/DryDemoStates.h \ - \ # sources/model/MModel.h # TODO is this needed? + sources/StateController.h \ sources/model/MAbstract.h \ # TODO is this needed? - \ # sources/model/MAbstractDynamic.h # TODO is this needed? - \ # ---------- Models - confirm - \ # ---------- Models - POST - \ # ---------- Models - settings sources/model/settings/MSettings.h \ - \ # ---------- Models - Alarm - \ # ---------- Models - States Data - \ # ---------- Models - HD - Adjustment - \ # ---------- Models - HD - Adjustment - Settings - \ # ---------- Models - HD - Adjustment - Pre-Treatment - \ # ---------- Models - HD - Adjustment - In-Treatment - \ # ---------- Models - HD - Adjustment - End-Treatment - \ # ---------- Models - HD - Adjustment - Post-Treatment - \ # ---------- Models - HD - Adjustment - Disinfeection - \ # ---------- Models - HD - Data - Pre-Treatment - Progress - \ # ---------- Models - HD - Data - \ # ---------- Models - HD - Data - Treatment Log - \ # ---------- Models - DG - Adjustment - \ # ---------- Models - DG - Adjustment - Settings - \ # ---------- Models - DG - Data - Pre-Treatment - Progress - \ # ---------- Models - DG - Data - Disinfect - Progress - \ # ---------- Models - DG - Data \ # CANBus sources/canbus/CanInterface.h \ sources/canbus/FrameInterface.h \ @@ -106,26 +81,6 @@ sources/canbus/MessageBuilder.h \ sources/canbus/MessageInterpreter.h \ sources/canbus/MessageDispatcher.h \ - \ # Gui - \ # ---------- Views ---------- - \ # ---------- Views - CONFIRM - \ # ---------- Views - POST - \ # ---------- Views - Settings - \ # ---------- Views - Alarm - \ # ---------- Views - HD - Adjustment - \ # ---------- Views - HD - Adjustment - common - \ # ---------- Views - HD - Adjustment - Pre-Treatment - \ # ---------- Views - HD - Adjustment - In-Treatment - \ # ---------- Views - HD - Adjustment - End-Treatment - \ # ---------- Views - HD - Adjustment - Post-Treatment - \ # ---------- Views - HD - Adjustment - Disinfection - \ # ---------- Views - HD - Data - States - \ # ---------- Views - HD - Data - Pre-Treatment - Progress - \ # ---------- Views - HD - Data - \ # ---------- Views - DG - Data - Pre-Treatment - Progress - \ # ---------- Views - DG - Data - Disinfection - Progress - \ # ---------- Views - DG - States - \ # ---------- Views - DG - Data \ # Storage sources/storage/StorageGlobals.h \ sources/storage/Logger.h \ @@ -138,7 +93,6 @@ sources/utility/qrcodegen.h SOURCES += \ - \ # common \ # Main main.cpp \ sources/Threads.cpp \ @@ -148,30 +102,11 @@ sources/ApplicationController.cpp \ sources/storage/Settings.cpp \ \ # ---------- States ---------- + sources/StateController.cpp \ \ # ---------- Models ---------- - sources/DryDemoStates.cpp \ sources/model/MAbstract.cpp \ - \ # ---------- Models - CONFIRM - \ # ---------- Models - POST \ # ---------- Models - settings sources/model/settings/MSettings.cpp \ - \ # ---------- Models - Alarm - \ # ---------- Models - Data - States - \ # ---------- Models - HD - Adjustment - \ # ---------- Models - HD - Adjustment - Settings - \ # ---------- Models - HD - Adjustment - Pre-Treatment - \ # ---------- Models - HD - Adjustment - In-Treatment - \ # ---------- Models - HD - Adjustment - End-Treatment - \ # ---------- Models - HD - Adjustment - Post-Treatment - \ # ---------- Models - HD - Adjustment - Disinfection - \ # ---------- Models - HD - Data - \ # ---------- Models - HD - Data - Pre-Treatment - \ # ---------- Models - HD - Data - Treatment Log - \ # ---------- Models - DG - Adjustment - \ # ---------- Models - DG - Adjustment - Settings - \ # ---------- Models - DG - Data - Pre-Treatment - Progress - \ # ---------- Models - DG - Data - Disinfection - Progress - \ # ---------- Models - DG - Data \ # CANBus sources/canbus/CanInterface.cpp \ sources/canbus/FrameInterface.cpp \ @@ -180,28 +115,6 @@ sources/canbus/MessageBuilder.cpp \ sources/canbus/MessageDispatcher.cpp \ sources/canbus/MessageInterpreter.cpp \ - \ # Gui - \ # ---------- Views ---------- - \ # ---------- Views - CONFIRM - \ # ---------- Views - POST - \ # ---------- Views - Alarm - \ # ---------- Views - Settings - \ # ---------- Views - HD - Adjustment - \ # ---------- Views - HD - Adjustment - common - \ # ---------- Views - HD - Adjustment - Pre-Treatment - \ # ---------- Views - HD - Adjustment - In-Treatment - \ # ---------- Views - HD - Adjustment - End-Treatment - \ # ---------- Views - HD - Adjustment - Post-Treatment - \ # ---------- Views - HD - Adjustment - Disinfection - \ # ---------- Views - HD - States Data - \ # ---------- Views - HD - Data - \ # ---------- Views - HD - Data - Pre-Treatment - \ # ---------- Views - HD - Data - In-Treatment - \ # ---------- Views - HD - Data - End-Treatment - \ # ---------- Views - DG - Data - Pre-Treatment - Progress - \ # ---------- Views - DG - Data - Disinfect - Progress - \ # ---------- Views - DG - States - \ # ---------- Views - DG - Data \ # Storage sources/storage/StorageGlobals.cpp \ sources/storage/FileHandler.cpp \ Index: main.cpp =================================================================== diff -u -rc8da96049610870d3a8c9c00edc04f80ae62085f -r584874a724b2d3e8c98247d3b0e42d6a34ce9478 --- main.cpp (.../main.cpp) (revision c8da96049610870d3a8c9c00edc04f80ae62085f) +++ main.cpp (.../main.cpp) (revision 584874a724b2d3e8c98247d3b0e42d6a34ce9478) @@ -46,6 +46,7 @@ #include "MessageDispatcher.h" #include "ApplicationController.h" #include "Logger.h" +#include "StateController.h" #include "Settings.h" #include "Threads.h" @@ -621,6 +622,8 @@ //! - Initializing Main Timer _MainTimer.init(); + _StateController.init(); + int app_exec = -1; _ApplicationController.startPOST(); app_exec = app.exec(); Index: sources/ApplicationController.cpp =================================================================== diff -u -r6abfb957108b171a8a5ab6770ad9b463235c210b -r584874a724b2d3e8c98247d3b0e42d6a34ce9478 --- sources/ApplicationController.cpp (.../ApplicationController.cpp) (revision 6abfb957108b171a8a5ab6770ad9b463235c210b) +++ sources/ApplicationController.cpp (.../ApplicationController.cpp) (revision 584874a724b2d3e8c98247d3b0e42d6a34ce9478) @@ -24,6 +24,7 @@ //#include "FileHandler.h" #include "Settings.h" #include "MSettings.h" +#include "StateController.h" // TODO: Clean up APPLICATION CONTROLLER @@ -79,10 +80,10 @@ quitThread(); // validated } -void ApplicationController::onUnhandledReceived(QString msg) +void ApplicationController::doUnhandledMsgAppController(const QVariantList &msg) { qDebug() << "Test Slot" << msg; - emit isUnhandledMsgReady(msg); + emit didUnhandledMsgAppController(msg); } // disabled coco end @@ -112,8 +113,8 @@ connect(&_settingsWatcher, SIGNAL(finished ()), this , SLOT(onSettingsUpdate())); - connect(this , SIGNAL(isUnhandledMsgReady(QString)), - &_dryDemoStates, SLOT(onMsgReceived(QString))); + connect(&_MessageDispatcher, SIGNAL(didUnhandledMsgDispatcher(const QVariantList &)), + this , SLOT(doUnhandledMsgAppController(const QVariantList &))); } /*! Index: sources/ApplicationController.h =================================================================== diff -u -rc8da96049610870d3a8c9c00edc04f80ae62085f -r584874a724b2d3e8c98247d3b0e42d6a34ce9478 --- sources/ApplicationController.h (.../ApplicationController.h) (revision c8da96049610870d3a8c9c00edc04f80ae62085f) +++ sources/ApplicationController.h (.../ApplicationController.h) (revision 584874a724b2d3e8c98247d3b0e42d6a34ce9478) @@ -22,7 +22,6 @@ #include "ApplicationPost.h" #include "MessageGlobals.h" -#include "DryDemoStates.h" #include "MessageInterpreter.h" // define @@ -59,8 +58,6 @@ ApplicationPost _post; // I may need to be put in a concurrent. - DryDemoStates _dryDemoStates; - public: void initSettings(); @@ -69,7 +66,7 @@ bool init(QThread &vThread); void quit(); - void onUnhandledReceived(QString msg); + void doUnhandledMsgAppController(const QVariantList &msg); private: void initConnections(); @@ -145,7 +142,7 @@ */ void didQuitApplication (); - void isUnhandledMsgReady(QString msg); + void didUnhandledMsgAppController(const QVariantList &msg); SAFE_CALL(startPOST) }; Fisheye: Tag 584874a724b2d3e8c98247d3b0e42d6a34ce9478 refers to a dead (removed) revision in file `sources/DryDemoStates.cpp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 584874a724b2d3e8c98247d3b0e42d6a34ce9478 refers to a dead (removed) revision in file `sources/DryDemoStates.h'. Fisheye: No comparison available. Pass `N' to diff? Index: sources/StateController.cpp =================================================================== diff -u --- sources/StateController.cpp (revision 0) +++ sources/StateController.cpp (revision 584874a724b2d3e8c98247d3b0e42d6a34ce9478) @@ -0,0 +1,47 @@ + +#include "StateController.h" +#include "ApplicationController.h" + +StateController::StateController(QObject *parent) : QObject(parent) {} + +void StateController::init() +{ + connect(&_ApplicationController, SIGNAL(didUnhandledMsgAppController(const QVariantList &)), + this , SLOT(onStateControllerUnhandledMsgReceived(const QVariantList &))); +} + +void StateController::quit() +{ + // TODo fill up +} + + +void StateController::onStateControllerUnhandledMsgReceived(const QVariantList &msg) +{ + qDebug() << "Message With new" << msg[0]; + + if (!_dryDemo.isRunning()) { + _dryDemo.start(); // TODO why cannot start the state machine somewhere else? + } + + switch(msg[0].toUInt()) + { + case 2500: // TODO enum for this + qDebug() << "Right here"; + _dryDemo.connectToState("Idle", _dryDemo.onEntry([&]() { + qDebug() << "In onEntry" << _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; + } + + qDebug() << "Msg Received" << msg; +} + Index: sources/StateController.h =================================================================== diff -u --- sources/StateController.h (revision 0) +++ sources/StateController.h (revision 584874a724b2d3e8c98247d3b0e42d6a34ce9478) @@ -0,0 +1,29 @@ +#pragma once + + +#include + +#include "main.h" +#include "MessageGlobals.h" +#include "drydemoxmlstates.h" + +// TODO maybe the DryDemoStates in the scxml not needed? + +#define _StateController StateController::I() + +class StateController : public QObject +{ + Q_OBJECT + + SINGLETON(StateController) + +public: + void init(); + void quit(); + +public slots: + void onStateControllerUnhandledMsgReceived(const QVariantList &msg); + +private: + drydemoXMLstates _dryDemo; +}; Index: sources/canbus/MessageDispatcher.cpp =================================================================== diff -u -r6abfb957108b171a8a5ab6770ad9b463235c210b -r584874a724b2d3e8c98247d3b0e42d6a34ce9478 --- sources/canbus/MessageDispatcher.cpp (.../MessageDispatcher.cpp) (revision 6abfb957108b171a8a5ab6770ad9b463235c210b) +++ sources/canbus/MessageDispatcher.cpp (.../MessageDispatcher.cpp) (revision 584874a724b2d3e8c98247d3b0e42d6a34ce9478) @@ -107,8 +107,8 @@ connect(&_ApplicationController, SIGNAL(didSettingsDone ()), this , SLOT( onSettingsDone ())); - connect(&_interpreter, SIGNAL(onUnhandledMsgReady(QString)), - &_ApplicationController, SLOT(onUnhandledReceived(QString))); + connect(&_interpreter , SIGNAL(didUnhandledMsgReady(const QVariantList &)), + this , SLOT(doUnhandledMsgReady(const QVariantList &))); } /*! @@ -382,22 +382,6 @@ Q_UNUSED(vMessage); Q_UNUSED(vSrcText); return true; - /* - GuiActionType mActionId = vMessage.actionId; - Sequence mSequence = vMessage.sequence; - bool ok = false; - if ( mActionId == GuiActionType::ID_Acknow ) { - ok = true; - if ( ! gDisableAcknowLog ) { - LOG_APPED(tr(" ,%1,Ack Bak, Sq:%2").arg(vSrcText).arg(mSequence)); - } - #ifdef DEBUG_ACKBACK_HD_TO_UI - qDebug() << tr(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ HD AckBak : %1 %2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ").arg(mSequence).arg(vMessage.actionId); - #endif - emit didAcknowReceive(mSequence); - } - return ok; -*/ } /*! @@ -536,7 +520,8 @@ return ok; } -void MessageDispatcher::testInterp() +void MessageDispatcher::doUnhandledMsgReady(const QVariantList &msg) { qDebug() << "In interp"; + emit didUnhandledMsgDispatcher(msg); } Index: sources/canbus/MessageDispatcher.h =================================================================== diff -u -r6abfb957108b171a8a5ab6770ad9b463235c210b -r584874a724b2d3e8c98247d3b0e42d6a34ce9478 --- sources/canbus/MessageDispatcher.h (.../MessageDispatcher.h) (revision 6abfb957108b171a8a5ab6770ad9b463235c210b) +++ sources/canbus/MessageDispatcher.h (.../MessageDispatcher.h) (revision 584874a724b2d3e8c98247d3b0e42d6a34ce9478) @@ -109,7 +109,7 @@ bool init(QThread &vThread); void quit(); - void testInterp(); + void doUnhandledMsgReady(const QVariantList &msg); public: void enableConsoleOut(bool vEnable) { _builder.enableConsoleOut(vEnable); } @@ -189,6 +189,8 @@ */ void didFailedTransmit(Sequence vSequence); + void didUnhandledMsgDispatcher(const QVariantList &) const; + private slots: // A Frame has been received from CanInterface void onFrameReceive (Can_Id vCan_Id, const QByteArray &vPayload); Index: sources/canbus/MessageInterpreter.cpp =================================================================== diff -u -r6abfb957108b171a8a5ab6770ad9b463235c210b -r584874a724b2d3e8c98247d3b0e42d6a34ce9478 --- sources/canbus/MessageInterpreter.cpp (.../MessageInterpreter.cpp) (revision 6abfb957108b171a8a5ab6770ad9b463235c210b) +++ sources/canbus/MessageInterpreter.cpp (.../MessageInterpreter.cpp) (revision 584874a724b2d3e8c98247d3b0e42d6a34ce9478) @@ -22,7 +22,7 @@ #include "Logger.h" #include "format.h" #include "Settings.h" -#include "DryDemoStates.h" +#include "StateController.h" using namespace Can; @@ -433,7 +433,10 @@ bool ok = false; quint16 id = vMessage.actionId; QString logString = QString("%1,").arg(id,4,16); + QVariantList logVariant; + logVariant.append(id); qDebug() << "ID" << logString; + if (_messageList.contains(id)) { ok = true; QStringList items = _messageList[id]; @@ -450,6 +453,7 @@ } } else { + logVariant.append(vMessage.data); if ( item == "F32" ) { Types::F32 param; if (! GetValue(vMessage.data, index, param )) logString += ",?"; @@ -494,7 +498,7 @@ } LOG_APPED(logString); qDebug() << "Message" << logString; - emit onUnhandledMsgReady(logString); + emit didUnhandledMsgReady(logVariant); } else { if ( gDisableUnhandledReport ) { // if the unhandled message error has been disabled, return. Index: sources/canbus/MessageInterpreter.h =================================================================== diff -u -rc8da96049610870d3a8c9c00edc04f80ae62085f -r584874a724b2d3e8c98247d3b0e42d6a34ce9478 --- sources/canbus/MessageInterpreter.h (.../MessageInterpreter.h) (revision c8da96049610870d3a8c9c00edc04f80ae62085f) +++ sources/canbus/MessageInterpreter.h (.../MessageInterpreter.h) (revision 584874a724b2d3e8c98247d3b0e42d6a34ce9478) @@ -84,6 +84,6 @@ static Can_Id identifyDestination(Can_Id vCanId, QString *vText = nullptr); signals: - void onUnhandledMsgReady( QString msg) const; + void didUnhandledMsgReady(const QVariantList &) const; }; }