multiple_target.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /* Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
  2. Date: Mon Aug 08 09:49:19 2016
  3. Model author: Glenn De Jonghe
  4. Model name: TestMultipleTarget
  5. Model description:
  6. Testing the enter-exit sequence when having a transition that specificies a target state with multiple nodes.*/
  7. // package "TestMultipleTarget"
  8. var TestMultipleTarget = {};
  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
  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/inner_1
  42. this.states["/parallel/orthogonal_1/inner_1"] = new State(3, this);
  43. this.states["/parallel/orthogonal_1/inner_1"].setEnter(this._parallel_orthogonal_1_inner_1_enter);
  44. // state /parallel/orthogonal_1/inner_2
  45. this.states["/parallel/orthogonal_1/inner_2"] = new State(4, this);
  46. this.states["/parallel/orthogonal_1/inner_2"].setEnter(this._parallel_orthogonal_1_inner_2_enter);
  47. // state /parallel/orthogonal_2
  48. this.states["/parallel/orthogonal_2"] = new State(5, this);
  49. // state /parallel/orthogonal_2/inner_1
  50. this.states["/parallel/orthogonal_2/inner_1"] = new State(6, this);
  51. this.states["/parallel/orthogonal_2/inner_1"].setEnter(this._parallel_orthogonal_2_inner_1_enter);
  52. // state /parallel/orthogonal_2/inner_2
  53. this.states["/parallel/orthogonal_2/inner_2"] = new State(7, this);
  54. this.states["/parallel/orthogonal_2/inner_2"].setEnter(this._parallel_orthogonal_2_inner_2_enter);
  55. // state /next_to_parallel
  56. this.states["/next_to_parallel"] = new State(8, this);
  57. this.states["/next_to_parallel"].setEnter(this._next_to_parallel_enter);
  58. // add children
  59. this.states[""].addChild(this.states["/parallel"]);
  60. this.states[""].addChild(this.states["/next_to_parallel"]);
  61. this.states["/parallel"].addChild(this.states["/parallel/orthogonal_1"]);
  62. this.states["/parallel"].addChild(this.states["/parallel/orthogonal_2"]);
  63. this.states["/parallel/orthogonal_1"].addChild(this.states["/parallel/orthogonal_1/inner_1"]);
  64. this.states["/parallel/orthogonal_1"].addChild(this.states["/parallel/orthogonal_1/inner_2"]);
  65. this.states["/parallel/orthogonal_2"].addChild(this.states["/parallel/orthogonal_2/inner_1"]);
  66. this.states["/parallel/orthogonal_2"].addChild(this.states["/parallel/orthogonal_2/inner_2"]);
  67. this.states[""].fixTree();
  68. this.states[""].default_state = this.states["/next_to_parallel"];
  69. this.states["/parallel/orthogonal_1"].default_state = this.states["/parallel/orthogonal_1/inner_1"];
  70. this.states["/parallel/orthogonal_2"].default_state = this.states["/parallel/orthogonal_2/inner_1"];
  71. // transition /next_to_parallel
  72. var _next_to_parallel_0 = new Transition(this, this.states["/next_to_parallel"], [this.states["/parallel/orthogonal_1/inner_2"], this.states["/parallel/orthogonal_2/inner_2"]]);
  73. _next_to_parallel_0.setTrigger(null);
  74. this.states["/next_to_parallel"].addTransition(_next_to_parallel_0);
  75. };
  76. Class1.prototype._parallel_orthogonal_1_inner_1_enter = function() {
  77. this.big_step.outputEvent(new Event("enter_1_1", "test_output", new Array()));
  78. };
  79. Class1.prototype._parallel_orthogonal_1_inner_2_enter = function() {
  80. this.big_step.outputEvent(new Event("enter_1_2", "test_output", new Array()));
  81. };
  82. Class1.prototype._parallel_orthogonal_2_inner_1_enter = function() {
  83. this.big_step.outputEvent(new Event("enter_2_1", "test_output", new Array()));
  84. };
  85. Class1.prototype._parallel_orthogonal_2_inner_2_enter = function() {
  86. this.big_step.outputEvent(new Event("enter_2_2", "test_output", new Array()));
  87. };
  88. Class1.prototype._next_to_parallel_enter = function() {
  89. this.big_step.outputEvent(new Event("enter_0", "test_output", new Array()));
  90. };
  91. Class1.prototype.initializeStatechart = function() {
  92. // enter default state
  93. var states = this.states["/next_to_parallel"].getEffectiveTargetStates();
  94. this.updateConfiguration(states);
  95. for (var state_idx in states) {
  96. if (!states.hasOwnProperty(state_idx)) continue;
  97. var state = states[state_idx]
  98. if (state.enter) {
  99. state.enter();
  100. }
  101. }
  102. };
  103. // add symbol 'Class1' to package 'TestMultipleTarget'
  104. TestMultipleTarget.Class1 = Class1;
  105. var ObjectManager = function(controller) {
  106. ObjectManagerBase.call(this, controller);
  107. };
  108. ObjectManager.prototype = new Object();
  109. (function() {
  110. var proto = new ObjectManagerBase();
  111. for (prop in proto) {
  112. ObjectManager.prototype[prop] = proto[prop];
  113. }
  114. })();
  115. ObjectManager.prototype.instantiate = function(class_name, construct_params) {
  116. if (class_name === "Class1") {
  117. var instance = new Class1(this.controller);
  118. instance.associations = new Object();
  119. } else {
  120. throw new Error("Cannot instantiate class " + class_name);
  121. }
  122. return instance;
  123. };
  124. // add symbol 'ObjectManager' to package 'TestMultipleTarget'
  125. TestMultipleTarget.ObjectManager = ObjectManager;
  126. var Controller = function(event_loop_callbacks, finished_callback, behind_schedule_callback) {
  127. if (finished_callback === undefined) finished_callback = null;
  128. if (behind_schedule_callback === undefined) behind_schedule_callback = null;
  129. EventLoopControllerBase.call(this, new ObjectManager(this), event_loop_callbacks, finished_callback, behind_schedule_callback);
  130. this.addInputPort("test_input");
  131. this.addOutputPort("test_output");
  132. this.object_manager.createInstance("Class1", new Array());
  133. };
  134. Controller.prototype = new Object();
  135. (function() {
  136. var proto = new EventLoopControllerBase();
  137. for (prop in proto) {
  138. Controller.prototype[prop] = proto[prop];
  139. }
  140. })();
  141. // add symbol 'Controller' to package 'TestMultipleTarget'
  142. TestMultipleTarget.Controller = Controller;
  143. var InputEvent = function(name, port, parameters, time_offset) {
  144. this.name = name;
  145. this.port = port;
  146. this.parameters = parameters;
  147. this.time_offset = time_offset;
  148. };
  149. // add symbol 'InputEvent' to package 'TestMultipleTarget'
  150. TestMultipleTarget.InputEvent = InputEvent;
  151. var Test = function() {
  152. };
  153. Test.prototype.input_events = new Array();
  154. Test.prototype.expected_events = [[new Event("enter_0", "test_output", new Array())], [new Event("enter_1_2", "test_output", new Array()), new Event("enter_2_2", "test_output", new Array())]];
  155. // add symbol 'Test' to package 'TestMultipleTarget'
  156. TestMultipleTarget.Test = Test;
  157. })();