Skip to content

exarkun/machinist

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A library for constructing finite state machines

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published