/* Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)

Date:   Wed Aug 03 16:10:19 2016

Model author: Glenn De Jonghe
Model name:   TestHistoryParallelDeep
Model description:
Testing history deep.*/


// package "TestHistoryParallelDeep"
var TestHistoryParallelDeep = {};
(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 /parallel
    this.states["/parallel"] = new ParallelState(1, this);
    
    // state /parallel/orthogonal
    this.states["/parallel/orthogonal"] = new State(2, this);
    
    // state /parallel/orthogonal/wrapper
    this.states["/parallel/orthogonal/wrapper"] = new ParallelState(3, this);
    
    // state /parallel/orthogonal/wrapper/state_1
    this.states["/parallel/orthogonal/wrapper/state_1"] = new State(4, this);
    
    // state /parallel/orthogonal/wrapper/state_1/inner_1
    this.states["/parallel/orthogonal/wrapper/state_1/inner_1"] = new State(5, this);
    
    // state /parallel/orthogonal/wrapper/state_1/inner_2
    this.states["/parallel/orthogonal/wrapper/state_1/inner_2"] = new State(6, this);
    
    // state /parallel/orthogonal/wrapper/state_2
    this.states["/parallel/orthogonal/wrapper/state_2"] = new State(7, this);
    
    // state /parallel/orthogonal/wrapper/state_2/inner_3
    this.states["/parallel/orthogonal/wrapper/state_2/inner_3"] = new State(8, this);
    
    // state /parallel/orthogonal/wrapper/state_2/inner_4
    this.states["/parallel/orthogonal/wrapper/state_2/inner_4"] = new State(9, this);
    
    // state /parallel/orthogonal/wrapper/history
    this.states["/parallel/orthogonal/wrapper/history"] = new DeepHistoryState(10, this);
    
    // state /parallel/orthogonal/outer
    this.states["/parallel/orthogonal/outer"] = new State(11, this);
    
    // state /parallel/orthogonal_tester
    this.states["/parallel/orthogonal_tester"] = new State(12, this);
    
    // state /parallel/orthogonal_tester/start
    this.states["/parallel/orthogonal_tester/start"] = new State(13, this);
    
    // state /parallel/orthogonal_tester/step1
    this.states["/parallel/orthogonal_tester/step1"] = new State(14, this);
    
    // state /parallel/orthogonal_tester/step2
    this.states["/parallel/orthogonal_tester/step2"] = new State(15, this);
    
    // state /parallel/orthogonal_tester/step3
    this.states["/parallel/orthogonal_tester/step3"] = new State(16, this);
    
    // state /parallel/orthogonal_tester/end
    this.states["/parallel/orthogonal_tester/end"] = new State(17, this);
    
    // add children
    this.states[""].addChild(this.states["/parallel"]);
    this.states["/parallel"].addChild(this.states["/parallel/orthogonal"]);
    this.states["/parallel"].addChild(this.states["/parallel/orthogonal_tester"]);
    this.states["/parallel/orthogonal"].addChild(this.states["/parallel/orthogonal/wrapper"]);
    this.states["/parallel/orthogonal"].addChild(this.states["/parallel/orthogonal/outer"]);
    this.states["/parallel/orthogonal/wrapper"].addChild(this.states["/parallel/orthogonal/wrapper/state_1"]);
    this.states["/parallel/orthogonal/wrapper"].addChild(this.states["/parallel/orthogonal/wrapper/state_2"]);
    this.states["/parallel/orthogonal/wrapper"].addChild(this.states["/parallel/orthogonal/wrapper/history"]);
    this.states["/parallel/orthogonal/wrapper/state_1"].addChild(this.states["/parallel/orthogonal/wrapper/state_1/inner_1"]);
    this.states["/parallel/orthogonal/wrapper/state_1"].addChild(this.states["/parallel/orthogonal/wrapper/state_1/inner_2"]);
    this.states["/parallel/orthogonal/wrapper/state_2"].addChild(this.states["/parallel/orthogonal/wrapper/state_2/inner_3"]);
    this.states["/parallel/orthogonal/wrapper/state_2"].addChild(this.states["/parallel/orthogonal/wrapper/state_2/inner_4"]);
    this.states["/parallel/orthogonal_tester"].addChild(this.states["/parallel/orthogonal_tester/start"]);
    this.states["/parallel/orthogonal_tester"].addChild(this.states["/parallel/orthogonal_tester/step1"]);
    this.states["/parallel/orthogonal_tester"].addChild(this.states["/parallel/orthogonal_tester/step2"]);
    this.states["/parallel/orthogonal_tester"].addChild(this.states["/parallel/orthogonal_tester/step3"]);
    this.states["/parallel/orthogonal_tester"].addChild(this.states["/parallel/orthogonal_tester/end"]);
    this.states[""].fixTree();
    this.states[""].default_state = this.states["/parallel"];
    this.states["/parallel/orthogonal"].default_state = this.states["/parallel/orthogonal/wrapper"];
    this.states["/parallel/orthogonal/wrapper/state_1"].default_state = this.states["/parallel/orthogonal/wrapper/state_1/inner_1"];
    this.states["/parallel/orthogonal/wrapper/state_2"].default_state = this.states["/parallel/orthogonal/wrapper/state_2/inner_3"];
    this.states["/parallel/orthogonal_tester"].default_state = this.states["/parallel/orthogonal_tester/start"];
    
    // transition /parallel/orthogonal/wrapper/state_1/inner_1
    var _parallel_orthogonal_wrapper_state_1_inner_1_0 = new Transition(this, this.states["/parallel/orthogonal/wrapper/state_1/inner_1"], [this.states["/parallel/orthogonal/wrapper/state_1/inner_2"]]);
    _parallel_orthogonal_wrapper_state_1_inner_1_0.trigger = new Event("to_inner_2", null);
    this.states["/parallel/orthogonal/wrapper/state_1/inner_1"].addTransition(_parallel_orthogonal_wrapper_state_1_inner_1_0);
    
    // transition /parallel/orthogonal/wrapper/state_2/inner_3
    var _parallel_orthogonal_wrapper_state_2_inner_3_0 = new Transition(this, this.states["/parallel/orthogonal/wrapper/state_2/inner_3"], [this.states["/parallel/orthogonal/wrapper/state_2/inner_4"]]);
    _parallel_orthogonal_wrapper_state_2_inner_3_0.trigger = new Event("to_inner_4", null);
    this.states["/parallel/orthogonal/wrapper/state_2/inner_3"].addTransition(_parallel_orthogonal_wrapper_state_2_inner_3_0);
    
    // transition /parallel/orthogonal/outer
    var _parallel_orthogonal_outer_0 = new Transition(this, this.states["/parallel/orthogonal/outer"], [this.states["/parallel/orthogonal/wrapper/history"]]);
    _parallel_orthogonal_outer_0.trigger = new Event("to_history", null);
    this.states["/parallel/orthogonal/outer"].addTransition(_parallel_orthogonal_outer_0);
    
    // transition /parallel/orthogonal_tester/start
    var _parallel_orthogonal_tester_start_0 = new Transition(this, this.states["/parallel/orthogonal_tester/start"], [this.states["/parallel/orthogonal_tester/step1"]]);
    _parallel_orthogonal_tester_start_0.setAction(this._parallel_orthogonal_tester_start_0_exec);
    this.states["/parallel/orthogonal_tester/start"].addTransition(_parallel_orthogonal_tester_start_0);
    
    // transition /parallel/orthogonal_tester/step1
    var _parallel_orthogonal_tester_step1_0 = new Transition(this, this.states["/parallel/orthogonal_tester/step1"], [this.states["/parallel/orthogonal_tester/step2"]]);
    _parallel_orthogonal_tester_step1_0.setAction(this._parallel_orthogonal_tester_step1_0_exec);
    _parallel_orthogonal_tester_step1_0.setGuard(this._parallel_orthogonal_tester_step1_0_guard);
    this.states["/parallel/orthogonal_tester/step1"].addTransition(_parallel_orthogonal_tester_step1_0);
    
    // transition /parallel/orthogonal_tester/step2
    var _parallel_orthogonal_tester_step2_0 = new Transition(this, this.states["/parallel/orthogonal_tester/step2"], [this.states["/parallel/orthogonal_tester/step3"]]);
    _parallel_orthogonal_tester_step2_0.setAction(this._parallel_orthogonal_tester_step2_0_exec);
    _parallel_orthogonal_tester_step2_0.setGuard(this._parallel_orthogonal_tester_step2_0_guard);
    this.states["/parallel/orthogonal_tester/step2"].addTransition(_parallel_orthogonal_tester_step2_0);
    
    // transition /parallel/orthogonal_tester/step3
    var _parallel_orthogonal_tester_step3_0 = new Transition(this, this.states["/parallel/orthogonal_tester/step3"], [this.states["/parallel/orthogonal_tester/end"]]);
    _parallel_orthogonal_tester_step3_0.setAction(this._parallel_orthogonal_tester_step3_0_exec);
    _parallel_orthogonal_tester_step3_0.setGuard(this._parallel_orthogonal_tester_step3_0_guard);
    this.states["/parallel/orthogonal_tester/step3"].addTransition(_parallel_orthogonal_tester_step3_0);
    
    // transition /parallel/orthogonal/wrapper
    var _parallel_orthogonal_wrapper_0 = new Transition(this, this.states["/parallel/orthogonal/wrapper"], [this.states["/parallel/orthogonal/outer"]]);
    _parallel_orthogonal_wrapper_0.trigger = new Event("to_outer", null);
    this.states["/parallel/orthogonal/wrapper"].addTransition(_parallel_orthogonal_wrapper_0);
};

