Easy C state machine - Documentation for users
This library intends to make easy the creation and the use of a state machine in a C program.
Usually when building a system you have to define the possible states that the system can be in, and how the system can move from one state to another (what we call here transitions). But that behavior often depends not only on the last or current event, but also the events that preceded it. With statecharts, this information is easy to express, and this library allow you to implement easily any statechart.
Statecharts are usually used in:
- Every event driven system.
- Many communication driver.
- Sometimes in other kind of system.
The concepts and notation of this library are based on those from Harel's Statecharts.
This library has been written in ANSI C and can so be compiled by any real C compiler. However, the makefile has been written for gcc and a tested on a gnu-linux system. If you want to build the library on another system you may have to re-write the makefile (the provided one will certainly help to write your own). The provided sample code has been as well written for a gnu-linux system and is using a system header for time measurement, but can be easily adapted on another system.
The sources are published under the GPL licence, a copy of the licence is attached to the sources. If not, see this page.
The library has been designed to be highly flexible and match any need a user might have. This when there are some adjustment that can be made in the makefile to define the wanted behaviour.
There are three axis to optimize the library:
- Size optimizations.
- Speed optimizations.
- Safety optimizations.
Of course acting on one axis might have repercussions on others.
This way you are able to highly optimize the runtime performances. But the highest level of this optimization implies an extra use of memory space and make the library become unsafe if used in an unsuitable way.
Don't be afraid about this unsafe behaviour as you probably won't parameter the library this way. If you want to do so, the documentation will help you see section How to carefully handle the library
If you want to see some numerical informations about the library see This page.
A big strength of this library is that it supports any modern behaviour one can expect from a state machine:
The next section will describe how to use the library.
- Nested state architectures.
- History state mechanism.
- Parallel state support.
The project is currently hosted on Source forge.
If you want to download the library and/or get involved in the project see this page.
Next: Getting started with the simple basis
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".