Show HN: µFSM – A state chart library for embedded applications
github.com
github.com
In my case, when I want to use a state machine for a project, I usually go with Quantum Leaps [1] tools. Nowadays their website seems cluttered and management-focused, but the tech is solid and the tools are very robust.
They also distribute a book [2] on how to use the model using their framework as an example, and I even implemented my version of it as an exercise years ago.
It does not have (or did not, I haven't checked in the last few years) a tool to translate from XMI to their framework, but they have a freeware to draw the chart. Frankly, I have not even used it: I draw the state machine using some editor and it is easy enough to translate to code and maintain. Maybe not the best, but up until now, very nice to deal with the limited complexity of most embedded systems.
[1] https://www.state-machine.com/doc/concepts#HSM [2] https://www.state-machine.com/psicc2/
They’re particularly ideal for embedded systems. The limited ram in many embedded systems makes a full dynamic language difficult to fit but a state chart interpreter can be very minimal while production runs can be compiled directly to code. Memory management in state charts can often be much easier to handle.
There’s also a lot of benefit to describing valid states for your system both in terms of correctness and the ability of algorithmically finding an optimal reduced state machine.
Personally I am fond of SCXML as it’s fairly concise, can include code snippets, and has a relatively well documented standard easy to display by converting to Vue/React/WebComponents. XMI with its connection to UML didn’t seem appealing to me, but this project seems pretty robust!
While I agree, I think this promotes the idea that they're only good for embedded systems, especially small ones. State machines are not always the right tool for the job... only most of the time :)
State machines(or DFAs for you CS guys) are used all over. For instance, AFAIK, grep is generally implemented with a state-machine, albeit one which is dynamically constructed at run-time(which is a pretty cool concept if you ask me).
IMHO, most websites / UI's implement half of a poorly understood state machine (to roughly paraphrase the Common Lisp quip). Qt apparently also has an interesting statechart engine as well: http://blog.qt.io/blog/2017/01/23/qt-scxml-state-chart-suppo...
So it's good to see others using Quantum Leaps RTOS. It take a little bit to set up the environment and understand some of the bounds, but I really enjoying using their QM Modeling tool[1], I would recommend it. I would mainly use it for the logic and abstract out the code in separate files, so that you are not maintaining code in the GUI tool.
At the time, I actually bought the book and I liked it. It was a bit dense in the beginning, and I skipped the example, but I had some good takeaways, specially on the implementation of the system, which is described in the book.
If you don't mind a 'drive-by' feature request: it would be fantastic if you were to support the PlantUML state DSL:
http://plantuml.com/state-diagram
That would push me from "interesting proof of concept" to figuring out how to use it in projects.
This has important consequences for visually impaired programmers, so I'm glad of that as well.
It is part of the Erlang's standard library. SSH and SSL state and connection management has been re-written recently to use this built-in module.
Here is a video of Raimo Niskanen, the author, describing the module:
https://www.youtube.com/watch?v=f_jl6MR3kXQ
The title is "The tool that you never knew that you always wanted", which was borrowed from another member of the community (Jesper L. Andersen)
Regardless, this looks very cool I will dive in later.
Embedded shouldn't rhyme with "C".
Writing in C means you can get small binaries, with minimal runtimes, easy control over things like memory allocation, and if you want to use the library you don't have to write C because almost any language with any form of FFI is going to target C before it targets C++.