diff --git a/scenario_execution/scenario_execution/model/model_to_py_tree.py b/scenario_execution/scenario_execution/model/model_to_py_tree.py index 9cce0282..f5a0074a 100644 --- a/scenario_execution/scenario_execution/model/model_to_py_tree.py +++ b/scenario_execution/scenario_execution/model/model_to_py_tree.py @@ -20,7 +20,7 @@ from pkg_resources import iter_entry_points import inspect -from scenario_execution.model.types import visit_expression, ActionDeclaration, BinaryExpression, EventReference, Expression, FunctionApplicationExpression, ModifierInvocation, ScenarioDeclaration, DoMember, WaitDirective, EmitDirective, BehaviorInvocation, EventCondition, EventDeclaration, RelationExpression, LogicalExpression, ElapsedExpression, PhysicalLiteral, ModifierDeclaration +from scenario_execution.model.types import KeepConstraintDeclaration, visit_expression, ActionDeclaration, BinaryExpression, EventReference, Expression, FunctionApplicationExpression, ModifierInvocation, ScenarioDeclaration, DoMember, WaitDirective, EmitDirective, BehaviorInvocation, EventCondition, EventDeclaration, RelationExpression, LogicalExpression, ElapsedExpression, PhysicalLiteral, ModifierDeclaration from scenario_execution.model.model_base_visitor import ModelBaseVisitor from scenario_execution.model.error import OSC2ParsingError from scenario_execution.actions.base_action import BaseAction @@ -409,3 +409,7 @@ def visit_modifier_invocation(self, node: ModifierInvocation): self.create_decorator(node.modifier, resolved_values) except ValueError as e: raise OSC2ParsingError(msg=f'ModifierDeclaration {e}.', context=node.get_ctx()) from e + + def visit_keep_constraint_declaration(self, node: KeepConstraintDeclaration): + # skip relation-expression + pass diff --git a/scenario_execution/scenario_execution/model/types.py b/scenario_execution/scenario_execution/model/types.py index 65c38ddc..9903e826 100644 --- a/scenario_execution/scenario_execution/model/types.py +++ b/scenario_execution/scenario_execution/model/types.py @@ -341,6 +341,8 @@ def get_value_child(self): for child in self.get_children(): if isinstance(child, (StringLiteral, FloatLiteral, BoolLiteral, IntegerLiteral, FunctionApplicationExpression, IdentifierReference, PhysicalLiteral, EnumValueReference, ListExpression, BinaryExpression, RelationExpression, LogicalExpression)): return child + elif isinstance(child, KeepConstraintDeclaration): + pass elif not isinstance(child, Type): raise OSC2ParsingError(msg=f'Parameter has invalid value "{type(child).__name__}".', context=self.get_ctx()) return None @@ -451,7 +453,7 @@ def get_type_string(self): return self.name -class Expression(ModelElement): +class ModelExpression(ModelElement): pass @@ -1553,7 +1555,7 @@ def get_base_type(self): return self.modifier -class RiseExpression(Expression): +class RiseExpression(ModelExpression): def __init__(self): super().__init__() @@ -1573,7 +1575,7 @@ def accept(self, visitor): return visitor.visit_children(self) -class FallExpression(Expression): +class FallExpression(ModelExpression): def __init__(self): super().__init__() @@ -1593,7 +1595,7 @@ def accept(self, visitor): return visitor.visit_children(self) -class ElapsedExpression(Expression): +class ElapsedExpression(ModelExpression): def __init__(self): super().__init__() @@ -1613,7 +1615,7 @@ def accept(self, visitor): return visitor.visit_children(self) -class EveryExpression(Expression): +class EveryExpression(ModelExpression): def __init__(self): super().__init__() @@ -1633,7 +1635,7 @@ def accept(self, visitor): return visitor.visit_children(self) -class SampleExpression(Expression): +class SampleExpression(ModelExpression): def __init__(self): super().__init__() @@ -1653,7 +1655,7 @@ def accept(self, visitor): return visitor.visit_children(self) -class CastExpression(Expression): +class CastExpression(ModelExpression): def __init__(self, object_def, target_type): super().__init__() @@ -1675,7 +1677,7 @@ def accept(self, visitor): return visitor.visit_children(self) -class TypeTestExpression(Expression): +class TypeTestExpression(ModelExpression): def __init__(self, object_def, target_type): super().__init__() @@ -1697,7 +1699,7 @@ def accept(self, visitor): return visitor.visit_children(self) -class ElementAccessExpression(Expression): +class ElementAccessExpression(ModelExpression): def __init__(self, list_name, index): super().__init__() @@ -1719,7 +1721,7 @@ def accept(self, visitor): return visitor.visit_children(self) -class FunctionApplicationExpression(Expression): +class FunctionApplicationExpression(ModelExpression): def __init__(self, func_name): super().__init__() @@ -1779,7 +1781,7 @@ def get_type_string(self): return self.get_type()[0].name -class FieldAccessExpression(Expression): +class FieldAccessExpression(ModelExpression): def __init__(self, field_name): super().__init__() @@ -1800,7 +1802,7 @@ def accept(self, visitor): return visitor.visit_children(self) -class BinaryExpression(Expression): +class BinaryExpression(ModelExpression): def __init__(self, operator): super().__init__() @@ -1837,7 +1839,7 @@ def get_resolved_value(self, blackboard=None): return visit_expression(self, blackboard).eval() -class UnaryExpression(Expression): +class UnaryExpression(ModelExpression): def __init__(self, operator): super().__init__() @@ -1858,7 +1860,7 @@ def accept(self, visitor): return visitor.visit_children(self) -class TernaryExpression(Expression): +class TernaryExpression(ModelExpression): def __init__(self): super().__init__() @@ -1878,7 +1880,7 @@ def accept(self, visitor): return visitor.visit_children(self) -class LogicalExpression(Expression): +class LogicalExpression(ModelExpression): def __init__(self, operator): super().__init__() @@ -1905,7 +1907,7 @@ def get_resolved_value(self, blackboard=None): return visit_expression(self, blackboard).eval() -class RelationExpression(Expression): +class RelationExpression(ModelExpression): def __init__(self, operator): super().__init__() @@ -1932,7 +1934,7 @@ def get_resolved_value(self, blackboard=None): return visit_expression(self, blackboard).eval() -class ListExpression(Expression): +class ListExpression(ModelExpression): def __init__(self): super().__init__() @@ -1967,7 +1969,7 @@ def get_resolved_value(self, blackboard=None): return value -class RangeExpression(Expression): +class RangeExpression(ModelExpression): def __init__(self): super().__init__()