transitions-gui
transitions-gui copied to clipboard
Without layout argument, ordered_transitions is required or nothing will be displayed
With this very simple minimum working example, nothing is displayed unless I add the layout
argument.
from transitions_gui import WebMachine
import time
states = ['locked', 'auto', 'spray', 'overflow']
# initializing the machine will also start the server (default port is 8080)
machine = WebMachine(states=states, initial='locked', name="Char Quencher",
ignore_invalid_triggers=True,
auto_transitions=False)
machine.add_transition('unlock', 'locked', 'auto') # locked -> auto (user commandded)
machine.add_transition('nominal_temp', ['spray', 'auto'], 'auto') # spray -> auto (pump stops)
machine.add_transition('lock', '*', 'locked') # all -> locked (user commanded)
machine.add_transition('flood', 'spray', 'overflow') # spray lasts too long, stick it in timeout
machine.add_transition('unlock', 'overflow', 'auto') # allow user to override timeout (user commanded)
machine.add_transition('high_temp', 'auto', 'spray') # auto -> spray (pump starts)
machine.add_transition('high_temp', 'spray', '=') # keep spraying while temp is high
try:
while True:
time.sleep(5)
#machine.next_state()
except KeyboardInterrupt: # Ctrl + C will shutdown the machine
machine.stop_server()
This also means I have to reset the layout every time I load, because I can't save a layout and load from that one.
Without layout argument:
With layout argument:
I just installed transitions and transitions-gui a day or two ago using pip, so seems like it's the current version.
Interestingly, the basic example given in Quickstart in the readme does in fact work without setting a layout. It seems like the transitions need to be in place before the machine finishes construction.
Is there a way to add transitions post-construction with WebMachine?