Finite State Machine
Project description
Finite State Machine
Object-oriented finite state machine implementation using python
Table of Contents
Installation
Download source code and run the following commands to install and uninstall the package:
pip install .
pip uninstall fsm_finite_state_machine
Usage
There are 3 main classes in this package to be used:
State
- Contains the definition of the state machine state as a string keyTransition
- Contains the definition of a state machine transition, such as transition name, the source state and the destination stateFSM
- Is the definition of the Finite State Machine which must be instatiated with the following arguments:
model
- The entity model which contains the state value, the state value setters and the transition triggers execution methods.states
- Its a dictionary of states that the state machine will use to operatetransitions
- Contains the list of transitions definitionscurrentStateValue
- Corresponds to the initial state or current state values to be passed to the state machine
After defining the states
and the transitions
the state machine can be used by:
- Instantiating a state machine object;
- Triggering a state machine transition, so the machine knows to which state it will jump next. In this step it is also possible to pass arguments to be used by the transition trigger methods. These arguments are optional;
- And finally by executing the state machine itself, which will execute the transition trigger methods.
Code example:
fsm = FSM(model, STATES, TRANSITIONS, stateValue)
fsm.triggerTransition(transitionName, data1, data2, ...)
fsm.execute()
Examples
Check the following link: examples
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file fsm_finite_state_machine-0.1.0.tar.gz
.
File metadata
- Download URL: fsm_finite_state_machine-0.1.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91643372cdf3f8e142913751fb3968502628344989bb95c740745f63b3efff7e |
|
MD5 | 9fb95d9ec1cf4daf3c904cce23f53722 |
|
BLAKE2b-256 | e851bea5c98d9739cd41251bb8356a6b09ec1c71a239c5ce2a46f1e017be1478 |