Class1.prototype._parallel_orthogonal_tester_start_0_exec = function(parameters) {
    this.raiseInternalEvent(new Event("to_inner_2", null, new Array()));
    this.raiseInternalEvent(new Event("to_inner_4", null, new Array()));
};

Class1.prototype._parallel_orthogonal_tester_step1_0_exec = function(parameters) {
    this.big_step.outputEvent(new Event("check1", "test_output", new Array()));
    this.raiseInternalEvent(new Event("to_outer", null, new Array()));
};

Class1.prototype._parallel_orthogonal_tester_step1_0_guard = function(parameters) {
    return this.inState(["/parallel/orthogonal/wrapper/state_2/inner_4", "/parallel/orthogonal/wrapper/state_1/inner_2"]);
};

Class1.prototype._parallel_orthogonal_tester_step2_0_exec = function(parameters) {
    this.big_step.outputEvent(new Event("check2", "test_output", new Array()));
    this.raiseInternalEvent(new Event("to_history", null, new Array()));
};

Class1.prototype._parallel_orthogonal_tester_step2_0_guard = function(parameters) {
    return this.inState(["/parallel/orthogonal/outer"]);
};

Class1.prototype._parallel_orthogonal_tester_step3_0_exec = function(parameters) {
    this.big_step.outputEvent(new Event("check3", "test_output", new Array()));
};

