Which State Machine execution frameworks for C++ i

2019-04-09 04:33发布

I'm looking for a framework that provides execution of hierarchical state machines (HSMs).

These are the requirements for the framework:

  • Conforms to UML state machine semantics (as much as possible)
  • Supports at least
    • run-to-completion semantics
    • hierarchical states
    • entry and exit actions
    • transition actions
    • guards
    • events with custom parameters
  • Is object-oriented or does at least not prohibit OO designs

The target platform is an medium- to large-sized embedded system with an OS.

Do you know a framework that fulfills the above requirements? What are the pros and cons of your framework?

5条回答
Emotional °昔
2楼-- · 2019-04-09 04:53

As of today there is a new C++ (supports C++11 and C++03 with Boost) alternative available. It's called yasmine (and I am the architect). It fulfills all the above requirements.

Some pros and cons (cited from the yasmine web page):

Advantages of using yasmine

  • She provides a complete implementation of UML state machine semantics.
  • yasmine is a modern C++ implementation using C++11 (C++03 support is available, too).
  • Because it's C++ (and not C) the code integrates nicely into OO code.
  • She's well documented [...]
  • Because she is open source you can check her implementation out. Also this guarantees long term usability and availability.
  • The library enables you to create state machines at runtime.
  • [...]

What yasmine is not

She's not a minimum foot print library that prioritizes on running on every system no matter how few resources are available. yasmine is not resource hungry, but she cannot (and does not want to) compete with switch-case-based bare-metal no-abstraction libraries.

Note

I know this is an old question, but it's Google's #1 for "c++ uml state machine" which makes it very relevant.

查看更多
Lonely孤独者°
3楼-- · 2019-04-09 05:14

Check out the Quantum Platform.

I've used it on several embedded projects (from very tiny to very large), and it supports all of the bullet items you require, and more.

The web page for the QP does a much better job of explaining itself than I can do here.

Be aware, the QP does not implement 100% of the functionality specified in the UML specification, but the departures are clearly explained, and in all my experience with the QP, none of them have been a problem for the project.

There are also 2 Boost statechart packages, which you seem to know about.

查看更多
ら.Afraid
4楼-- · 2019-04-09 05:18

If you are looking for a framework that supports hierarchical and concurrent state machines with UML semantics (entry/exit, transitions, guards, events with parameters, asynchronous/synchronous), have a look at my state machine code and diagram generator.

Instead on implementing the state machine "by hand", describe the state machine in a simple human readable and writable xml description and let the state machine generator write the code source in C++, C# or java.

Actually, for the C++ version, the generated code can be easily cross-compiled for an medium/large size embedded system. It has been done already.

查看更多
对你真心纯属浪费
5楼-- · 2019-04-09 05:18

You may have a look at my C++ template class framework STTCL that is purposed to provide mapping of UML 2.2 state diagram notation to implementation classes. The STTCL approach is a refinement of the GoF state pattern and tries to fill the gap(s) to the UML state chart notation.

The framework implementations are configurable regarding OS dependencies as far these are needed (only for asynchronous execution models).

There's a PDF document available explaining the concept in more detail.

查看更多
Emotional °昔
6楼-- · 2019-04-09 05:19

You should go and check out Boost MSM, it's new for Boost 1.44 but seems quite complete. I have not yet tried it out myself but it looks quite promising.

查看更多
登录 后发表回答