parallel_history.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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: Glenn De Jonghe
  4. Model name: TestParallelHistory
  5. Model description:
  6. Testing history in parallel.*/
  7. // package "TestParallelHistory"
  8. var TestParallelHistory = {};
  9. (function() {
  10. var TestClass = 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. TestClass.prototype.user_defined_constructor.call(this);
  21. };
  22. TestClass.prototype = new Object();
  23. (function() {
  24. var proto = new RuntimeClassBase();
  25. for (prop in proto) {
  26. TestClass.prototype[prop] = proto[prop];
  27. }
  28. })();
  29. TestClass.prototype.user_defined_constructor = function() {
  30. };
  31. TestClass.prototype.user_defined_destructor = function() {
  32. };
  33. // builds Statechart structure
  34. TestClass.prototype.build_statechart_structure = function() {
  35. // state <root>
  36. this.states[""] = new State(0, this);
  37. // state /parallel
  38. this.states["/parallel"] = new ParallelState(1, this);
  39. // state /parallel/orthogonal_1
  40. this.states["/parallel/orthogonal_1"] = new State(2, this);
  41. // state /parallel/orthogonal_1/orthogonal_inner_1
  42. this.states["/parallel/orthogonal_1/orthogonal_inner_1"] = new State(3, this);
  43. // state /parallel/orthogonal_1/orthogonal_inner_1/state_1
  44. this.states["/parallel/orthogonal_1/orthogonal_inner_1/state_1"] = new State(4, this);
  45. this.states["/parallel/orthogonal_1/orthogonal_inner_1/state_1"].setEnter(this._parallel_orthogonal_1_orthogonal_inner_1_state_1_enter);
  46. // state /parallel/orthogonal_1/orthogonal_inner_1/state_2
  47. this.states["/parallel/orthogonal_1/orthogonal_inner_1/state_2"] = new State(5, this);
  48. this.states["/parallel/orthogonal_1/orthogonal_inner_1/state_2"].setEnter(this._parallel_orthogonal_1_orthogonal_inner_1_state_2_enter);
  49. // state /parallel/orthogonal_1/orthogonal_inner_1/history_1
  50. this.states["/parallel/orthogonal_1/orthogonal_inner_1/history_1"] = new ShallowHistoryState(6, this);
  51. // state /parallel/orthogonal_1/outer_1
  52. this.states["/parallel/orthogonal_1/outer_1"] = new State(7, this);
  53. this.states["/parallel/orthogonal_1/outer_1"].setEnter(this._parallel_orthogonal_1_outer_1_enter);
  54. // state /parallel/orthogonal_2
  55. this.states["/parallel/orthogonal_2"] = new State(8, this);
  56. // state /parallel/orthogonal_2/orthogonal_inner_2
  57. this.states["/parallel/orthogonal_2/orthogonal_inner_2"] = new State(9, this);
  58. // state /parallel/orthogonal_2/orthogonal_inner_2/state_3
  59. this.states["/parallel/orthogonal_2/orthogonal_inner_2/state_3"] = new State(10, this);
  60. this.states["/parallel/orthogonal_2/orthogonal_inner_2/state_3"].setEnter(this._parallel_orthogonal_2_orthogonal_inner_2_state_3_enter);
  61. // state /parallel/orthogonal_2/orthogonal_inner_2/state_4
  62. this.states["/parallel/orthogonal_2/orthogonal_inner_2/state_4"] = new State(11, this);
  63. this.states["/parallel/orthogonal_2/orthogonal_inner_2/state_4"].setEnter(this._parallel_orthogonal_2_orthogonal_inner_2_state_4_enter);
  64. // state /parallel/orthogonal_2/orthogonal_inner_2/history_2
  65. this.states["/parallel/orthogonal_2/orthogonal_inner_2/history_2"] = new ShallowHistoryState(12, this);
  66. // state /parallel/orthogonal_2/outer_2
  67. this.states["/parallel/orthogonal_2/outer_2"] = new State(13, this);
  68. this.states["/parallel/orthogonal_2/outer_2"].setEnter(this._parallel_orthogonal_2_outer_2_enter);
  69. // add children
  70. this.states[""].addChild(this.states["/parallel"]);
  71. this.states["/parallel"].addChild(this.states["/parallel/orthogonal_1"]);
  72. this.states["/parallel"].addChild(this.states["/parallel/orthogonal_2"]);
  73. this.states["/parallel/orthogonal_1"].addChild(this.states["/parallel/orthogonal_1/orthogonal_inner_1"]);
  74. this.states["/parallel/orthogonal_1"].addChild(this.states["/parallel/orthogonal_1/outer_1"]);
  75. this.states["/parallel/orthogonal_1/orthogonal_inner_1"].addChild(this.states["/parallel/orthogonal_1/orthogonal_inner_1/state_1"]);
  76. this.states["/parallel/orthogonal_1/orthogonal_inner_1"].addChild(this.states["/parallel/orthogonal_1/orthogonal_inner_1/state_2"]);
  77. this.states["/parallel/orthogonal_1/orthogonal_inner_1"].addChild(this.states["/parallel/orthogonal_1/orthogonal_inner_1/history_1"]);
  78. this.states["/parallel/orthogonal_2"].addChild(this.states["/parallel/orthogonal_2/orthogonal_inner_2"]);
  79. this.states["/parallel/orthogonal_2"].addChild(this.states["/parallel/orthogonal_2/outer_2"]);
  80. this.states["/parallel/orthogonal_2/orthogonal_inner_2"].addChild(this.states["/parallel/orthogonal_2/orthogonal_inner_2/state_3"]);
  81. this.states["/parallel/orthogonal_2/orthogonal_inner_2"].addChild(this.states["/parallel/orthogonal_2/orthogonal_inner_2/state_4"]);
  82. this.states["/parallel/orthogonal_2/orthogonal_inner_2"].addChild(this.states["/parallel/orthogonal_2/orthogonal_inner_2/history_2"]);
  83. this.states[""].fixTree();
  84. this.states[""].default_state = this.states["/parallel"];
  85. this.states["/parallel/orthogonal_1"].default_state = this.states["/parallel/orthogonal_1/orthogonal_inner_1"];
  86. this.states["/parallel/orthogonal_1/orthogonal_inner_1"].default_state = this.states["/parallel/orthogonal_1/orthogonal_inner_1/state_1"];
  87. this.states["/parallel/orthogonal_2"].default_state = this.states["/parallel/orthogonal_2/orthogonal_inner_2"];
  88. this.states["/parallel/orthogonal_2/orthogonal_inner_2"].default_state = this.states["/parallel/orthogonal_2/orthogonal_inner_2/state_3"];
  89. // transition /parallel/orthogonal_1/orthogonal_inner_1/state_1
  90. var _parallel_orthogonal_1_orthogonal_inner_1_state_1_0 = new Transition(this, this.states["/parallel/orthogonal_1/orthogonal_inner_1/state_1"], [this.states["/parallel/orthogonal_1/orthogonal_inner_1/state_2"]]);
  91. _parallel_orthogonal_1_orthogonal_inner_1_state_1_0.setTrigger(new Event("to_state_2", "test_input"));
  92. this.states["/parallel/orthogonal_1/orthogonal_inner_1/state_1"].addTransition(_parallel_orthogonal_1_orthogonal_inner_1_state_1_0);
  93. // transition /parallel/orthogonal_1/outer_1
  94. var _parallel_orthogonal_1_outer_1_0 = new Transition(this, this.states["/parallel/orthogonal_1/outer_1"], [this.states["/parallel/orthogonal_1/orthogonal_inner_1/history_1"]]);
  95. _parallel_orthogonal_1_outer_1_0.setTrigger(new Event("to_history_1", "test_input"));
  96. this.states["/parallel/orthogonal_1/outer_1"].addTransition(_parallel_orthogonal_1_outer_1_0);
  97. // transition /parallel/orthogonal_2/orthogonal_inner_2/state_3
  98. var _parallel_orthogonal_2_orthogonal_inner_2_state_3_0 = new Transition(this, this.states["/parallel/orthogonal_2/orthogonal_inner_2/state_3"], [this.states["/parallel/orthogonal_2/orthogonal_inner_2/state_4"]]);
  99. _parallel_orthogonal_2_orthogonal_inner_2_state_3_0.setTrigger(new Event("to_state_4", "test_input"));
  100. this.states["/parallel/orthogonal_2/orthogonal_inner_2/state_3"].addTransition(_parallel_orthogonal_2_orthogonal_inner_2_state_3_0);
  101. // transition /parallel/orthogonal_2/outer_2
  102. var _parallel_orthogonal_2_outer_2_0 = new Transition(this, this.states["/parallel/orthogonal_2/outer_2"], [this.states["/parallel/orthogonal_2/orthogonal_inner_2/history_2"]]);
  103. _parallel_orthogonal_2_outer_2_0.setTrigger(new Event("to_history_2", "test_input"));
  104. this.states["/parallel/orthogonal_2/outer_2"].addTransition(_parallel_orthogonal_2_outer_2_0);
  105. // transition /parallel/orthogonal_1/orthogonal_inner_1
  106. var _parallel_orthogonal_1_orthogonal_inner_1_0 = new Transition(this, this.states["/parallel/orthogonal_1/orthogonal_inner_1"], [this.states["/parallel/orthogonal_1/outer_1"]]);
  107. _parallel_orthogonal_1_orthogonal_inner_1_0.setTrigger(new Event("to_outer_1", "test_input"));
  108. this.states["/parallel/orthogonal_1/orthogonal_inner_1"].addTransition(_parallel_orthogonal_1_orthogonal_inner_1_0);
  109. // transition /parallel/orthogonal_2/orthogonal_inner_2
  110. var _parallel_orthogonal_2_orthogonal_inner_2_0 = new Transition(this, this.states["/parallel/orthogonal_2/orthogonal_inner_2"], [this.states["/parallel/orthogonal_2/outer_2"]]);
  111. _parallel_orthogonal_2_orthogonal_inner_2_0.setTrigger(new Event("to_outer_2", "test_input"));
  112. this.states["/parallel/orthogonal_2/orthogonal_inner_2"].addTransition(_parallel_orthogonal_2_orthogonal_inner_2_0);
  113. };
  114. TestClass.prototype._parallel_orthogonal_1_orthogonal_inner_1_state_1_enter = function() {
  115. this.big_step.outputEvent(new Event("in_state_1", "test_output", new Array()));
  116. };
  117. TestClass.prototype._parallel_orthogonal_1_orthogonal_inner_1_state_2_enter = function() {
  118. this.big_step.outputEvent(new Event("in_state_2", "test_output", new Array()));
  119. };
  120. TestClass.prototype._parallel_orthogonal_1_outer_1_enter = function() {
  121. this.big_step.outputEvent(new Event("in_outer_1", "test_output", new Array()));
  122. };
  123. TestClass.prototype._parallel_orthogonal_2_orthogonal_inner_2_state_3_enter = function() {
  124. this.big_step.outputEvent(new Event("in_state_3", "test_output", new Array()));
  125. };
  126. TestClass.prototype._parallel_orthogonal_2_orthogonal_inner_2_state_4_enter = function() {
  127. this.big_step.outputEvent(new Event("in_state_4", "test_output", new Array()));
  128. };
  129. TestClass.prototype._parallel_orthogonal_2_outer_2_enter = function() {
  130. this.big_step.outputEvent(new Event("in_outer_2", "test_output", new Array()));
  131. };
  132. TestClass.prototype.initializeStatechart = function() {
  133. // enter default state
  134. this.default_targets = this.states["/parallel"].getEffectiveTargetStates();
  135. RuntimeClassBase.prototype.initializeStatechart.call(this);
  136. };
  137. // add symbol 'TestClass' to package 'TestParallelHistory'
  138. TestParallelHistory.TestClass = TestClass;
  139. var ObjectManager = function(controller) {
  140. ObjectManagerBase.call(this, controller);
  141. };
  142. ObjectManager.prototype = new Object();
  143. (function() {
  144. var proto = new ObjectManagerBase();
  145. for (prop in proto) {
  146. ObjectManager.prototype[prop] = proto[prop];
  147. }
  148. })();
  149. ObjectManager.prototype.instantiate = function(class_name, construct_params) {
  150. if (class_name === "TestClass") {
  151. var instance = new TestClass(this.controller);
  152. instance.associations = new Object();
  153. } else {
  154. throw new Error("Cannot instantiate class " + class_name);
  155. }
  156. return instance;
  157. };
  158. // add symbol 'ObjectManager' to package 'TestParallelHistory'
  159. TestParallelHistory.ObjectManager = ObjectManager;
  160. var Controller = function(event_loop_callbacks, finished_callback, behind_schedule_callback) {
  161. if (finished_callback === undefined) finished_callback = null;
  162. if (behind_schedule_callback === undefined) behind_schedule_callback = null;
  163. EventLoopControllerBase.call(this, new ObjectManager(this), event_loop_callbacks, finished_callback, behind_schedule_callback);
  164. this.addInputPort("test_input");
  165. this.addOutputPort("test_output");
  166. this.object_manager.createInstance("TestClass", new Array());
  167. };
  168. Controller.prototype = new Object();
  169. (function() {
  170. var proto = new EventLoopControllerBase();
  171. for (prop in proto) {
  172. Controller.prototype[prop] = proto[prop];
  173. }
  174. })();
  175. // add symbol 'Controller' to package 'TestParallelHistory'
  176. TestParallelHistory.Controller = Controller;
  177. var InputEvent = function(name, port, parameters, time_offset) {
  178. this.name = name;
  179. this.port = port;
  180. this.parameters = parameters;
  181. this.time_offset = time_offset;
  182. };
  183. // add symbol 'InputEvent' to package 'TestParallelHistory'
  184. TestParallelHistory.InputEvent = InputEvent;
  185. var Test = function() {
  186. };
  187. Test.prototype.input_events = [new InputEvent("to_state_2", "test_input", new Array(), 0.0), new InputEvent("to_state_4", "test_input", new Array(), 0.0), new InputEvent("to_outer_1", "test_input", new Array(), 0.0), new InputEvent("to_outer_2", "test_input", new Array(), 0.0), new InputEvent("to_history_1", "test_input", new Array(), 0.0), new InputEvent("to_history_2", "test_input", new Array(), 0.0)];
  188. Test.prototype.expected_events = [[new Event("in_state_1", "test_output", new Array()), new Event("in_state_3", "test_output", new Array())], [new Event("in_state_2", "test_output", new Array())], [new Event("in_state_4", "test_output", new Array())], [new Event("in_outer_1", "test_output", new Array())], [new Event("in_outer_2", "test_output", new Array())], [new Event("in_state_2", "test_output", new Array())], [new Event("in_state_4", "test_output", new Array())]];
  189. // add symbol 'Test' to package 'TestParallelHistory'
  190. TestParallelHistory.Test = Test;
  191. })();