Skip to content

Commit

Permalink
Add update state diagram script
Browse files Browse the repository at this point in the history
  • Loading branch information
oysand committed Feb 27, 2025
1 parent 46b7dd6 commit 8235c8b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/update_state_diagram.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import os
from pathlib import Path
from injector import Injector
from transitions.extensions import GraphMachine

from isar.modules import get_injector
from isar.state_machine.state_machine import StateMachine

if __name__ == "__main__":
injector: Injector = get_injector()
state_machine: StateMachine = injector.get(StateMachine)
machine = GraphMachine(states=state_machine.states, initial="off", queued=True)
machine.add_transitions(state_machine.transitions)
gp = machine.get_combined_graph()

state_machine_diagram_file = (
Path(__file__).parent.resolve().joinpath(Path("state_machine_diagram.png"))
)

os.remove(state_machine_diagram_file)

gp.draw(state_machine_diagram_file, prog="dot")

0 comments on commit 8235c8b

Please sign in to comment.