outer_first.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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:20 2016
  3. Model author: Glenn De Jonghe
  4. Model name: TestOuterFirst
  5. Model description:
  6. Testing outer first.*/
  7. // package "TestOuterFirst"
  8. var TestOuterFirst = {};
  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 /state1
  38. this.states["/state1"] = new State(1, this);
  39. // state /state1/state1
  40. this.states["/state1/state1"] = new State(2, this);
  41. // state /state1/statea
  42. this.states["/state1/statea"] = new State(3, this);
  43. this.states["/state1/statea"].setEnter(this._state1_statea_enter);
  44. // state /stateb
  45. this.states["/stateb"] = new State(4, this);
  46. this.states["/stateb"].setEnter(this._stateb_enter);
  47. // add children
  48. this.states[""].addChild(this.states["/state1"]);
  49. this.states[""].addChild(this.states["/stateb"]);
  50. this.states["/state1"].addChild(this.states["/state1/state1"]);
  51. this.states["/state1"].addChild(this.states["/state1/statea"]);
  52. this.states[""].fixTree();
  53. this.states[""].default_state = this.states["/state1"];
  54. this.states["/state1"].default_state = this.states["/state1/state1"];
  55. // transition /state1/state1
  56. var _state1_state1_0 = new Transition(this, this.states["/state1/state1"], [this.states["/state1/statea"]]);
  57. _state1_state1_0.setTrigger(new Event("event", "test_input"));
  58. this.states["/state1/state1"].addTransition(_state1_state1_0);
  59. // transition /state1
  60. var _state1_0 = new Transition(this, this.states["/state1"], [this.states["/stateb"]]);
  61. _state1_0.setTrigger(new Event("event", "test_input"));
  62. this.states["/state1"].addTransition(_state1_0);
  63. };
  64. Class1.prototype._state1_statea_enter = function() {
  65. this.big_step.outputEvent(new Event("in_a", "test_output", new Array()));
  66. };
  67. Class1.prototype._stateb_enter = function() {
  68. this.big_step.outputEvent(new Event("in_b", "test_output", new Array()));
  69. };
  70. Class1.prototype.initializeStatechart = function() {
  71. // enter default state
  72. var states = this.states["/state1"].getEffectiveTargetStates();
  73. this.updateConfiguration(states);
  74. for (var state_idx in states) {
  75. if (!states.hasOwnProperty(state_idx)) continue;
  76. var state = states[state_idx]
  77. if (state.enter) {
  78. state.enter();
  79. }
  80. }
  81. };
  82. // add symbol 'Class1' to package 'TestOuterFirst'
  83. TestOuterFirst.Class1 = Class1;
  84. var ObjectManager = function(controller) {
  85. ObjectManagerBase.call(this, controller);
  86. };
  87. ObjectManager.prototype = new Object();
  88. (function() {
  89. var proto = new ObjectManagerBase();
  90. for (prop in proto) {
  91. ObjectManager.prototype[prop] = proto[prop];
  92. }
  93. })();
  94. ObjectManager.prototype.instantiate = function(class_name, construct_params) {
  95. if (class_name === "Class1") {
  96. var instance = new Class1(this.controller);
  97. instance.associations = new Object();
  98. } else {
  99. throw new Error("Cannot instantiate class " + class_name);
  100. }
  101. return instance;
  102. };
  103. // add symbol 'ObjectManager' to package 'TestOuterFirst'
  104. TestOuterFirst.ObjectManager = ObjectManager;
  105. var Controller = function(event_loop_callbacks, finished_callback, behind_schedule_callback) {
  106. if (finished_callback === undefined) finished_callback = null;
  107. if (behind_schedule_callback === undefined) behind_schedule_callback = null;
  108. EventLoopControllerBase.call(this, new ObjectManager(this), event_loop_callbacks, finished_callback, behind_schedule_callback);
  109. this.addInputPort("test_input");
  110. this.addOutputPort("test_output");
  111. this.object_manager.createInstance("Class1", new Array());
  112. };
  113. Controller.prototype = new Object();
  114. (function() {
  115. var proto = new EventLoopControllerBase();
  116. for (prop in proto) {
  117. Controller.prototype[prop] = proto[prop];
  118. }
  119. })();
  120. // add symbol 'Controller' to package 'TestOuterFirst'
  121. TestOuterFirst.Controller = Controller;
  122. var InputEvent = function(name, port, parameters, time_offset) {
  123. this.name = name;
  124. this.port = port;
  125. this.parameters = parameters;
  126. this.time_offset = time_offset;
  127. };
  128. // add symbol 'InputEvent' to package 'TestOuterFirst'
  129. TestOuterFirst.InputEvent = InputEvent;
  130. var Test = function() {
  131. };
  132. Test.prototype.input_events = [new InputEvent("event", "test_input", new Array(), 0.0)];
  133. Test.prototype.expected_events = [[new Event("in_b", "test_output", new Array())]];
  134. // add symbol 'Test' to package 'TestOuterFirst'
  135. TestOuterFirst.Test = Test;
  136. })();