コード例 #1
0
 class TestEntity(crest.Entity):
     in_port = crest.Input(res, 12)
     in_port2 = crest.Input(res, 33)
     state = current = crest.State()
     other_state = crest.State()
     
     # the evaluation of the guard of these will be mocked anyway
     transA = crest.Transition(source=state, target=other_state, guard=(lambda self: True))
     transB = crest.Transition(source=state, target=other_state, guard=(lambda self: True))
コード例 #2
0
        class Test(crest.Entity):
            s1 = current = crest.State()
            s2 = crest.State()
            s3 = crest.State()

            @crest.transition(source=[s1, s3], target=s2)
            def t1(self):
                return True

            t2 = crest.Transition(source=s2,
                                  target=s3,
                                  guard=(lambda self: True))
            t3 = crest.Transition(source=[s3, s2],
                                  target=s1,
                                  guard=(lambda self: False))
コード例 #3
0
    def test_transition_correctly_created(self):
        self.testclass.trans = crest.Transition(source="A", target="B", guard=(lambda self: True))

        instance = self.instance()
        transitions = crest.get_transitions(instance)
        self.assertEqual(len(transitions), 1)
        self.assertEqual(self._count_transitions_from_to(transitions, instance.A, instance.B), 1)
コード例 #4
0
    def test_transitions_source_slash(self):
        self.testclass.trans = crest.Transition(source="/", target="A", guard=(lambda self: True))

        instance = self.instance()
        transitions = crest.get_transitions(instance)
        self.assertEqual(len(transitions), 2)
        self.assertEqual(self._count_transitions_from_to(transitions, instance.B, instance.A), 1)
        self.assertEqual(self._count_transitions_from_to(transitions, instance.C, instance.A), 1)
コード例 #5
0
ファイル: test_convenience.py プロジェクト: ieasydevops/CREST
        class TestEntity(crest.Entity):
            state = current = crest.State()
            second_state = crest.State()
            trans = crest.Transition(source=state,
                                     target=second_state,
                                     guard=(lambda self: True))

            def __init__(self):
                api.add(self, "second_state", crest.State())
コード例 #6
0
 class RootType(crest.Entity):
     stateA = current = crest.State()
     stateB = crest.State()
     
     inport = crest.Input(crest.Resource("watt", crest.REAL), 0)
     local = crest.Local(crest.Resource("watt", crest.REAL), 1234)
     local2 = crest.Local(crest.Resource("watt", crest.REAL), 1234)
     outport = crest.Output(crest.Resource("watt", crest.REAL), 3.14)
     
     trans = crest.Transition(source=stateA, target=stateB, guard=(lambda self: False))
     inf = crest.Influence(source=inport, target=local, function=(lambda value: value * 2 + 15))
     up = crest.Update(state=stateA, target=outport, function=(lambda self: 1337))
     action = crest.Action(transition=trans, target=local2, function=(lambda self: self.local2 + 1))
コード例 #7
0
ファイル: test_convenience.py プロジェクト: ieasydevops/CREST
        class TestEntity(crest.Entity):
            port_out = crest.Output(res, 987)
            state = current = crest.State()
            second_state = crest.State()
            transition = crest.Transition(source=state,
                                          target=second_state,
                                          guard=(lambda self: True))

            action = crest.Action(transition=transition,
                                  target=port_out,
                                  function=(lambda self: 12345))

            def __init__(self):
                api.add(self, "port_out", crest.Output(res, 7777))
コード例 #8
0
 class Subtype(self.basetype):
     trans = crest.Transition(source="stateA", target="stateB", guard=(lambda self: True))
コード例 #9
0
 class Subtype(self.basetype):
     newtransition = crest.Transition(source="stateA", target="stateB", guard=(lambda self: False))