-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'cpp_refactoring' into refactoring-dejan
- Loading branch information
Showing
9 changed files
with
1,022 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
162 changes: 162 additions & 0 deletions
162
rtamt/operation/stl/discrete_time/online/cpp/ast_visitor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
from rtamt.ast.visitor.stl.ast_visitor import StlAstVisitor | ||
|
||
from rtamt.enumerations.comp_op import StlComparisonOperator as CompOp | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_combinatorial_binary_node import CombinatorialBinaryOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_comp_op import StlComparisonOperator | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_not_node import NotOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_addition_node import AdditionOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_predicate_node import PredicateOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_multiplication_node import MultiplicationOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_subtraction_node import SubtractionOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_division_node import DivisionOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_and_node import AndOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_or_node import OrOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_implies_node import ImpliesOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_iff_node import IffOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_xor_node import XorOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_since_node import SinceOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_abs_node import AbsOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_rise_node import RiseOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_fall_node import FallOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_once_node import OnceOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_historically_node import HistoricallyOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_always_node import AlwaysOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_eventually_node import EventuallyOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_previous_node import PreviousOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_constant_node import ConstantOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_once_bounded_node import OnceBoundedOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_historically_bounded_node import HistoricallyBoundedOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_since_bounded_node import SinceBoundedOperation | ||
from rtamt.lib.rtamt_stl_library_wrapper.stl_precedes_bounded_node import PrecedesBoundedOperation | ||
|
||
from rtamt.exception.stl.exception import STLNotImplementedException, STLParseException | ||
|
||
|
||
class StlDiscreteTimeOnlineAstVisitorCpp(StlAstVisitor): | ||
|
||
def visitPredicate(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = PredicateOperation(node.operator) | ||
|
||
def visitAbs(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = AbsOperation() | ||
|
||
def visitAddition(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = AdditionOperation() | ||
|
||
def visitSubtraction(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = SubtractionOperation() | ||
|
||
def visitMultiplication(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = MultiplicationOperation() | ||
|
||
def visitDivision(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = DivisionOperation() | ||
|
||
def visitNot(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = NotOperation() | ||
|
||
def visitAnd(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = AndOperation() | ||
|
||
def visitOr(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = OrOperation() | ||
|
||
def visitImplies(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = ImpliesOperation() | ||
|
||
def visitIff(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = IffOperation() | ||
|
||
def visitXor(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = XorOperation() | ||
|
||
def visitEventually(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = EventuallyOperation() | ||
|
||
def visitAlways(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = AlwaysOperation() | ||
|
||
def visitUntil(self, node, *args, **kwargs): | ||
raise STLNotImplementedException('Until operator is not implemented in the STL online monitor.') | ||
|
||
def visitOnce(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = OnceOperation() | ||
|
||
def visitHistorically(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = HistoricallyOperation() | ||
|
||
def visitSince(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = SinceOperation() | ||
|
||
def visitRise(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = RiseOperation() | ||
|
||
def visitFall(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = FallOperation() | ||
|
||
def visitPrevious(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = PreviousOperation() | ||
|
||
def visitNext(self, node, *args, **kwargs): | ||
raise STLNotImplementedException('Next operator not implemented in STL online monitor.') | ||
|
||
def visitTimedPrecedes(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = PrecedesBoundedOperation(node.begin, node.end) | ||
|
||
def visitTimedOnce(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = OnceBoundedOperation(node.begin, node.end) | ||
|
||
def visitTimedHistorically(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = HistoricallyBoundedOperation(node.begin, node.end) | ||
|
||
def visitTimedSince(self, node, *args, **kwargs): | ||
self.visitChildren(node, *args, **kwargs) | ||
self.online_operator_dict[node.name] = SinceBoundedOperation(node.begin, node.end) | ||
|
||
def visitTimedAlways(self, node, *args, **kwargs): | ||
raise STLNotImplementedException('Bounded always operator not implemented in STL online monitor.') | ||
|
||
def visitTimedEventually(self, node, *args, **kwargs): | ||
raise STLNotImplementedException('Bounded eventually operator not implemented in STL online monitor.') | ||
|
||
def visitTimedUntil(self, node, *args, **kwargs): | ||
raise STLNotImplementedException('Bounded until operator not implemented in STL online monitor.') | ||
|
||
def op_cpp(self, op): | ||
if op == CompOp.GEQ: | ||
return StlComparisonOperator.GEQ | ||
elif op == CompOp.GREATER: | ||
return StlComparisonOperator.GREATER | ||
elif op == CompOp.LEQ: | ||
return StlComparisonOperator.LEQ | ||
elif op == CompOp.LESS: | ||
return StlComparisonOperator.LESS | ||
elif op == CompOp.NEQ: | ||
return StlComparisonOperator.NEQ | ||
elif op == CompOp.EQUAL: | ||
return StlComparisonOperator.EQUAL | ||
else: | ||
raise STLParseException('Could not find operator {}!'.format(op)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from rtamt.operation.stl.discrete_time.online.cpp.ast_visitor import StlDiscreteTimeOnlineAstVisitorCpp | ||
from rtamt.operation.abstract_discrete_time_online_evaluator import discrete_time_online_evaluator_factory | ||
|
||
def StlDiscreteTimeOnlineEvaluatorCpp(): | ||
stlDiscreteTimeOnlineEvaluatorCpp = discrete_time_online_evaluator_factory(StlDiscreteTimeOnlineAstVisitorCpp)() | ||
return stlDiscreteTimeOnlineEvaluatorCpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.