123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- /* Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
- Date: Mon Aug 08 09:49:18 2016
- Model author: Glenn De Jonghe
- Model name: TestEnterExitHierarchy
- Model description:
- Testing the enter and exit hierarchy.*/
- // package "TestEnterExitHierarchy"
- var TestEnterExitHierarchy = {};
- (function() {
- var Class1 = function(controller) {
- RuntimeClassBase.call(this, controller);
-
- this.semantics.big_step_maximality = StatechartSemantics.TakeMany;
- this.semantics.internal_event_lifeline = StatechartSemantics.Queue;
- this.semantics.input_event_lifeline = StatechartSemantics.FirstComboStep;
- this.semantics.priority = StatechartSemantics.SourceParent;
- this.semantics.concurrency = StatechartSemantics.Single;
-
- // build Statechart structure
- this.build_statechart_structure();
-
- // call user defined constructor
- Class1.prototype.user_defined_constructor.call(this);
- };
- Class1.prototype = new Object();
- (function() {
- var proto = new RuntimeClassBase();
- for (prop in proto) {
- Class1.prototype[prop] = proto[prop];
- }
- })();
- Class1.prototype.user_defined_constructor = function() {
- };
- Class1.prototype.user_defined_destructor = function() {
- };
- // builds Statechart structure
- Class1.prototype.build_statechart_structure = function() {
-
- // state <root>
- this.states[""] = new State(0, this);
-
- // state /outside
- this.states["/outside"] = new State(1, this);
-
- // state /composite
- this.states["/composite"] = new State(2, this);
-
- // state /composite/state1
- this.states["/composite/state1"] = new State(3, this);
- this.states["/composite/state1"].setEnter(this._composite_state1_enter);
- this.states["/composite/state1"].setExit(this._composite_state1_exit);
-
- // state /composite/state1/inner1
- this.states["/composite/state1/inner1"] = new State(4, this);
- this.states["/composite/state1/inner1"].setEnter(this._composite_state1_inner1_enter);
- this.states["/composite/state1/inner1"].setExit(this._composite_state1_inner1_exit);
-
- // state /composite/state1/inner2
- this.states["/composite/state1/inner2"] = new State(5, this);
- this.states["/composite/state1/inner2"].setEnter(this._composite_state1_inner2_enter);
- this.states["/composite/state1/inner2"].setExit(this._composite_state1_inner2_exit);
-
- // state /composite/state2
- this.states["/composite/state2"] = new State(6, this);
- this.states["/composite/state2"].setEnter(this._composite_state2_enter);
- this.states["/composite/state2"].setExit(this._composite_state2_exit);
-
- // state /composite/state2/inner3
- this.states["/composite/state2/inner3"] = new State(7, this);
- this.states["/composite/state2/inner3"].setEnter(this._composite_state2_inner3_enter);
- this.states["/composite/state2/inner3"].setExit(this._composite_state2_inner3_exit);
-
- // state /composite/state2/inner4
- this.states["/composite/state2/inner4"] = new State(8, this);
- this.states["/composite/state2/inner4"].setEnter(this._composite_state2_inner4_enter);
- this.states["/composite/state2/inner4"].setExit(this._composite_state2_inner4_exit);
-
- // add children
- this.states[""].addChild(this.states["/outside"]);
- this.states[""].addChild(this.states["/composite"]);
- this.states["/composite"].addChild(this.states["/composite/state1"]);
- this.states["/composite"].addChild(this.states["/composite/state2"]);
- this.states["/composite/state1"].addChild(this.states["/composite/state1/inner1"]);
- this.states["/composite/state1"].addChild(this.states["/composite/state1/inner2"]);
- this.states["/composite/state2"].addChild(this.states["/composite/state2/inner3"]);
- this.states["/composite/state2"].addChild(this.states["/composite/state2/inner4"]);
- this.states[""].fixTree();
- this.states[""].default_state = this.states["/outside"];
- this.states["/composite"].default_state = this.states["/composite/state1"];
- this.states["/composite/state1"].default_state = this.states["/composite/state1/inner1"];
- this.states["/composite/state2"].default_state = this.states["/composite/state2/inner3"];
-
- // transition /outside
- var _outside_0 = new Transition(this, this.states["/outside"], [this.states["/composite"]]);
- _outside_0.setTrigger(new Event("to_composite", "test_input"));
- this.states["/outside"].addTransition(_outside_0);
- var _outside_1 = new Transition(this, this.states["/outside"], [this.states["/composite/state2/inner3"]]);
- _outside_1.setTrigger(new Event("to_inner3", "test_input"));
- this.states["/outside"].addTransition(_outside_1);
- var _outside_2 = new Transition(this, this.states["/outside"], [this.states["/composite/state2/inner4"]]);
- _outside_2.setTrigger(new Event("to_inner4", "test_input"));
- this.states["/outside"].addTransition(_outside_2);
-
- // transition /composite/state1/inner1
- var _composite_state1_inner1_0 = new Transition(this, this.states["/composite/state1/inner1"], [this.states["/composite/state1/inner2"]]);
- _composite_state1_inner1_0.setTrigger(new Event("to_inner2", "test_input"));
- this.states["/composite/state1/inner1"].addTransition(_composite_state1_inner1_0);
-
- // transition /composite
- var _composite_0 = new Transition(this, this.states["/composite"], [this.states["/outside"]]);
- _composite_0.setTrigger(new Event("to_outside", "test_input"));
- this.states["/composite"].addTransition(_composite_0);
- };
- Class1.prototype._composite_state1_enter = function() {
- this.big_step.outputEvent(new Event("enter_state1", "test_output", new Array()));
- };
- Class1.prototype._composite_state1_exit = function() {
- this.big_step.outputEvent(new Event("exit_state1", "test_output", new Array()));
- };
- Class1.prototype._composite_state2_enter = function() {
- this.big_step.outputEvent(new Event("enter_state2", "test_output", new Array()));
- };
- Class1.prototype._composite_state2_exit = function() {
- this.big_step.outputEvent(new Event("exit_state2", "test_output", new Array()));
- };
- Class1.prototype._composite_state1_inner1_enter = function() {
- this.big_step.outputEvent(new Event("enter_inner1", "test_output", new Array()));
- };
- Class1.prototype._composite_state1_inner1_exit = function() {
- this.big_step.outputEvent(new Event("exit_inner1", "test_output", new Array()));
- };
- Class1.prototype._composite_state1_inner2_enter = function() {
- this.big_step.outputEvent(new Event("enter_inner2", "test_output", new Array()));
- };
- Class1.prototype._composite_state1_inner2_exit = function() {
- this.big_step.outputEvent(new Event("exit_inner2", "test_output", new Array()));
- };
- Class1.prototype._composite_state2_inner3_enter = function() {
- this.big_step.outputEvent(new Event("enter_inner3", "test_output", new Array()));
- };
- Class1.prototype._composite_state2_inner3_exit = function() {
- this.big_step.outputEvent(new Event("exit_inner3", "test_output", new Array()));
- };
- Class1.prototype._composite_state2_inner4_enter = function() {
- this.big_step.outputEvent(new Event("enter_inner4", "test_output", new Array()));
- };
- Class1.prototype._composite_state2_inner4_exit = function() {
- this.big_step.outputEvent(new Event("exit_inner4", "test_output", new Array()));
- };
- Class1.prototype.initializeStatechart = function() {
- // enter default state
- var states = this.states["/outside"].getEffectiveTargetStates();
- this.updateConfiguration(states);
- for (var state_idx in states) {
- if (!states.hasOwnProperty(state_idx)) continue;
- var state = states[state_idx]
- if (state.enter) {
- state.enter();
- }
- }
- };
- // add symbol 'Class1' to package 'TestEnterExitHierarchy'
- TestEnterExitHierarchy.Class1 = Class1;
- var ObjectManager = function(controller) {
- ObjectManagerBase.call(this, controller);
- };
- ObjectManager.prototype = new Object();
- (function() {
- var proto = new ObjectManagerBase();
- for (prop in proto) {
- ObjectManager.prototype[prop] = proto[prop];
- }
- })();
- ObjectManager.prototype.instantiate = function(class_name, construct_params) {
- if (class_name === "Class1") {
- var instance = new Class1(this.controller);
- instance.associations = new Object();
- } else {
- throw new Error("Cannot instantiate class " + class_name);
- }
- return instance;
- };
- // add symbol 'ObjectManager' to package 'TestEnterExitHierarchy'
- TestEnterExitHierarchy.ObjectManager = ObjectManager;
- var Controller = function(event_loop_callbacks, finished_callback, behind_schedule_callback) {
- if (finished_callback === undefined) finished_callback = null;
- if (behind_schedule_callback === undefined) behind_schedule_callback = null;
- EventLoopControllerBase.call(this, new ObjectManager(this), event_loop_callbacks, finished_callback, behind_schedule_callback);
- this.addInputPort("test_input");
- this.addOutputPort("test_output");
- this.object_manager.createInstance("Class1", new Array());
- };
- Controller.prototype = new Object();
- (function() {
- var proto = new EventLoopControllerBase();
- for (prop in proto) {
- Controller.prototype[prop] = proto[prop];
- }
- })();
- // add symbol 'Controller' to package 'TestEnterExitHierarchy'
- TestEnterExitHierarchy.Controller = Controller;
- var InputEvent = function(name, port, parameters, time_offset) {
- this.name = name;
- this.port = port;
- this.parameters = parameters;
- this.time_offset = time_offset;
- };
- // add symbol 'InputEvent' to package 'TestEnterExitHierarchy'
- TestEnterExitHierarchy.InputEvent = InputEvent;
- var Test = function() {
- };
- Test.prototype.input_events = [new InputEvent("to_composite", "test_input", new Array(), 0.0), new InputEvent("to_inner2", "test_input", new Array(), 0.0), new InputEvent("to_outside", "test_input", new Array(), 0.0), new InputEvent("to_inner3", "test_input", new Array(), 0.0), new InputEvent("to_outside", "test_input", new Array(), 0.0), new InputEvent("to_inner4", "test_input", new Array(), 0.0)];
- Test.prototype.expected_events = [[new Event("enter_state1", "test_output", new Array())], [new Event("enter_inner1", "test_output", new Array())], [new Event("exit_inner1", "test_output", new Array())], [new Event("enter_inner2", "test_output", new Array())], [new Event("exit_inner2", "test_output", new Array())], [new Event("exit_state1", "test_output", new Array())], [new Event("enter_state2", "test_output", new Array())], [new Event("enter_inner3", "test_output", new Array())], [new Event("exit_inner3", "test_output", new Array())], [new Event("exit_state2", "test_output", new Array())], [new Event("enter_state2", "test_output", new Array())], [new Event("enter_inner4", "test_output", new Array())]];
- // add symbol 'Test' to package 'TestEnterExitHierarchy'
- TestEnterExitHierarchy.Test = Test;
- })();
|