/* Date: Fri Jul 30 16:04:21 2021 Model author: Joeri Exelmans Model name: Ping Model description: A class that logs to console 'ping' every 1s */ // package Ping let Ping = {}; (function() { let Main = function(controller) { RuntimeClassBase.call(this, controller); this.semantics.bigStepMaximality = StatechartSemantics.TakeMany; this.semantics.internalEventLifeline = StatechartSemantics.NextComboStep; this.semantics.inputEventLifeline = StatechartSemantics.FirstComboStep; this.semantics.priority = StatechartSemantics.SourceParent; this.semantics.concurrency = StatechartSemantics.Single; // build Statechart structure this.buildStatechartStructure(); // call user defined constructor Main.prototype.userDefinedConstructor.call(this); }; Main.prototype = new Object(); (function() { var proto = new RuntimeClassBase(); for (let prop in proto) { Main.prototype[prop] = proto[prop]; } })(); Main.prototype.userDefinedConstructor = function() { }; Main.prototype.userDefinedDestructor = function() { }; // builds Statechart structure Main.prototype.buildStatechartStructure = function() { // state this.states[""] = new State(0, "", this); // state /p this.states["/p"] = new ParallelState(1, "/p", this); // state /p/r1 this.states["/p/r1"] = new State(2, "/p/r1", this); // state /p/r1/A this.states["/p/r1/A"] = new State(3, "/p/r1/A", this); this.states["/p/r1/A"].setEnter(this.PR1AEnter); this.states["/p/r1/A"].setExit(this.PR1AExit); // state /p/r2 this.states["/p/r2"] = new State(4, "/p/r2", this); // state /p/r2/B this.states["/p/r2/B"] = new State(5, "/p/r2/B", this); this.states["/p/r2/B"].setEnter(this.PR2BEnter); this.states["/p/r2/B"].setExit(this.PR2BExit); // add children this.states[""].addChild(this.states["/p"]); this.states["/p"].addChild(this.states["/p/r1"]); this.states["/p"].addChild(this.states["/p/r2"]); this.states["/p/r1"].addChild(this.states["/p/r1/A"]); this.states["/p/r2"].addChild(this.states["/p/r2/B"]); this.states[""].fixTree(); this.states[""].defaultState = this.states["/p"]; this.states["/p/r1"].defaultState = this.states["/p/r1/A"]; this.states["/p/r2"].defaultState = this.states["/p/r2/B"]; // transition /p/r1/A var PR1A_0 = new Transition(this, this.states["/p/r1/A"], [this.states["/p/r1/A"]]); PR1A_0.setAction(this.PR1A_0Exec); PR1A_0.setTrigger(new Event("event0After")); this.states["/p/r1/A"].addTransition(PR1A_0); // transition /p/r2/B var PR2B_0 = new Transition(this, this.states["/p/r2/B"], [this.states["/p/r2/B"]]); PR2B_0.setAction(this.PR2B_0Exec); PR2B_0.setTrigger(new Event("event1After")); this.states["/p/r2/B"].addTransition(PR2B_0); }; Main.prototype.PR1AEnter = function() { this.addTimer(0, 1); }; Main.prototype.PR1AExit = function() { this.removeTimer(0); }; Main.prototype.PR2BEnter = function() { this.addTimer(1, 2); }; Main.prototype.PR2BExit = function() { this.removeTimer(1); }; Main.prototype.PR1A_0Exec = function(parameters) { console.log("A"); }; Main.prototype.PR2B_0Exec = function(parameters) { console.log("B"); }; Main.prototype.initializeStatechart = function() { // enter default state this.defaultTargets = this.states["/p"].getEffectiveTargetStates(); RuntimeClassBase.prototype.initializeStatechart.call(this); }; // Add symbol 'Main' to package 'Ping' Ping.Main = Main; let ObjectManager = function(controller) { ObjectManagerBase.call(this, controller); }; ObjectManager.prototype = new Object(); (function() { var proto = new ObjectManagerBase(); for (let prop in proto) { ObjectManager.prototype[prop] = proto[prop]; } })(); ObjectManager.prototype.instantiate = function(className, constructParams) { if (className === "Main") { var instance = new Main(this.controller); instance.associations = new Object(); } else { throw new Error("Cannot instantiate class " + className); } return instance; }; // Add symbol 'ObjectManager' to package 'Ping' Ping.ObjectManager = ObjectManager; let Controller = function(eventLoopCallbacks, finishedCallback, behindScheduleCallback) { if (finishedCallback === undefined) finishedCallback = null; if (behindScheduleCallback === undefined) behindScheduleCallback = null; EventLoopControllerBase.call(this, new ObjectManager(this), eventLoopCallbacks, finishedCallback, behindScheduleCallback); this.objectManager.createInstance("Main", new Array()); }; Controller.prototype = new Object(); (function() { var proto = new EventLoopControllerBase(); for (let prop in proto) { Controller.prototype[prop] = proto[prop]; } })(); // Add symbol 'Controller' to package 'Ping' Ping.Controller = Controller; })();