import sys
import time
from os.path import join, realpath, dirname
import logging

sys.path.append(join(dirname(realpath(__file__)), ".."))

from transitions_gui import WebMachine  # noqa

logging.basicConfig(level=logging.INFO)

states = ["A", "B", "C", "D", "E", "F"]
machine = WebMachine(
    states=states,
    initial="A",
    name="Simple Machine",
    ordered_transitions=True,
    ignore_invalid_triggers=True,
    auto_transitions=False,
)

try:
    while True:
        time.sleep(5)
        machine.next_state()
except KeyboardInterrupt:  # Ctrl + C will shutdown the machine
    machine.stop_server()
