def visitExprPredicate(self, ctx):
        child1 = self.visit(ctx.expression(0))
        child2 = self.visit(ctx.expression(1))
        op_type = self.str_to_op_type(ctx.comparisonOp().getText())
        node = Predicate(child1, child2, op_type)

        node.horizon = int(0)
        return node
示例#2
0
    def test_predicate_neq(self):
        var_node_1 = Variable('req', '', 'output')
        var_node_2 = Variable('gnt', '', 'output')
        node = Predicate(var_node_1, var_node_2, StlComparisonOperator.NEQ)

        pastifier = STLPastifier()
        node.accept(pastifier)
        new_node = pastifier.pastify(node)

        self.assertEqual('(req)!=(gnt)', new_node.name, 'Predicate NEQ pastification assertion')
示例#3
0
    def test_predicate_leq_2(self):
        var_node_1 = Variable('req', '', 'output')
        var_node_2 = Variable('gnt', '', 'output')
        node = Predicate(var_node_1, var_node_2, StlComparisonOperator.LEQ)
        node.horizon = 5

        pastifier = STLPastifier()
        node.accept(pastifier)
        new_node = pastifier.pastify(node)

        self.assertEqual('(once[5,5](req))<=(once[5,5](gnt))', new_node.name, 'Predicate LEQ pastification assertion')
示例#4
0
    def test_complex_bounded_future_1(self):
        var_node_1 = Variable('req', '', 'output')
        var_node_2 = Variable('gnt', '', 'output')
        cnt_node_1 = Constant(3)
        cnt_node_2 = Constant(3)
        pd_node_1 = Predicate(var_node_1, cnt_node_1, StlComparisonOperator.GEQ)
        pd_node_2 = Predicate(var_node_2, cnt_node_2, StlComparisonOperator.GEQ)
        rise_node = Rise(pd_node_1)
        hist_node = TimedAlways(pd_node_2, 3, 4)
        once_node = TimedEventually(hist_node, 1, 2)
        add_node = Implies(rise_node, once_node)
        add_node.horizon = 6

        pastifier = STLPastifier()
        add_node.accept(pastifier)
        new_node = pastifier.pastify(add_node)

        self.assertEqual('(rise((once[6,6](req))>=(3)))->(once[0,1](historically[0,1]((gnt)>=(3))))', new_node.name, 'Complex pastification assertion')
示例#5
0
 def visitPredicate(self, element, args):
     child1_node = self.visit(element.children[0], args)
     child2_node = self.visit(element.children[1], args)
     node = Predicate(child1_node, child2_node, element.operator)
     return node