0

I am facing the problem of migrating a C application consisting of different parallel Finite-State-Machines (FSM) to a new plattform (YOCTO/Linux based). The C application has been developed for running on a Cortex M3 based Microcontroller using the Keil RTOS.

The implementation of the FSM was done in a naive way where each FSM is written in an own RTOS-task (basically just a C method). Inside these methods is just a big switch statement which determines the behaviour based on the current state (int variable). FSM interact with each other using global variables, guarded by a Mutex, or Events.

Since we ran into some hardware limitation and also having no real-time requirement I am planning to migrate the software to a Yocto-based system using C++ and Qt, supporting parallel and Sub-Statemachines. Additionally a GUI should be part of the system using QT QML.

My question is: Is there some kind of best practice of achieving the desired funtionality? Is there maybe some kind of code generation for the FSMs out of an UML diagram using some tool (Enterprise Architect, etc)? I have read about the QT StateMachine Framework and the SCXML support, would these be the best way to go?

I am glad for any help.

kain
  • 129
  • 1
  • 7
  • I'm not sure whether this answers any of your specific questions but would like to use the opportunity for personal ad: I recently wrote a sample for `std::thread`s doing some work and how to "mix in" results in Qt GUI: [SO: Qt C++ Displaying images outside the GUI thread (Boost thread)](https://stackoverflow.com/a/47470395/7478597). Btw. the questioner found a distinct solution which he mentions in his own answer. – Scheff's Cat Dec 01 '17 at 09:21
  • I would wonder if you couldn't execute a [`QStateMachine`](http://doc.qt.io/qt-5/qstatemachine.html) in a [`QThread`](http://doc.qt.io/qt-5/qthread.html). IMHO, most attention must be paid to signals (as calling handlers in _direct mode_ which "belongs to" another thread could become critical). But, [Qt signals](http://doc.qt.io/qt-5/signalsandslots.html) are already prepared for this (search for "queued connections" in that intro). – Scheff's Cat Dec 01 '17 at 09:39
  • By googling I also found a nice overview (which I never recognized before): [Multithreading Technologies in Qt](http://doc.qt.io/qt-5/threads-technologies.html). – Scheff's Cat Dec 01 '17 at 09:41
  • Btw. are you aware that you can have a look into sources (to check whether it matches your needs)? Google "woboq qstatemachine" provided (among others): [Browse the source code of qtbase/src/corelib/statemachine/qstatemachine.cpp](https://code.woboq.org/qt5/qtbase/src/corelib/statemachine/qstatemachine.cpp.html) – Scheff's Cat Dec 01 '17 at 09:46

0 Answers0