multiple_target.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /* Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
  2. Date: Wed Aug 03 16:10: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. this.states["/next_to_parallel"].addTransition(_next_to_parallel_0);
  74. };
  75. Class1.prototype._parallel_orthogonal_1_inner_1_enter = function() {
  76. this.big_step.outputEvent(new Event("enter_1_1", "test_output", new Array()));
  77. };
  78. Class1.prototype._parallel_orthogonal_1_inner_2_enter = function() {
  79. this.big_step.outputEvent(new Event("enter_1_2", "test_output", new Array()));
  80. };
  81. Class1.prototype._parallel_orthogonal_2_inner_1_enter = function() {
  82. this.big_step.outputEvent(new Event("enter_2_1", "test_output", new Array()));
  83. };
  84. Class1.prototype._parallel_orthogonal_2_inner_2_enter = function() {
  85. this.big_step.outputEvent(new Event("enter_2_2", "test_output", new Array()));
  86. };
  87. Class1.prototype._next_to_parallel_enter = function() {
  88. this.big_step.outputEvent(new Event("enter_0", "test_output", new Array()));
  89. };
  90. Class1.prototype.initializeStatechart = function() {
  91. // enter default state
  92. var states = this.states["/next_to_parallel"].getEffectiveTargetStates();
  93. this.updateConfiguration(states);
  94. for (var state_idx in states) {
  95. if (!states.hasOwnProperty(state_idx)) continue;
  96. var state = states[state_idx]
  97. if (state.enter) {
  98. state.enter();
  99. }
  100. }
  101. };
  102. // add symbol 'Class1' to package 'TestMultipleTarget'
  103. TestMultipleTarget.Class1 = Class1;
  104. var ObjectManager = function(controller) {
  105. ObjectManagerBase.call(this, controller);
  106. };
  107. ObjectManager.prototype = new Object();
  108. (function() {
  109. var proto = new ObjectManagerBase();
  110. for (prop in proto) {
  111. ObjectManager.prototype[prop] = proto[prop];
  112. }
  113. })();
  114. ObjectManager.prototype.instantiate = function(class_name, construct_params) {
  115. if (class_name === "Class1") {
  116. var instance = new Class1(this.controller);
  117. instance.associations = new Object();
  118. }
  119. return instance;
  120. };
  121. // add symbol 'ObjectManager' to package 'TestMultipleTarget'
  122. TestMultipleTarget.ObjectManager = ObjectManager;
  123. var Controller = function(event_loop_callbacks, finished_callback) {
  124. if (finished_callback === undefined) finished_callback = null;
  125. EventLoopControllerBase.call(this, new ObjectManager(this), event_loop_callbacks, finished_callback);
  126. this.addInputPort("test_input");
  127. this.addOutputPort("test_output");
  128. this.object_manager.createInstance("Class1", new Array());
  129. };
  130. Controller.prototype = new Object();
  131. (function() {
  132. var proto = new EventLoopControllerBase();
  133. for (prop in proto) {
  134. Controller.prototype[prop] = proto[prop];
  135. }
  136. })();
  137. // add symbol 'Controller' to package 'TestMultipleTarget'
  138. TestMultipleTarget.Controller = Controller;
  139. var InputEvent = function(name, port, parameters, time_offset) {
  140. this.name = name;
  141. this.port = port;
  142. this.parameters = parameters;
  143. this.time_offset = time_offset;
  144. };
  145. // add symbol 'InputEvent' to package 'TestMultipleTarget'
  146. TestMultipleTarget.InputEvent = InputEvent;
  147. var Test = function() {
  148. };
  149. Test.prototype.input_events = new Array();
  150. 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())]];
  151. // add symbol 'Test' to package 'TestMultipleTarget'
  152. TestMultipleTarget.Test = Test;
  153. })();