""" Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration) Date: Thu Sep 07 09:33:21 2017 Model author: Yentl Van Tendeloo Model name: Testing Model description: Testing """ from sccd.runtime.statecharts_core import * # package "Testing" class Testing(RuntimeClassBase): def __init__(self, controller): RuntimeClassBase.__init__(self, controller) self.semantics.big_step_maximality = StatechartSemantics.TakeMany self.semantics.internal_event_lifeline = StatechartSemantics.Queue self.semantics.input_event_lifeline = StatechartSemantics.FirstComboStep self.semantics.priority = StatechartSemantics.SourceParent self.semantics.concurrency = StatechartSemantics.Single # build Statechart structure self.build_statechart_structure() # call user defined constructor Testing.user_defined_constructor(self) def user_defined_constructor(self): pass def user_defined_destructor(self): pass # builds Statechart structure def build_statechart_structure(self): # state self.states[""] = State(0, "", self) # state /A self.states["/A"] = ParallelState(1, "/A", self) # state /A/B self.states["/A/B"] = State(2, "/A/B", self) # state /A/B/C self.states["/A/B/C"] = State(3, "/A/B/C", self) self.states["/A/B/C"].setEnter(self._A_B_C_enter) # state /A/D self.states["/A/D"] = State(4, "/A/D", self) # state /A/D/E self.states["/A/D/E"] = State(5, "/A/D/E", self) # add children self.states[""].addChild(self.states["/A"]) self.states["/A"].addChild(self.states["/A/B"]) self.states["/A"].addChild(self.states["/A/D"]) self.states["/A/B"].addChild(self.states["/A/B/C"]) self.states["/A/D"].addChild(self.states["/A/D/E"]) self.states[""].fixTree() self.states[""].default_state = self.states["/A"] self.states["/A/B"].default_state = self.states["/A/B/C"] self.states["/A/D"].default_state = self.states["/A/D/E"] # transition /A/D/E _A_D_E_0 = Transition(self, self.states["/A/D/E"], [self.states["/A/D/E"]]) _A_D_E_0.setAction(self._A_D_E_0_exec) _A_D_E_0.setTrigger(Event("Z", None)) self.states["/A/D/E"].addTransition(_A_D_E_0) def _A_B_C_enter(self): self.raiseInternalEvent(Event("Z", None, [])) def _A_D_E_0_exec(self, parameters): self.big_step.outputEventOM(Event("broad_cast", None, [self, Event("Z", None, [])])) print("Transition fired!") def initializeStatechart(self): # enter default state self.default_targets = self.states["/A"].getEffectiveTargetStates() RuntimeClassBase.initializeStatechart(self) class ObjectManager(ObjectManagerBase): def __init__(self, controller): ObjectManagerBase.__init__(self, controller) def instantiate(self, class_name, construct_params): if class_name == "Testing": instance = Testing(self.controller) instance.associations = {} else: raise Exception("Cannot instantiate class " + class_name) return instance class Controller(ThreadsControllerBase): def __init__(self, keep_running = None, behind_schedule_callback = None): if keep_running == None: keep_running = True if behind_schedule_callback == None: behind_schedule_callback = None ThreadsControllerBase.__init__(self, ObjectManager(self), keep_running, behind_schedule_callback) self.object_manager.createInstance("Testing", [])