Update FSM documentation

This commit is contained in:
Kristóf Tóth 2018-07-11 10:17:19 +02:00
parent 7949d94493
commit 185f1165cf
1 changed files with 7 additions and 1 deletions

View File

@ -209,7 +209,7 @@ There are two ways to define a state machine:
- Using a YAML configuration file
- Implementing it in Python by hand
The first option enables you to handle FSM callbacks and custom logic in any programming language (not just Python) and is generally really easy to work with.
The first option allows you to handle FSM callbacks and custom logic in any programming language (not just Python) and is generally really easy to work with (you can execute arbitrary shell commands on events).
You should choose this method unless you have good reason not to.
This involves creating your YAML file (see `test_fsm.yml` for an example) and parsing it using our `YamlFSM` class (see `event_handler_main.py` for an example).
@ -224,6 +224,12 @@ Transition callbacks:
- `before`
- `after`
In your YAML file you can use these in the state and transition objects as keys, then add a shell command to run as a value (again, see `test_fsm.yml` for examples).
It is also possible to add preconditions to transitions.
This is done by adding a `predicates` key with a list of shell commands to run.
If you do this, the transition will only succeed if the return code of all predicates was `0` (as per unix convention for success).
## Baby steps
When creating your own challenge the process should be the following: