Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add missing fields in plain scxml #63

Merged
merged 14 commits into from
Oct 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add method to retrieve all events received by an automaton in plain s…
…cxml

Signed-off-by: Marco Lampacrescia <marco.lampacrescia@de.bosch.com>
MarcoLm993 committed Oct 25, 2024
commit d2dfab583ac12ac27b4bf26eddb611006ce64a99
11 changes: 9 additions & 2 deletions src/as2fm/jani_generator/scxml_helpers/top_level_interpreter.py
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@
import os
from copy import deepcopy
from dataclasses import dataclass, field
from typing import Dict, List, Optional, Tuple
from typing import Dict, List, Optional, Set, Tuple

import lxml.etree as ET

@@ -207,7 +207,14 @@ def export_plain_scxml_models(
global_timer_scxml = make_global_timer_scxml(all_timers, max_time)
if global_timer_scxml is not None:
models_to_export.append(global_timer_scxml)
# Compute the targets
# Compute the set of target automaton for each event
event_targets: Dict[str, Set[str]] = {}
for scxml_model in models_to_export:
for event in scxml_model.get_transition_events():
if event not in event_targets:
event_targets[event] = set()
event_targets[event].add(scxml_model.get_name())
# Add the target automaton to each event sent
# TODO
# Export the models
for scxml_model in models_to_export:
14 changes: 13 additions & 1 deletion src/as2fm/scxml_converter/scxml_entries/scxml_root.py
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@

from copy import deepcopy
from os.path import isfile
from typing import List, Optional, Tuple, get_args
from typing import List, Optional, Set, Tuple, get_args

from lxml import etree as ET

@@ -149,6 +149,18 @@ def get_data_model(self) -> Optional[ScxmlDataModel]:
def get_states(self) -> List[ScxmlState]:
return self._states

def get_transition_events(self) -> Set[str]:
"""Generate the set of events that are expected by the SCXML automaton."""
assert self.is_plain_scxml(), (
f"Error: SCXML root: {self.get_name()} must be plain SCXML "
"for generating the list of transition events."
)
transition_events = set()
for state in self._states:
for transition in state.get_body():
transition_events.update({ev for ev in transition.get_events()})
return transition_events

def get_state_by_id(self, state_id: str) -> Optional[ScxmlState]:
for state in self._states:
if state.get_id() == state_id: