parallel.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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: TestParallel
  5. Model description:
  6. Testing parallelism.*/
  7. // package "TestParallel"
  8. var TestParallel = {};
  9. (function() {
  10. var Class1 = 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. 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/orthogonal_1
  40. this.states["/parallel_1/orthogonal_1"] = new State(2, this);
  41. // state /parallel_1/orthogonal_1/state_1
  42. this.states["/parallel_1/orthogonal_1/state_1"] = new State(3, this);
  43. this.states["/parallel_1/orthogonal_1/state_1"].setEnter(this._parallel_1_orthogonal_1_state_1_enter);
  44. // state /parallel_1/orthogonal_1/state_2
  45. this.states["/parallel_1/orthogonal_1/state_2"] = new State(4, this);
  46. this.states["/parallel_1/orthogonal_1/state_2"].setEnter(this._parallel_1_orthogonal_1_state_2_enter);
  47. // state /parallel_1/orthogonal_2
  48. this.states["/parallel_1/orthogonal_2"] = new State(5, this);
  49. // state /parallel_1/orthogonal_2/state_3
  50. this.states["/parallel_1/orthogonal_2/state_3"] = new State(6, this);
  51. this.states["/parallel_1/orthogonal_2/state_3"].setEnter(this._parallel_1_orthogonal_2_state_3_enter);
  52. // state /parallel_1/orthogonal_2/state_4
  53. this.states["/parallel_1/orthogonal_2/state_4"] = new State(7, this);
  54. this.states["/parallel_1/orthogonal_2/state_4"].setEnter(this._parallel_1_orthogonal_2_state_4_enter);
  55. // add children
  56. this.states[""].addChild(this.states["/parallel_1"]);
  57. this.states["/parallel_1"].addChild(this.states["/parallel_1/orthogonal_1"]);
  58. this.states["/parallel_1"].addChild(this.states["/parallel_1/orthogonal_2"]);
  59. this.states["/parallel_1/orthogonal_1"].addChild(this.states["/parallel_1/orthogonal_1/state_1"]);
  60. this.states["/parallel_1/orthogonal_1"].addChild(this.states["/parallel_1/orthogonal_1/state_2"]);
  61. this.states["/parallel_1/orthogonal_2"].addChild(this.states["/parallel_1/orthogonal_2/state_3"]);
  62. this.states["/parallel_1/orthogonal_2"].addChild(this.states["/parallel_1/orthogonal_2/state_4"]);
  63. this.states[""].fixTree();
  64. this.states[""].default_state = this.states["/parallel_1"];
  65. this.states["/parallel_1/orthogonal_1"].default_state = this.states["/parallel_1/orthogonal_1/state_1"];
  66. this.states["/parallel_1/orthogonal_2"].default_state = this.states["/parallel_1/orthogonal_2/state_3"];
  67. // transition /parallel_1/orthogonal_1/state_1
  68. var _parallel_1_orthogonal_1_state_1_0 = new Transition(this, this.states["/parallel_1/orthogonal_1/state_1"], [this.states["/parallel_1/orthogonal_1/state_2"]]);
  69. _parallel_1_orthogonal_1_state_1_0.setTrigger(new Event("to_state_2", "test_input"));
  70. this.states["/parallel_1/orthogonal_1/state_1"].addTransition(_parallel_1_orthogonal_1_state_1_0);
  71. // transition /parallel_1/orthogonal_1/state_2
  72. var _parallel_1_orthogonal_1_state_2_0 = new Transition(this, this.states["/parallel_1/orthogonal_1/state_2"], [this.states["/parallel_1/orthogonal_1/state_1"]]);
  73. _parallel_1_orthogonal_1_state_2_0.setTrigger(new Event("to_state_1", "test_input"));
  74. this.states["/parallel_1/orthogonal_1/state_2"].addTransition(_parallel_1_orthogonal_1_state_2_0);
  75. // transition /parallel_1/orthogonal_2/state_3
  76. var _parallel_1_orthogonal_2_state_3_0 = new Transition(this, this.states["/parallel_1/orthogonal_2/state_3"], [this.states["/parallel_1/orthogonal_2/state_4"]]);
  77. _parallel_1_orthogonal_2_state_3_0.setTrigger(new Event("to_state_4", "test_input"));
  78. this.states["/parallel_1/orthogonal_2/state_3"].addTransition(_parallel_1_orthogonal_2_state_3_0);
  79. // transition /parallel_1/orthogonal_2/state_4
  80. var _parallel_1_orthogonal_2_state_4_0 = new Transition(this, this.states["/parallel_1/orthogonal_2/state_4"], [this.states["/parallel_1/orthogonal_2/state_3"]]);
  81. _parallel_1_orthogonal_2_state_4_0.setTrigger(new Event("to_state_3", "test_input"));
  82. this.states["/parallel_1/orthogonal_2/state_4"].addTransition(_parallel_1_orthogonal_2_state_4_0);
  83. };
  84. Class1.prototype._parallel_1_orthogonal_1_state_1_enter = function() {
  85. this.big_step.outputEvent(new Event("in_state_1", "test_output", new Array()));
  86. };
  87. Class1.prototype._parallel_1_orthogonal_1_state_2_enter = function() {
  88. this.big_step.outputEvent(new Event("in_state_2", "test_output", new Array()));
  89. };
  90. Class1.prototype._parallel_1_orthogonal_2_state_3_enter = function() {
  91. this.big_step.outputEvent(new Event("in_state_3", "test_output", new Array()));
  92. };
  93. Class1.prototype._parallel_1_orthogonal_2_state_4_enter = function() {
  94. this.big_step.outputEvent(new Event("in_state_4", "test_output", new Array()));
  95. };
  96. Class1.prototype.initializeStatechart = function() {
  97. // enter default state
  98. this.default_targets = this.states["/parallel_1"].getEffectiveTargetStates();
  99. RuntimeClassBase.prototype.initializeStatechart.call(this);
  100. };
  101. // add symbol 'Class1' to package 'TestParallel'
  102. TestParallel.Class1 = Class1;
  103. var ObjectManager = function(controller) {
  104. ObjectManagerBase.call(this, controller);
  105. };
  106. ObjectManager.prototype = new Object();
  107. (function() {
  108. var proto = new ObjectManagerBase();
  109. for (prop in proto) {
  110. ObjectManager.prototype[prop] = proto[prop];
  111. }
  112. })();
  113. ObjectManager.prototype.instantiate = function(class_name, construct_params) {
  114. if (class_name === "Class1") {
  115. var instance = new Class1(this.controller);
  116. instance.associations = new Object();
  117. } else {
  118. throw new Error("Cannot instantiate class " + class_name);
  119. }
  120. return instance;
  121. };
  122. // add symbol 'ObjectManager' to package 'TestParallel'
  123. TestParallel.ObjectManager = ObjectManager;
  124. var Controller = function(event_loop_callbacks, finished_callback, behind_schedule_callback) {
  125. if (finished_callback === undefined) finished_callback = null;
  126. if (behind_schedule_callback === undefined) behind_schedule_callback = null;
  127. EventLoopControllerBase.call(this, new ObjectManager(this), event_loop_callbacks, finished_callback, behind_schedule_callback);
  128. this.addInputPort("test_input");
  129. this.addOutputPort("test_output");
  130. this.object_manager.createInstance("Class1", new Array());
  131. };
  132. Controller.prototype = new Object();
  133. (function() {
  134. var proto = new EventLoopControllerBase();
  135. for (prop in proto) {
  136. Controller.prototype[prop] = proto[prop];
  137. }
  138. })();
  139. // add symbol 'Controller' to package 'TestParallel'
  140. TestParallel.Controller = Controller;
  141. var InputEvent = function(name, port, parameters, time_offset) {
  142. this.name = name;
  143. this.port = port;
  144. this.parameters = parameters;
  145. this.time_offset = time_offset;
  146. };
  147. // add symbol 'InputEvent' to package 'TestParallel'
  148. TestParallel.InputEvent = InputEvent;
  149. var Test = function() {
  150. };
  151. 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_state_1", "test_input", new Array(), 0.0), new InputEvent("to_state_2", "test_input", new Array(), 0.0), new InputEvent("to_state_3", "test_input", new Array(), 0.0)];
  152. 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_state_1", "test_output", new Array())], [new Event("in_state_2", "test_output", new Array())], [new Event("in_state_3", "test_output", new Array())]];
  153. // add symbol 'Test' to package 'TestParallel'
  154. TestParallel.Test = Test;
  155. })();