target.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. """
  2. Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
  3. Model author: Sam Pieters
  4. Model name: Multiple Files
  5. Model description:
  6. Test 11: Check if multiple files can run a model
  7. """
  8. from sccd.runtime.statecharts_core import *
  9. # package "Multiple Files"
  10. class MainApp(RuntimeClassBase):
  11. def __init__(self, controller):
  12. RuntimeClassBase.__init__(self, controller)
  13. self.semantics.big_step_maximality = StatechartSemantics.TakeMany
  14. self.semantics.internal_event_lifeline = StatechartSemantics.Queue
  15. self.semantics.input_event_lifeline = StatechartSemantics.FirstComboStep
  16. self.semantics.priority = StatechartSemantics.SourceParent
  17. self.semantics.concurrency = StatechartSemantics.Single
  18. # build Statechart structure
  19. self.build_statechart_structure()
  20. # call user defined constructor
  21. MainApp.user_defined_constructor(self)
  22. def user_defined_constructor(self):
  23. pass
  24. def user_defined_destructor(self):
  25. pass
  26. # builds Statechart structure
  27. def build_statechart_structure(self):
  28. # state <root>
  29. self.states[""] = State(0, "", self)
  30. # state /state1
  31. self.states["/state1"] = State(1, "/state1", self)
  32. # add children
  33. self.states[""].addChild(self.states["/state1"])
  34. self.states[""].fixTree()
  35. self.states[""].default_state = self.states["/state1"]
  36. def initializeStatechart(self):
  37. # enter default state
  38. self.default_targets = self.states["/state1"].getEffectiveTargetStates()
  39. RuntimeClassBase.initializeStatechart(self)
  40. class ObjectManager(ObjectManagerBase):
  41. def __init__(self, controller):
  42. ObjectManagerBase.__init__(self, controller)
  43. def instantiate(self, class_name, construct_params):
  44. if class_name == "MainApp":
  45. instance = MainApp(self.controller)
  46. instance.associations = {}
  47. instance.associations["linkA"] = Association("A", 0, -1)
  48. instance.associations["linkB"] = Association("B", 0, -1)
  49. else:
  50. raise Exception("Cannot instantiate class " + class_name)
  51. return instance
  52. class Controller(ThreadsControllerBase):
  53. def __init__(self, keep_running = None, behind_schedule_callback = None):
  54. if keep_running == None: keep_running = True
  55. if behind_schedule_callback == None: behind_schedule_callback = None
  56. ThreadsControllerBase.__init__(self, ObjectManager(self), keep_running, behind_schedule_callback)
  57. self.addInputPort("ui")
  58. self.addOutputPort("ui")
  59. self.object_manager.createInstance("MainApp", [])