| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- /*
- 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 <root>
- 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;
- })();
|