01_take_many.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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:50 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. _a_0.setTrigger(null);
  55. this.states["/a"].addTransition(_a_0);
  56. // transition /b
  57. var _b_0 = new Transition(this, this.states["/b"], [this.states["/c"]]);
  58. _b_0.setTrigger(null);
  59. this.states["/b"].addTransition(_b_0);
  60. };
  61. c.prototype._a_enter = function() {
  62. this.big_step.outputEvent(new Event("entered_a", "out", new Array()));
  63. };
  64. c.prototype._b_enter = function() {
  65. this.big_step.outputEvent(new Event("entered_b", "out", new Array()));
  66. };
  67. c.prototype._c_enter = function() {
  68. this.big_step.outputEvent(new Event("entered_c", "out", new Array()));
  69. };
  70. c.prototype.initializeStatechart = function() {
  71. // enter default state
  72. this.default_targets = this.states["/a"].getEffectiveTargetStates();
  73. RuntimeClassBase.prototype.initializeStatechart.call(this);
  74. };
  75. // add symbol 'c' to package 'take_many'
  76. take_many.c = c;
  77. var ObjectManager = function(controller) {
  78. ObjectManagerBase.call(this, controller);
  79. };
  80. ObjectManager.prototype = new Object();
  81. (function() {
  82. var proto = new ObjectManagerBase();
  83. for (prop in proto) {
  84. ObjectManager.prototype[prop] = proto[prop];
  85. }
  86. })();
  87. ObjectManager.prototype.instantiate = function(class_name, construct_params) {
  88. if (class_name === "c") {
  89. var instance = new c(this.controller);
  90. instance.associations = new Object();
  91. } else {
  92. throw new Error("Cannot instantiate class " + class_name);
  93. }
  94. return instance;
  95. };
  96. // add symbol 'ObjectManager' to package 'take_many'
  97. take_many.ObjectManager = ObjectManager;
  98. var Controller = function(event_loop_callbacks, finished_callback, behind_schedule_callback) {
  99. if (finished_callback === undefined) finished_callback = null;
  100. if (behind_schedule_callback === undefined) behind_schedule_callback = null;
  101. EventLoopControllerBase.call(this, new ObjectManager(this), event_loop_callbacks, finished_callback, behind_schedule_callback);
  102. this.addInputPort("in");
  103. this.addOutputPort("out");
  104. this.object_manager.createInstance("c", new Array());
  105. };
  106. Controller.prototype = new Object();
  107. (function() {
  108. var proto = new EventLoopControllerBase();
  109. for (prop in proto) {
  110. Controller.prototype[prop] = proto[prop];
  111. }
  112. })();
  113. // add symbol 'Controller' to package 'take_many'
  114. take_many.Controller = Controller;
  115. var InputEvent = function(name, port, parameters, time_offset) {
  116. this.name = name;
  117. this.port = port;
  118. this.parameters = parameters;
  119. this.time_offset = time_offset;
  120. };
  121. // add symbol 'InputEvent' to package 'take_many'
  122. take_many.InputEvent = InputEvent;
  123. var Test = function() {
  124. };
  125. Test.prototype.input_events = new Array();
  126. 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())]];
  127. // add symbol 'Test' to package 'take_many'
  128. take_many.Test = Test;
  129. })();