after_0.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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:52 2016
  3. Model author: Yentl Van Tendeloo
  4. Model name: after_0
  5. Model description:
  6. Used for testing the AFTER(0) event---which should not block the deletion of the B instance.*/
  7. // package "after_0"
  8. var after_0 = {};
  9. (function() {
  10. var A = 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. A.prototype.user_defined_constructor.call(this);
  21. };
  22. A.prototype = new Object();
  23. (function() {
  24. var proto = new RuntimeClassBase();
  25. for (prop in proto) {
  26. A.prototype[prop] = proto[prop];
  27. }
  28. })();
  29. A.prototype.user_defined_constructor = function() {
  30. };
  31. A.prototype.user_defined_destructor = function() {
  32. };
  33. // builds Statechart structure
  34. A.prototype.build_statechart_structure = function() {
  35. // state <root>
  36. this.states[""] = new State(0, this);
  37. // state /x
  38. this.states["/x"] = new State(1, this);
  39. this.states["/x"].setEnter(this._x_enter);
  40. // state /ready
  41. this.states["/ready"] = new State(2, this);
  42. this.states["/ready"].setEnter(this._ready_enter);
  43. // state /done
  44. this.states["/done"] = new State(3, this);
  45. // add children
  46. this.states[""].addChild(this.states["/x"]);
  47. this.states[""].addChild(this.states["/ready"]);
  48. this.states[""].addChild(this.states["/done"]);
  49. this.states[""].fixTree();
  50. this.states[""].default_state = this.states["/x"];
  51. // transition /x
  52. var _x_0 = new Transition(this, this.states["/x"], [this.states["/ready"]]);
  53. _x_0.setTrigger(new Event("instance_created", null));
  54. this.states["/x"].addTransition(_x_0);
  55. // transition /ready
  56. var _ready_0 = new Transition(this, this.states["/ready"], [this.states["/done"]]);
  57. _ready_0.setAction(this._ready_0_exec);
  58. _ready_0.setTrigger(new Event("close", null));
  59. this.states["/ready"].addTransition(_ready_0);
  60. };
  61. A.prototype._x_enter = function() {
  62. this.big_step.outputEventOM(new Event("create_instance", null, [this, 'child', 'B']));
  63. this.big_step.outputEvent(new Event("creating_instance", "test_output", new Array()));
  64. };
  65. A.prototype._ready_enter = function() {
  66. this.big_step.outputEventOM(new Event("start_instance", null, [this, 'child[0]']));
  67. this.big_step.outputEvent(new Event("starting_instance", "test_output", new Array()));
  68. };
  69. A.prototype._ready_0_exec = function(parameters) {
  70. this.big_step.outputEventOM(new Event("delete_instance", null, [this, 'child[0]']));
  71. this.big_step.outputEvent(new Event("deleting_instance", "test_output", new Array()));
  72. };
  73. A.prototype.initializeStatechart = function() {
  74. // enter default state
  75. this.default_targets = this.states["/x"].getEffectiveTargetStates();
  76. RuntimeClassBase.prototype.initializeStatechart.call(this);
  77. };
  78. // add symbol 'A' to package 'after_0'
  79. after_0.A = A;
  80. var B = function(controller) {
  81. RuntimeClassBase.call(this, controller);
  82. this.semantics.big_step_maximality = StatechartSemantics.TakeMany;
  83. this.semantics.internal_event_lifeline = StatechartSemantics.Queue;
  84. this.semantics.input_event_lifeline = StatechartSemantics.FirstComboStep;
  85. this.semantics.priority = StatechartSemantics.SourceParent;
  86. this.semantics.concurrency = StatechartSemantics.Single;
  87. // build Statechart structure
  88. this.build_statechart_structure();
  89. // call user defined constructor
  90. B.prototype.user_defined_constructor.call(this);
  91. };
  92. B.prototype = new Object();
  93. (function() {
  94. var proto = new RuntimeClassBase();
  95. for (prop in proto) {
  96. B.prototype[prop] = proto[prop];
  97. }
  98. })();
  99. B.prototype.user_defined_constructor = function() {
  100. };
  101. B.prototype.user_defined_destructor = function() {
  102. };
  103. // builds Statechart structure
  104. B.prototype.build_statechart_structure = function() {
  105. // state <root>
  106. this.states[""] = new State(0, this);
  107. // state /z
  108. this.states["/z"] = new State(1, this);
  109. this.states["/z"].setEnter(this._z_enter);
  110. this.states["/z"].setExit(this._z_exit);
  111. // add children
  112. this.states[""].addChild(this.states["/z"]);
  113. this.states[""].fixTree();
  114. this.states[""].default_state = this.states["/z"];
  115. // transition /z
  116. var _z_0 = new Transition(this, this.states["/z"], [this.states["/z"]]);
  117. _z_0.setAction(this._z_0_exec);
  118. _z_0.setTrigger(new Event("_0after"));
  119. this.states["/z"].addTransition(_z_0);
  120. };
  121. B.prototype._z_enter = function() {
  122. this.addTimer(0, 0);
  123. };
  124. B.prototype._z_exit = function() {
  125. this.removeTimer(0);
  126. };
  127. B.prototype._z_0_exec = function(parameters) {
  128. this.big_step.outputEventOM(new Event("broad_cast", null, [new Event("close", null, new Array())]));
  129. this.big_step.outputEvent(new Event("after_0", "test_output", new Array()));
  130. };
  131. B.prototype.initializeStatechart = function() {
  132. // enter default state
  133. this.default_targets = this.states["/z"].getEffectiveTargetStates();
  134. RuntimeClassBase.prototype.initializeStatechart.call(this);
  135. };
  136. // add symbol 'B' to package 'after_0'
  137. after_0.B = B;
  138. var ObjectManager = function(controller) {
  139. ObjectManagerBase.call(this, controller);
  140. };
  141. ObjectManager.prototype = new Object();
  142. (function() {
  143. var proto = new ObjectManagerBase();
  144. for (prop in proto) {
  145. ObjectManager.prototype[prop] = proto[prop];
  146. }
  147. })();
  148. ObjectManager.prototype.instantiate = function(class_name, construct_params) {
  149. if (class_name === "A") {
  150. var instance = new A(this.controller);
  151. instance.associations = new Object();
  152. instance.associations["child"] = new Association("B", 0, 1);
  153. } else if (class_name === "B") {
  154. var instance = new B(this.controller);
  155. instance.associations = new Object();
  156. instance.associations["parent"] = new Association("A", 1, 1);
  157. } else {
  158. throw new Error("Cannot instantiate class " + class_name);
  159. }
  160. return instance;
  161. };
  162. // add symbol 'ObjectManager' to package 'after_0'
  163. after_0.ObjectManager = ObjectManager;
  164. var Controller = function(event_loop_callbacks, finished_callback, behind_schedule_callback) {
  165. if (finished_callback === undefined) finished_callback = null;
  166. if (behind_schedule_callback === undefined) behind_schedule_callback = null;
  167. EventLoopControllerBase.call(this, new ObjectManager(this), event_loop_callbacks, finished_callback, behind_schedule_callback);
  168. this.addOutputPort("test_output");
  169. this.object_manager.createInstance("A", new Array());
  170. };
  171. Controller.prototype = new Object();
  172. (function() {
  173. var proto = new EventLoopControllerBase();
  174. for (prop in proto) {
  175. Controller.prototype[prop] = proto[prop];
  176. }
  177. })();
  178. // add symbol 'Controller' to package 'after_0'
  179. after_0.Controller = Controller;
  180. var InputEvent = function(name, port, parameters, time_offset) {
  181. this.name = name;
  182. this.port = port;
  183. this.parameters = parameters;
  184. this.time_offset = time_offset;
  185. };
  186. // add symbol 'InputEvent' to package 'after_0'
  187. after_0.InputEvent = InputEvent;
  188. var Test = function() {
  189. };
  190. Test.prototype.input_events = new Array();
  191. Test.prototype.expected_events = [[new Event("creating_instance", "test_output", new Array())], [new Event("starting_instance", "test_output", new Array())], [new Event("after_0", "test_output", new Array())], [new Event("deleting_instance", "test_output", new Array()), new Event("after_0", "test_output", new Array())]];
  192. // add symbol 'Test' to package 'after_0'
  193. after_0.Test = Test;
  194. })();