Skip to content

Latest commit

 

History

History
63 lines (46 loc) · 1.68 KB

README.rst

File metadata and controls

63 lines (46 loc) · 1.68 KB

put together finite state machines

class TurnstileInput(Names):
    FARE_PAID = NamedConstant()
    ARM_UNLOCKED = NamedConstant()
    ARM_TURNED = NamedConstant()
    ARM_LOCKED = NamedConstant()

class TurnstileOutput(Names):
    ENGAGE_LOCK = NamedConstant()
    DISENGAGE_LOCK = NamedConstant()

class TurnstileState(Names):
    LOCKED = NamedConstant()
    UNLOCKED = NamedConstant()
    ACTIVE = NamedConstant()

table = TransitionTable()

# Any number of things like this
table = table.addTransitions(
    TurnstileState.UNLOCKED, {
        TurnstileInput.ARM_TURNED:
            ([TurnstileOutput.ENGAGE_LOCK], TurnstileState.ACTIVE),
    })

turnstileFSM = constructFiniteStateMachine(
    inputs=TurnstileInput,
    outputs=TurnstileOutput,
    states=TurnstileState,
    table=table,
    initial=TurnstileState.LOCKED,
    richInputs={},
    inputContext={},
    world=MethodSuffixOutputer(Turnstile(hardware)),
)

For the rest of this example, see doc/turnstile.py.

For more discussion of the benefits of this style, see:

installation

$ pip install machinist

contributing

See http://github.com/hybridcluster/machinist for development.

https://coveralls.io/repos/hybridcluster/machinist/badge.png