01_take_many.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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:17 2016
  3. Model author: Herr Joeri Exelmans
  4. Model name: take_many
  5. Model description:
  6. Take Many-semantics: A big step doesn't end until there are no more enabled transitions.*/
  7. // package "take_many"
  8. var take_many = {};
  9. (function() {
  10. var c = 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. c.prototype.user_defined_constructor.call(this);
  21. };
  22. c.prototype = new Object();
  23. (function() {
  24. var proto = new RuntimeClassBase();
  25. for (prop in proto) {
  26. c.prototype[prop] = proto[prop];
  27. }
  28. })();
  29. c.prototype.user_defined_constructor = function() {
  30. };
  31. c.prototype.user_defined_destructor = function() {
  32. };
  33. // builds Statechart structure
  34. c.prototype.build_statechart_structure = function() {
  35. // state <root>
  36. this.states[""] = new State(0, this);
  37. // state /a
  38. this.states["/a"] = new State(1, this);
  39. this.states["/a"].setEnter(this._a_enter);
  40. // state /b
  41. this.states["/b"] = new State(2, this);
  42. this.states["/b"].setEnter(this._b_enter);
  43. // state /c
  44. this.states["/c"] = new State(3, this);
  45. this.states["/c"].setEnter(this._c_enter);
  46. // add children
  47. this.states[""].addChild(this.states["/a"]);
  48. this.states[""].addChild(this.states["/b"]);
  49. this.states[""].addChild(this.states["/c"]);
  50. this.states[""].fixTree();
  51. this.states[""].default_state = this.states["/a"];
  52. // transition /a
  53. var _a_0 = new Transition(this, this.states["/a"], [this.states["/b"]]);
  54. this.states["/a"].addTransition(_a_0);
  55. // transition /b
  56. var _b_0 = new Transition(this, this.states["/b"], [this.states["/c"]]);
  57. this.states["/b"].addTransition(_b_0);
  58. };
  59. c.prototype._a_enter = function() {
  60. this.big_step.outputEvent(new Event("entered_a", "out", new Array()));
  61. };
  62. c.prototype._b_enter = function() {
  63. this.big_step.outputEvent(new Event("entered_b", "out", new Array()));
  64. };
  65. c.prototype._c_enter = function() {
  66. this.big_step.outputEvent(new Event("entered_c", "out", new Array()));
  67. };
  68. c.prototype.initializeStatechart = function() {
  69. // enter default state
  70. var states = this.states["/a"].getEffectiveTargetStates();
  71. this.updateConfiguration(states);
  72. for (var state_idx in states) {
  73. if (!states.hasOwnProperty(state_idx)) continue;
  74. var state = states[state_idx]
  75. if (state.enter) {
  76. state.enter();
  77. }
  78. }
  79. };
  80. // add symbol 'c' to package 'take_many'
  81. take_many.c = c;
  82. var ObjectManager = function(controller) {
  83. ObjectManagerBase.call(this, controller);
  84. };
  85. ObjectManager.prototype = new Object();
  86. (function() {
  87. var proto = new ObjectManagerBase();
  88. for (prop in proto) {
  89. ObjectManager.prototype[prop] = proto[prop];
  90. }
  91. })();
  92. ObjectManager.prototype.instantiate = function(class_name, construct_params) {
  93. if (class_name === "c") {
  94. var instance = new c(this.controller);
  95. instance.associations = new Object();
  96. }
  97. return instance;
  98. };
  99. // add symbol 'ObjectManager' to package 'take_many'
  100. take_many.ObjectManager = ObjectManager;
  101. var Controller = function(event_loop_callbacks, finished_callback) {
  102. if (finished_callback === undefined) finished_callback = null;
  103. EventLoopControllerBase.call(this, new ObjectManager(this), event_loop_callbacks, finished_callback);
  104. this.addInputPort("in");
  105. this.addOutputPort("out");
  106. this.object_manager.createInstance("c", new Array());
  107. };
  108. Controller.prototype = new Object();
  109. (function() {
  110. var proto = new EventLoopControllerBase();
  111. for (prop in proto) {
  112. Controller.prototype[prop] = proto[prop];
  113. }
  114. })();
  115. // add symbol 'Controller' to package 'take_many'
  116. take_many.Controller = Controller;
  117. var InputEvent = function(name, port, parameters, time_offset) {
  118. this.name = name;
  119. this.port = port;
  120. this.parameters = parameters;
  121. this.time_offset = time_offset;
  122. };
  123. // add symbol 'InputEvent' to package 'take_many'
  124. take_many.InputEvent = InputEvent;
  125. var Test = function() {
  126. };
  127. Test.prototype.input_events = new Array();
  128. Test.prototype.expected_events = [[new Event("entered_a", "out", new Array())], [new Event("entered_b", "out", new Array()), new Event("entered_c", "out", new Array())]];
  129. // add symbol 'Test' to package 'take_many'
  130. take_many.Test = Test;
  131. })();