Пример #1
0
 def visitTimedEventually(self, element, args):
     horizon = args[0] - element.end
     node = self.visit(element.children[0], [horizon])
     begin = 0
     end = element.end - element.begin
     if end > 0:
         node = TimedOnce(node, begin, end)
     return node
Пример #2
0
 def visitExpreOnce(self, ctx):
     child = self.visit(ctx.expression())
     if ctx.interval() == None:
         node = Once(child)
     else:
         interval = self.visit(ctx.interval())
         node = TimedOnce(child, interval.begin, interval.end)
     node.horizon = child.horizon
     return node
Пример #3
0
    def test_complex_past_2(self):
        var_node_1 = Variable('req', '', 'output')
        var_node_2 = Variable('gnt', '', 'output')
        rise_node = Rise(var_node_1)
        hist_node = Historically(var_node_2)
        once_node = TimedOnce(hist_node, 1, 2)
        add_node = TimedSince(rise_node, once_node, 2, 6)
        add_node.horizon = 0

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

        self.assertEqual('(rise(req))since[2,6](once[1,2](historically(gnt)))', new_node.name, 'Complex pastification assertion')
Пример #4
0
    def test_complex_mixed_2(self):
        var_node_1 = Variable('req', '', 'output')
        var_node_2 = Variable('gnt', '', 'output')

        ev_node = TimedEventually(var_node_1, 5, 6)
        once_node = TimedOnce(var_node_2, 1, 2)
        alw_node = TimedAlways(once_node, 3, 3)
        add_node = Implies(ev_node, alw_node)
        add_node.horizon = 6

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

        self.assertEqual('(once[0,1](req))->(once[1,2](once[3,3](gnt)))', new_node.name, 'Complex pastification assertion')
Пример #5
0
    def test_once_0_1(self):
        var_node = Variable('req', '', 'output')
        node = TimedOnce(var_node, 0, 1)

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

        self.assertEqual('once[0,1](req)', new_node.name, 'Once pastification assertion')

        node.horizon = 5

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

        self.assertEqual('once[0,1](once[5,5](req))', new_node.name, 'Once pastification assertion')
Пример #6
0
 def visitTimedOnce(self, element, args):
     child_node = self.visit(element.children[0], args)
     node = TimedOnce(child_node, element.begin, element.end)
     return node
Пример #7
0
 def visitVariable(self, element, args):
     horizon = args[0]
     node = Variable(element.var, element.field, element.io_type)
     if horizon > 0:
         node = TimedOnce(node, horizon, horizon)
     return node