history.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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: TestHistory
  5. Model description:
  6. Testing the History state.*/
  7. // package "TestHistory"
  8. var TestHistory = {};
  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 /composite_1
  38. this.states["/composite_1"] = new State(1, this);
  39. // state /composite_1/state_1
  40. this.states["/composite_1/state_1"] = new State(2, this);
  41. this.states["/composite_1/state_1"].setEnter(this._composite_1_state_1_enter);
  42. // state /composite_1/state_2
  43. this.states["/composite_1/state_2"] = new State(3, this);
  44. this.states["/composite_1/state_2"].setEnter(this._composite_1_state_2_enter);
  45. // state /composite_1/composite_history
  46. this.states["/composite_1/composite_history"] = new ShallowHistoryState(4, this);
  47. // state /state_3
  48. this.states["/state_3"] = new State(5, this);
  49. this.states["/state_3"].setEnter(this._state_3_enter);
  50. // add children
  51. this.states[""].addChild(this.states["/composite_1"]);
  52. this.states[""].addChild(this.states["/state_3"]);
  53. this.states["/composite_1"].addChild(this.states["/composite_1/state_1"]);
  54. this.states["/composite_1"].addChild(this.states["/composite_1/state_2"]);
  55. this.states["/composite_1"].addChild(this.states["/composite_1/composite_history"]);
  56. this.states[""].fixTree();
  57. this.states[""].default_state = this.states["/composite_1"];
  58. this.states["/composite_1"].default_state = this.states["/composite_1/state_1"];
  59. // transition /composite_1/state_1
  60. var _composite_1_state_1_0 = new Transition(this, this.states["/composite_1/state_1"], [this.states["/composite_1/state_2"]]);
  61. _composite_1_state_1_0.setTrigger(new Event("to_state_2", "test_input"));
  62. this.states["/composite_1/state_1"].addTransition(_composite_1_state_1_0);
  63. // transition /state_3
  64. var _state_3_0 = new Transition(this, this.states["/state_3"], [this.states["/composite_1/composite_history"]]);
  65. _state_3_0.setTrigger(null);
  66. this.states["/state_3"].addTransition(_state_3_0);
  67. // transition /composite_1
  68. var _composite_1_0 = new Transition(this, this.states["/composite_1"], [this.states["/state_3"]]);
  69. _composite_1_0.setTrigger(new Event("to_state_3", "test_input"));
  70. this.states["/composite_1"].addTransition(_composite_1_0);
  71. };
  72. Class1.prototype._composite_1_state_1_enter = function() {
  73. this.big_step.outputEvent(new Event("in_state_1", "test_output", new Array()));
  74. };
  75. Class1.prototype._composite_1_state_2_enter = function() {
  76. this.big_step.outputEvent(new Event("in_state_2", "test_output", new Array()));
  77. };
  78. Class1.prototype._state_3_enter = function() {
  79. this.big_step.outputEvent(new Event("in_state_3", "test_output", new Array()));
  80. };
  81. Class1.prototype.initializeStatechart = function() {
  82. // enter default state
  83. this.default_targets = this.states["/composite_1"].getEffectiveTargetStates();
  84. RuntimeClassBase.prototype.initializeStatechart.call(this);
  85. };
  86. // add symbol 'Class1' to package 'TestHistory'
  87. TestHistory.Class1 = Class1;
  88. var ObjectManager = function(controller) {
  89. ObjectManagerBase.call(this, controller);
  90. };
  91. ObjectManager.prototype = new Object();
  92. (function() {
  93. var proto = new ObjectManagerBase();
  94. for (prop in proto) {
  95. ObjectManager.prototype[prop] = proto[prop];
  96. }
  97. })();
  98. ObjectManager.prototype.instantiate = function(class_name, construct_params) {
  99. if (class_name === "Class1") {
  100. var instance = new Class1(this.controller);
  101. instance.associations = new Object();
  102. } else {
  103. throw new Error("Cannot instantiate class " + class_name);
  104. }
  105. return instance;
  106. };
  107. // add symbol 'ObjectManager' to package 'TestHistory'
  108. TestHistory.ObjectManager = ObjectManager;
  109. var Controller = function(event_loop_callbacks, finished_callback, behind_schedule_callback) {
  110. if (finished_callback === undefined) finished_callback = null;
  111. if (behind_schedule_callback === undefined) behind_schedule_callback = null;
  112. EventLoopControllerBase.call(this, new ObjectManager(this), event_loop_callbacks, finished_callback, behind_schedule_callback);
  113. this.addInputPort("test_input");
  114. this.addOutputPort("test_output");
  115. this.object_manager.createInstance("Class1", new Array());
  116. };
  117. Controller.prototype = new Object();
  118. (function() {
  119. var proto = new EventLoopControllerBase();
  120. for (prop in proto) {
  121. Controller.prototype[prop] = proto[prop];
  122. }
  123. })();
  124. // add symbol 'Controller' to package 'TestHistory'
  125. TestHistory.Controller = Controller;
  126. var InputEvent = function(name, port, parameters, time_offset) {
  127. this.name = name;
  128. this.port = port;
  129. this.parameters = parameters;
  130. this.time_offset = time_offset;
  131. };
  132. // add symbol 'InputEvent' to package 'TestHistory'
  133. TestHistory.InputEvent = InputEvent;
  134. var Test = function() {
  135. };
  136. Test.prototype.input_events = [new InputEvent("to_state_2", "test_input", new Array(), 0.0), new InputEvent("to_state_3", "test_input", new Array(), 0.0)];
  137. Test.prototype.expected_events = [[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())], [new Event("in_state_2", "test_output", new Array())]];
  138. // add symbol 'Test' to package 'TestHistory'
  139. TestHistory.Test = Test;
  140. })();