multiple_target.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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: 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. this.default_targets = this.states["/next_to_parallel"].getEffectiveTargetStates();
  94. RuntimeClassBase.prototype.initializeStatechart.call(this);
  95. };
  96. // add symbol 'Class1' to package 'TestMultipleTarget'
  97. TestMultipleTarget.Class1 = Class1;
  98. var ObjectManager = function(controller) {
  99. ObjectManagerBase.call(this, controller);
  100. };
  101. ObjectManager.prototype = new Object();
  102. (function() {
  103. var proto = new ObjectManagerBase();
  104. for (prop in proto) {
  105. ObjectManager.prototype[prop] = proto[prop];
  106. }
  107. })();
  108. ObjectManager.prototype.instantiate = function(class_name, construct_params) {
  109. if (class_name === "Class1") {
  110. var instance = new Class1(this.controller);
  111. instance.associations = new Object();
  112. } else {
  113. throw new Error("Cannot instantiate class " + class_name);
  114. }
  115. return instance;
  116. };
  117. // add symbol 'ObjectManager' to package 'TestMultipleTarget'
  118. TestMultipleTarget.ObjectManager = ObjectManager;
  119. var Controller = function(event_loop_callbacks, finished_callback, behind_schedule_callback) {
  120. if (finished_callback === undefined) finished_callback = null;
  121. if (behind_schedule_callback === undefined) behind_schedule_callback = null;
  122. EventLoopControllerBase.call(this, new ObjectManager(this), event_loop_callbacks, finished_callback, behind_schedule_callback);
  123. this.addInputPort("test_input");
  124. this.addOutputPort("test_output");
  125. this.object_manager.createInstance("Class1", new Array());
  126. };
  127. Controller.prototype = new Object();
  128. (function() {
  129. var proto = new EventLoopControllerBase();
  130. for (prop in proto) {
  131. Controller.prototype[prop] = proto[prop];
  132. }
  133. })();
  134. // add symbol 'Controller' to package 'TestMultipleTarget'
  135. TestMultipleTarget.Controller = Controller;
  136. var InputEvent = function(name, port, parameters, time_offset) {
  137. this.name = name;
  138. this.port = port;
  139. this.parameters = parameters;
  140. this.time_offset = time_offset;
  141. };
  142. // add symbol 'InputEvent' to package 'TestMultipleTarget'
  143. TestMultipleTarget.InputEvent = InputEvent;
  144. var Test = function() {
  145. };
  146. Test.prototype.input_events = new Array();
  147. 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())]];
  148. // add symbol 'Test' to package 'TestMultipleTarget'
  149. TestMultipleTarget.Test = Test;
  150. })();