From 52b2c06a3faba7f140bf1044f8a926798c286482 Mon Sep 17 00:00:00 2001 From: Marco Lampacrescia <65171491+MarcoLm993@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:29:33 +0200 Subject: [PATCH] Switch to agreed scxml and bt format (#16) Signed-off-by: Marco Lampacrescia --- .../scxml_helpers/scxml_tags.py | 15 ++- .../battery_example/battery_drainer.scxml | 2 +- .../battery_example/battery_manager.scxml | 2 +- .../events_sync_examples/receiver.scxml | 4 +- .../events_sync_examples/sender.scxml | 4 +- .../receiver.scxml | 2 +- .../sender_a.scxml | 2 +- .../sender_b.scxml | 2 +- .../ros_example/battery_drainer.scxml | 2 +- .../ros_example/battery_manager.scxml | 2 +- .../ros_example_w_bt/battery_drainer.scxml | 2 +- .../ros_example_w_bt/battery_manager.scxml | 2 +- .../test/_test_data/ros_example_w_bt/bt.xml | 4 +- .../ros_example_w_bt/bt_topic_condition.scxml | 2 +- .../src/scxml_converter/bt_converter.py | 5 +- .../scxml_converter/scxml_entries/__init__.py | 1 + .../scxml_entries/scxml_data.py | 120 ++++++++++++++++++ .../scxml_entries/scxml_data_model.py | 27 +--- .../scxml_entries/scxml_executable_entries.py | 8 +- .../scxml_entries/scxml_param.py | 6 +- .../10000_TopicCondition.scxml | 2 +- .../battery_drainer.scxml | 2 +- .../bt_topic_condition.scxml | 2 +- .../input_files/battery_drainer.scxml | 2 +- .../test/_test_data/input_files/bt.xml | 4 +- .../input_files/bt_topic_condition.scxml | 2 +- .../invalid_xmls/battery_drainer.scxml | 2 +- .../test/test_systemtest_scxml_entries.py | 10 +- 28 files changed, 175 insertions(+), 65 deletions(-) create mode 100644 scxml_converter/src/scxml_converter/scxml_entries/scxml_data.py diff --git a/jani_generator/src/jani_generator/scxml_helpers/scxml_tags.py b/jani_generator/src/jani_generator/scxml_helpers/scxml_tags.py index 297168dd..1d7e48b7 100644 --- a/jani_generator/src/jani_generator/scxml_helpers/scxml_tags.py +++ b/jani_generator/src/jani_generator/scxml_helpers/scxml_tags.py @@ -32,7 +32,7 @@ parse_ecmascript_to_jani_expression from as2fm_common.ecmascript_interpretation import \ interpret_ecma_script_expr -from scxml_converter.scxml_entries import (ScxmlAssign, ScxmlBase, +from scxml_converter.scxml_entries import (ScxmlAssign, ScxmlBase, ScxmlData, ScxmlDataModel, ScxmlExecutionBody, ScxmlIf, ScxmlRoot, ScxmlSend, ScxmlState, ScxmlTransition) @@ -284,14 +284,17 @@ def get_children(self) -> List[ScxmlBase]: return [] def write_model(self): - for name, expr in self.element.get_data_entries(): - assert expr is not None, f"No init value for {name}." + for scxml_data in self.element.get_data_entries(): + assert isinstance(scxml_data, ScxmlData), "Unexpected element in the DataModel." + assert scxml_data.check_validity(), "Found invalid data entry." # TODO: ScxmlData from scxml_helpers provide many more options. # It should be ported to scxml_entries.ScxmlDataModel - init_value = parse_ecmascript_to_jani_expression(expr) - expr_type = type(interpret_ecma_script_expr(expr)) + init_value = parse_ecmascript_to_jani_expression(scxml_data.get_expr()) + expr_type = type(interpret_ecma_script_expr(scxml_data.get_expr())) + assert expr_type == scxml_data.get_type(), \ + f"Expected type {scxml_data.get_type()}, got {expr_type}." self.automaton.add_variable( - JaniVariable(name, expr_type, init_value)) + JaniVariable(scxml_data.get_name(), scxml_data.get_type(), init_value)) class ScxmlTag(BaseTag): diff --git a/jani_generator/test/_test_data/battery_example/battery_drainer.scxml b/jani_generator/test/_test_data/battery_example/battery_drainer.scxml index 4896c740..13d3af94 100644 --- a/jani_generator/test/_test_data/battery_example/battery_drainer.scxml +++ b/jani_generator/test/_test_data/battery_example/battery_drainer.scxml @@ -7,7 +7,7 @@ xmlns="http://www.w3.org/2005/07/scxml"> - + diff --git a/jani_generator/test/_test_data/battery_example/battery_manager.scxml b/jani_generator/test/_test_data/battery_example/battery_manager.scxml index 13894fca..951f3bd8 100644 --- a/jani_generator/test/_test_data/battery_example/battery_manager.scxml +++ b/jani_generator/test/_test_data/battery_example/battery_manager.scxml @@ -7,7 +7,7 @@ xmlns="http://www.w3.org/2005/07/scxml"> - + diff --git a/jani_generator/test/_test_data/events_sync_examples/receiver.scxml b/jani_generator/test/_test_data/events_sync_examples/receiver.scxml index 5a3187ee..34a09a12 100644 --- a/jani_generator/test/_test_data/events_sync_examples/receiver.scxml +++ b/jani_generator/test/_test_data/events_sync_examples/receiver.scxml @@ -7,8 +7,8 @@ xmlns="http://www.w3.org/2005/07/scxml"> - - + + diff --git a/jani_generator/test/_test_data/events_sync_examples/sender.scxml b/jani_generator/test/_test_data/events_sync_examples/sender.scxml index 99e5aafd..f17b2070 100644 --- a/jani_generator/test/_test_data/events_sync_examples/sender.scxml +++ b/jani_generator/test/_test_data/events_sync_examples/sender.scxml @@ -7,8 +7,8 @@ xmlns="http://www.w3.org/2005/07/scxml"> - - + + diff --git a/jani_generator/test/_test_data/multiple_senders_same_event/receiver.scxml b/jani_generator/test/_test_data/multiple_senders_same_event/receiver.scxml index df9ef4bd..098d527d 100644 --- a/jani_generator/test/_test_data/multiple_senders_same_event/receiver.scxml +++ b/jani_generator/test/_test_data/multiple_senders_same_event/receiver.scxml @@ -7,7 +7,7 @@ xmlns="http://www.w3.org/2005/07/scxml"> - + diff --git a/jani_generator/test/_test_data/multiple_senders_same_event/sender_a.scxml b/jani_generator/test/_test_data/multiple_senders_same_event/sender_a.scxml index ad3fdd0b..bd89e1ca 100644 --- a/jani_generator/test/_test_data/multiple_senders_same_event/sender_a.scxml +++ b/jani_generator/test/_test_data/multiple_senders_same_event/sender_a.scxml @@ -7,7 +7,7 @@ xmlns="http://www.w3.org/2005/07/scxml"> - + diff --git a/jani_generator/test/_test_data/multiple_senders_same_event/sender_b.scxml b/jani_generator/test/_test_data/multiple_senders_same_event/sender_b.scxml index 4835cd68..a776aaaf 100644 --- a/jani_generator/test/_test_data/multiple_senders_same_event/sender_b.scxml +++ b/jani_generator/test/_test_data/multiple_senders_same_event/sender_b.scxml @@ -7,7 +7,7 @@ xmlns="http://www.w3.org/2005/07/scxml"> - + diff --git a/jani_generator/test/_test_data/ros_example/battery_drainer.scxml b/jani_generator/test/_test_data/ros_example/battery_drainer.scxml index 9b99fa22..0ab2c430 100644 --- a/jani_generator/test/_test_data/ros_example/battery_drainer.scxml +++ b/jani_generator/test/_test_data/ros_example/battery_drainer.scxml @@ -7,7 +7,7 @@ xmlns="http://www.w3.org/2005/07/scxml"> - + diff --git a/jani_generator/test/_test_data/ros_example/battery_manager.scxml b/jani_generator/test/_test_data/ros_example/battery_manager.scxml index c285245f..d350b6bd 100644 --- a/jani_generator/test/_test_data/ros_example/battery_manager.scxml +++ b/jani_generator/test/_test_data/ros_example/battery_manager.scxml @@ -7,7 +7,7 @@ xmlns="http://www.w3.org/2005/07/scxml"> - + diff --git a/jani_generator/test/_test_data/ros_example_w_bt/battery_drainer.scxml b/jani_generator/test/_test_data/ros_example_w_bt/battery_drainer.scxml index ed8acf51..d8aee8fb 100644 --- a/jani_generator/test/_test_data/ros_example_w_bt/battery_drainer.scxml +++ b/jani_generator/test/_test_data/ros_example_w_bt/battery_drainer.scxml @@ -7,7 +7,7 @@ xmlns="http://www.w3.org/2005/07/scxml"> - + diff --git a/jani_generator/test/_test_data/ros_example_w_bt/battery_manager.scxml b/jani_generator/test/_test_data/ros_example_w_bt/battery_manager.scxml index 668ab31e..08bc007a 100644 --- a/jani_generator/test/_test_data/ros_example_w_bt/battery_manager.scxml +++ b/jani_generator/test/_test_data/ros_example_w_bt/battery_manager.scxml @@ -7,7 +7,7 @@ xmlns="http://www.w3.org/2005/07/scxml"> - + diff --git a/jani_generator/test/_test_data/ros_example_w_bt/bt.xml b/jani_generator/test/_test_data/ros_example_w_bt/bt.xml index 5d5d2474..8e3434ce 100644 --- a/jani_generator/test/_test_data/ros_example_w_bt/bt.xml +++ b/jani_generator/test/_test_data/ros_example_w_bt/bt.xml @@ -1,8 +1,8 @@ - - + + \ No newline at end of file diff --git a/jani_generator/test/_test_data/ros_example_w_bt/bt_topic_condition.scxml b/jani_generator/test/_test_data/ros_example_w_bt/bt_topic_condition.scxml index 7173cf23..6c5bd625 100644 --- a/jani_generator/test/_test_data/ros_example_w_bt/bt_topic_condition.scxml +++ b/jani_generator/test/_test_data/ros_example_w_bt/bt_topic_condition.scxml @@ -7,7 +7,7 @@ xmlns="http://www.w3.org/2005/07/scxml"> - + diff --git a/scxml_converter/src/scxml_converter/bt_converter.py b/scxml_converter/src/scxml_converter/bt_converter.py index dc12c6af..369d25f9 100644 --- a/scxml_converter/src/scxml_converter/bt_converter.py +++ b/scxml_converter/src/scxml_converter/bt_converter.py @@ -24,7 +24,6 @@ from enum import Enum, auto from typing import List -import networkx as nx from btlib.bt_to_fsm.bt_to_fsm import Bt2FSM from btlib.bts import xml_to_networkx from btlib.common import NODE_CAT @@ -87,8 +86,8 @@ def bt_converter( assert 'category' in bt_graph.nodes[node], 'Node must have a category.' if bt_graph.nodes[node]['category'] == NODE_CAT.LEAF: leaf_node_ids.append(node) - assert 'NAME' in bt_graph.nodes[node], 'Leaf node must have a type.' - node_type = bt_graph.nodes[node]['NAME'] + assert 'ID' in bt_graph.nodes[node], 'Leaf node must have a type.' + node_type = bt_graph.nodes[node]['ID'] node_id = node assert node_type in bt_plugins_scxml, \ f'Leaf node must have a plugin. {node_type} not found.' diff --git a/scxml_converter/src/scxml_converter/scxml_entries/__init__.py b/scxml_converter/src/scxml_converter/scxml_entries/__init__.py index e1044311..50c4ad3a 100644 --- a/scxml_converter/src/scxml_converter/scxml_entries/__init__.py +++ b/scxml_converter/src/scxml_converter/scxml_entries/__init__.py @@ -1,5 +1,6 @@ from .scxml_base import ScxmlBase # noqa: F401 from .utils import HelperRosDeclarations # noqa: F401 +from .scxml_data import ScxmlData # noqa: F401 from .scxml_data_model import ScxmlDataModel # noqa: F401 from .scxml_param import ScxmlParam # noqa: F401 from .scxml_executable_entries import ScxmlAssign, ScxmlIf, ScxmlSend # noqa: F401 diff --git a/scxml_converter/src/scxml_converter/scxml_entries/scxml_data.py b/scxml_converter/src/scxml_converter/scxml_entries/scxml_data.py new file mode 100644 index 00000000..2c509fdd --- /dev/null +++ b/scxml_converter/src/scxml_converter/scxml_entries/scxml_data.py @@ -0,0 +1,120 @@ +# Copyright (c) 2024 - for information on the respective copyright owner +# see the NOTICE file + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Container for a single variable definition in SCXML. In XML, it has the tag `data`. +""" + +from typing import Any +from scxml_converter.scxml_entries import ScxmlBase + +from xml.etree import ElementTree as ET + + +# TODO: add lower and upper bounds depending on the n. of bits used. +# TODO: add support to uint +SCXML_DATA_MAPPING = { + "bool": bool, + "float32": float, + "float64": float, + "int8": int, + "int16": int, + "int32": int, + "int64": int +} + + +class ScxmlData(ScxmlBase): + """This class represents the variables defined in the model.""" + + @staticmethod + def get_tag_name() -> str: + return "data" + + @staticmethod + def from_xml_tree(xml_tree: ET.Element) -> "ScxmlData": + """Create a ScxmlData object from an XML tree.""" + assert xml_tree.tag == ScxmlData.get_tag_name(), \ + f"Error: SCXML data: XML tag name is not {ScxmlData.get_tag_name()}." + data_id = xml_tree.attrib.get("id") + assert data_id is not None, "Error: SCXML data: 'id' not found." + data_expr = xml_tree.attrib.get("expr") + assert data_expr is not None, "Error: SCXML data: 'expr' not found." + data_type = xml_tree.attrib.get("type") + assert data_type is not None, "Error: SCXML data: 'type' not found." + lower_bound = xml_tree.attrib.get("lower_bound_incl", None) + upper_bound = xml_tree.attrib.get("upper_bound_incl", None) + return ScxmlData(data_id, data_expr, data_type, lower_bound, upper_bound) + + def __init__( + self, id: str, expr: str, data_type: str, + lower_bound: Any = None, upper_bound: Any = None): + self._id = id + self._expr = expr + self._data_type = data_type + self._lower_bound = lower_bound + self._upper_bound = upper_bound + + def get_name(self) -> str: + return self._id + + def get_type(self) -> type: + return SCXML_DATA_MAPPING[self._data_type] + + def get_expr(self) -> str: + return self._expr + + def check_validity(self) -> bool: + validity = True + # ID + if not (isinstance(self._id, str) and len(self._id) > 0): + print(f"Error: SCXML data: 'id' {self._id} is not valid.") + validity = False + # Expression + if not (isinstance(self._expr, str) and len(self._expr) > 0): + print(f"Error: SCXML data: 'expr' {self._expr} is not valid.") + validity = False + # Data type + if not (isinstance(self._data_type, str) and self._data_type in SCXML_DATA_MAPPING): + print(f"Error: SCXML data: 'type' {self._data_type} is not valid.") + validity = False + type_of_data = SCXML_DATA_MAPPING[self._data_type] + # Lower bound + if self._lower_bound is not None: + if not isinstance(self._lower_bound, type_of_data): + print(f"Error: SCXML data: 'lower_bound_incl' type {self._lower_bound} is invalid.") + validity = False + # Upper bound + if self._upper_bound is not None: + if not isinstance(self._upper_bound, type_of_data): + print(f"Error: SCXML data: 'upper_bound_incl' type {self._upper_bound} is invalid.") + validity = False + # Check if lower bound is smaller than upper bound + if validity and self._upper_bound is not None and self._lower_bound is not None: + if self._lower_bound >= self._upper_bound: + print(f"Error: SCXML data: 'lower_bound_incl' {self._lower_bound} is not smaller " + f"than 'upper_bound_incl' {self._upper_bound}.") + validity = False + return validity + + def as_xml(self) -> ET.Element: + assert self.check_validity(), "SCXML: found invalid data object." + xml_data = ET.Element(ScxmlData.get_tag_name(), + {"id": self._id, "expr": self._expr, "type": self._data_type}) + if self._lower_bound is not None: + xml_data.set("lower_bound_incl", str(self._lower_bound_incl)) + if self._upper_bound is not None: + xml_data.set("upper_bound_incl", str(self._upper_bound)) + return xml_data diff --git a/scxml_converter/src/scxml_converter/scxml_entries/scxml_data_model.py b/scxml_converter/src/scxml_converter/scxml_entries/scxml_data_model.py index 69821125..654c288e 100644 --- a/scxml_converter/src/scxml_converter/scxml_entries/scxml_data_model.py +++ b/scxml_converter/src/scxml_converter/scxml_entries/scxml_data_model.py @@ -17,15 +17,12 @@ Container for the variables defined in the SCXML model. In XML, it has the tag `datamodel`. """ -from scxml_converter.scxml_entries import ScxmlBase +from scxml_converter.scxml_entries import ScxmlBase, ScxmlData -from typing import List, Optional, Tuple +from typing import List, Optional from xml.etree import ElementTree as ET -# Tuple with the variable name and, if set, the expression for the init value -ScxmlData = Tuple[str, Optional[str]] - class ScxmlDataModel(ScxmlBase): """This class represents the variables defined in the model.""" @@ -47,10 +44,7 @@ def from_xml_tree(xml_tree: ET.Element) -> "ScxmlDataModel": assert data_entries_xml is not None, "Error: SCXML datamodel: No data entries found." data_entries = [] for data_entry_xml in data_entries_xml: - name = data_entry_xml.attrib.get("id") - assert name is not None, "Error: SCXML datamodel: 'id' not found for data entry." - expr = data_entry_xml.attrib.get("expr", None) - data_entries.append((name, expr)) + data_entries.append(ScxmlData.from_xml_tree(data_entry_xml)) return ScxmlDataModel(data_entries) def check_validity(self) -> bool: @@ -59,16 +53,11 @@ def check_validity(self) -> bool: valid_data_entries = isinstance(self._data_entries, list) if valid_data_entries: for data_entry in self._data_entries: - valid_data_entry = isinstance(data_entry, tuple) and len(data_entry) == 2 + valid_data_entry = isinstance(data_entry, ScxmlData) and \ + data_entry.check_validity() if not valid_data_entry: valid_data_entries = False break - name, expr = data_entry - valid_name = isinstance(name, str) and len(name) > 0 - valid_expr = expr is None or isinstance(expr, str) - if not valid_name or not valid_expr: - valid_data_entries = False - break if not valid_data_entries: print("Error: SCXML datamodel: data entries are not valid.") return valid_data_entries @@ -79,9 +68,5 @@ def as_xml(self) -> Optional[ET.Element]: return None xml_datamodel = ET.Element(ScxmlDataModel.get_tag_name()) for data_entry in self._data_entries: - name, expr = data_entry - xml_data = ET.Element("data", {"id": name}) - if expr is not None: - xml_data.set("expr", expr) - xml_datamodel.append(xml_data) + xml_datamodel.append(data_entry.as_xml()) return xml_datamodel diff --git a/scxml_converter/src/scxml_converter/scxml_entries/scxml_executable_entries.py b/scxml_converter/src/scxml_converter/scxml_entries/scxml_executable_entries.py index 2801e8c2..073882a8 100644 --- a/scxml_converter/src/scxml_converter/scxml_entries/scxml_executable_entries.py +++ b/scxml_converter/src/scxml_converter/scxml_entries/scxml_executable_entries.py @@ -47,11 +47,11 @@ def __init__(self, def get_tag_name() -> str: return "if" - + def get_conditional_executions(self) -> List[ConditionalExecutionBody]: """Get the conditional executions.""" return self._conditional_executions - + def get_else_execution(self) -> Optional[ScxmlExecutionBody]: """Get the else execution.""" return self._else_execution @@ -215,11 +215,11 @@ def __init__(self, location: str, expr: str): def get_tag_name() -> str: return "assign" - + def get_location(self) -> str: """Get the location to assign.""" return self._location - + def get_expr(self) -> str: """Get the expression to assign.""" return self._expr diff --git a/scxml_converter/src/scxml_converter/scxml_entries/scxml_param.py b/scxml_converter/src/scxml_converter/scxml_entries/scxml_param.py index 0ad9f245..0af93d62 100644 --- a/scxml_converter/src/scxml_converter/scxml_entries/scxml_param.py +++ b/scxml_converter/src/scxml_converter/scxml_entries/scxml_param.py @@ -34,13 +34,13 @@ def __init__(self, name: str, *, expr: Optional[str] = None, location: Optional[ def get_tag_name() -> str: return "param" - + def get_name(self) -> str: return self._name - + def get_expr(self) -> Optional[str]: return self._expr - + def get_location(self) -> Optional[str]: return self._location diff --git a/scxml_converter/test/_test_data/expected_output_bt_and_plugins/10000_TopicCondition.scxml b/scxml_converter/test/_test_data/expected_output_bt_and_plugins/10000_TopicCondition.scxml index ec249671..f458bfc9 100644 --- a/scxml_converter/test/_test_data/expected_output_bt_and_plugins/10000_TopicCondition.scxml +++ b/scxml_converter/test/_test_data/expected_output_bt_and_plugins/10000_TopicCondition.scxml @@ -7,7 +7,7 @@ xmlns="http://www.w3.org/2005/07/scxml"> - + diff --git a/scxml_converter/test/_test_data/expected_output_ros_to_scxml/battery_drainer.scxml b/scxml_converter/test/_test_data/expected_output_ros_to_scxml/battery_drainer.scxml index c1dbaac3..3ce31988 100644 --- a/scxml_converter/test/_test_data/expected_output_ros_to_scxml/battery_drainer.scxml +++ b/scxml_converter/test/_test_data/expected_output_ros_to_scxml/battery_drainer.scxml @@ -7,7 +7,7 @@ xmlns="http://www.w3.org/2005/07/scxml"> - + diff --git a/scxml_converter/test/_test_data/expected_output_ros_to_scxml/bt_topic_condition.scxml b/scxml_converter/test/_test_data/expected_output_ros_to_scxml/bt_topic_condition.scxml index 10fe8354..e81ee036 100644 --- a/scxml_converter/test/_test_data/expected_output_ros_to_scxml/bt_topic_condition.scxml +++ b/scxml_converter/test/_test_data/expected_output_ros_to_scxml/bt_topic_condition.scxml @@ -1,7 +1,7 @@ - + diff --git a/scxml_converter/test/_test_data/input_files/battery_drainer.scxml b/scxml_converter/test/_test_data/input_files/battery_drainer.scxml index b0da1361..f38f1ff2 100644 --- a/scxml_converter/test/_test_data/input_files/battery_drainer.scxml +++ b/scxml_converter/test/_test_data/input_files/battery_drainer.scxml @@ -7,7 +7,7 @@ xmlns="http://www.w3.org/2005/07/scxml"> - + diff --git a/scxml_converter/test/_test_data/input_files/bt.xml b/scxml_converter/test/_test_data/input_files/bt.xml index b3a740e1..2a4cb98b 100644 --- a/scxml_converter/test/_test_data/input_files/bt.xml +++ b/scxml_converter/test/_test_data/input_files/bt.xml @@ -2,9 +2,9 @@ - + - + \ No newline at end of file diff --git a/scxml_converter/test/_test_data/input_files/bt_topic_condition.scxml b/scxml_converter/test/_test_data/input_files/bt_topic_condition.scxml index 71b8f251..4fa248cd 100644 --- a/scxml_converter/test/_test_data/input_files/bt_topic_condition.scxml +++ b/scxml_converter/test/_test_data/input_files/bt_topic_condition.scxml @@ -7,7 +7,7 @@ xmlns="http://www.w3.org/2005/07/scxml"> - + diff --git a/scxml_converter/test/_test_data/input_files/invalid_xmls/battery_drainer.scxml b/scxml_converter/test/_test_data/input_files/invalid_xmls/battery_drainer.scxml index ca82c5da..c46f6cd6 100644 --- a/scxml_converter/test/_test_data/input_files/invalid_xmls/battery_drainer.scxml +++ b/scxml_converter/test/_test_data/input_files/invalid_xmls/battery_drainer.scxml @@ -7,7 +7,7 @@ xmlns="http://www.w3.org/2005/07/scxml"> - + diff --git a/scxml_converter/test/test_systemtest_scxml_entries.py b/scxml_converter/test/test_systemtest_scxml_entries.py index 6e6b029a..82c25605 100644 --- a/scxml_converter/test/test_systemtest_scxml_entries.py +++ b/scxml_converter/test/test_systemtest_scxml_entries.py @@ -16,8 +16,8 @@ import os from xml.etree import ElementTree as ET -from scxml_converter.scxml_entries import (ScxmlAssign, ScxmlDataModel, ScxmlParam, ScxmlRoot, - ScxmlSend, ScxmlState, ScxmlTransition, +from scxml_converter.scxml_entries import (ScxmlAssign, ScxmlData, ScxmlDataModel, ScxmlParam, + ScxmlRoot, ScxmlSend, ScxmlState, ScxmlTransition, RosTimeRate, RosTopicPublisher, RosTopicSubscriber, RosRateCallback, RosTopicPublish, RosTopicCallback, RosField) @@ -47,7 +47,8 @@ def test_battery_drainer_from_code(): - assign """ battery_drainer_scxml = ScxmlRoot("BatteryDrainer") - battery_drainer_scxml.set_data_model(ScxmlDataModel([("battery_percent", "100")])) + battery_drainer_scxml.set_data_model(ScxmlDataModel([ + ScxmlData("battery_percent", "100", "int16")])) use_battery_state = ScxmlState( "use_battery", on_entry=[ScxmlSend("ros_topic.level", @@ -95,7 +96,8 @@ def test_battery_drainer_ros_from_code(): - assign """ battery_drainer_scxml = ScxmlRoot("BatteryDrainer") - battery_drainer_scxml.set_data_model(ScxmlDataModel([("battery_percent", "100")])) + battery_drainer_scxml.set_data_model(ScxmlDataModel([ + ScxmlData("battery_percent", "100", "int16")])) ros_topic_sub = RosTopicSubscriber("charge", "std_msgs/Empty") ros_topic_pub = RosTopicPublisher("level", "std_msgs/Int32") ros_timer = RosTimeRate("my_timer", 1)