Skip to content

Commit

Permalink
Merge pull request #96 from Zinoex/feature/history_memory_arrow
Browse files Browse the repository at this point in the history
PlantUML: add arrow from history to initial memory
  • Loading branch information
AlexandreDecan authored Mar 27, 2020
2 parents f12050a + 9ceb319 commit e826951
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion sismic/io/plantuml.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re
import sys

from typing import Dict, List, Tuple, Optional
from typing import Dict, List, Tuple, Union
from ..io import import_from_yaml
from ..model import (
DeepHistoryState, FinalState, Transition, CompoundState,
Expand Down Expand Up @@ -170,6 +170,9 @@ def export_state(self, name: str) -> None:

self.export_transitions(name)

if isinstance(state, (ShallowHistoryState, DeepHistoryState)):
self.export_history_memory(state)

# Nested states
for i, child in enumerate(self.statechart.children_for(name)):
if i != 0 and isinstance(state, OrthogonalState):
Expand Down Expand Up @@ -226,6 +229,16 @@ def export_transition(self, transition: Transition) -> None:
text=''.join(text),
))

def export_history_memory(self, history_state: Union[ShallowHistoryState, DeepHistoryState]):
if history_state.memory:
target = self.statechart.state_for(history_state.memory)

self.output('{source} {arrow} {target}'.format(
source=self.state_id(history_state.name),
arrow=self.arrow(history_state, target),
target=self.state_id(target.name)
))

def export(self) -> str:
self.output('@startuml')

Expand Down

0 comments on commit e826951

Please sign in to comment.