tester.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. """
  2. Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
  3. Date: Fri Sep 08 11:03:01 2017
  4. Model author: Yentl Van Tendeloo
  5. Model name: Testing
  6. Model description:
  7. Testing
  8. """
  9. from sccd.runtime.statecharts_core import *
  10. # package "Testing"
  11. class Testing(RuntimeClassBase):
  12. def __init__(self, controller):
  13. RuntimeClassBase.__init__(self, controller)
  14. self.semantics.big_step_maximality = StatechartSemantics.TakeMany
  15. self.semantics.internal_event_lifeline = StatechartSemantics.Queue
  16. self.semantics.input_event_lifeline = StatechartSemantics.FirstComboStep
  17. self.semantics.priority = StatechartSemantics.SourceParent
  18. self.semantics.concurrency = StatechartSemantics.Single
  19. # build Statechart structure
  20. self.build_statechart_structure()
  21. # call user defined constructor
  22. Testing.user_defined_constructor(self)
  23. def user_defined_constructor(self):
  24. pass
  25. def user_defined_destructor(self):
  26. pass
  27. # builds Statechart structure
  28. def build_statechart_structure(self):
  29. # state <root>
  30. self.states[""] = State(0, "", self)
  31. # state /A
  32. self.states["/A"] = ParallelState(1, "/A", self)
  33. # state /A/B
  34. self.states["/A/B"] = State(2, "/A/B", self)
  35. self.states["/A/B"].setExit(self._A_B_exit)
  36. # state /A/B/1
  37. self.states["/A/B/1"] = State(3, "/A/B/1", self)
  38. self.states["/A/B/1"].setEnter(self._A_B_1_enter)
  39. # state /A/D
  40. self.states["/A/D"] = State(4, "/A/D", self)
  41. # state /A/D/a
  42. self.states["/A/D/a"] = State(5, "/A/D/a", self)
  43. # state /A/D/b
  44. self.states["/A/D/b"] = State(6, "/A/D/b", self)
  45. # add children
  46. self.states[""].addChild(self.states["/A"])
  47. self.states["/A"].addChild(self.states["/A/B"])
  48. self.states["/A"].addChild(self.states["/A/D"])
  49. self.states["/A/B"].addChild(self.states["/A/B/1"])
  50. self.states["/A/D"].addChild(self.states["/A/D/a"])
  51. self.states["/A/D"].addChild(self.states["/A/D/b"])
  52. self.states[""].fixTree()
  53. self.states[""].default_state = self.states["/A"]
  54. self.states["/A/B"].default_state = self.states["/A/B/1"]
  55. self.states["/A/D"].default_state = self.states["/A/D/a"]
  56. # transition /A/D
  57. _A_D_0 = Transition(self, self.states["/A/D"], [self.states["/A/D/a"]])
  58. _A_D_0.setTrigger(Event("Z", None))
  59. self.states["/A/D"].addTransition(_A_D_0)
  60. def _A_B_exit(self):
  61. raise Exception("Should never leave!")
  62. def _A_B_1_enter(self):
  63. self.raiseInternalEvent(Event("Z", None, []))
  64. def initializeStatechart(self):
  65. # enter default state
  66. self.default_targets = self.states["/A"].getEffectiveTargetStates()
  67. RuntimeClassBase.initializeStatechart(self)
  68. class ObjectManager(ObjectManagerBase):
  69. def __init__(self, controller):
  70. ObjectManagerBase.__init__(self, controller)
  71. def instantiate(self, class_name, construct_params):
  72. if class_name == "Testing":
  73. instance = Testing(self.controller)
  74. instance.associations = {}
  75. else:
  76. raise Exception("Cannot instantiate class " + class_name)
  77. return instance
  78. class Controller(ThreadsControllerBase):
  79. def __init__(self, keep_running = None, behind_schedule_callback = None):
  80. if keep_running == None: keep_running = True
  81. if behind_schedule_callback == None: behind_schedule_callback = None
  82. ThreadsControllerBase.__init__(self, ObjectManager(self), keep_running, behind_schedule_callback)
  83. self.object_manager.createInstance("Testing", [])