2022-11-30 16:24:37 +03:00
|
|
|
# Examples
|
|
|
|
|
|
|
|
## Turnstile
|
|
|
|
|
|
|
|
An example of a simple mechanism that can be modeled by a state machine is a
|
|
|
|
turnstile. A turnstile, used to control access to subways and amusement park
|
|
|
|
rides, is a gate with three rotating arms at waist height, one across the
|
|
|
|
entryway. Initially the arms are locked, blocking the entry, preventing patrons
|
|
|
|
from passing through. Depositing a coin or token in a slot on the turnstile
|
|
|
|
unlocks the arms, allowing a single customer to push through. After the customer
|
|
|
|
passes through, the arms are locked again until another coin is inserted.
|
|
|
|
|
2022-11-30 16:26:54 +03:00
|
|
|
![Turnstile diagram](https://git.pleshevski.ru/pleshevskiy/it-fsm/raw/branch/main/assets/turnstile.svg)
|
2022-11-30 16:24:37 +03:00
|
|
|
|
|
|
|
```sh
|
|
|
|
deno run ./examples/turnstile.ts
|
|
|
|
```
|
2022-11-30 16:50:16 +03:00
|
|
|
|
|
|
|
## Project
|
|
|
|
|
|
|
|
This is more complex example illustrate all features of this library
|
|
|
|
|
|
|
|
![Project diagram](https://git.pleshevski.ru/pleshevskiy/it-fsm/raw/branch/main/assets/project.svg)
|
|
|
|
|
|
|
|
```sh
|
|
|
|
deno run ./examples/project.ts
|
|
|
|
```
|