class TestEntity(crest.Entity): sub = TestSubEntity() inf = crest.Influence(source=sub.out1, target=sub.in1) active = current = crest.State() inactive = crest.State() up_active = crest.Update(state=active, target=sub.in2, function=(lambda self, dt: 0)) up_inactive = crest.Update(state=inactive, target=sub.in2, function=(lambda self, dt: 0))
class TestEntity(crest.Entity): port_out = crest.Output(res, 987) state = current = crest.State() update = crest.Update(state=state, target=port_out, function=(lambda self: 12345)) def __init__(self): api.add(self, "port_out", crest.Output(res, 7777))
class TestEntity(crest.Entity): port_in = crest.Input(res, 1234) sub = SubEntity() state = current = crest.State() update = crest.Update(state=state, target=sub.sub_in, function=(lambda self: 12345)) def __init__(self): api.add(self, "sub", SubEntity())
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))
class Subtype(self.basetype): newupdate = crest.Update(state="stateA", target="local", function=(lambda self: 33))