| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- """
- Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
- Date: Sun Oct 15 20:24:57 2017
- Model author: Simon Van Mierlo
- Model name: Translational Semantics Debugging Interface
- Model description:
- A debugging interface for a formalism with translational semantics.
- """
- from sccd.runtime.statecharts_core import *
- # package "Translational Semantics Debugging Interface"
- class Interface(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
- Interface.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 <root>
- self.states[""] = State(0, "", self)
-
- # state /running
- self.states["/running"] = State(1, "/running", self)
-
- # add children
- self.states[""].addChild(self.states["/running"])
- self.states[""].fixTree()
- self.states[""].default_state = self.states["/running"]
-
- # transition /running
- _running_0 = Transition(self, self.states["/running"], [self.states["/running"]])
- _running_0.setAction(self._running_0_exec)
- _running_0.setTrigger(Event("input", "mv_input"))
- self.states["/running"].addTransition(_running_0)
- _running_1 = Transition(self, self.states["/running"], [self.states["/running"]])
- _running_1.setAction(self._running_1_exec)
- _running_1.setTrigger(Event("mv_input", "input"))
- self.states["/running"].addTransition(_running_1)
-
- def _running_0_exec(self, parameters):
- params = parameters[0]
- print 'sending output to the console'
- self.big_step.outputEvent(Event("mv_output", "output", [params]))
-
- def _running_1_exec(self, parameters):
- params = parameters[0]
- print 'sending output to the modelverse'
- self.big_step.outputEvent(Event("output", "mv_output", [params]))
-
- def initializeStatechart(self):
- # enter default state
- self.default_targets = self.states["/running"].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 == "Interface":
- instance = Interface(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.addInputPort("input")
- self.addInputPort("mv_input")
- self.addOutputPort("output")
- self.addOutputPort("mv_output")
- self.object_manager.createInstance("Interface", [])
|