summaryrefslogtreecommitdiffstats
path: root/support/testing/tests/package/sample_python_automat.py
blob: baf536f993b0d4ac52ba3b74848846451518abd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from automat import MethodicalMachine


class Led(object):
    _machine = MethodicalMachine()

    @_machine.state()
    def led_on(self):
        "led is on"

    @_machine.state(initial=True)
    def led_off(self):
        "led is off"

    @_machine.input()
    def turn_on(self):
        "turn the led on"

    @_machine.output()
    def _light(self):
        print("light")

    led_off.upon(turn_on, enter=led_on, outputs=[_light])


led = Led()
led.turn_on()
OpenPOWER on IntegriCloud