Crystal Clear Design's Hierarchical State Machine for Python
hierarchical_state_machine
This python library provides an easy-to-learn and easy-to-use API for using Hierarchical State Machines in your project. The state machine is defined using a basic JSON string, and includes convenience timers.
Simplest Example
The Blinky Light
Countdown Example
Fireworks
A More Involved Example
A Hierarchical State Machine Implementing a Simple Crosswalk Controller
- Get the location of the examples:
python -m pip show hierarchical_state_machine - Go to the example folder:
cd <site-packages>/hierarchical_state_machine/example/pedestrian_crosswalk/ - Look at the state machine diagram:
hierarchical_example_pedestrian_crosswalk_signaler.pdf - Execute and follow along:
python crosswalk_light_simulator.py - Press the
bbutton to request a crossing. - Press the
Escbutton to exit the simulation.
A Tutorial
Here are details about creating a hierarchical state machine in python.
Components of a State Machine
--Events - Are user inputs, timeouts, code-generated, or an output of another state machine. --States - A state machine waits in a state until an event or condition causes a transition to another state. --Transitions - Are paths gated by events and/or conditions, to go to another state. --Actions - Are behaviors (i.e. callbacks) evoked as a side-effect of a transition.
Creating a State
Each state contains the following optional elements: entry A list of callback functions that will be invoked each time the state is entered. exit A list of callback functions that will be invoked each time the state is exited. tran A list of transitions which will be followed when conditions are met.
Metadata
Release files for hierarchical-state-machine 1.0.16
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hierarchical_state_machine-1.0.16.tar.gz | 76.7 kB | Without provenance | Details for hierarchical_state_machine-1.0.16.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hierarchical_state_machine-1.0.16-py3-none-any.whl | Python 3 | none | any | Details for hierarchical_state_machine-1.0.16-py3-none-any.whl |
Total release size: 151.9 kB
Release files / hierarchical_state_machine-1.0.16.tar.gz
| Download URL | hierarchical_state_machine-1.0.16.tar.gz |
|---|---|
| Size | 76.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fc3fa0f4c32bf4de3ba9a1df9c8102d92e1192409efdc91f375584b75050dd8b
|
|
BLAKE2b-256 checksum How to use checksums |
27abd2d11aa5513211ea0e5d04df6e58264edbc65f37e0fe1e682afe0720fb4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.3
|
Release files / hierarchical_state_machine-1.0.16-py3-none-any.whl
| Download URL | hierarchical_state_machine-1.0.16-py3-none-any.whl |
|---|---|
| Size | 75.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c9afff9eafc8730d2b2bec6ff6a28f0f972ad7ba3fb5e3c2223e10fc8115e521
|
|
BLAKE2b-256 checksum How to use checksums |
cb07c423886bec152eb2f2a4c14f46ab3a8aa05100c1c0276a3681fddb4f9633
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.3
|
Security for hierarchical-state-machine 1.0.16
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.