Skip to content

Instantly share code, notes, and snippets.

@john-j-mclaughlin
Created August 15, 2021 05:33
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save john-j-mclaughlin/344d26cac08f33eec933d5d2de2e1cf9 to your computer and use it in GitHub Desktop.
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