Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A simple FSM modeling a 2 switch light circuit
state_machine(two_switch_light : LIGHTS) {
parallel_state(switches) {
state(switch_1) {
on_event("toggle/up/1", up) ;
on_event("toggle/down/1", down) ;
state(up) ;
state(down) ;
}
state(switch_2) {
on_event("toggle/up/2", up) ;
on_event("toggle/down/2", down) ;
state(up) ;
state(down) ;
}
state(light) {
on_state_all([../switch_1/up, ../switch_2/up], on) ;
on_state_all([../switch_1/down, ../switch_2/down], on) ;
state(on) {
on_event("toggle/*", ../off) ;
on_entry ${
turnOnLight()
$}
on_exit ${
turnOffLight()
$}
}
state(off) ;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment