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))
Example #2
0
        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))
 class Subtype(self.basetype):
     newaction = crest.Action(transition="trans", target="local", function=(lambda self: 33))