Last active
December 8, 2019 18:15
-
-
Save avesus/a397f424aea8ae8ddfa6f439bcc78d13 to your computer and use it in GitHub Desktop.
Experimental Statechart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const deviceMachine = Machine({ | |
id: 'device', | |
initial: 'powered_off', | |
states: { | |
powered_on: { | |
type: 'parallel', | |
on: { | |
OFF: 'powered_off', | |
}, | |
states: { | |
fan_machine: { | |
initial: 'fanOff', | |
states: { | |
fanOff: { | |
on: { | |
POWER: 'fanOn', | |
HIGH_POWER: 'fanOn.third' | |
} | |
}, | |
fanOn: { | |
initial: 'first', | |
states: { | |
first: { | |
on: { TIMER: 'second' } | |
}, | |
second: { | |
on: { TIMER: 'third' } | |
}, | |
third: { | |
on: { TIMER: 'first' } | |
}, | |
}, | |
on: { | |
POWER: 'fanOff' | |
} | |
} | |
} | |
}, | |
traffic_light_working: { | |
initial: 'green', | |
states: { | |
green: { | |
on: { | |
TIMER: 'yellow' | |
} | |
}, | |
yellow: { | |
on: { | |
TIMER: 'red' | |
} | |
}, | |
red: { | |
initial: 'walk', | |
on: { | |
TIMER: 'green' | |
}, | |
states: { | |
walk: { | |
on: { | |
PED_TIMER: 'wait' | |
} | |
}, | |
wait: { | |
on: { | |
PED_TIMER: 'stop' | |
} | |
}, | |
stop: {} | |
} | |
} | |
} | |
} | |
} | |
}, | |
powered_off: { | |
on: { | |
ON: 'powered_on' | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment