Closed xiaohuihui1024 closed 4 years ago
The behavior I desired is: the graph can show the internal transitions defined in the substate, and in addition the go
transitions above can be displayed in parallel.
Hi @xiaohuihui1024,
thank you for the report and your test case. Transitions should be shown regardless where they originate and where they are going. I guess that edges are currently not correctly collected for the new HSM version. I will have a look and report back!
The error you have found has been fixed. I also improved the layout of parallel states a bit. However, parallel state/transition support is still work in progress. Only the last transition can be shown at the moment. Since machine.go()
triggers actually two independent transitions, only the last one (2_z -> 2_x) is shown.
from transitions.extensions.factory import HierarchicalGraphMachine as Machine
import logging
states = ['A', 'B', {'name': 'C', 'parallel': [{'name': '1', 'children': ['a', 'b', 'c'], 'initial': 'a',
'transitions': [['go', 'a', 'b']]},
{'name': '2', 'children': ['x', 'y', 'z'], 'initial': 'z'}],
'transitions': [['go', '2_z', '2_x']]}]
transitions = [['reset', 'C_1_b', 'B'], ['start', 'A', 'C']]
logging.basicConfig(level=logging.INFO)
Machine.hierarchical_machine_attributes['ranksep'] = '0.3' # shorter edges
extra_args = dict(show_conditions=True, show_state_attributes=True, use_pygraphviz=False)
machine = Machine(states=states, transitions=transitions, initial='A', **extra_args)
machine.start()
machine.get_graph().draw('diagram_01.png', prog='dot')
machine.go()
machine.get_graph().draw('diagram_02.png', prog='dot')
I will close this issue for now but please do not hestitate to comment if you find further problems with diagrams or (py)graphviz. I will reopen the issue if necessary.
Using: Windows 10 64 bit Python 3.7.4 (Anaconda) transitions 0.8.0 Graphviz 2.38.0 (binary) graphviz 0.13.2 (python package)
The following code is from
README.md
and changesHierarchicalMachine
toHierarchicalGraphMachine
because I want to visualize parallel HSMThis produces the graph like this:
Note: The transition from
C_1_a
toC_1_b
is not shown, but it is defined instates
then I try the following triggers:
It can be found from the log output that
C_1_a
->C_1_b
did occur, but it cannot be displayed in the graph.Changing the
states
definition in the above code to the following also happens.Is this expected behavior ?