instate.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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:53 2016
  3. Model author: Glenn De Jonghe
  4. Model name: TestInstate
  5. Model description:
  6. Testing the INSTATE macro.*/
  7. // package "TestInstate"
  8. var TestInstate = {};
  9. (function() {
  10. var Class1 = function(controller) {
  11. RuntimeClassBase.call(this, controller);
  12. this.semantics.big_step_maximality = StatechartSemantics.TakeOne;
  13. this.semantics.internal_event_lifeline = StatechartSemantics.NextSmallStep;
  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. Class1.prototype.user_defined_constructor.call(this);
  21. };
  22. Class1.prototype = new Object();
  23. (function() {
  24. var proto = new RuntimeClassBase();
  25. for (prop in proto) {
  26. Class1.prototype[prop] = proto[prop];
  27. }
  28. })();
  29. Class1.prototype.user_defined_constructor = function() {
  30. };
  31. Class1.prototype.user_defined_destructor = function() {
  32. };
  33. // builds Statechart structure
  34. Class1.prototype.build_statechart_structure = function() {
  35. // state <root>
  36. this.states[""] = new State(0, this);
  37. // state /parallel_1
  38. this.states["/parallel_1"] = new ParallelState(1, this);
  39. // state /parallel_1/orthogonal1
  40. this.states["/parallel_1/orthogonal1"] = new State(2, this);
  41. // state /parallel_1/orthogonal1/state1
  42. this.states["/parallel_1/orthogonal1/state1"] = new State(3, this);
  43. // state /parallel_1/orthogonal1/inner
  44. this.states["/parallel_1/orthogonal1/inner"] = new State(4, this);
  45. // state /parallel_1/orthogonal1/inner/state2
  46. this.states["/parallel_1/orthogonal1/inner/state2"] = new State(5, this);
  47. // state /parallel_1/orthogonal1/inner/state3
  48. this.states["/parallel_1/orthogonal1/inner/state3"] = new State(6, this);
  49. // state /parallel_1/orthogonal2
  50. this.states["/parallel_1/orthogonal2"] = new State(7, this);
  51. // state /parallel_1/orthogonal2/tester
  52. this.states["/parallel_1/orthogonal2/tester"] = new State(8, this);
  53. // state /parallel_1/orthogonal2/stop
  54. this.states["/parallel_1/orthogonal2/stop"] = new State(9, this);
  55. // add children
  56. this.states[""].addChild(this.states["/parallel_1"]);
  57. this.states["/parallel_1"].addChild(this.states["/parallel_1/orthogonal1"]);
  58. this.states["/parallel_1"].addChild(this.states["/parallel_1/orthogonal2"]);
  59. this.states["/parallel_1/orthogonal1"].addChild(this.states["/parallel_1/orthogonal1/state1"]);
  60. this.states["/parallel_1/orthogonal1"].addChild(this.states["/parallel_1/orthogonal1/inner"]);
  61. this.states["/parallel_1/orthogonal1/inner"].addChild(this.states["/parallel_1/orthogonal1/inner/state2"]);
  62. this.states["/parallel_1/orthogonal1/inner"].addChild(this.states["/parallel_1/orthogonal1/inner/state3"]);
  63. this.states["/parallel_1/orthogonal2"].addChild(this.states["/parallel_1/orthogonal2/tester"]);
  64. this.states["/parallel_1/orthogonal2"].addChild(this.states["/parallel_1/orthogonal2/stop"]);
  65. this.states[""].fixTree();
  66. this.states[""].default_state = this.states["/parallel_1"];
  67. this.states["/parallel_1/orthogonal1"].default_state = this.states["/parallel_1/orthogonal1/state1"];
  68. this.states["/parallel_1/orthogonal1/inner"].default_state = this.states["/parallel_1/orthogonal1/inner/state2"];
  69. this.states["/parallel_1/orthogonal2"].default_state = this.states["/parallel_1/orthogonal2/tester"];
  70. // transition /parallel_1/orthogonal1/state1
  71. var _parallel_1_orthogonal1_state1_0 = new Transition(this, this.states["/parallel_1/orthogonal1/state1"], [this.states["/parallel_1/orthogonal1/inner"]]);
  72. _parallel_1_orthogonal1_state1_0.setTrigger(new Event("to_inner", null));
  73. this.states["/parallel_1/orthogonal1/state1"].addTransition(_parallel_1_orthogonal1_state1_0);
  74. // transition /parallel_1/orthogonal1/inner/state2
  75. var _parallel_1_orthogonal1_inner_state2_0 = new Transition(this, this.states["/parallel_1/orthogonal1/inner/state2"], [this.states["/parallel_1/orthogonal1/inner/state3"]]);
  76. _parallel_1_orthogonal1_inner_state2_0.setTrigger(new Event("to_state3", null));
  77. this.states["/parallel_1/orthogonal1/inner/state2"].addTransition(_parallel_1_orthogonal1_inner_state2_0);
  78. // transition /parallel_1/orthogonal2/tester
  79. var _parallel_1_orthogonal2_tester_0 = new Transition(this, this.states["/parallel_1/orthogonal2/tester"], [this.states["/parallel_1/orthogonal2/tester"]]);
  80. _parallel_1_orthogonal2_tester_0.setAction(this._parallel_1_orthogonal2_tester_0_exec);
  81. _parallel_1_orthogonal2_tester_0.setTrigger(null);
  82. _parallel_1_orthogonal2_tester_0.setGuard(this._parallel_1_orthogonal2_tester_0_guard);
  83. this.states["/parallel_1/orthogonal2/tester"].addTransition(_parallel_1_orthogonal2_tester_0);
  84. var _parallel_1_orthogonal2_tester_1 = new Transition(this, this.states["/parallel_1/orthogonal2/tester"], [this.states["/parallel_1/orthogonal2/tester"]]);
  85. _parallel_1_orthogonal2_tester_1.setAction(this._parallel_1_orthogonal2_tester_1_exec);
  86. _parallel_1_orthogonal2_tester_1.setTrigger(null);
  87. _parallel_1_orthogonal2_tester_1.setGuard(this._parallel_1_orthogonal2_tester_1_guard);
  88. this.states["/parallel_1/orthogonal2/tester"].addTransition(_parallel_1_orthogonal2_tester_1);
  89. var _parallel_1_orthogonal2_tester_2 = new Transition(this, this.states["/parallel_1/orthogonal2/tester"], [this.states["/parallel_1/orthogonal2/stop"]]);
  90. _parallel_1_orthogonal2_tester_2.setAction(this._parallel_1_orthogonal2_tester_2_exec);
  91. _parallel_1_orthogonal2_tester_2.setTrigger(null);
  92. _parallel_1_orthogonal2_tester_2.setGuard(this._parallel_1_orthogonal2_tester_2_guard);
  93. this.states["/parallel_1/orthogonal2/tester"].addTransition(_parallel_1_orthogonal2_tester_2);
  94. };
  95. Class1.prototype._parallel_1_orthogonal2_tester_0_exec = function(parameters) {
  96. this.big_step.outputEvent(new Event("check1", "test_output", new Array()));
  97. this.raiseInternalEvent(new Event("to_inner", null, new Array()));
  98. };
  99. Class1.prototype._parallel_1_orthogonal2_tester_0_guard = function(parameters) {
  100. return this.inState(["/parallel_1/orthogonal1/state1"]);
  101. };
  102. Class1.prototype._parallel_1_orthogonal2_tester_1_exec = function(parameters) {
  103. this.big_step.outputEvent(new Event("check2", "test_output", new Array()));
  104. this.raiseInternalEvent(new Event("to_state3", null, new Array()));
  105. };
  106. Class1.prototype._parallel_1_orthogonal2_tester_1_guard = function(parameters) {
  107. return this.inState(["/parallel_1/orthogonal1/inner/state2"]);
  108. };
  109. Class1.prototype._parallel_1_orthogonal2_tester_2_exec = function(parameters) {
  110. this.big_step.outputEvent(new Event("check3", "test_output", new Array()));
  111. };
  112. Class1.prototype._parallel_1_orthogonal2_tester_2_guard = function(parameters) {
  113. return this.inState(["/parallel_1/orthogonal1/inner/state3"]);
  114. };
  115. Class1.prototype.initializeStatechart = function() {
  116. // enter default state
  117. this.default_targets = this.states["/parallel_1"].getEffectiveTargetStates();
  118. RuntimeClassBase.prototype.initializeStatechart.call(this);
  119. };
  120. // add symbol 'Class1' to package 'TestInstate'
  121. TestInstate.Class1 = Class1;
  122. var ObjectManager = function(controller) {
  123. ObjectManagerBase.call(this, controller);
  124. };
  125. ObjectManager.prototype = new Object();
  126. (function() {
  127. var proto = new ObjectManagerBase();
  128. for (prop in proto) {
  129. ObjectManager.prototype[prop] = proto[prop];
  130. }
  131. })();
  132. ObjectManager.prototype.instantiate = function(class_name, construct_params) {
  133. if (class_name === "Class1") {
  134. var instance = new Class1(this.controller);
  135. instance.associations = new Object();
  136. } else {
  137. throw new Error("Cannot instantiate class " + class_name);
  138. }
  139. return instance;
  140. };
  141. // add symbol 'ObjectManager' to package 'TestInstate'
  142. TestInstate.ObjectManager = ObjectManager;
  143. var Controller = function(event_loop_callbacks, finished_callback, behind_schedule_callback) {
  144. if (finished_callback === undefined) finished_callback = null;
  145. if (behind_schedule_callback === undefined) behind_schedule_callback = null;
  146. EventLoopControllerBase.call(this, new ObjectManager(this), event_loop_callbacks, finished_callback, behind_schedule_callback);
  147. this.addOutputPort("test_output");
  148. this.object_manager.createInstance("Class1", new Array());
  149. };
  150. Controller.prototype = new Object();
  151. (function() {
  152. var proto = new EventLoopControllerBase();
  153. for (prop in proto) {
  154. Controller.prototype[prop] = proto[prop];
  155. }
  156. })();
  157. // add symbol 'Controller' to package 'TestInstate'
  158. TestInstate.Controller = Controller;
  159. var InputEvent = function(name, port, parameters, time_offset) {
  160. this.name = name;
  161. this.port = port;
  162. this.parameters = parameters;
  163. this.time_offset = time_offset;
  164. };
  165. // add symbol 'InputEvent' to package 'TestInstate'
  166. TestInstate.InputEvent = InputEvent;
  167. var Test = function() {
  168. };
  169. Test.prototype.input_events = new Array();
  170. Test.prototype.expected_events = [[new Event("check1", "test_output", new Array())], [new Event("check2", "test_output", new Array())], [new Event("check3", "test_output", new Array())]];
  171. // add symbol 'Test' to package 'TestInstate'
  172. TestInstate.Test = Test;
  173. })();