Class1.prototype._parallel_orthogonal_tester_step3_0_guard = function(parameters) {
    return this.inState(["/parallel/orthogonal/wrapper/state_2/inner_4", "/parallel/orthogonal/wrapper/state_1/inner_2"]);
};

Class1.prototype.initializeStatechart = function() {
    // enter default state
    var states = this.states["/parallel"].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 'TestHistoryParallelDeep'
TestHistoryParallelDeep.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();
    }
    return instance;
};

// add symbol 'ObjectManager' to package 'TestHistoryParallelDeep'
TestHistoryParallelDeep.ObjectManager = ObjectManager;

var Controller = function(event_loop_callbacks, finished_callback) {
    if (finished_callback === undefined) finished_callback = null;
    EventLoopControllerBase.call(this, new ObjectManager(this), event_loop_callbacks, finished_callback);
    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 'TestHistoryParallelDeep'
TestHistoryParallelDeep.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 'TestHistoryParallelDeep'
TestHistoryParallelDeep.InputEvent = InputEvent;

var Test = function() {
};
Test.prototype.input_events = new Array();
Test.prototype.expected_events = [[new Event("check1", "test_output", new Array())], [new Event("check2", "test_output", new Array())], [new Event("check3", "test_output", new Array())]];

// add symbol 'Test' to package 'TestHistoryParallelDeep'
TestHistoryParallelDeep.Test = Test;
})();