00_source_parent.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /* Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
  2. Date: Tue Aug 09 09:35:54 2016
  3. Model author: Herr Joeri Exelmans
  4. Model name: source_parent
  5. Model description:
  6. 'Source Parent' priority-semantics: If 2 transitions are enabled, and the source state of the first is an ancestor of the second, only the first is executed.*/
  7. // package "source_parent"
  8. var source_parent = {};
  9. (function() {
  10. var c = function(controller) {
  11. RuntimeClassBase.call(this, controller);
  12. this.semantics.big_step_maximality = StatechartSemantics.TakeMany;
  13. this.semantics.internal_event_lifeline = StatechartSemantics.Queue;
  14. this.semantics.input_event_lifeline = StatechartSemantics.FirstComboStep;
  15. this.semantics.priority = StatechartSemantics.SourceParent;
  16. this.semantics.concurrency = StatechartSemantics.Single;
  17. // build Statechart structure
  18. this.build_statechart_structure();
  19. // call user defined constructor
  20. c.prototype.user_defined_constructor.call(this);
  21. };
  22. c.prototype = new Object();
  23. (function() {
  24. var proto = new RuntimeClassBase();
  25. for (prop in proto) {
  26. c.prototype[prop] = proto[prop];
  27. }
  28. })();
  29. c.prototype.user_defined_constructor = function() {
  30. };
  31. c.prototype.user_defined_destructor = function() {
  32. };
  33. // builds Statechart structure
  34. c.prototype.build_statechart_structure = function() {
  35. // state <root>
  36. this.states[""] = new State(0, this);
  37. // state /parent
  38. this.states["/parent"] = new State(1, this);
  39. this.states["/parent"].setEnter(this._parent_enter);
  40. // state /parent/a
  41. this.states["/parent/a"] = new State(2, this);
  42. this.states["/parent/a"].setEnter(this._parent_a_enter);
  43. // state /parent/b
  44. this.states["/parent/b"] = new State(3, this);
  45. this.states["/parent/b"].setEnter(this._parent_b_enter);
  46. // state /c
  47. this.states["/c"] = new State(4, this);
  48. this.states["/c"].setEnter(this._c_enter);
  49. // add children
  50. this.states[""].addChild(this.states["/parent"]);
  51. this.states[""].addChild(this.states["/c"]);
  52. this.states["/parent"].addChild(this.states["/parent/a"]);
  53. this.states["/parent"].addChild(this.states["/parent/b"]);
  54. this.states[""].fixTree();
  55. this.states[""].default_state = this.states["/parent"];
  56. this.states["/parent"].default_state = this.states["/parent/a"];
  57. // transition /parent/a
  58. var _parent_a_0 = new Transition(this, this.states["/parent/a"], [this.states["/parent/b"]]);
  59. _parent_a_0.setTrigger(null);
  60. this.states["/parent/a"].addTransition(_parent_a_0);
  61. // transition /parent
  62. var _parent_0 = new Transition(this, this.states["/parent"], [this.states["/c"]]);
  63. _parent_0.setTrigger(null);
  64. this.states["/parent"].addTransition(_parent_0);
  65. };
  66. c.prototype._parent_enter = function() {
  67. this.big_step.outputEvent(new Event("entered_parent", "out", new Array()));
  68. };
  69. c.prototype._parent_a_enter = function() {
  70. this.big_step.outputEvent(new Event("entered_a", "out", new Array()));
  71. };
  72. c.prototype._parent_b_enter = function() {
  73. this.big_step.outputEvent(new Event("entered_b", "out", new Array()));
  74. };
  75. c.prototype._c_enter = function() {
  76. this.big_step.outputEvent(new Event("entered_c", "out", new Array()));
  77. };
  78. c.prototype.initializeStatechart = function() {
  79. // enter default state
  80. this.default_targets = this.states["/parent"].getEffectiveTargetStates();
  81. RuntimeClassBase.prototype.initializeStatechart.call(this);
  82. };
  83. // add symbol 'c' to package 'source_parent'
  84. source_parent.c = c;
  85. var ObjectManager = function(controller) {
  86. ObjectManagerBase.call(this, controller);
  87. };
  88. ObjectManager.prototype = new Object();
  89. (function() {
  90. var proto = new ObjectManagerBase();
  91. for (prop in proto) {
  92. ObjectManager.prototype[prop] = proto[prop];
  93. }
  94. })();
  95. ObjectManager.prototype.instantiate = function(class_name, construct_params) {
  96. if (class_name === "c") {
  97. var instance = new c(this.controller);
  98. instance.associations = new Object();
  99. } else {
  100. throw new Error("Cannot instantiate class " + class_name);
  101. }
  102. return instance;
  103. };
  104. // add symbol 'ObjectManager' to package 'source_parent'
  105. source_parent.ObjectManager = ObjectManager;
  106. var Controller = function(event_loop_callbacks, finished_callback, behind_schedule_callback) {
  107. if (finished_callback === undefined) finished_callback = null;
  108. if (behind_schedule_callback === undefined) behind_schedule_callback = null;
  109. EventLoopControllerBase.call(this, new ObjectManager(this), event_loop_callbacks, finished_callback, behind_schedule_callback);
  110. this.addInputPort("in");
  111. this.addOutputPort("out");
  112. this.object_manager.createInstance("c", new Array());
  113. };
  114. Controller.prototype = new Object();
  115. (function() {
  116. var proto = new EventLoopControllerBase();
  117. for (prop in proto) {
  118. Controller.prototype[prop] = proto[prop];
  119. }
  120. })();
  121. // add symbol 'Controller' to package 'source_parent'
  122. source_parent.Controller = Controller;
  123. var InputEvent = function(name, port, parameters, time_offset) {
  124. this.name = name;
  125. this.port = port;
  126. this.parameters = parameters;
  127. this.time_offset = time_offset;
  128. };
  129. // add symbol 'InputEvent' to package 'source_parent'
  130. source_parent.InputEvent = InputEvent;
  131. var Test = function() {
  132. };
  133. Test.prototype.input_events = new Array();
  134. Test.prototype.expected_events = [[new Event("entered_parent", "out", new Array()), new Event("entered_a", "out", new Array())], [new Event("entered_c", "out", new Array())]];
  135. // add symbol 'Test' to package 'source_parent'
  136. source_parent.Test = Test;
  137. })();