diff --git a/com.yakindu.sct.examples.coffeemachine.c/index.html b/com.yakindu.sct.examples.coffeemachine.c/index.html index 756efbe6..81762ae5 100644 --- a/com.yakindu.sct.examples.coffeemachine.c/index.html +++ b/com.yakindu.sct.examples.coffeemachine.c/index.html @@ -10,7 +10,7 @@

[Pro] Coffee Machine with C integration

- This is a comprehensive example for the deep integration of YAKINDU + This is a comprehensive example for the deep integration of itemis CREATE statecharts with manually written C code. The example is implemented as a simple command line tool. It makes use of POSIX threads. So you need a compiler tool chain and a 'pthread' library to build an run the example. diff --git a/com.yakindu.sct.examples.coffeemachine.c/main.c b/com.yakindu.sct.examples.coffeemachine.c/main.c index c3d070e5..b7b4d443 100644 --- a/com.yakindu.sct.examples.coffeemachine.c/main.c +++ b/com.yakindu.sct.examples.coffeemachine.c/main.c @@ -8,7 +8,7 @@ #include "src-gen/CoffeeMachine.h" #include "src-gen/sc_timer_service.h" -/*! \file Implementation of the main function and setup of the virtual YAKINDU Coffee Maker. +/*! \file Implementation of the main function and setup of the virtual itemis CREATE Coffee Maker. * It includes everything to setup and run the example. * The example applies a cycle based execution model. */ diff --git a/com.yakindu.sct.examples.coffeemachine.c/metadata.json b/com.yakindu.sct.examples.coffeemachine.c/metadata.json index 9485484f..6c19e425 100644 --- a/com.yakindu.sct.examples.coffeemachine.c/metadata.json +++ b/com.yakindu.sct.examples.coffeemachine.c/metadata.json @@ -2,7 +2,7 @@ "id": "com.yakindu.sct.examples.coffeemachine.c", "title": "Coffee Machine (Deep C)", "author": "itemis AG", - "description": "This is a comprehensive example for the deep integration of YAKINDU statecharts with manually written C code. The example is implemented as a simple command line tool.", + "description": "This is a comprehensive example for the deep integration of itemis CREATE statecharts with manually written C code. The example is implemented as a simple command line tool.", "previewImage": "coffee_machine_thumb.jpg", "category": [ "professional", diff --git a/com.yakindu.sct.examples.coffeemachine.c/model/CoffeeMachine.ysc b/com.yakindu.sct.examples.coffeemachine.c/model/CoffeeMachine.ysc index 35e8838b..840c3541 100644 --- a/com.yakindu.sct.examples.coffeemachine.c/model/CoffeeMachine.ysc +++ b/com.yakindu.sct.examples.coffeemachine.c/model/CoffeeMachine.ysc @@ -11,7 +11,7 @@ - + diff --git a/com.yakindu.sct.examples.coffeemachine.cpp/index.html b/com.yakindu.sct.examples.coffeemachine.cpp/index.html index c0891ede..468f67ad 100644 --- a/com.yakindu.sct.examples.coffeemachine.cpp/index.html +++ b/com.yakindu.sct.examples.coffeemachine.cpp/index.html @@ -10,7 +10,7 @@

[Pro] Coffee Machine with C++ integration

- This is a example for the deep C++ integration of YAKINDU + This is a example for the deep C++ integration of itemis CREATE statecharts. It shows how C++ classes can be used as variables and is based on the C example:

Model

The statechart consists of two diff --git a/com.yakindu.sct.examples.coffeemachine.cpp/metadata.json b/com.yakindu.sct.examples.coffeemachine.cpp/metadata.json index 1ba77458..254f490c 100644 --- a/com.yakindu.sct.examples.coffeemachine.cpp/metadata.json +++ b/com.yakindu.sct.examples.coffeemachine.cpp/metadata.json @@ -2,7 +2,7 @@ "id": "com.yakindu.sct.examples.coffeemachine.cpp", "title": "Coffee Machine (Deep C++)", "author": "itemis AG", - "description": "This is a comprehensive example for the deep C++ integration of YAKINDU statecharts.", + "description": "This is a comprehensive example for the deep C++ integration of itemis CREATE statecharts.", "previewImage": "coffee_machine_thumb.jpg", "category": [ "professional", diff --git a/com.yakindu.sct.examples.coffeemachine.cpp/model/CoffeeMachineCpp.ysc b/com.yakindu.sct.examples.coffeemachine.cpp/model/CoffeeMachineCpp.ysc index 4e4a4df4..a220127d 100644 --- a/com.yakindu.sct.examples.coffeemachine.cpp/model/CoffeeMachineCpp.ysc +++ b/com.yakindu.sct.examples.coffeemachine.cpp/model/CoffeeMachineCpp.ysc @@ -8,7 +8,7 @@ - + diff --git a/com.yakindu.sct.examples.msp430.blinky/index.html b/com.yakindu.sct.examples.msp430.blinky/index.html index ef061d2d..03ba5d8e 100644 --- a/com.yakindu.sct.examples.msp430.blinky/index.html +++ b/com.yakindu.sct.examples.msp430.blinky/index.html @@ -16,14 +16,14 @@

Overview

This tutorial contains three parts:

-

1. Installing the YAKINDU Statechart Tool as a Plugin into Texas +

1. Installing the itemis CREATE Statechart Tool as a Plugin into Texas Instruments Code Composer Studio

2. Adding state machines to the project

3. Creating the Blinky example with the Professional Edition

The whole tutorial gives you step-by-step instructions to enable you to upload the project.

-

Installing the YAKINDU Statechart Tool as a Plugin into Texas +

Installing the itemis CREATE Statechart Tool as a Plugin into Texas Instruments Code Composer Studio

First, you need to install TIs Code Composer Studio, which you can find here:

@@ -56,7 +56,7 @@

Installing the YAKINDU Statechart Tool as a Plugin into Texas

- After this, you need to get the download site of YAKINDU Statechart Tools. + After this, you need to get the download site of itemis CREATE. Go to our download site and complete the free registration, in case you have not done this already. Then you will get a number of different @@ -68,7 +68,7 @@

Installing the YAKINDU Statechart Tool as a Plugin into Texas

Once again, go over to install new software. There you add the URL - you copied from our site. Choose at least the YAKINDU Statechart + you copied from our site. Choose at least the itemis CREATE Statechart Tools Professional Edition. You will get a trial version, which lasts for 30 days. Don’t hesitate, our aren’t buying anything. If the time expired, you can still use all free Standard Edition features. @@ -83,7 +83,7 @@

Installing the YAKINDU Statechart Tool as a Plugin into Texas needs to be restarted. Afterwards, the installation is finished.

-

Working with YAKINDU Statecharts Tool in CCS

+

Working with itemis CREATE Statecharts Tool in CCS

To use state machines proceed as normal and create a new CCS Project. Open the File tab, open New, click on Other and search for @@ -95,7 +95,7 @@

Working with YAKINDU Statecharts Tool in CCS

Now you can start working with state machines!

-

Working with YAKINDU Statecharts Tool Professional Edition

+

Working with itemis CREATE Statecharts Tool Professional Edition

Right click the project, open New and choose a C Statechart Model. A Wizard will be opened in which you can select your project and name your @@ -160,7 +160,7 @@

Generate the C-Code

and click on Code Generator Model. Choose a name for the sgen file. It is good practice to stay with the state machine name. Call it "blinkyStateMachine.sgen" for example and click on Next. Choose the desired state machine by - clicking on the checkbox. Ensure that you have chosen the YAKINDU + clicking on the checkbox. Ensure that you have chosen the itemis CREATE SCT C Code Generator and click on Finish.

@@ -224,7 +224,7 @@

That’s it - Now you can build and upload the program to your

System and Version Information

The following tools were used in the creation of this tutorial:

System: Windows 10

-

YAKINDU Statechart Tool Version: 2.9.3

+

itemis CREATE Statechart Tool Version: 2.9.3

Code Composer Version: 7.0.0.00043

Note: The MSP430G2 Launchpad does not support Linux. @@ -232,18 +232,18 @@

System and Version Information

Support for Code Composer Studio Version 6

Code Composer Studio V6 is based Eclipse Mars (4.5.) and Java 7. - Installing and running YAKINDU Statechart Tools within CCSV6 requires two steps:

+ Installing and running itemis CREATE within CCSV6 requires two steps:

1st: Use the Mars update site instead of the Neon update site, which you can find here. As I mentioned before, you do not need to install anything of the Mars update site. Just add the update site. - After this you are able to install YAKINDU Statechart Tools within CCS V6 as described before. - You need to get the download site of YAKINDU Statechart Tools. + After this you are able to install itemis CREATE within CCS V6 as described before. + You need to get the download site of itemis CREATE. Go to our download site and complete the free registration, in case you have not done this already. Then you will get a number of different installation options. Choose the black button with install from update site.

-

2nd: YAKINDU Statechart Tools has been added, but it won't be executed, +

2nd: itemis CREATE has been added, but it won't be executed, because Java 8 is missing. Therefore, if you don't already have, install a 32 bit version of Java 8. Afterwards, right click your CCS V6 shortcut and add the path of the 32 bit Java 8. For my machine it looks like this:

diff --git a/com.yakindu.sct.examples.msp430.blinky/metadata.json b/com.yakindu.sct.examples.msp430.blinky/metadata.json index 3ad19b25..095a6214 100644 --- a/com.yakindu.sct.examples.msp430.blinky/metadata.json +++ b/com.yakindu.sct.examples.msp430.blinky/metadata.json @@ -1,7 +1,7 @@ { "id": "com.yakindu.sct.examples.msp430.blinky", "title": "MSP430 - Blinky LED (Deep C)", - "description": "Blinking LED on MSP430G2553 by using TIs Code Composer Studio and YAKINDU Statechart Tools as a plugin", + "description": "Blinking LED on MSP430G2553 by using TIs Code Composer Studio and itemis CREATE as a plugin", "previewImage": "msp430_thumb.jpg", "author": "itemis AG", "category": [ diff --git a/com.yakindu.sct.examples.stm32f407vg.blinky/Core/Inc/sc_timer_service.h b/com.yakindu.sct.examples.stm32f407vg.blinky/Core/Inc/sc_timer_service.h index b883deea..33815405 100644 --- a/com.yakindu.sct.examples.stm32f407vg.blinky/Core/Inc/sc_timer_service.h +++ b/com.yakindu.sct.examples.stm32f407vg.blinky/Core/Inc/sc_timer_service.h @@ -14,7 +14,7 @@ extern "C" { #endif -/*! file/ Interface definition of a POSIX thread based timer service for YAKINDU SCT state machines. */ +/*! file/ Interface definition of a POSIX thread based timer service for itemis CREATE state machines. */ struct sc_timer_service; diff --git a/com.yakindu.sct.examples.stm32f407vg.blinky/index.html b/com.yakindu.sct.examples.stm32f407vg.blinky/index.html index be096811..11dfcbed 100644 --- a/com.yakindu.sct.examples.stm32f407vg.blinky/index.html +++ b/com.yakindu.sct.examples.stm32f407vg.blinky/index.html @@ -12,7 +12,7 @@

[Pro] STM32F407 Discovery Board With Deep C Integration

- This is an example for the integration of YAKINDU Statechart Tools with another IDE, here the STM32CubeIDE. + This is an example for the integration of itemis CREATE with another IDE, here the STM32CubeIDE. The example model makes use of the deep C integration to directly call functions from the HAL headers in the statechart model:

@@ -29,7 +29,7 @@

Getting started

required. You can find it HERE.

- After downloading and installing the STM32CubeIDE, YAKINDU Statechart Tools Professional Edition must + After downloading and installing the STM32CubeIDE, itemis CREATE Professional Edition must installed via the update site. You can follow these STEPS. diff --git a/com.yakindu.sct.examples.stm32f407vg.multism.blinky/Core/Inc/sc_timer_service.h b/com.yakindu.sct.examples.stm32f407vg.multism.blinky/Core/Inc/sc_timer_service.h index b883deea..33815405 100644 --- a/com.yakindu.sct.examples.stm32f407vg.multism.blinky/Core/Inc/sc_timer_service.h +++ b/com.yakindu.sct.examples.stm32f407vg.multism.blinky/Core/Inc/sc_timer_service.h @@ -14,7 +14,7 @@ extern "C" { #endif -/*! file/ Interface definition of a POSIX thread based timer service for YAKINDU SCT state machines. */ +/*! file/ Interface definition of a POSIX thread based timer service for itemis CREATE state machines. */ struct sc_timer_service; diff --git a/com.yakindu.sct.examples.stm32f407vg.multism.blinky/Core/Src/sc_timer_service.c b/com.yakindu.sct.examples.stm32f407vg.multism.blinky/Core/Src/sc_timer_service.c index 21fe894f..5687ff4e 100644 --- a/com.yakindu.sct.examples.stm32f407vg.multism.blinky/Core/Src/sc_timer_service.c +++ b/com.yakindu.sct.examples.stm32f407vg.multism.blinky/Core/Src/sc_timer_service.c @@ -10,7 +10,7 @@ #include "sc_timer_service.h" -/*! \file Implementation of YAKINDU SCT timer functionality based on POSIX threads. */ +/*! \file Implementation of itemis CREATE timer functionality based on POSIX threads. */ /*! Callback that is called when a timer fires. */ diff --git a/com.yakindu.sct.examples.stm32f407vg.multism.blinky/index.html b/com.yakindu.sct.examples.stm32f407vg.multism.blinky/index.html index b8a05d50..053e2afd 100644 --- a/com.yakindu.sct.examples.stm32f407vg.multism.blinky/index.html +++ b/com.yakindu.sct.examples.stm32f407vg.multism.blinky/index.html @@ -12,7 +12,7 @@

[Pro] STM32F407 Discovery Board Using Multi State Machines With Deep C Integration

- This is an example for the integration of YAKINDU Statechart Tools with another IDE, here the + This is an example for the integration of itemis CREATE with another IDE, here the STM32CubeIDE. The example model demonstrates the usage of the multi state machines feature together with the deep C @@ -44,7 +44,7 @@

Getting started

required. You can find it HERE.

- After downloading and installing the STM32CubeIDE, YAKINDU Statechart Tools Professional Edition must + After downloading and installing the STM32CubeIDE, itemis CREATE Professional Edition must installed via the update site. You can follow these STEPS. diff --git a/org.yakindu.sct.examples.basic.childfirst/childfirst-player/assets/bundle.js b/org.yakindu.sct.examples.basic.childfirst/childfirst-player/assets/bundle.js new file mode 100644 index 00000000..d93b4323 --- /dev/null +++ b/org.yakindu.sct.examples.basic.childfirst/childfirst-player/assets/bundle.js @@ -0,0 +1,550 @@ +var com; +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Instances represent state machine trace events. + * @param {com.yakindu.core.TraceEventType} type + * @param {*} machine + * @param {*} state + * @param {*} feature + * @param {*} value + * @class + */ + class TraceEvent { + constructor(type, machine, state, feature, value) { + if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && ((state != null) || state === null) && ((feature != null) || feature === null) && ((value != null) || value === null)) { + let __args = arguments; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + else if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && state === undefined && feature === undefined && value === undefined) { + let __args = arguments; + { + let __args = arguments; + let state = null; + let feature = null; + let value = null; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + } + else + throw new Error('invalid overload'); + } + getType() { + return this.type; + } + getMachine() { + return this.machine; + } + getState() { + return this.state; + } + getFeature() { + return this.feature; + } + getValue() { + return this.value; + } + } + core.TraceEvent = TraceEvent; + TraceEvent["__class"] = "com.yakindu.core.TraceEvent"; + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Trace event type enumeration. + * @enum + * @property {com.yakindu.core.TraceEventType} MACHINE_ENTER + * @property {com.yakindu.core.TraceEventType} MACHINE_EXIT + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_START + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_STOP + * @property {com.yakindu.core.TraceEventType} STATE_ENTERED + * @property {com.yakindu.core.TraceEventType} STATE_EXITED + * @property {com.yakindu.core.TraceEventType} STATE_TRANSITION + * @property {com.yakindu.core.TraceEventType} EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} VARIABLE_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_UNSET + * @class + */ + let TraceEventType; + (function (TraceEventType) { + TraceEventType[TraceEventType["MACHINE_ENTER"] = 0] = "MACHINE_ENTER"; + TraceEventType[TraceEventType["MACHINE_EXIT"] = 1] = "MACHINE_EXIT"; + TraceEventType[TraceEventType["MACHINE_RTS_START"] = 2] = "MACHINE_RTS_START"; + TraceEventType[TraceEventType["MACHINE_RTS_STOP"] = 3] = "MACHINE_RTS_STOP"; + TraceEventType[TraceEventType["STATE_ENTERED"] = 4] = "STATE_ENTERED"; + TraceEventType[TraceEventType["STATE_EXITED"] = 5] = "STATE_EXITED"; + TraceEventType[TraceEventType["STATE_TRANSITION"] = 6] = "STATE_TRANSITION"; + TraceEventType[TraceEventType["EVENT_RAISED"] = 7] = "EVENT_RAISED"; + TraceEventType[TraceEventType["VARIABLE_SET"] = 8] = "VARIABLE_SET"; + TraceEventType[TraceEventType["TIME_EVENT_RAISED"] = 9] = "TIME_EVENT_RAISED"; + TraceEventType[TraceEventType["TIME_EVENT_SET"] = 10] = "TIME_EVENT_SET"; + TraceEventType[TraceEventType["TIME_EVENT_UNSET"] = 11] = "TIME_EVENT_UNSET"; + })(TraceEventType = core.TraceEventType || (core.TraceEventType = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + var rx; + (function (rx) { + class Observable { + constructor() { + this.observers = ([]); + } + next(value) { + for (let index = 0; index < this.observers.length; index++) { + let observer = this.observers[index]; + { + observer.next(value); + } + } + } + subscribe(observer) { + return observer != null ? /* add */ (this.observers.push(observer) > 0) : false; + } + unsubscribe(observer) { + return observer != null ? /* remove */ (a => { let index = a.indexOf(observer); if (index >= 0) { + a.splice(index, 1); + return true; + } + else { + return false; + } })(this.observers) : false; + } + } + rx.Observable = Observable; + Observable["__class"] = "com.yakindu.core.rx.Observable"; + })(rx = core.rx || (core.rx = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +var sct; +(function (sct) { + var yakindu; + (function (yakindu) { + var io; + (function (io) { + class Statemachine { + constructor() { + this.stateVector = [null]; + this.trace = (new com.yakindu.core.rx.Observable()); + this.inEventQueue = ([]); + if (this.isExecuting === undefined) { + this.isExecuting = false; + } + if (this.e === undefined) { + this.e = false; + } + if (this.m === undefined) { + this.m = 0; + } + if (this.n === undefined) { + this.n = 0; + } + if (this.o === undefined) { + this.o = 0; + } + for (let i = 0; i < 1; i++) { + { + this.stateVector[i] = Statemachine.State.$NULLSTATE$; + } + ; + } + this.clearInEvents(); + this.setM(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.M, this.m))); + this.setN(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.N, this.n))); + this.setO(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.O, this.o))); + this.isExecuting = false; + } + getIsExecuting() { + return this.isExecuting; + } + setIsExecuting(value) { + this.isExecuting = value; + } + enter() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_ENTER, this))); + this.enterSequence_main_region_default(); + this.isExecuting = false; + } + exit() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_EXIT, this))); + this.exitSequence_main_region(); + this.isExecuting = false; + } + /** + * @see IStatemachine#isActive() + * @return {boolean} + */ + isActive() { + return this.stateVector[0] !== Statemachine.State.$NULLSTATE$; + } + /** + * + * Always returns 'false' since this state machine can never become final. + * + * @see IStatemachine#isFinal() + * @return {boolean} + */ + isFinal() { + return false; + } + clearInEvents() { + this.e = false; + } + microStep() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_A_R1_B: + this.main_region_A_r1_B_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_A_R1_C: + this.main_region_A_r1_C_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_D: + this.main_region_D_react(-1); + break; + default: + break; + } + } + runCycle() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_START, this))); + this.nextEvent(); + do { + { + this.microStep(); + this.clearInEvents(); + this.nextEvent(); + } + } while ((this.e)); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_STOP, this))); + this.isExecuting = false; + } + nextEvent() { + if (!(this.inEventQueue.length == 0)) { + (target => (typeof target === 'function') ? target() : target.run())(/* poll */ (a => a.length == 0 ? null : a.shift())(this.inEventQueue)); + return; + } + } + /** + * Returns true if the given state is currently active otherwise false. + * @param {sct.yakindu.io.Statemachine.State} state + * @return {boolean} + */ + isStateActive(state) { + switch ((state)) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_A: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_A]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_A_R1_C]]; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_A_R1_B: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_A_R1_B; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_A_R1_C: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_A_R1_C; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_D: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_D; + default: + return false; + } + } + getTrace() { + return this.trace; + } + raiseE() { + /* add */ (this.inEventQueue.push(() => { + this.e = true; + }) > 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this, null, Statemachine.Feature.E, null))); + this.runCycle(); + } + getM() { + return this.m; + } + setM(value) { + this.m = value; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.M, this.m))); + } + getN() { + return this.n; + } + setN(value) { + this.n = value; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.N, this.n))); + } + getO() { + return this.o; + } + setO(value) { + this.o = value; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.O, this.o))); + } + entryAction_main_region_A() { + this.setM(1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.M, this.m))); + } + entryAction_main_region_A_r1_B() { + this.setM(2); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.M, this.m))); + } + exitAction_main_region_A() { + this.setO(1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.O, this.o))); + } + exitAction_main_region_A_r1_B() { + this.setO(2); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.O, this.o))); + } + enterSequence_main_region_A_default() { + this.entryAction_main_region_A(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_A, null, null))); + this.enterSequence_main_region_A_r1_default(); + } + enterSequence_main_region_A_r1_B_default() { + this.entryAction_main_region_A_r1_B(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_A_R1_B, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_A_R1_B; + } + enterSequence_main_region_A_r1_C_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_A_R1_C, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_A_R1_C; + } + enterSequence_main_region_D_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_D, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_D; + } + enterSequence_main_region_default() { + this.react_main_region__entry_Default(); + } + enterSequence_main_region_A_r1_default() { + this.react_main_region_A_r1__entry_Default(); + } + exitSequence_main_region_A() { + this.exitSequence_main_region_A_r1(); + this.exitAction_main_region_A(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_A, null, null))); + } + exitSequence_main_region_A_r1_B() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.exitAction_main_region_A_r1_B(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_A_R1_B, null, null))); + } + exitSequence_main_region_A_r1_C() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_A_R1_C, null, null))); + } + exitSequence_main_region_D() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_D, null, null))); + } + exitSequence_main_region() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_A_R1_B: + this.exitSequence_main_region_A_r1_B(); + this.exitAction_main_region_A(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_A, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_A_R1_C: + this.exitSequence_main_region_A_r1_C(); + this.exitAction_main_region_A(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_A, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_D: + this.exitSequence_main_region_D(); + break; + default: + break; + } + } + exitSequence_main_region_A_r1() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_A_R1_B: + this.exitSequence_main_region_A_r1_B(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_A_R1_C: + this.exitSequence_main_region_A_r1_C(); + break; + default: + break; + } + } + react_main_region_A_r1__entry_Default() { + this.enterSequence_main_region_A_r1_B_default(); + } + react_main_region__entry_Default() { + this.enterSequence_main_region_A_default(); + } + react(transitioned_before) { + return transitioned_before; + } + main_region_A_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.e) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_A, null, 0))); + this.exitSequence_main_region_A(); + this.enterSequence_main_region_D_default(); + this.react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + if (this.e) { + this.setN(1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.N, this.n))); + } + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_region_A_r1_B_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.e) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_A_R1_B, null, 0))); + this.exitSequence_main_region_A_r1_B(); + this.enterSequence_main_region_A_r1_C_default(); + this.main_region_A_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + if (this.e) { + this.setN(2); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.N, this.n))); + } + transitioned_after = this.main_region_A_react(transitioned_before); + } + return transitioned_after; + } + main_region_A_r1_C_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_A_react(transitioned_before); + } + return transitioned_after; + } + main_region_D_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + } + io.Statemachine = Statemachine; + Statemachine["__class"] = "sct.yakindu.io.Statemachine"; + Statemachine["__interfaces"] = ["com.yakindu.core.IStatemachine"]; + (function (Statemachine) { + let State; + (function (State) { + State[State["MAIN_REGION_A"] = 0] = "MAIN_REGION_A"; + State[State["MAIN_REGION_A_R1_B"] = 1] = "MAIN_REGION_A_R1_B"; + State[State["MAIN_REGION_A_R1_C"] = 2] = "MAIN_REGION_A_R1_C"; + State[State["MAIN_REGION_D"] = 3] = "MAIN_REGION_D"; + State[State["$NULLSTATE$"] = 4] = "$NULLSTATE$"; + })(State = Statemachine.State || (Statemachine.State = {})); + /** + * Enumeration of all features of the statechart + * @enum + * @property {sct.yakindu.io.Statemachine.Feature} NO_FEATURE + * @property {sct.yakindu.io.Statemachine.Feature} E + * @property {sct.yakindu.io.Statemachine.Feature} M + * @property {sct.yakindu.io.Statemachine.Feature} N + * @property {sct.yakindu.io.Statemachine.Feature} O + * @class + */ + let Feature; + (function (Feature) { + Feature[Feature["NO_FEATURE"] = 0] = "NO_FEATURE"; + Feature[Feature["E"] = 1] = "E"; + Feature[Feature["M"] = 2] = "M"; + Feature[Feature["N"] = 3] = "N"; + Feature[Feature["O"] = 4] = "O"; + })(Feature = Statemachine.Feature || (Statemachine.Feature = {})); + })(Statemachine = io.Statemachine || (io.Statemachine = {})); + })(io = yakindu.io || (yakindu.io = {})); + })(yakindu = sct.yakindu || (sct.yakindu = {})); +})(sct || (sct = {})); diff --git a/org.yakindu.sct.examples.basic.childfirst/childfirst-player/assets/context.json.js b/org.yakindu.sct.examples.basic.childfirst/childfirst-player/assets/context.json.js new file mode 100644 index 00000000..df20296f --- /dev/null +++ b/org.yakindu.sct.examples.basic.childfirst/childfirst-player/assets/context.json.js @@ -0,0 +1 @@ +const contextJson = {"elements":[{"elements":[{"kind":"event","name":"e","fqName":"e","featureId":"E","writable":true},{"kind":"variable","type":"integer","name":"m","fqName":"m","featureId":"M","writable":true,"value":0},{"kind":"variable","type":"integer","name":"n","fqName":"n","featureId":"N","writable":true,"value":0},{"kind":"variable","type":"integer","name":"o","fqName":"o","featureId":"O","writable":true,"value":0}],"kind":"composite","name":"default","featureId":"","writable":true}]} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.childfirst/childfirst-player/assets/hashes.json.js b/org.yakindu.sct.examples.basic.childfirst/childfirst-player/assets/hashes.json.js new file mode 100644 index 00000000..0429c25c --- /dev/null +++ b/org.yakindu.sct.examples.basic.childfirst/childfirst-player/assets/hashes.json.js @@ -0,0 +1 @@ +const hashesJson = {"MAIN_REGION_A_R1_B_tr0":"6e0d1ca2-a571-4b99-80d2-9b5af32ec56b","MAIN_REGION_A_R1_B":"8e25f8e2-0c5b-4c86-a61b-5f89d171d8cb","MAIN_REGION_A_R1_C":"28a8064c-d355-481a-9cba-67e8e7001341","MAIN_REGION_A":"4b7141ed-a359-4fb0-bf64-3e82ecaa43bd","MAIN_REGION_A_tr0":"df33b6e4-03e6-467c-8ac3-3e33369a58c6","MAIN_REGION_D":"b2b05fa3-4f82-41b2-9c2e-ce73bbb51e91"} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.childfirst/childfirst-player/assets/statemachine.svg.js b/org.yakindu.sct.examples.basic.childfirst/childfirst-player/assets/statemachine.svg.js new file mode 100644 index 00000000..f2b03e13 --- /dev/null +++ b/org.yakindu.sct.examples.basic.childfirst/childfirst-player/assets/statemachine.svg.js @@ -0,0 +1 @@ +let svg = `main region1-Aentry / m = 1e / n = 1exit / o = 1r1-Bentry / m = 2e / n = 2exit / o = 2-CD-1-1ee1ee1` \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.childfirst/childfirst-player/assets/ypi.css b/org.yakindu.sct.examples.basic.childfirst/childfirst-player/assets/ypi.css new file mode 100644 index 00000000..771aaa11 --- /dev/null +++ b/org.yakindu.sct.examples.basic.childfirst/childfirst-player/assets/ypi.css @@ -0,0 +1,113 @@ +/*! + * itemis CREATE Player Styles + * Copyright 2021 itemis AG + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ + + + /*! + * Style definitions follow BEM pattern using and additional 'y' namespace (for itemis CREATE). + */ +.y-declaration { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; + background-color: #eee; + font-family: 'Courier New', Courier, monospace; +} + + +.y-entry { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; +} + +.y-entry:after { + content: ' \25CF '; + font-size: larger; +} + +.y-state { + background-color: rgb(209, 223, 238); + padding: 3px; + border: 0.5pt;; + border: 0.5pt; + border-radius: 4px; + border-color: #bbb; + font-family: 'Courier New', Courier, monospace; +} + +.y-state--active { + background-color: rgb(244, 215, 66); +} + +.y-state--inactive { + background-color: rgb(209, 223, 238); +} + +.y-variable{ + background-color: #eee; + border-color: #aaa; + border: 0.5pt; + border: 0.5pt; + border-radius: 2px; + font-family: 'Courier New', Courier, monospace; +} + +.y-variable::after { + color: #aaa; + content: attr(value); + font-family: 'Courier New', Courier, monospace; +} + +.y-do-enter { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; +} + +.y-do-enter:before { + content: ' \2192 '; +} + +.y-do-exit { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer +} + +.y-do-exit:before { + content: ' \2192 '; +} + +.y-do-raise { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; + white-space: nowrap; +} + +.y-do-raise:before { + content: ' \2192 '; +} + +button.y-do-raise:before { + content: ''; +} + +button.y-do-raise { + cursor: pointer; +} + +.y-do--over { + color: blue; + background-color: #eee; + cursor: pointer; +} + +.y-player { + border-style: solid; + border-width: 1px; + border-color: ; +} diff --git a/org.yakindu.sct.examples.basic.childfirst/childfirst-player/model.scm b/org.yakindu.sct.examples.basic.childfirst/childfirst-player/model.scm new file mode 100644 index 00000000..657df6ec --- /dev/null +++ b/org.yakindu.sct.examples.basic.childfirst/childfirst-player/model.scm @@ -0,0 +1,472 @@ +{ + "cells": [ + { + "position": { + "x": 0, + "y": 0 + }, + "size": { + "height": 10, + "width": 10 + }, + "angle": 0, + "type": "Statechart", + "id": "c61e5c49-f8f4-4a2b-82f6-647a13ca0ed3", + "linkable": false, + "z": 1, + "attrs": { + "name": { + "text": "childfirst" + }, + "specification": { + "text": "@ChildFirstExecution\n@CycleBased(200)\n\ninterface:\n in event e\n var m : integer = 0\n var n : integer = 0\n var o : integer = 0" + } + } + }, + { + "type": "Region", + "position": { + "x": 4, + "y": 0 + }, + "size": { + "width": 417, + "height": 429 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "f8e0a667-0239-46cb-a603-462a925cc24c", + "z": 2, + "embeds": [ + "df33b6e4-03e6-467c-8ac3-3e33369a58c6", + "c77f8a92-2e1e-41f3-870c-e4029df5713f", + "b67eb288-2475-43e6-9771-037bf624d4d2", + "4b7141ed-a359-4fb0-bf64-3e82ecaa43bd", + "b2b05fa3-4f82-41b2-9c2e-ce73bbb51e91" + ], + "attrs": { + "priority": { + "text": 1 + }, + "name": { + "fontSize": "9", + "text": "main region" + } + } + }, + { + "type": "Entry", + "position": { + "x": 86, + "y": 48 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "b67eb288-2475-43e6-9771-037bf624d4d2", + "parent": "f8e0a667-0239-46cb-a603-462a925cc24c", + "z": 3, + "embeds": [ + "1e091169-bc5d-4735-8a77-a4d6f53e8172" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 86, + "y": 63 + }, + "id": "1e091169-bc5d-4735-8a77-a4d6f53e8172", + "z": 4, + "parent": "b67eb288-2475-43e6-9771-037bf624d4d2", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 73, + "y": 107 + }, + "size": { + "width": 208, + "height": 302 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "4b7141ed-a359-4fb0-bf64-3e82ecaa43bd", + "parent": "f8e0a667-0239-46cb-a603-462a925cc24c", + "z": 5, + "embeds": [ + "70675d40-8666-4022-ae90-641c029b97bc" + ], + "attrs": { + "name": { + "text": "A" + }, + "specification": { + "text": "entry / m = 1\ne / n = 1\nexit / o = 1", + "fontSize": "9" + } + } + }, + { + "type": "Region", + "position": { + "x": 74, + "y": 168 + }, + "size": { + "width": 206, + "height": 240 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "70675d40-8666-4022-ae90-641c029b97bc", + "z": 6, + "parent": "4b7141ed-a359-4fb0-bf64-3e82ecaa43bd", + "embeds": [ + "6e0d1ca2-a571-4b99-80d2-9b5af32ec56b", + "0a6d3538-3d3c-4a6d-b84e-9d50349db9db", + "8e25f8e2-0c5b-4c86-a61b-5f89d171d8cb", + "76ca553f-48e8-4f8f-92d1-6257589f9d02", + "28a8064c-d355-481a-9cba-67e8e7001341" + ], + "attrs": { + "name": { + "fontSize": "9", + "text": "r1" + } + } + }, + { + "type": "State", + "position": { + "x": 134, + "y": 217 + }, + "size": { + "width": 90, + "height": 61 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "8e25f8e2-0c5b-4c86-a61b-5f89d171d8cb", + "parent": "70675d40-8666-4022-ae90-641c029b97bc", + "z": 7, + "attrs": { + "name": { + "text": "B" + }, + "specification": { + "text": "entry / m = 2\ne / n = 2\nexit / o = 2", + "fontSize": "9" + } + } + }, + { + "type": "Entry", + "position": { + "x": 92, + "y": 240 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "76ca553f-48e8-4f8f-92d1-6257589f9d02", + "parent": "70675d40-8666-4022-ae90-641c029b97bc", + "z": 8, + "embeds": [ + "37d23794-1833-4316-805c-d5fc6f9298d8" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 92, + "y": 255 + }, + "id": "37d23794-1833-4316-805c-d5fc6f9298d8", + "z": 9, + "parent": "76ca553f-48e8-4f8f-92d1-6257589f9d02", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 131, + "y": 320 + }, + "size": { + "width": 98, + "height": 62 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "28a8064c-d355-481a-9cba-67e8e7001341", + "parent": "70675d40-8666-4022-ae90-641c029b97bc", + "z": 10, + "attrs": { + "name": { + "text": "C" + } + } + }, + { + "type": "State", + "position": { + "x": 336, + "y": 111 + }, + "size": { + "width": 40, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "b2b05fa3-4f82-41b2-9c2e-ce73bbb51e91", + "parent": "f8e0a667-0239-46cb-a603-462a925cc24c", + "z": 11, + "attrs": { + "name": { + "text": "D" + } + } + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "49.21313766596787%", + "dy": "50%", + "rotate": true + } + }, + "id": "b67eb288-2475-43e6-9771-037bf624d4d2" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "9.799024350911143%", + "dy": "50%", + "rotate": true + } + }, + "id": "4b7141ed-a359-4fb0-bf64-3e82ecaa43bd" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "c77f8a92-2e1e-41f3-870c-e4029df5713f", + "z": 12, + "parent": "f8e0a667-0239-46cb-a603-462a925cc24c", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "96.6893424036281%", + "dy": "42.59958071278826%", + "rotate": true + } + }, + "id": "76ca553f-48e8-4f8f-92d1-6257589f9d02" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "3.3408919123204823%", + "dy": "48.18022476543974%", + "rotate": true + } + }, + "id": "8e25f8e2-0c5b-4c86-a61b-5f89d171d8cb" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "0a6d3538-3d3c-4a6d-b84e-9d50349db9db", + "z": 13, + "parent": "70675d40-8666-4022-ae90-641c029b97bc", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "80.15142718916304%", + "dy": "9.597622828774393%", + "rotate": true + } + }, + "id": "4b7141ed-a359-4fb0-bf64-3e82ecaa43bd" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "47.14117159037484%", + "rotate": true + } + }, + "id": "b2b05fa3-4f82-41b2-9c2e-ce73bbb51e91" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "e", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "df33b6e4-03e6-467c-8ac3-3e33369a58c6", + "z": 14, + "parent": "f8e0a667-0239-46cb-a603-462a925cc24c", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "58.00491629931748%", + "dy": "50%", + "rotate": true + } + }, + "id": "8e25f8e2-0c5b-4c86-a61b-5f89d171d8cb" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "56.331045581005846%", + "dy": "50%", + "rotate": true + } + }, + "id": "28a8064c-d355-481a-9cba-67e8e7001341" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "e", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "6e0d1ca2-a571-4b99-80d2-9b5af32ec56b", + "z": 15, + "parent": "70675d40-8666-4022-ae90-641c029b97bc", + "attrs": {} + } + ] +} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.childfirst/childfirst-player/player.html b/org.yakindu.sct.examples.basic.childfirst/childfirst-player/player.html new file mode 100644 index 00000000..a40d8757 --- /dev/null +++ b/org.yakindu.sct.examples.basic.childfirst/childfirst-player/player.html @@ -0,0 +1,52 @@ + +sct-web-player demo + + + + + + + + + + + + + + + +

+ +
+ + + + + \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.childfirst/index.html b/org.yakindu.sct.examples.basic.childfirst/index.html index 383dc622..0b666e5e 100644 --- a/org.yakindu.sct.examples.basic.childfirst/index.html +++ b/org.yakindu.sct.examples.basic.childfirst/index.html @@ -1,57 +1,109 @@ + - -Parent-first vs. Child-first Execution - + + Parent-first vs. Child-first Execution + +

Parent-first vs. Child-first Execution

-

This example demonstrates the two different execution schemes of composite states: child-first and parent-first execution. For more information, please also refer to chapter Parent-first and child-first execution.

- -

Composite state execution schemes

-

-The parent-first and child-first execution schemes define in which order a composite state and its substates are processed: -

    -
  • -In the parent-first execution scheme, the composite state (parent) is processed first, before its substates are processed. -
  • -
  • -In the child-first execution scheme, the active substate (child) is processed first, before its parent composite state is processed. -
  • -
-

-

Example

-We will use the following example model to explain the two different execution schemes: -

- Example model to explain parent-first vs. child-first execution -

-

-The question that we want to answer is: What happens if event e is raised, i.e. which state gets activated, C or D; and what are the values of the statechart variables m, n and o afterwards? -

-

-Let's first answer which state gets active. When the event e is raised, the specified execution scheme defines which of the currently active states', A's or B's, outgoing transitions are evaluated first. In the child-first execution scheme, state B, the active child of the composite state, is processed first. Hence, the transition to state C is evaluated and taken. In contrast to that, in the parent-first execution scheme, the outer state A is processed first and state D gets activated: -

-

- Example model after parent-first execution -

-

-Now let's take a look at the variable values. When starting the simulation (or when entering the statechart), the outer state A is activated first, independent of the used execution scheme. Afterwards, the entry action of state B sets m to 2. After event e is raised, the inner state B is exited first, before A is exited which sets the value of o to 1. -

-

-Notice the difference when child-first execution is used: -

-

- Example model after child-first execution -

-

-When event e is raised, state B is exited, setting variable o to 2. Furthermore, the outer state A stays active in this run-to-completion step and hence its local reaction is executed, setting n to 1. -

+

This example demonstrates the two different execution schemes of composite states: child-first and parent-first + execution. For more information, please also refer to chapter Parent-first + and child-first execution.

+ +

Composite state execution schemes

+

+ The parent-first and child-first execution schemes define in which order a composite state and its substates are + processed: +

    +
  • + In the parent-first execution scheme, the composite state (parent) is processed first, before its + substates are processed. +
  • +
  • + In the child-first execution scheme, the active substate (child) is processed first, before its parent + composite state is processed. +
  • +
+

+

Example

+ We will use the following example model to explain the two different execution schemes: +

+

+

+

+ The question that we want to answer is: What happens if event e is raised, i.e. which state gets + activated, C or D; and what are the values of the statechart variables + m, n and o afterwards? +

+

+ Let's first answer which state gets active. When the event e is raised, the specified execution + scheme defines which of the currently active states', A's or B's, outgoing + transitions are evaluated first. In the child-first execution scheme, state B, the active child + of the composite state, is processed first. Hence, the transition to state C is evaluated and + taken. In contrast to that, in the parent-first execution scheme, the outer state A is processed + first and state D gets activated: +

+

+

+

+

+ Now let's take a look at the variable values. When starting the simulation (or when entering the statechart), the + outer state A is activated first, independent of the used execution scheme. Afterwards, the entry + action of state B sets m to 2. After event e is raised, the inner state + B is exited first, before A is exited which sets the value of o to + 1. +

+

+ Notice the difference when child-first execution is used: +

+

+ Example model after child-first execution +

+

+ When event e is raised, state B is exited, setting variable o to 2. + Furthermore, the outer state A stays active in this run-to-completion step and hence its local + reaction is executed, setting n to 1. +

+ - + + \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.childfirst/parentfirst-player/assets/bundle.js b/org.yakindu.sct.examples.basic.childfirst/parentfirst-player/assets/bundle.js new file mode 100644 index 00000000..d93b4323 --- /dev/null +++ b/org.yakindu.sct.examples.basic.childfirst/parentfirst-player/assets/bundle.js @@ -0,0 +1,550 @@ +var com; +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Instances represent state machine trace events. + * @param {com.yakindu.core.TraceEventType} type + * @param {*} machine + * @param {*} state + * @param {*} feature + * @param {*} value + * @class + */ + class TraceEvent { + constructor(type, machine, state, feature, value) { + if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && ((state != null) || state === null) && ((feature != null) || feature === null) && ((value != null) || value === null)) { + let __args = arguments; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + else if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && state === undefined && feature === undefined && value === undefined) { + let __args = arguments; + { + let __args = arguments; + let state = null; + let feature = null; + let value = null; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + } + else + throw new Error('invalid overload'); + } + getType() { + return this.type; + } + getMachine() { + return this.machine; + } + getState() { + return this.state; + } + getFeature() { + return this.feature; + } + getValue() { + return this.value; + } + } + core.TraceEvent = TraceEvent; + TraceEvent["__class"] = "com.yakindu.core.TraceEvent"; + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Trace event type enumeration. + * @enum + * @property {com.yakindu.core.TraceEventType} MACHINE_ENTER + * @property {com.yakindu.core.TraceEventType} MACHINE_EXIT + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_START + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_STOP + * @property {com.yakindu.core.TraceEventType} STATE_ENTERED + * @property {com.yakindu.core.TraceEventType} STATE_EXITED + * @property {com.yakindu.core.TraceEventType} STATE_TRANSITION + * @property {com.yakindu.core.TraceEventType} EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} VARIABLE_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_UNSET + * @class + */ + let TraceEventType; + (function (TraceEventType) { + TraceEventType[TraceEventType["MACHINE_ENTER"] = 0] = "MACHINE_ENTER"; + TraceEventType[TraceEventType["MACHINE_EXIT"] = 1] = "MACHINE_EXIT"; + TraceEventType[TraceEventType["MACHINE_RTS_START"] = 2] = "MACHINE_RTS_START"; + TraceEventType[TraceEventType["MACHINE_RTS_STOP"] = 3] = "MACHINE_RTS_STOP"; + TraceEventType[TraceEventType["STATE_ENTERED"] = 4] = "STATE_ENTERED"; + TraceEventType[TraceEventType["STATE_EXITED"] = 5] = "STATE_EXITED"; + TraceEventType[TraceEventType["STATE_TRANSITION"] = 6] = "STATE_TRANSITION"; + TraceEventType[TraceEventType["EVENT_RAISED"] = 7] = "EVENT_RAISED"; + TraceEventType[TraceEventType["VARIABLE_SET"] = 8] = "VARIABLE_SET"; + TraceEventType[TraceEventType["TIME_EVENT_RAISED"] = 9] = "TIME_EVENT_RAISED"; + TraceEventType[TraceEventType["TIME_EVENT_SET"] = 10] = "TIME_EVENT_SET"; + TraceEventType[TraceEventType["TIME_EVENT_UNSET"] = 11] = "TIME_EVENT_UNSET"; + })(TraceEventType = core.TraceEventType || (core.TraceEventType = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + var rx; + (function (rx) { + class Observable { + constructor() { + this.observers = ([]); + } + next(value) { + for (let index = 0; index < this.observers.length; index++) { + let observer = this.observers[index]; + { + observer.next(value); + } + } + } + subscribe(observer) { + return observer != null ? /* add */ (this.observers.push(observer) > 0) : false; + } + unsubscribe(observer) { + return observer != null ? /* remove */ (a => { let index = a.indexOf(observer); if (index >= 0) { + a.splice(index, 1); + return true; + } + else { + return false; + } })(this.observers) : false; + } + } + rx.Observable = Observable; + Observable["__class"] = "com.yakindu.core.rx.Observable"; + })(rx = core.rx || (core.rx = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +var sct; +(function (sct) { + var yakindu; + (function (yakindu) { + var io; + (function (io) { + class Statemachine { + constructor() { + this.stateVector = [null]; + this.trace = (new com.yakindu.core.rx.Observable()); + this.inEventQueue = ([]); + if (this.isExecuting === undefined) { + this.isExecuting = false; + } + if (this.e === undefined) { + this.e = false; + } + if (this.m === undefined) { + this.m = 0; + } + if (this.n === undefined) { + this.n = 0; + } + if (this.o === undefined) { + this.o = 0; + } + for (let i = 0; i < 1; i++) { + { + this.stateVector[i] = Statemachine.State.$NULLSTATE$; + } + ; + } + this.clearInEvents(); + this.setM(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.M, this.m))); + this.setN(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.N, this.n))); + this.setO(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.O, this.o))); + this.isExecuting = false; + } + getIsExecuting() { + return this.isExecuting; + } + setIsExecuting(value) { + this.isExecuting = value; + } + enter() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_ENTER, this))); + this.enterSequence_main_region_default(); + this.isExecuting = false; + } + exit() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_EXIT, this))); + this.exitSequence_main_region(); + this.isExecuting = false; + } + /** + * @see IStatemachine#isActive() + * @return {boolean} + */ + isActive() { + return this.stateVector[0] !== Statemachine.State.$NULLSTATE$; + } + /** + * + * Always returns 'false' since this state machine can never become final. + * + * @see IStatemachine#isFinal() + * @return {boolean} + */ + isFinal() { + return false; + } + clearInEvents() { + this.e = false; + } + microStep() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_A_R1_B: + this.main_region_A_r1_B_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_A_R1_C: + this.main_region_A_r1_C_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_D: + this.main_region_D_react(-1); + break; + default: + break; + } + } + runCycle() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_START, this))); + this.nextEvent(); + do { + { + this.microStep(); + this.clearInEvents(); + this.nextEvent(); + } + } while ((this.e)); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_STOP, this))); + this.isExecuting = false; + } + nextEvent() { + if (!(this.inEventQueue.length == 0)) { + (target => (typeof target === 'function') ? target() : target.run())(/* poll */ (a => a.length == 0 ? null : a.shift())(this.inEventQueue)); + return; + } + } + /** + * Returns true if the given state is currently active otherwise false. + * @param {sct.yakindu.io.Statemachine.State} state + * @return {boolean} + */ + isStateActive(state) { + switch ((state)) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_A: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_A]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_A_R1_C]]; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_A_R1_B: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_A_R1_B; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_A_R1_C: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_A_R1_C; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_D: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_D; + default: + return false; + } + } + getTrace() { + return this.trace; + } + raiseE() { + /* add */ (this.inEventQueue.push(() => { + this.e = true; + }) > 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this, null, Statemachine.Feature.E, null))); + this.runCycle(); + } + getM() { + return this.m; + } + setM(value) { + this.m = value; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.M, this.m))); + } + getN() { + return this.n; + } + setN(value) { + this.n = value; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.N, this.n))); + } + getO() { + return this.o; + } + setO(value) { + this.o = value; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.O, this.o))); + } + entryAction_main_region_A() { + this.setM(1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.M, this.m))); + } + entryAction_main_region_A_r1_B() { + this.setM(2); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.M, this.m))); + } + exitAction_main_region_A() { + this.setO(1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.O, this.o))); + } + exitAction_main_region_A_r1_B() { + this.setO(2); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.O, this.o))); + } + enterSequence_main_region_A_default() { + this.entryAction_main_region_A(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_A, null, null))); + this.enterSequence_main_region_A_r1_default(); + } + enterSequence_main_region_A_r1_B_default() { + this.entryAction_main_region_A_r1_B(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_A_R1_B, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_A_R1_B; + } + enterSequence_main_region_A_r1_C_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_A_R1_C, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_A_R1_C; + } + enterSequence_main_region_D_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_D, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_D; + } + enterSequence_main_region_default() { + this.react_main_region__entry_Default(); + } + enterSequence_main_region_A_r1_default() { + this.react_main_region_A_r1__entry_Default(); + } + exitSequence_main_region_A() { + this.exitSequence_main_region_A_r1(); + this.exitAction_main_region_A(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_A, null, null))); + } + exitSequence_main_region_A_r1_B() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.exitAction_main_region_A_r1_B(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_A_R1_B, null, null))); + } + exitSequence_main_region_A_r1_C() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_A_R1_C, null, null))); + } + exitSequence_main_region_D() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_D, null, null))); + } + exitSequence_main_region() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_A_R1_B: + this.exitSequence_main_region_A_r1_B(); + this.exitAction_main_region_A(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_A, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_A_R1_C: + this.exitSequence_main_region_A_r1_C(); + this.exitAction_main_region_A(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_A, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_D: + this.exitSequence_main_region_D(); + break; + default: + break; + } + } + exitSequence_main_region_A_r1() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_A_R1_B: + this.exitSequence_main_region_A_r1_B(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_A_R1_C: + this.exitSequence_main_region_A_r1_C(); + break; + default: + break; + } + } + react_main_region_A_r1__entry_Default() { + this.enterSequence_main_region_A_r1_B_default(); + } + react_main_region__entry_Default() { + this.enterSequence_main_region_A_default(); + } + react(transitioned_before) { + return transitioned_before; + } + main_region_A_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.e) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_A, null, 0))); + this.exitSequence_main_region_A(); + this.enterSequence_main_region_D_default(); + this.react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + if (this.e) { + this.setN(1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.N, this.n))); + } + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_region_A_r1_B_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.e) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_A_R1_B, null, 0))); + this.exitSequence_main_region_A_r1_B(); + this.enterSequence_main_region_A_r1_C_default(); + this.main_region_A_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + if (this.e) { + this.setN(2); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.N, this.n))); + } + transitioned_after = this.main_region_A_react(transitioned_before); + } + return transitioned_after; + } + main_region_A_r1_C_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_A_react(transitioned_before); + } + return transitioned_after; + } + main_region_D_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + } + io.Statemachine = Statemachine; + Statemachine["__class"] = "sct.yakindu.io.Statemachine"; + Statemachine["__interfaces"] = ["com.yakindu.core.IStatemachine"]; + (function (Statemachine) { + let State; + (function (State) { + State[State["MAIN_REGION_A"] = 0] = "MAIN_REGION_A"; + State[State["MAIN_REGION_A_R1_B"] = 1] = "MAIN_REGION_A_R1_B"; + State[State["MAIN_REGION_A_R1_C"] = 2] = "MAIN_REGION_A_R1_C"; + State[State["MAIN_REGION_D"] = 3] = "MAIN_REGION_D"; + State[State["$NULLSTATE$"] = 4] = "$NULLSTATE$"; + })(State = Statemachine.State || (Statemachine.State = {})); + /** + * Enumeration of all features of the statechart + * @enum + * @property {sct.yakindu.io.Statemachine.Feature} NO_FEATURE + * @property {sct.yakindu.io.Statemachine.Feature} E + * @property {sct.yakindu.io.Statemachine.Feature} M + * @property {sct.yakindu.io.Statemachine.Feature} N + * @property {sct.yakindu.io.Statemachine.Feature} O + * @class + */ + let Feature; + (function (Feature) { + Feature[Feature["NO_FEATURE"] = 0] = "NO_FEATURE"; + Feature[Feature["E"] = 1] = "E"; + Feature[Feature["M"] = 2] = "M"; + Feature[Feature["N"] = 3] = "N"; + Feature[Feature["O"] = 4] = "O"; + })(Feature = Statemachine.Feature || (Statemachine.Feature = {})); + })(Statemachine = io.Statemachine || (io.Statemachine = {})); + })(io = yakindu.io || (yakindu.io = {})); + })(yakindu = sct.yakindu || (sct.yakindu = {})); +})(sct || (sct = {})); diff --git a/org.yakindu.sct.examples.basic.childfirst/parentfirst-player/assets/context.json.js b/org.yakindu.sct.examples.basic.childfirst/parentfirst-player/assets/context.json.js new file mode 100644 index 00000000..df20296f --- /dev/null +++ b/org.yakindu.sct.examples.basic.childfirst/parentfirst-player/assets/context.json.js @@ -0,0 +1 @@ +const contextJson = {"elements":[{"elements":[{"kind":"event","name":"e","fqName":"e","featureId":"E","writable":true},{"kind":"variable","type":"integer","name":"m","fqName":"m","featureId":"M","writable":true,"value":0},{"kind":"variable","type":"integer","name":"n","fqName":"n","featureId":"N","writable":true,"value":0},{"kind":"variable","type":"integer","name":"o","fqName":"o","featureId":"O","writable":true,"value":0}],"kind":"composite","name":"default","featureId":"","writable":true}]} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.childfirst/parentfirst-player/assets/hashes.json.js b/org.yakindu.sct.examples.basic.childfirst/parentfirst-player/assets/hashes.json.js new file mode 100644 index 00000000..3c905528 --- /dev/null +++ b/org.yakindu.sct.examples.basic.childfirst/parentfirst-player/assets/hashes.json.js @@ -0,0 +1 @@ +const hashesJson = {"MAIN_REGION_A_R1_B_tr0":"fdc3becd-797f-4dbf-ad00-252f67c9e2de","MAIN_REGION_A_R1_B":"dd246b60-002d-43d6-93d9-44dcffd46426","MAIN_REGION_A_R1_C":"5687f149-dc3d-4416-95a7-c8cdf1e5467d","MAIN_REGION_A":"468565f3-02ec-47ed-b767-059ee6703538","MAIN_REGION_A_tr0":"1dc9ecb5-63c5-4b54-bbac-bbce885d94da","MAIN_REGION_D":"3bde80cd-6d4f-4734-b8da-29b0187366be"} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.childfirst/parentfirst-player/assets/statemachine.svg.js b/org.yakindu.sct.examples.basic.childfirst/parentfirst-player/assets/statemachine.svg.js new file mode 100644 index 00000000..d4ce1156 --- /dev/null +++ b/org.yakindu.sct.examples.basic.childfirst/parentfirst-player/assets/statemachine.svg.js @@ -0,0 +1 @@ +let svg = `main region1-Aentry / m = 1e / n = 1exit / o = 1r1-Bentry / m = 2e / n = 2exit / o = 2-CD-1-1ee1ee1` \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.childfirst/parentfirst-player/assets/ypi.css b/org.yakindu.sct.examples.basic.childfirst/parentfirst-player/assets/ypi.css new file mode 100644 index 00000000..771aaa11 --- /dev/null +++ b/org.yakindu.sct.examples.basic.childfirst/parentfirst-player/assets/ypi.css @@ -0,0 +1,113 @@ +/*! + * itemis CREATE Player Styles + * Copyright 2021 itemis AG + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ + + + /*! + * Style definitions follow BEM pattern using and additional 'y' namespace (for itemis CREATE). + */ +.y-declaration { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; + background-color: #eee; + font-family: 'Courier New', Courier, monospace; +} + + +.y-entry { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; +} + +.y-entry:after { + content: ' \25CF '; + font-size: larger; +} + +.y-state { + background-color: rgb(209, 223, 238); + padding: 3px; + border: 0.5pt;; + border: 0.5pt; + border-radius: 4px; + border-color: #bbb; + font-family: 'Courier New', Courier, monospace; +} + +.y-state--active { + background-color: rgb(244, 215, 66); +} + +.y-state--inactive { + background-color: rgb(209, 223, 238); +} + +.y-variable{ + background-color: #eee; + border-color: #aaa; + border: 0.5pt; + border: 0.5pt; + border-radius: 2px; + font-family: 'Courier New', Courier, monospace; +} + +.y-variable::after { + color: #aaa; + content: attr(value); + font-family: 'Courier New', Courier, monospace; +} + +.y-do-enter { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; +} + +.y-do-enter:before { + content: ' \2192 '; +} + +.y-do-exit { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer +} + +.y-do-exit:before { + content: ' \2192 '; +} + +.y-do-raise { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; + white-space: nowrap; +} + +.y-do-raise:before { + content: ' \2192 '; +} + +button.y-do-raise:before { + content: ''; +} + +button.y-do-raise { + cursor: pointer; +} + +.y-do--over { + color: blue; + background-color: #eee; + cursor: pointer; +} + +.y-player { + border-style: solid; + border-width: 1px; + border-color: ; +} diff --git a/org.yakindu.sct.examples.basic.childfirst/parentfirst-player/model.scm b/org.yakindu.sct.examples.basic.childfirst/parentfirst-player/model.scm new file mode 100644 index 00000000..90ca1c99 --- /dev/null +++ b/org.yakindu.sct.examples.basic.childfirst/parentfirst-player/model.scm @@ -0,0 +1,472 @@ +{ + "cells": [ + { + "position": { + "x": 0, + "y": 0 + }, + "size": { + "height": 10, + "width": 10 + }, + "angle": 0, + "type": "Statechart", + "id": "592faad3-287e-4fe1-927e-e2c9f57ce118", + "linkable": false, + "z": 1, + "attrs": { + "name": { + "text": "parentfirst" + }, + "specification": { + "text": "@ParentFirstExecution\n@CycleBased(200)\n\ninterface:\n in event e\n var m : integer = 0\n var n : integer = 0\n var o : integer = 0" + } + } + }, + { + "type": "Region", + "position": { + "x": 4, + "y": 0 + }, + "size": { + "width": 417, + "height": 429 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "ebeaaa6d-a225-4749-9e6c-7b26a269bb4a", + "z": 2, + "embeds": [ + "1dc9ecb5-63c5-4b54-bbac-bbce885d94da", + "94669889-3f41-4f7a-8285-48292e2ea73a", + "c0cf3307-9f4f-4654-a130-b702860ce15a", + "468565f3-02ec-47ed-b767-059ee6703538", + "3bde80cd-6d4f-4734-b8da-29b0187366be" + ], + "attrs": { + "priority": { + "text": 1 + }, + "name": { + "fontSize": "9", + "text": "main region" + } + } + }, + { + "type": "Entry", + "position": { + "x": 86, + "y": 48 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "c0cf3307-9f4f-4654-a130-b702860ce15a", + "parent": "ebeaaa6d-a225-4749-9e6c-7b26a269bb4a", + "z": 3, + "embeds": [ + "d1981b5e-d299-4175-8f0c-ba7e8b20dc41" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 86, + "y": 63 + }, + "id": "d1981b5e-d299-4175-8f0c-ba7e8b20dc41", + "z": 4, + "parent": "c0cf3307-9f4f-4654-a130-b702860ce15a", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 73, + "y": 107 + }, + "size": { + "width": 208, + "height": 302 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "468565f3-02ec-47ed-b767-059ee6703538", + "parent": "ebeaaa6d-a225-4749-9e6c-7b26a269bb4a", + "z": 5, + "embeds": [ + "2e4e6a7e-3473-42ca-aa30-50c306031ab8" + ], + "attrs": { + "name": { + "text": "A" + }, + "specification": { + "text": "entry / m = 1\ne / n = 1\nexit / o = 1", + "fontSize": "9" + } + } + }, + { + "type": "Region", + "position": { + "x": 74, + "y": 168 + }, + "size": { + "width": 206, + "height": 240 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "2e4e6a7e-3473-42ca-aa30-50c306031ab8", + "z": 6, + "parent": "468565f3-02ec-47ed-b767-059ee6703538", + "embeds": [ + "fdc3becd-797f-4dbf-ad00-252f67c9e2de", + "edd55426-622e-45b1-9b6b-a35ee984af24", + "dd246b60-002d-43d6-93d9-44dcffd46426", + "98b9aba7-8ba0-4802-a6bc-74533a9768d8", + "5687f149-dc3d-4416-95a7-c8cdf1e5467d" + ], + "attrs": { + "name": { + "fontSize": "9", + "text": "r1" + } + } + }, + { + "type": "State", + "position": { + "x": 134, + "y": 217 + }, + "size": { + "width": 90, + "height": 61 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "dd246b60-002d-43d6-93d9-44dcffd46426", + "parent": "2e4e6a7e-3473-42ca-aa30-50c306031ab8", + "z": 7, + "attrs": { + "name": { + "text": "B" + }, + "specification": { + "text": "entry / m = 2\ne / n = 2\nexit / o = 2", + "fontSize": "9" + } + } + }, + { + "type": "Entry", + "position": { + "x": 91, + "y": 240 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "98b9aba7-8ba0-4802-a6bc-74533a9768d8", + "parent": "2e4e6a7e-3473-42ca-aa30-50c306031ab8", + "z": 8, + "embeds": [ + "1b13a388-e60e-4a92-9c39-85754499aec5" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 91, + "y": 255 + }, + "id": "1b13a388-e60e-4a92-9c39-85754499aec5", + "z": 9, + "parent": "98b9aba7-8ba0-4802-a6bc-74533a9768d8", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 131, + "y": 320 + }, + "size": { + "width": 98, + "height": 62 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "5687f149-dc3d-4416-95a7-c8cdf1e5467d", + "parent": "2e4e6a7e-3473-42ca-aa30-50c306031ab8", + "z": 10, + "attrs": { + "name": { + "text": "C" + } + } + }, + { + "type": "State", + "position": { + "x": 336, + "y": 111 + }, + "size": { + "width": 40, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "3bde80cd-6d4f-4734-b8da-29b0187366be", + "parent": "ebeaaa6d-a225-4749-9e6c-7b26a269bb4a", + "z": 11, + "attrs": { + "name": { + "text": "D" + } + } + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "49.21313766596787%", + "dy": "50%", + "rotate": true + } + }, + "id": "c0cf3307-9f4f-4654-a130-b702860ce15a" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "9.799024350911143%", + "dy": "50%", + "rotate": true + } + }, + "id": "468565f3-02ec-47ed-b767-059ee6703538" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "94669889-3f41-4f7a-8285-48292e2ea73a", + "z": 12, + "parent": "ebeaaa6d-a225-4749-9e6c-7b26a269bb4a", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "98.9115646258504%", + "dy": "42.59958071278826%", + "rotate": true + } + }, + "id": "98b9aba7-8ba0-4802-a6bc-74533a9768d8" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "2.970521541950101%", + "dy": "48.18022476543974%", + "rotate": true + } + }, + "id": "dd246b60-002d-43d6-93d9-44dcffd46426" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "edd55426-622e-45b1-9b6b-a35ee984af24", + "z": 13, + "parent": "2e4e6a7e-3473-42ca-aa30-50c306031ab8", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "80.15142718916304%", + "dy": "9.597622828774393%", + "rotate": true + } + }, + "id": "468565f3-02ec-47ed-b767-059ee6703538" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "47.14117159037484%", + "rotate": true + } + }, + "id": "3bde80cd-6d4f-4734-b8da-29b0187366be" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "e", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "1dc9ecb5-63c5-4b54-bbac-bbce885d94da", + "z": 14, + "parent": "ebeaaa6d-a225-4749-9e6c-7b26a269bb4a", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "58.00491629931748%", + "dy": "50%", + "rotate": true + } + }, + "id": "dd246b60-002d-43d6-93d9-44dcffd46426" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "56.331045581005846%", + "dy": "50%", + "rotate": true + } + }, + "id": "5687f149-dc3d-4416-95a7-c8cdf1e5467d" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "e", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "fdc3becd-797f-4dbf-ad00-252f67c9e2de", + "z": 15, + "parent": "2e4e6a7e-3473-42ca-aa30-50c306031ab8", + "attrs": {} + } + ] +} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.childfirst/parentfirst-player/player.html b/org.yakindu.sct.examples.basic.childfirst/parentfirst-player/player.html new file mode 100644 index 00000000..a40d8757 --- /dev/null +++ b/org.yakindu.sct.examples.basic.childfirst/parentfirst-player/player.html @@ -0,0 +1,52 @@ + +sct-web-player demo + + + + + + + + + + + + + + + +
+ +
+ + + + + \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.eventdriven/index.html b/org.yakindu.sct.examples.basic.eventdriven/index.html index 02a3cc73..fa615c08 100644 --- a/org.yakindu.sct.examples.basic.eventdriven/index.html +++ b/org.yakindu.sct.examples.basic.eventdriven/index.html @@ -11,7 +11,7 @@

Event-driven vs. Cycle-based Execution

-

This example demonstrates the two different execution schemes of YAKINDU statecharts: event-driven and cycle-based execution. For more details, please refer to chapter Execution schemes in our documentation.

+

This example demonstrates the two different execution schemes of itemis CREATE statecharts: event-driven and cycle-based execution. For more details, please refer to chapter Execution schemes in our documentation.

Execution schemes

The state machine can define one of two different execution schemes:

@@ -35,9 +35,9 @@

Cycle-based execution scheme

In the cycle-based execution scheme, a run-to-completion step is processed in regular time intervals. For example, the annotation @CycleBased(2000) means that a cycle is invoked every 2000 milliseconds. In the example below, this means that it might take up to two seconds after the input event has been raised for the statechart to process it and activate StateB. Same holds for time events. To illustrate this, StateC has two outgoing transitions with different time triggers. With a cycle period of 2 seconds, both time triggers are valid. The state machine will then take the higher prioritized transition, which in this case is the one to StateE. Changing the cycle period from 2000 to 200 milliseconds will cause StateD to be activated as the run-to-completion cycle is executed before the 500ms trigger is raised.

- Example model to explain cycle based execution. + Example model to explain cycle based execution.

Please note that it is the responsibility of the client code to implement the cycle loop. The generated state machine code provides a runCycle() method that needs to be called periodically. diff --git a/org.yakindu.sct.examples.basic.hierarchical/composite_states/lightswitch-player/assets/bundle.js b/org.yakindu.sct.examples.basic.hierarchical/composite_states/lightswitch-player/assets/bundle.js new file mode 100644 index 00000000..0475efe6 --- /dev/null +++ b/org.yakindu.sct.examples.basic.hierarchical/composite_states/lightswitch-player/assets/bundle.js @@ -0,0 +1,828 @@ +var com; +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Instances represent state machine trace events. + * @param {com.yakindu.core.TraceEventType} type + * @param {*} machine + * @param {*} state + * @param {*} feature + * @param {*} value + * @class + */ + class TraceEvent { + constructor(type, machine, state, feature, value) { + if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && ((state != null) || state === null) && ((feature != null) || feature === null) && ((value != null) || value === null)) { + let __args = arguments; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + else if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && state === undefined && feature === undefined && value === undefined) { + let __args = arguments; + { + let __args = arguments; + let state = null; + let feature = null; + let value = null; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + } + else + throw new Error('invalid overload'); + } + getType() { + return this.type; + } + getMachine() { + return this.machine; + } + getState() { + return this.state; + } + getFeature() { + return this.feature; + } + getValue() { + return this.value; + } + } + core.TraceEvent = TraceEvent; + TraceEvent["__class"] = "com.yakindu.core.TraceEvent"; + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Trace event type enumeration. + * @enum + * @property {com.yakindu.core.TraceEventType} MACHINE_ENTER + * @property {com.yakindu.core.TraceEventType} MACHINE_EXIT + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_START + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_STOP + * @property {com.yakindu.core.TraceEventType} STATE_ENTERED + * @property {com.yakindu.core.TraceEventType} STATE_EXITED + * @property {com.yakindu.core.TraceEventType} STATE_TRANSITION + * @property {com.yakindu.core.TraceEventType} EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} VARIABLE_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_UNSET + * @class + */ + let TraceEventType; + (function (TraceEventType) { + TraceEventType[TraceEventType["MACHINE_ENTER"] = 0] = "MACHINE_ENTER"; + TraceEventType[TraceEventType["MACHINE_EXIT"] = 1] = "MACHINE_EXIT"; + TraceEventType[TraceEventType["MACHINE_RTS_START"] = 2] = "MACHINE_RTS_START"; + TraceEventType[TraceEventType["MACHINE_RTS_STOP"] = 3] = "MACHINE_RTS_STOP"; + TraceEventType[TraceEventType["STATE_ENTERED"] = 4] = "STATE_ENTERED"; + TraceEventType[TraceEventType["STATE_EXITED"] = 5] = "STATE_EXITED"; + TraceEventType[TraceEventType["STATE_TRANSITION"] = 6] = "STATE_TRANSITION"; + TraceEventType[TraceEventType["EVENT_RAISED"] = 7] = "EVENT_RAISED"; + TraceEventType[TraceEventType["VARIABLE_SET"] = 8] = "VARIABLE_SET"; + TraceEventType[TraceEventType["TIME_EVENT_RAISED"] = 9] = "TIME_EVENT_RAISED"; + TraceEventType[TraceEventType["TIME_EVENT_SET"] = 10] = "TIME_EVENT_SET"; + TraceEventType[TraceEventType["TIME_EVENT_UNSET"] = 11] = "TIME_EVENT_UNSET"; + })(TraceEventType = core.TraceEventType || (core.TraceEventType = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + var rx; + (function (rx) { + class Observable { + constructor() { + this.observers = ([]); + } + next(value) { + for (let index = 0; index < this.observers.length; index++) { + let observer = this.observers[index]; + { + observer.next(value); + } + } + } + subscribe(observer) { + return observer != null ? /* add */ (this.observers.push(observer) > 0) : false; + } + unsubscribe(observer) { + return observer != null ? /* remove */ (a => { let index = a.indexOf(observer); if (index >= 0) { + a.splice(index, 1); + return true; + } + else { + return false; + } })(this.observers) : false; + } + } + rx.Observable = Observable; + Observable["__class"] = "com.yakindu.core.rx.Observable"; + })(rx = core.rx || (core.rx = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +var sct; +(function (sct) { + var yakindu; + (function (yakindu) { + var io; + (function (io) { + class Statemachine { + constructor() { + if (this.__user === undefined) { + this.__user = null; + } + if (this.__sensor === undefined) { + this.__sensor = null; + } + if (this.__lum_sensor === undefined) { + this.__lum_sensor = null; + } + this.stateVector = [null]; + this.trace = (new com.yakindu.core.rx.Observable()); + if (this.timerService === undefined) { + this.timerService = null; + } + this.timeEvents = [false]; + this.inEventQueue = ([]); + if (this.brightness === undefined) { + this.brightness = 0; + } + if (this.isExecuting === undefined) { + this.isExecuting = false; + } + this.__user = new Statemachine.User(this); + this.__sensor = new Statemachine.Sensor(this); + this.__lum_sensor = new Statemachine.Lum_sensor(this); + for (let i = 0; i < 1; i++) { + { + this.stateVector[i] = Statemachine.State.$NULLSTATE$; + } + ; + } + this.clearInEvents(); + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + this.isExecuting = false; + } + getBrightness() { + return this.brightness; + } + setBrightness(value) { + this.brightness = value; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + getIsExecuting() { + return this.isExecuting; + } + setIsExecuting(value) { + this.isExecuting = value; + } + enter() { + if (this.timerService == null) { + throw Object.defineProperty(new Error("Timer service must be set."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.IllegalStateException', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.Exception'] }); + } + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_ENTER, this))); + this.enterSequence_main_region_default(); + this.isExecuting = false; + } + exit() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_EXIT, this))); + this.exitSequence_main_region(); + this.isExecuting = false; + } + /** + * @see IStatemachine#isActive() + * @return {boolean} + */ + isActive() { + return this.stateVector[0] !== Statemachine.State.$NULLSTATE$; + } + /** + * + * Always returns 'false' since this state machine can never become final. + * + * @see IStatemachine#isFinal() + * @return {boolean} + */ + isFinal() { + return false; + } + clearInEvents() { + this.__user.on_button = false; + this.__user.off_button = false; + this.__user.mode_button = false; + this.__sensor.motion = false; + this.__lum_sensor.bright = false; + this.__lum_sensor.dark = false; + this.timeEvents[0] = false; + } + microStep() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MANUALMODE: + this.main_region_ManualMode_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE_R1_IDLE: + this.main_region_TwilightDetectionMode_r1_Idle_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED: + this.main_region_TwilightDetectionMode_r1_TwilightDetected_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE_R1_IDLE: + this.main_region_MotionDetectionMode_r1_Idle_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE_R1_MOTIONDETECTED: + this.main_region_MotionDetectionMode_r1_MotionDetected_react(-1); + break; + default: + break; + } + } + runCycle() { + if (this.timerService == null) { + throw Object.defineProperty(new Error("Timer service must be set."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.IllegalStateException', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.Exception'] }); + } + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_START, this))); + this.nextEvent(); + do { + { + this.microStep(); + this.clearInEvents(); + this.nextEvent(); + } + } while ((((((((this.__user.on_button || this.__user.off_button) || this.__user.mode_button) || this.__sensor.motion) || this.__lum_sensor.bright) || this.__lum_sensor.dark) || this.timeEvents[0]))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_STOP, this))); + this.isExecuting = false; + } + nextEvent() { + if (!(this.inEventQueue.length == 0)) { + (target => (typeof target === 'function') ? target() : target.run())(/* poll */ (a => a.length == 0 ? null : a.shift())(this.inEventQueue)); + return; + } + } + /** + * Returns true if the given state is currently active otherwise false. + * @param {sct.yakindu.io.Statemachine.State} state + * @return {boolean} + */ + isStateActive(state) { + switch ((state)) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MANUALMODE: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_MANUALMODE; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED]]; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE_R1_IDLE: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE_R1_IDLE; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE_R1_MOTIONDETECTED]]; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE_R1_IDLE: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE_R1_IDLE; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE_R1_MOTIONDETECTED: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE_R1_MOTIONDETECTED; + default: + return false; + } + } + setTimerService(timerService) { + this.timerService = timerService; + } + getTimerService() { + return this.timerService; + } + raiseTimeEvent(eventID) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_RAISED, this, null, null, eventID))); + /* add */ (this.inEventQueue.push(() => { + this.timeEvents[eventID] = true; + }) > 0); + this.runCycle(); + } + user() { + return this.__user; + } + sensor() { + return this.__sensor; + } + lum_sensor() { + return this.__lum_sensor; + } + getTrace() { + return this.trace; + } + entryAction_main_region_ManualMode() { + this.setBrightness(this.getBrightness() + 1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + entryAction_main_region_TwilightDetectionMode_r1_Idle() { + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + entryAction_main_region_TwilightDetectionMode_r1_TwilightDetected() { + this.setBrightness(1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + entryAction_main_region_MotionDetectionMode_r1_Idle() { + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + entryAction_main_region_MotionDetectionMode_r1_MotionDetected() { + this.timerService.setTimer(this, 0, (30 * 1000), false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_SET, this, null, null, 0))); + this.setBrightness(1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + exitAction_main_region_MotionDetectionMode_r1_MotionDetected() { + this.timerService.unsetTimer(this, 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_UNSET, this, null, null, 0))); + } + enterSequence_main_region_ManualMode_default() { + this.entryAction_main_region_ManualMode(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_MANUALMODE, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_MANUALMODE; + } + enterSequence_main_region_TwilightDetectionMode_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE, null, null))); + this.enterSequence_main_region_TwilightDetectionMode_r1_default(); + } + enterSequence_main_region_TwilightDetectionMode_r1_Idle_default() { + this.entryAction_main_region_TwilightDetectionMode_r1_Idle(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE_R1_IDLE, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE_R1_IDLE; + } + enterSequence_main_region_TwilightDetectionMode_r1_TwilightDetected_default() { + this.entryAction_main_region_TwilightDetectionMode_r1_TwilightDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED; + } + enterSequence_main_region_MotionDetectionMode_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE, null, null))); + this.enterSequence_main_region_MotionDetectionMode_r1_default(); + } + enterSequence_main_region_MotionDetectionMode_r1_Idle_default() { + this.entryAction_main_region_MotionDetectionMode_r1_Idle(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE_R1_IDLE, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE_R1_IDLE; + } + enterSequence_main_region_MotionDetectionMode_r1_MotionDetected_default() { + this.entryAction_main_region_MotionDetectionMode_r1_MotionDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE_R1_MOTIONDETECTED, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE_R1_MOTIONDETECTED; + } + enterSequence_main_region_default() { + this.react_main_region__entry_Default(); + } + enterSequence_main_region_TwilightDetectionMode_r1_default() { + this.react_main_region_TwilightDetectionMode_r1__entry_Default(); + } + enterSequence_main_region_MotionDetectionMode_r1_default() { + this.react_main_region_MotionDetectionMode_r1__entry_Default(); + } + exitSequence_main_region_ManualMode() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_MANUALMODE, null, null))); + } + exitSequence_main_region_TwilightDetectionMode() { + this.exitSequence_main_region_TwilightDetectionMode_r1(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE, null, null))); + } + exitSequence_main_region_TwilightDetectionMode_r1_Idle() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE_R1_IDLE, null, null))); + } + exitSequence_main_region_TwilightDetectionMode_r1_TwilightDetected() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED, null, null))); + } + exitSequence_main_region_MotionDetectionMode() { + this.exitSequence_main_region_MotionDetectionMode_r1(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE, null, null))); + } + exitSequence_main_region_MotionDetectionMode_r1_Idle() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE_R1_IDLE, null, null))); + } + exitSequence_main_region_MotionDetectionMode_r1_MotionDetected() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.exitAction_main_region_MotionDetectionMode_r1_MotionDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE_R1_MOTIONDETECTED, null, null))); + } + exitSequence_main_region() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MANUALMODE: + this.exitSequence_main_region_ManualMode(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE_R1_IDLE: + this.exitSequence_main_region_TwilightDetectionMode_r1_Idle(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED: + this.exitSequence_main_region_TwilightDetectionMode_r1_TwilightDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE_R1_IDLE: + this.exitSequence_main_region_MotionDetectionMode_r1_Idle(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE_R1_MOTIONDETECTED: + this.exitSequence_main_region_MotionDetectionMode_r1_MotionDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE, null, null))); + break; + default: + break; + } + } + exitSequence_main_region_TwilightDetectionMode_r1() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE_R1_IDLE: + this.exitSequence_main_region_TwilightDetectionMode_r1_Idle(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED: + this.exitSequence_main_region_TwilightDetectionMode_r1_TwilightDetected(); + break; + default: + break; + } + } + exitSequence_main_region_MotionDetectionMode_r1() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE_R1_IDLE: + this.exitSequence_main_region_MotionDetectionMode_r1_Idle(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE_R1_MOTIONDETECTED: + this.exitSequence_main_region_MotionDetectionMode_r1_MotionDetected(); + break; + default: + break; + } + } + react_main_region_TwilightDetectionMode_r1__entry_Default() { + this.enterSequence_main_region_TwilightDetectionMode_r1_Idle_default(); + } + react_main_region_MotionDetectionMode_r1__entry_Default() { + this.enterSequence_main_region_MotionDetectionMode_r1_Idle_default(); + } + react_main_region__entry_Default() { + this.enterSequence_main_region_MotionDetectionMode_default(); + } + react(transitioned_before) { + return transitioned_before; + } + main_region_ManualMode_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__user.off_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_MANUALMODE, null, 0))); + this.exitSequence_main_region_ManualMode(); + this.enterSequence_main_region_MotionDetectionMode_default(); + this.react(0); + transitioned_after = 0; + } + else { + if (((this.__user.on_button) && (this.getBrightness() < 10))) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_MANUALMODE, null, 1))); + this.exitSequence_main_region_ManualMode(); + this.enterSequence_main_region_ManualMode_default(); + this.react(0); + transitioned_after = 0; + } + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_region_TwilightDetectionMode_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__user.mode_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE, null, 0))); + this.exitSequence_main_region_TwilightDetectionMode(); + this.enterSequence_main_region_MotionDetectionMode_default(); + this.react(0); + transitioned_after = 0; + } + else { + if (this.__user.on_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE, null, 1))); + this.exitSequence_main_region_TwilightDetectionMode(); + this.enterSequence_main_region_ManualMode_default(); + this.react(0); + transitioned_after = 0; + } + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_region_TwilightDetectionMode_r1_Idle_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__lum_sensor.dark) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE_R1_IDLE, null, 0))); + this.exitSequence_main_region_TwilightDetectionMode_r1_Idle(); + this.enterSequence_main_region_TwilightDetectionMode_r1_TwilightDetected_default(); + this.main_region_TwilightDetectionMode_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_TwilightDetectionMode_react(transitioned_before); + } + return transitioned_after; + } + main_region_TwilightDetectionMode_r1_TwilightDetected_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__lum_sensor.bright) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED, null, 0))); + this.exitSequence_main_region_TwilightDetectionMode_r1_TwilightDetected(); + this.enterSequence_main_region_TwilightDetectionMode_r1_Idle_default(); + this.main_region_TwilightDetectionMode_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_TwilightDetectionMode_react(transitioned_before); + } + return transitioned_after; + } + main_region_MotionDetectionMode_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__user.on_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE, null, 0))); + this.exitSequence_main_region_MotionDetectionMode(); + this.enterSequence_main_region_ManualMode_default(); + this.react(0); + transitioned_after = 0; + } + else { + if (this.__user.mode_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE, null, 1))); + this.exitSequence_main_region_MotionDetectionMode(); + this.enterSequence_main_region_TwilightDetectionMode_default(); + this.react(0); + transitioned_after = 0; + } + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_region_MotionDetectionMode_r1_Idle_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__sensor.motion) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE_R1_IDLE, null, 0))); + this.exitSequence_main_region_MotionDetectionMode_r1_Idle(); + this.enterSequence_main_region_MotionDetectionMode_r1_MotionDetected_default(); + this.main_region_MotionDetectionMode_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_MotionDetectionMode_react(transitioned_before); + } + return transitioned_after; + } + main_region_MotionDetectionMode_r1_MotionDetected_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.timeEvents[0]) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE_R1_MOTIONDETECTED, null, 0))); + this.exitSequence_main_region_MotionDetectionMode_r1_MotionDetected(); + this.timeEvents[0] = false; + this.enterSequence_main_region_MotionDetectionMode_r1_Idle_default(); + this.main_region_MotionDetectionMode_react(0); + transitioned_after = 0; + } + else { + if (this.__sensor.motion) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE_R1_MOTIONDETECTED, null, 1))); + this.exitSequence_main_region_MotionDetectionMode_r1_MotionDetected(); + this.enterSequence_main_region_MotionDetectionMode_r1_MotionDetected_default(); + this.main_region_MotionDetectionMode_react(0); + transitioned_after = 0; + } + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_MotionDetectionMode_react(transitioned_before); + } + return transitioned_after; + } + } + io.Statemachine = Statemachine; + Statemachine["__class"] = "sct.yakindu.io.Statemachine"; + Statemachine["__interfaces"] = ["com.yakindu.core.IStatemachine", "com.yakindu.core.ITimed"]; + (function (Statemachine) { + class User { + constructor(parent) { + if (this.parent === undefined) { + this.parent = null; + } + if (this.on_button === undefined) { + this.on_button = false; + } + if (this.off_button === undefined) { + this.off_button = false; + } + if (this.mode_button === undefined) { + this.mode_button = false; + } + this.parent = parent; + } + raiseOn_button() { + /* add */ (this.parent.inEventQueue.push(() => { + this.on_button = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.USER_ON_BUTTON, null))); + this.parent.runCycle(); + } + raiseOff_button() { + /* add */ (this.parent.inEventQueue.push(() => { + this.off_button = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.USER_OFF_BUTTON, null))); + this.parent.runCycle(); + } + raiseMode_button() { + /* add */ (this.parent.inEventQueue.push(() => { + this.mode_button = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.USER_MODE_BUTTON, null))); + this.parent.runCycle(); + } + } + Statemachine.User = User; + User["__class"] = "sct.yakindu.io.Statemachine.User"; + class Sensor { + constructor(parent) { + if (this.parent === undefined) { + this.parent = null; + } + if (this.motion === undefined) { + this.motion = false; + } + this.parent = parent; + } + raiseMotion() { + /* add */ (this.parent.inEventQueue.push(() => { + this.motion = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.SENSOR_MOTION, null))); + this.parent.runCycle(); + } + } + Statemachine.Sensor = Sensor; + Sensor["__class"] = "sct.yakindu.io.Statemachine.Sensor"; + class Lum_sensor { + constructor(parent) { + if (this.parent === undefined) { + this.parent = null; + } + if (this.bright === undefined) { + this.bright = false; + } + if (this.dark === undefined) { + this.dark = false; + } + this.parent = parent; + } + raiseBright() { + /* add */ (this.parent.inEventQueue.push(() => { + this.bright = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.LUM_SENSOR_BRIGHT, null))); + this.parent.runCycle(); + } + raiseDark() { + /* add */ (this.parent.inEventQueue.push(() => { + this.dark = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.LUM_SENSOR_DARK, null))); + this.parent.runCycle(); + } + } + Statemachine.Lum_sensor = Lum_sensor; + Lum_sensor["__class"] = "sct.yakindu.io.Statemachine.Lum_sensor"; + let State; + (function (State) { + State[State["MAIN_REGION_MANUALMODE"] = 0] = "MAIN_REGION_MANUALMODE"; + State[State["MAIN_REGION_TWILIGHTDETECTIONMODE"] = 1] = "MAIN_REGION_TWILIGHTDETECTIONMODE"; + State[State["MAIN_REGION_TWILIGHTDETECTIONMODE_R1_IDLE"] = 2] = "MAIN_REGION_TWILIGHTDETECTIONMODE_R1_IDLE"; + State[State["MAIN_REGION_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED"] = 3] = "MAIN_REGION_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED"; + State[State["MAIN_REGION_MOTIONDETECTIONMODE"] = 4] = "MAIN_REGION_MOTIONDETECTIONMODE"; + State[State["MAIN_REGION_MOTIONDETECTIONMODE_R1_IDLE"] = 5] = "MAIN_REGION_MOTIONDETECTIONMODE_R1_IDLE"; + State[State["MAIN_REGION_MOTIONDETECTIONMODE_R1_MOTIONDETECTED"] = 6] = "MAIN_REGION_MOTIONDETECTIONMODE_R1_MOTIONDETECTED"; + State[State["$NULLSTATE$"] = 7] = "$NULLSTATE$"; + })(State = Statemachine.State || (Statemachine.State = {})); + /** + * Enumeration of all features of the statechart + * @enum + * @property {sct.yakindu.io.Statemachine.Feature} NO_FEATURE + * @property {sct.yakindu.io.Statemachine.Feature} INTERNAL_BRIGHTNESS + * @property {sct.yakindu.io.Statemachine.Feature} USER_ON_BUTTON + * @property {sct.yakindu.io.Statemachine.Feature} USER_OFF_BUTTON + * @property {sct.yakindu.io.Statemachine.Feature} USER_MODE_BUTTON + * @property {sct.yakindu.io.Statemachine.Feature} SENSOR_MOTION + * @property {sct.yakindu.io.Statemachine.Feature} LUM_SENSOR_BRIGHT + * @property {sct.yakindu.io.Statemachine.Feature} LUM_SENSOR_DARK + * @class + */ + let Feature; + (function (Feature) { + Feature[Feature["NO_FEATURE"] = 0] = "NO_FEATURE"; + Feature[Feature["INTERNAL_BRIGHTNESS"] = 1] = "INTERNAL_BRIGHTNESS"; + Feature[Feature["USER_ON_BUTTON"] = 2] = "USER_ON_BUTTON"; + Feature[Feature["USER_OFF_BUTTON"] = 3] = "USER_OFF_BUTTON"; + Feature[Feature["USER_MODE_BUTTON"] = 4] = "USER_MODE_BUTTON"; + Feature[Feature["SENSOR_MOTION"] = 5] = "SENSOR_MOTION"; + Feature[Feature["LUM_SENSOR_BRIGHT"] = 6] = "LUM_SENSOR_BRIGHT"; + Feature[Feature["LUM_SENSOR_DARK"] = 7] = "LUM_SENSOR_DARK"; + })(Feature = Statemachine.Feature || (Statemachine.Feature = {})); + })(Statemachine = io.Statemachine || (io.Statemachine = {})); + })(io = yakindu.io || (yakindu.io = {})); + })(yakindu = sct.yakindu || (sct.yakindu = {})); +})(sct || (sct = {})); diff --git a/org.yakindu.sct.examples.basic.hierarchical/composite_states/lightswitch-player/assets/context.json.js b/org.yakindu.sct.examples.basic.hierarchical/composite_states/lightswitch-player/assets/context.json.js new file mode 100644 index 00000000..82175cf3 --- /dev/null +++ b/org.yakindu.sct.examples.basic.hierarchical/composite_states/lightswitch-player/assets/context.json.js @@ -0,0 +1 @@ +const contextJson = {"elements":[{"elements":[{"kind":"variable","type":"integer","name":"brightness","fqName":"brightness","featureId":"INTERNAL_BRIGHTNESS","writable":true,"value":0}],"kind":"composite","name":"internal","featureId":"","writable":true},{"elements":[{"kind":"event","name":"on_button","fqName":"user.on_button","featureId":"USER_ON_BUTTON","writable":true},{"kind":"event","name":"off_button","fqName":"user.off_button","featureId":"USER_OFF_BUTTON","writable":true},{"kind":"event","name":"mode_button","fqName":"user.mode_button","featureId":"USER_MODE_BUTTON","writable":true}],"kind":"composite","name":"user","fqName":"user","featureId":"","writable":true},{"elements":[{"kind":"event","name":"motion","fqName":"sensor.motion","featureId":"SENSOR_MOTION","writable":true}],"kind":"composite","name":"sensor","fqName":"sensor","featureId":"","writable":true},{"elements":[{"kind":"event","name":"bright","fqName":"lum_sensor.bright","featureId":"LUM_SENSOR_BRIGHT","writable":true},{"kind":"event","name":"dark","fqName":"lum_sensor.dark","featureId":"LUM_SENSOR_DARK","writable":true}],"kind":"composite","name":"lum_sensor","fqName":"lum_sensor","featureId":"","writable":true},{"elements":[{"kind":"event","type":"integer","name":"MotionDetected_time_event_0","fqName":"LightSwitch.main_region.MotionDetectionMode.r1.MotionDetected_time_event_0","featureId":"MOTIONDETECTED_TIME_EVENT_0","writable":true,"value":0}],"kind":"composite","name":"time events","featureId":"","writable":true}]} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.hierarchical/composite_states/lightswitch-player/assets/hashes.json.js b/org.yakindu.sct.examples.basic.hierarchical/composite_states/lightswitch-player/assets/hashes.json.js new file mode 100644 index 00000000..cde762d8 --- /dev/null +++ b/org.yakindu.sct.examples.basic.hierarchical/composite_states/lightswitch-player/assets/hashes.json.js @@ -0,0 +1 @@ +const hashesJson = {"MAIN_REGION_TWILIGHTDETECTIONMODE_R1_IDLE":"a621a9a4-be28-4bf7-bb8f-8d62c8c47ca6","MAIN_REGION_MOTIONDETECTIONMODE_tr0":"f788bbad-1714-41b8-8834-ee539439d7d2","MAIN_REGION_MOTIONDETECTIONMODE_tr1":"956397d9-3dc0-4fc6-912b-71a797a27b20","MAIN_REGION_TWILIGHTDETECTIONMODE_R1_IDLE_tr0":"c9e25e9c-21ea-4c7e-b7ef-70fe6301fb4f","MAIN_REGION_MOTIONDETECTIONMODE":"6b424766-21cc-4633-ae25-39cc46559429","MAIN_REGION_MANUALMODE":"bdb30744-1ef5-4dba-a035-7f14c0749852","MAIN_REGION_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED":"8412a71b-104f-4856-8cb9-58f06777fba3","MAIN_REGION_MOTIONDETECTIONMODE_R1_IDLE_tr0":"c53c7469-a357-4e23-88af-a631cb93dbee","MAIN_REGION_MOTIONDETECTIONMODE_R1_MOTIONDETECTED":"8e73421b-1d4a-4ad8-b2fc-0096cdd4cb6a","MAIN_REGION_MOTIONDETECTIONMODE_R1_MOTIONDETECTED_tr0":"e4bd2abb-1b34-4f7f-a78f-551476b42e6a","MAIN_REGION_TWILIGHTDETECTIONMODE":"6ffed9d4-73fc-4a7a-86b0-226a0c1e89bc","MAIN_REGION_MOTIONDETECTIONMODE_R1_MOTIONDETECTED_tr1":"96c22fad-cc61-470b-9206-29f9afa61585","MAIN_REGION_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED_tr0":"b4dd75f7-0011-4b3d-bef6-887b7412396e","MAIN_REGION_TWILIGHTDETECTIONMODE_tr1":"61635871-c353-4335-a334-b24b261a6146","MAIN_REGION_TWILIGHTDETECTIONMODE_tr0":"b6d1ad94-d5a6-4dfe-8564-f4234918767d","MAIN_REGION_MANUALMODE_tr0":"6378a9c5-6ff7-49d8-a1a3-5aa8651c9ec9","MAIN_REGION_MANUALMODE_tr1":"2d5093e8-8956-4b82-b54b-2b07753aa4d1","MAIN_REGION_MOTIONDETECTIONMODE_R1_IDLE":"15421854-0e22-4a6a-9257-1b0fc5d1847d"} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.hierarchical/composite_states/lightswitch-player/assets/statemachine.svg.js b/org.yakindu.sct.examples.basic.hierarchical/composite_states/lightswitch-player/assets/statemachine.svg.js new file mode 100644 index 00000000..4c45e52d --- /dev/null +++ b/org.yakindu.sct.examples.basic.hierarchical/composite_states/lightswitch-player/assets/statemachine.svg.js @@ -0,0 +1 @@ +let svg = `main region1-ManualModeentry / brightness += 1TwilightDetectionModer1-Idleentry / brightness = 0TwilightDetectedentry / brightness = 1-MotionDetectionModer1-Idleentry / brightness = 0MotionDetectedentry / brightness = 1--1sensor.motionsensor.motion1after 30safter 30s1user.on_buttonuser.on_button1user.off_buttonuser.off_button1user.on_button [brightness < 10]user.on_button [brightness < 10]2sensor.motionsensor.motion2lum_sensor.darklum_sensor.dark1lum_sensor.brightlum_sensor.bright1user.mode_buttonuser.mode_button1user.mode_buttonuser.mode_button1user.on_buttonuser.on_button2-1-1` \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.hierarchical/composite_states/lightswitch-player/assets/ypi.css b/org.yakindu.sct.examples.basic.hierarchical/composite_states/lightswitch-player/assets/ypi.css new file mode 100644 index 00000000..771aaa11 --- /dev/null +++ b/org.yakindu.sct.examples.basic.hierarchical/composite_states/lightswitch-player/assets/ypi.css @@ -0,0 +1,113 @@ +/*! + * itemis CREATE Player Styles + * Copyright 2021 itemis AG + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ + + + /*! + * Style definitions follow BEM pattern using and additional 'y' namespace (for itemis CREATE). + */ +.y-declaration { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; + background-color: #eee; + font-family: 'Courier New', Courier, monospace; +} + + +.y-entry { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; +} + +.y-entry:after { + content: ' \25CF '; + font-size: larger; +} + +.y-state { + background-color: rgb(209, 223, 238); + padding: 3px; + border: 0.5pt;; + border: 0.5pt; + border-radius: 4px; + border-color: #bbb; + font-family: 'Courier New', Courier, monospace; +} + +.y-state--active { + background-color: rgb(244, 215, 66); +} + +.y-state--inactive { + background-color: rgb(209, 223, 238); +} + +.y-variable{ + background-color: #eee; + border-color: #aaa; + border: 0.5pt; + border: 0.5pt; + border-radius: 2px; + font-family: 'Courier New', Courier, monospace; +} + +.y-variable::after { + color: #aaa; + content: attr(value); + font-family: 'Courier New', Courier, monospace; +} + +.y-do-enter { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; +} + +.y-do-enter:before { + content: ' \2192 '; +} + +.y-do-exit { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer +} + +.y-do-exit:before { + content: ' \2192 '; +} + +.y-do-raise { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; + white-space: nowrap; +} + +.y-do-raise:before { + content: ' \2192 '; +} + +button.y-do-raise:before { + content: ''; +} + +button.y-do-raise { + cursor: pointer; +} + +.y-do--over { + color: blue; + background-color: #eee; + cursor: pointer; +} + +.y-player { + border-style: solid; + border-width: 1px; + border-color: ; +} diff --git a/org.yakindu.sct.examples.basic.hierarchical/composite_states/lightswitch-player/model.scm b/org.yakindu.sct.examples.basic.hierarchical/composite_states/lightswitch-player/model.scm new file mode 100644 index 00000000..5064e609 --- /dev/null +++ b/org.yakindu.sct.examples.basic.hierarchical/composite_states/lightswitch-player/model.scm @@ -0,0 +1,1157 @@ +{ + "cells": [ + { + "position": { + "x": 0, + "y": 0 + }, + "size": { + "height": 10, + "width": 10 + }, + "angle": 0, + "type": "Statechart", + "id": "043cdabd-aeda-424c-b344-d636dbc60e03", + "linkable": false, + "z": 1, + "attrs": { + "name": { + "text": "LightSwitch" + }, + "specification": { + "text": "@CycleBased(200)\n\ninternal:\n\tvar brightness: integer\n\t\ninterface user:\n\tin event on_button\n\tin event off_button\n\tin event mode_button\n\t\ninterface sensor:\n\tin event motion\n\t\ninterface lum_sensor:\n \tin event bright\n \tin event dark" + } + } + }, + { + "type": "Region", + "position": { + "x": 0, + "y": 0 + }, + "size": { + "width": 1218, + "height": 561 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "918215e2-3fd8-491e-be0b-eb46fd317e7e", + "z": 2, + "embeds": [ + "61635871-c353-4335-a334-b24b261a6146", + "956397d9-3dc0-4fc6-912b-71a797a27b20", + "b6d1ad94-d5a6-4dfe-8564-f4234918767d", + "2d5093e8-8956-4b82-b54b-2b07753aa4d1", + "6378a9c5-6ff7-49d8-a1a3-5aa8651c9ec9", + "f788bbad-1714-41b8-8834-ee539439d7d2", + "d15e8a85-079a-46a0-8847-6b921289241b", + "46e59768-fddc-4f7b-b804-434d9ab8a730", + "bdb30744-1ef5-4dba-a035-7f14c0749852", + "6ffed9d4-73fc-4a7a-86b0-226a0c1e89bc", + "6b424766-21cc-4633-ae25-39cc46559429" + ], + "attrs": { + "priority": { + "text": 1 + }, + "name": { + "fontSize": "9", + "text": "main region" + } + } + }, + { + "type": "Entry", + "position": { + "x": 721, + "y": 66 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "46e59768-fddc-4f7b-b804-434d9ab8a730", + "parent": "918215e2-3fd8-491e-be0b-eb46fd317e7e", + "z": 3, + "embeds": [ + "37330f51-ffc3-4760-8e4f-231d27171aef" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 721, + "y": 81 + }, + "id": "37330f51-ffc3-4760-8e4f-231d27171aef", + "z": 4, + "parent": "46e59768-fddc-4f7b-b804-434d9ab8a730", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 598, + "y": 458 + }, + "size": { + "width": 181, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "bdb30744-1ef5-4dba-a035-7f14c0749852", + "parent": "918215e2-3fd8-491e-be0b-eb46fd317e7e", + "z": 5, + "attrs": { + "name": { + "text": "ManualMode" + }, + "specification": { + "text": "entry / brightness += 1", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 25, + "y": 127 + }, + "size": { + "width": 487, + "height": 194 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "6ffed9d4-73fc-4a7a-86b0-226a0c1e89bc", + "parent": "918215e2-3fd8-491e-be0b-eb46fd317e7e", + "z": 6, + "embeds": [ + "2c0b49c2-4da7-4af4-a96f-a4d83dc41173" + ], + "attrs": { + "name": { + "text": "TwilightDetectionMode" + } + } + }, + { + "type": "Region", + "position": { + "x": 26, + "y": 167 + }, + "size": { + "width": 485, + "height": 153 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "2c0b49c2-4da7-4af4-a96f-a4d83dc41173", + "z": 7, + "parent": "6ffed9d4-73fc-4a7a-86b0-226a0c1e89bc", + "embeds": [ + "49f826c7-ae13-4bdd-9718-de59d86d41a6", + "b4dd75f7-0011-4b3d-bef6-887b7412396e", + "c9e25e9c-21ea-4c7e-b7ef-70fe6301fb4f", + "a621a9a4-be28-4bf7-bb8f-8d62c8c47ca6", + "8412a71b-104f-4856-8cb9-58f06777fba3", + "dba20652-1e4a-4044-8b18-64c2489b05a2" + ], + "attrs": { + "name": { + "fontSize": "9", + "text": "r1" + } + } + }, + { + "type": "State", + "position": { + "x": 66, + "y": 216 + }, + "size": { + "width": 157, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "a621a9a4-be28-4bf7-bb8f-8d62c8c47ca6", + "parent": "2c0b49c2-4da7-4af4-a96f-a4d83dc41173", + "z": 8, + "attrs": { + "name": { + "text": "Idle" + }, + "specification": { + "text": "entry / brightness = 0", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 330, + "y": 216 + }, + "size": { + "width": 157, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "8412a71b-104f-4856-8cb9-58f06777fba3", + "parent": "2c0b49c2-4da7-4af4-a96f-a4d83dc41173", + "z": 9, + "attrs": { + "name": { + "text": "TwilightDetected" + }, + "specification": { + "text": "entry / brightness = 1", + "fontSize": "9" + } + } + }, + { + "type": "Entry", + "position": { + "x": 38, + "y": 235 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "dba20652-1e4a-4044-8b18-64c2489b05a2", + "parent": "2c0b49c2-4da7-4af4-a96f-a4d83dc41173", + "z": 10, + "embeds": [ + "4c3592d5-725d-4dbf-ac10-51f7653bf306" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 38, + "y": 250 + }, + "id": "4c3592d5-725d-4dbf-ac10-51f7653bf306", + "z": 11, + "parent": "dba20652-1e4a-4044-8b18-64c2489b05a2", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 643, + "y": 127 + }, + "size": { + "width": 525, + "height": 194 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "6b424766-21cc-4633-ae25-39cc46559429", + "parent": "918215e2-3fd8-491e-be0b-eb46fd317e7e", + "z": 12, + "embeds": [ + "813e6b14-8298-4422-b119-7be4f2688204" + ], + "attrs": { + "name": { + "text": "MotionDetectionMode" + } + } + }, + { + "type": "Region", + "position": { + "x": 644, + "y": 167 + }, + "size": { + "width": 523, + "height": 153 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "813e6b14-8298-4422-b119-7be4f2688204", + "z": 13, + "parent": "6b424766-21cc-4633-ae25-39cc46559429", + "embeds": [ + "bc58b3af-619a-4d34-8210-d8198cb724c8", + "96c22fad-cc61-470b-9206-29f9afa61585", + "e4bd2abb-1b34-4f7f-a78f-551476b42e6a", + "c53c7469-a357-4e23-88af-a631cb93dbee", + "15421854-0e22-4a6a-9257-1b0fc5d1847d", + "8e73421b-1d4a-4ad8-b2fc-0096cdd4cb6a", + "0042899f-5400-4859-9ab0-3d2c04df8350" + ], + "attrs": { + "name": { + "fontSize": "9", + "text": "r1" + } + } + }, + { + "type": "State", + "position": { + "x": 704, + "y": 216 + }, + "size": { + "width": 139, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "15421854-0e22-4a6a-9257-1b0fc5d1847d", + "parent": "813e6b14-8298-4422-b119-7be4f2688204", + "z": 14, + "attrs": { + "name": { + "text": "Idle" + }, + "specification": { + "text": "entry / brightness = 0", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 964, + "y": 216 + }, + "size": { + "width": 164, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "8e73421b-1d4a-4ad8-b2fc-0096cdd4cb6a", + "parent": "813e6b14-8298-4422-b119-7be4f2688204", + "z": 15, + "attrs": { + "name": { + "text": "MotionDetected" + }, + "specification": { + "text": "entry / brightness = 1", + "fontSize": "9" + } + } + }, + { + "type": "Entry", + "position": { + "x": 665, + "y": 229 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "0042899f-5400-4859-9ab0-3d2c04df8350", + "parent": "813e6b14-8298-4422-b119-7be4f2688204", + "z": 16, + "embeds": [ + "d23023b6-643b-4289-b405-70948df53575" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 665, + "y": 244 + }, + "id": "d23023b6-643b-4289-b405-70948df53575", + "z": 17, + "parent": "0042899f-5400-4859-9ab0-3d2c04df8350", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "49.44350537149755%", + "dy": "97.71069345711471%", + "rotate": true + } + }, + "id": "46e59768-fddc-4f7b-b804-434d9ab8a730" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "16.269814439185645%", + "dy": "0.41917940058475045%", + "rotate": true + } + }, + "id": "6b424766-21cc-4633-ae25-39cc46559429" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "d15e8a85-079a-46a0-8847-6b921289241b", + "z": 18, + "parent": "918215e2-3fd8-491e-be0b-eb46fd317e7e", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "26.41509433962264%", + "rotate": true + } + }, + "id": "15421854-0e22-4a6a-9257-1b0fc5d1847d" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "26.41509433962264%", + "rotate": true + } + }, + "id": "8e73421b-1d4a-4ad8-b2fc-0096cdd4cb6a" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "sensor.motion", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "c53c7469-a357-4e23-88af-a631cb93dbee", + "z": 19, + "parent": "813e6b14-8298-4422-b119-7be4f2688204", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "14.074019395503864%", + "dy": "50%", + "rotate": true + } + }, + "id": "8e73421b-1d4a-4ad8-b2fc-0096cdd4cb6a" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "46.016745719046384%", + "dy": "50%", + "rotate": true + } + }, + "id": "15421854-0e22-4a6a-9257-1b0fc5d1847d" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "after 30s", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "e4bd2abb-1b34-4f7f-a78f-551476b42e6a", + "z": 20, + "parent": "813e6b14-8298-4422-b119-7be4f2688204", + "vertices": [ + { + "x": 987.0813918086263, + "y": 293 + }, + { + "x": 767.9632765494745, + "y": 293 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "16.26158677523985%", + "dy": "50%", + "rotate": true + } + }, + "id": "6b424766-21cc-4633-ae25-39cc46559429" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "72.02946440332%", + "dy": "1.3272591551811892%", + "rotate": true + } + }, + "id": "bdb30744-1ef5-4dba-a035-7f14c0749852" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.on_button", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "f788bbad-1714-41b8-8834-ee539439d7d2", + "z": 21, + "parent": "918215e2-3fd8-491e-be0b-eb46fd317e7e", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "36.23296699608171%", + "dy": "1.1272185789995899%", + "rotate": true + } + }, + "id": "bdb30744-1ef5-4dba-a035-7f14c0749852" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "3.920318145315789%", + "dy": "50%", + "rotate": true + } + }, + "id": "6b424766-21cc-4633-ae25-39cc46559429" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.off_button", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "6378a9c5-6ff7-49d8-a1a3-5aa8651c9ec9", + "z": 22, + "parent": "918215e2-3fd8-491e-be0b-eb46fd317e7e", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "72.15418368163986%", + "dy": "50%", + "rotate": true + } + }, + "id": "bdb30744-1ef5-4dba-a035-7f14c0749852" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "36.795067659540415%", + "dy": "50%", + "rotate": true + } + }, + "id": "bdb30744-1ef5-4dba-a035-7f14c0749852" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.on_button [brightness < 10]", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "2" + } + } + } + ], + "id": "2d5093e8-8956-4b82-b54b-2b07753aa4d1", + "z": 23, + "parent": "918215e2-3fd8-491e-be0b-eb46fd317e7e", + "vertices": [ + { + "x": 728.5990724637682, + "y": 537.7258064516129 + }, + { + "x": 664.5990724637682, + "y": 537.7258064516129 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "91.07395751376876%", + "dy": "50%", + "rotate": true + } + }, + "id": "8e73421b-1d4a-4ad8-b2fc-0096cdd4cb6a" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "47.17151848937851%", + "dy": "50%", + "rotate": true + } + }, + "id": "8e73421b-1d4a-4ad8-b2fc-0096cdd4cb6a" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "sensor.motion", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "2" + } + } + } + ], + "id": "96c22fad-cc61-470b-9206-29f9afa61585", + "z": 24, + "parent": "813e6b14-8298-4422-b119-7be4f2688204", + "vertices": [ + { + "x": 1113.3612903225808, + "y": 289 + }, + { + "x": 1041.3612903225808, + "y": 289 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "49.371069182389974%", + "rotate": true + } + }, + "id": "a621a9a4-be28-4bf7-bb8f-8d62c8c47ca6" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.2600849256900019%", + "dy": "49.371069182389974%", + "rotate": true + } + }, + "id": "8412a71b-104f-4856-8cb9-58f06777fba3" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "lum_sensor.dark", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "c9e25e9c-21ea-4c7e-b7ef-70fe6301fb4f", + "z": 25, + "parent": "2c0b49c2-4da7-4af4-a96f-a4d83dc41173", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "41.44120163513645%", + "dy": "50%", + "rotate": true + } + }, + "id": "8412a71b-104f-4856-8cb9-58f06777fba3" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "55.49576955984408%", + "dy": "50%", + "rotate": true + } + }, + "id": "a621a9a4-be28-4bf7-bb8f-8d62c8c47ca6" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "lum_sensor.bright", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "b4dd75f7-0011-4b3d-bef6-887b7412396e", + "z": 26, + "parent": "2c0b49c2-4da7-4af4-a96f-a4d83dc41173", + "vertices": [ + { + "x": 395.06268656716423, + "y": 295 + }, + { + "x": 153.1283582089552, + "y": 295 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "45.6244635646769%", + "rotate": true + } + }, + "id": "6ffed9d4-73fc-4a7a-86b0-226a0c1e89bc" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.00592783044976386%", + "dy": "45.6244635646769%", + "rotate": true + } + }, + "id": "6b424766-21cc-4633-ae25-39cc46559429" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.mode_button", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "b6d1ad94-d5a6-4dfe-8564-f4234918767d", + "z": 27, + "parent": "918215e2-3fd8-491e-be0b-eb46fd317e7e", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.07413655102848116%", + "dy": "26.072514149993342%", + "rotate": true + } + }, + "id": "6b424766-21cc-4633-ae25-39cc46559429" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "26.072514149993342%", + "rotate": true + } + }, + "id": "6ffed9d4-73fc-4a7a-86b0-226a0c1e89bc" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.mode_button", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "956397d9-3dc0-4fc6-912b-71a797a27b20", + "z": 28, + "parent": "918215e2-3fd8-491e-be0b-eb46fd317e7e", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "91.03682982727742%", + "dy": "50%", + "rotate": true + } + }, + "id": "6ffed9d4-73fc-4a7a-86b0-226a0c1e89bc" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.07788947590401704%", + "dy": "55.68101619264737%", + "rotate": true + } + }, + "id": "bdb30744-1ef5-4dba-a035-7f14c0749852" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.on_button", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "2" + } + } + } + ], + "id": "61635871-c353-4335-a334-b24b261a6146", + "z": 29, + "parent": "918215e2-3fd8-491e-be0b-eb46fd317e7e", + "vertices": [ + { + "x": 468.349361258841, + "y": 487.5109385821031 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "97.52902155887236%", + "dy": "48.88888888888896%", + "rotate": true + } + }, + "id": "dba20652-1e4a-4044-8b18-64c2489b05a2" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.48325252717305484%", + "dy": "49.68553459119499%", + "rotate": true + } + }, + "id": "a621a9a4-be28-4bf7-bb8f-8d62c8c47ca6" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "49f826c7-ae13-4bdd-9718-de59d86d41a6", + "z": 30, + "parent": "2c0b49c2-4da7-4af4-a96f-a4d83dc41173", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "98.27529021558955%", + "dy": "53.333333333333336%", + "rotate": true + } + }, + "id": "0042899f-5400-4859-9ab0-3d2c04df8350" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "5.02344393142204%", + "dy": "39.62264150943396%", + "rotate": true + } + }, + "id": "15421854-0e22-4a6a-9257-1b0fc5d1847d" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "bc58b3af-619a-4d34-8210-d8198cb724c8", + "z": 31, + "parent": "813e6b14-8298-4422-b119-7be4f2688204", + "attrs": {} + } + ] +} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.hierarchical/composite_states/lightswitch-player/player.html b/org.yakindu.sct.examples.basic.hierarchical/composite_states/lightswitch-player/player.html new file mode 100644 index 00000000..a40d8757 --- /dev/null +++ b/org.yakindu.sct.examples.basic.hierarchical/composite_states/lightswitch-player/player.html @@ -0,0 +1,52 @@ + +sct-web-player demo + + + + + + + + + + + + + + + +

+ +
+ + + + + \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.hierarchical/index.html b/org.yakindu.sct.examples.basic.hierarchical/index.html index ff3b5a01..22a825bc 100644 --- a/org.yakindu.sct.examples.basic.hierarchical/index.html +++ b/org.yakindu.sct.examples.basic.hierarchical/index.html @@ -1,78 +1,147 @@ + - -Light Switch Series - + + Light Switch Series + + -
+
+ +

Hierarchical Statecharts

+ +

This example demonstrates the usage of hierarchies in statecharts. It explains the concepts of composite + states and subdiagrams.

+ +

Starting Point

+ +

Let's revisit the light switch example of the Basic + Tutorial. To be more concrete, let's start at the point where our light switch can be in one of + three possible modes: +

    +
  1. a twilight / luminosity mode in which the light automatically turns on when it is dark, +
  2. +
  3. a motion sensing mode in which the light automatically turns on when motion is + detected, and
  4. +
  5. a manual mode in which the user can change the brightness manually.
  6. +
+ The user can enable the manual mode by pressing the On button. Pressing the + Off button enables the motion sensing mode. With a Mode button the user can + switch between the motion sensing and the twilight mode. +

+

+ As each mode may be reflected in multiple states, switching between the different modes requires the + modeling of many transitions. The following example shows one possible solution without using any means of + hierarchies: +

+

+

+

+

Although the statechart consists of only five states, it is difficult to understand the underlying behavior + because of the relatively high number of transitions. Consider the states + TwilightDetectionMode and TwilightDetected. Both states have an outgoing + transition to MotionDetectionMode with the same trigger. Same holds for all four automatic + mode states, which have an identical transition to the ManualMode state. +

+

Having multiple states with an identical transition to the same target state is an indicator for the + potential to group these states into one composite state.

+ +

Using Composite States

+ +

+ A composite state is a state that contains one or more other substates. It can be used to group states into + logical compounds and thus make the statechart more comprehensible. Having one outgoing transition from a + composite state is semantically the same as having outgoing transitions from each of the composite's + substates. In that way, a composite stay can drastically reduce the number of transitions in the statechart + and hence improve readability. +

+

+ Let's introduce composite states to our light switch example: +

+

+

+

+

+ Compare the model with the one above. We introduced two composite states to logically group the states by + the respective light switch modes. In that way we could reduce a number of transitions without changing the + model's behavior. +

+

+ There are multiple ways to create a composite state: +

    +
  • Use the statechart element palette on the right to create a composite state.
  • +
  • Select a normal state, press [Ctrl]+[Space] and choose Add subregion.
  • +
  • Select a number of states (by holding [Ctrl]), right-click and choose Refactor -> Group States Into + Composite.
  • +
+

+

+ We can go one step further and create a further layer of hierarchy by grouping the two composite states into + another composite state. In that way we can create multiple layers of hierarchy. +

+

+

+

+

Using Subdiagrams

+

+ Using composite states is a great way to make your statechart more comprehensible. However, as your + statechart becomes bigger you might want to hide the details and only focus on the higher level + relationships without loosing the semantic of your statechart. Subdiagrams come as a solution here. +

+

+ When the Extract Subdiagram refactoring is executed on a composite state, all containing regions + are extracted into a separate diagram. The composite state no longer clutters the diagram with all its + internal details, but instead appears almost like a normal state. The only difference is a small decorator + icon in the lower-right corner of the state, indicating the existence of a subdiagram. When you hover over + this decorator with the mouse cursor, you’ll see a small preview of the subdiagram’s content. +

+

+ Light switch with subdiagrams +

+

+ By introducing subdiagrams, we have hidden the details of the two light switch automatic light switch modes. + In that way, you can directly understand which modes the light switch has and how to switch between them. If + you are interested in the details, you can hover or click on the decorator to open the respective + subdiagrams. You can revert these changes again by using the Inline Subdiagram refactoring. +

+
+ - + \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.hierarchical/nested_composite_states/assets/bundle.js b/org.yakindu.sct.examples.basic.hierarchical/nested_composite_states/assets/bundle.js new file mode 100644 index 00000000..e73f8c9f --- /dev/null +++ b/org.yakindu.sct.examples.basic.hierarchical/nested_composite_states/assets/bundle.js @@ -0,0 +1,869 @@ +var com; +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Instances represent state machine trace events. + * @param {com.yakindu.core.TraceEventType} type + * @param {*} machine + * @param {*} state + * @param {*} feature + * @param {*} value + * @class + */ + class TraceEvent { + constructor(type, machine, state, feature, value) { + if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && ((state != null) || state === null) && ((feature != null) || feature === null) && ((value != null) || value === null)) { + let __args = arguments; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + else if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && state === undefined && feature === undefined && value === undefined) { + let __args = arguments; + { + let __args = arguments; + let state = null; + let feature = null; + let value = null; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + } + else + throw new Error('invalid overload'); + } + getType() { + return this.type; + } + getMachine() { + return this.machine; + } + getState() { + return this.state; + } + getFeature() { + return this.feature; + } + getValue() { + return this.value; + } + } + core.TraceEvent = TraceEvent; + TraceEvent["__class"] = "com.yakindu.core.TraceEvent"; + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Trace event type enumeration. + * @enum + * @property {com.yakindu.core.TraceEventType} MACHINE_ENTER + * @property {com.yakindu.core.TraceEventType} MACHINE_EXIT + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_START + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_STOP + * @property {com.yakindu.core.TraceEventType} STATE_ENTERED + * @property {com.yakindu.core.TraceEventType} STATE_EXITED + * @property {com.yakindu.core.TraceEventType} STATE_TRANSITION + * @property {com.yakindu.core.TraceEventType} EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} VARIABLE_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_UNSET + * @class + */ + let TraceEventType; + (function (TraceEventType) { + TraceEventType[TraceEventType["MACHINE_ENTER"] = 0] = "MACHINE_ENTER"; + TraceEventType[TraceEventType["MACHINE_EXIT"] = 1] = "MACHINE_EXIT"; + TraceEventType[TraceEventType["MACHINE_RTS_START"] = 2] = "MACHINE_RTS_START"; + TraceEventType[TraceEventType["MACHINE_RTS_STOP"] = 3] = "MACHINE_RTS_STOP"; + TraceEventType[TraceEventType["STATE_ENTERED"] = 4] = "STATE_ENTERED"; + TraceEventType[TraceEventType["STATE_EXITED"] = 5] = "STATE_EXITED"; + TraceEventType[TraceEventType["STATE_TRANSITION"] = 6] = "STATE_TRANSITION"; + TraceEventType[TraceEventType["EVENT_RAISED"] = 7] = "EVENT_RAISED"; + TraceEventType[TraceEventType["VARIABLE_SET"] = 8] = "VARIABLE_SET"; + TraceEventType[TraceEventType["TIME_EVENT_RAISED"] = 9] = "TIME_EVENT_RAISED"; + TraceEventType[TraceEventType["TIME_EVENT_SET"] = 10] = "TIME_EVENT_SET"; + TraceEventType[TraceEventType["TIME_EVENT_UNSET"] = 11] = "TIME_EVENT_UNSET"; + })(TraceEventType = core.TraceEventType || (core.TraceEventType = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + var rx; + (function (rx) { + class Observable { + constructor() { + this.observers = ([]); + } + next(value) { + for (let index = 0; index < this.observers.length; index++) { + let observer = this.observers[index]; + { + observer.next(value); + } + } + } + subscribe(observer) { + return observer != null ? /* add */ (this.observers.push(observer) > 0) : false; + } + unsubscribe(observer) { + return observer != null ? /* remove */ (a => { let index = a.indexOf(observer); if (index >= 0) { + a.splice(index, 1); + return true; + } + else { + return false; + } })(this.observers) : false; + } + } + rx.Observable = Observable; + Observable["__class"] = "com.yakindu.core.rx.Observable"; + })(rx = core.rx || (core.rx = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +var sct; +(function (sct) { + var yakindu; + (function (yakindu) { + var io; + (function (io) { + class Statemachine { + constructor() { + if (this.__user === undefined) { + this.__user = null; + } + if (this.__sensor === undefined) { + this.__sensor = null; + } + if (this.__lum_sensor === undefined) { + this.__lum_sensor = null; + } + this.stateVector = [null]; + this.trace = (new com.yakindu.core.rx.Observable()); + if (this.timerService === undefined) { + this.timerService = null; + } + this.timeEvents = [false]; + this.inEventQueue = ([]); + if (this.brightness === undefined) { + this.brightness = 0; + } + if (this.isExecuting === undefined) { + this.isExecuting = false; + } + this.__user = new Statemachine.User(this); + this.__sensor = new Statemachine.Sensor(this); + this.__lum_sensor = new Statemachine.Lum_sensor(this); + for (let i = 0; i < 1; i++) { + { + this.stateVector[i] = Statemachine.State.$NULLSTATE$; + } + ; + } + this.clearInEvents(); + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + this.isExecuting = false; + } + getBrightness() { + return this.brightness; + } + setBrightness(value) { + this.brightness = value; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + getIsExecuting() { + return this.isExecuting; + } + setIsExecuting(value) { + this.isExecuting = value; + } + enter() { + if (this.timerService == null) { + throw Object.defineProperty(new Error("Timer service must be set."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.IllegalStateException', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.Exception'] }); + } + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_ENTER, this))); + this.enterSequence_main_region_default(); + this.isExecuting = false; + } + exit() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_EXIT, this))); + this.exitSequence_main_region(); + this.isExecuting = false; + } + /** + * @see IStatemachine#isActive() + * @return {boolean} + */ + isActive() { + return this.stateVector[0] !== Statemachine.State.$NULLSTATE$; + } + /** + * + * Always returns 'false' since this state machine can never become final. + * + * @see IStatemachine#isFinal() + * @return {boolean} + */ + isFinal() { + return false; + } + clearInEvents() { + this.__user.on_button = false; + this.__user.off_button = false; + this.__user.mode_button = false; + this.__sensor.motion = false; + this.__lum_sensor.bright = false; + this.__lum_sensor.dark = false; + this.timeEvents[0] = false; + } + microStep() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE: + this.main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED: + this.main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE: + this.main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED: + this.main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MANUALMODE: + this.main_region_ManualMode_react(-1); + break; + default: + break; + } + } + runCycle() { + if (this.timerService == null) { + throw Object.defineProperty(new Error("Timer service must be set."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.IllegalStateException', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.Exception'] }); + } + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_START, this))); + this.nextEvent(); + do { + { + this.microStep(); + this.clearInEvents(); + this.nextEvent(); + } + } while ((((((((this.__user.on_button || this.__user.off_button) || this.__user.mode_button) || this.__sensor.motion) || this.__lum_sensor.bright) || this.__lum_sensor.dark) || this.timeEvents[0]))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_STOP, this))); + this.isExecuting = false; + } + nextEvent() { + if (!(this.inEventQueue.length == 0)) { + (target => (typeof target === 'function') ? target() : target.run())(/* poll */ (a => a.length == 0 ? null : a.shift())(this.inEventQueue)); + return; + } + } + /** + * Returns true if the given state is currently active otherwise false. + * @param {sct.yakindu.io.Statemachine.State} state + * @return {boolean} + */ + isStateActive(state) { + switch ((state)) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_AUTOMATICMODE]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED]]; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED]]; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED]]; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MANUALMODE: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_MANUALMODE; + default: + return false; + } + } + setTimerService(timerService) { + this.timerService = timerService; + } + getTimerService() { + return this.timerService; + } + raiseTimeEvent(eventID) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_RAISED, this, null, null, eventID))); + /* add */ (this.inEventQueue.push(() => { + this.timeEvents[eventID] = true; + }) > 0); + this.runCycle(); + } + user() { + return this.__user; + } + sensor() { + return this.__sensor; + } + lum_sensor() { + return this.__lum_sensor; + } + getTrace() { + return this.trace; + } + entryAction_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle() { + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + entryAction_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected() { + this.setBrightness(1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + entryAction_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle() { + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + entryAction_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected() { + this.timerService.setTimer(this, 0, (30 * 1000), false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_SET, this, null, null, 0))); + this.setBrightness(1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + entryAction_main_region_ManualMode() { + this.setBrightness(this.getBrightness() + 1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + exitAction_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected() { + this.timerService.unsetTimer(this, 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_UNSET, this, null, null, 0))); + } + enterSequence_main_region_AutomaticMode_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE, null, null))); + this.enterSequence_main_region_AutomaticMode_r1_default(); + } + enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE, null, null))); + this.enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_default(); + } + enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle_default() { + this.entryAction_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE; + } + enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected_default() { + this.entryAction_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED; + } + enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE, null, null))); + this.enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_default(); + } + enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle_default() { + this.entryAction_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE; + } + enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected_default() { + this.entryAction_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED; + } + enterSequence_main_region_ManualMode_default() { + this.entryAction_main_region_ManualMode(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_MANUALMODE, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_MANUALMODE; + } + enterSequence_main_region_default() { + this.react_main_region__entry_Default(); + } + enterSequence_main_region_AutomaticMode_r1_default() { + this.react_main_region_AutomaticMode_r1__entry_Default(); + } + enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_default() { + this.react_main_region_AutomaticMode_r1_TwilightDetectionMode_r1__entry_Default(); + } + enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_default() { + this.react_main_region_AutomaticMode_r1_MotionDetectionMode_r1__entry_Default(); + } + exitSequence_main_region_AutomaticMode() { + this.exitSequence_main_region_AutomaticMode_r1(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE, null, null))); + } + exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode() { + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE, null, null))); + } + exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE, null, null))); + } + exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED, null, null))); + } + exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode() { + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE, null, null))); + } + exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE, null, null))); + } + exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.exitAction_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED, null, null))); + } + exitSequence_main_region_ManualMode() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_MANUALMODE, null, null))); + } + exitSequence_main_region() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE: + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE, null, null))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED: + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE, null, null))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE: + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE, null, null))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED: + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE, null, null))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MANUALMODE: + this.exitSequence_main_region_ManualMode(); + break; + default: + break; + } + } + exitSequence_main_region_AutomaticMode_r1() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE: + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED: + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE: + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED: + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE, null, null))); + break; + default: + break; + } + } + exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE: + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED: + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected(); + break; + default: + break; + } + } + exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE: + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED: + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected(); + break; + default: + break; + } + } + react_main_region_AutomaticMode_r1_TwilightDetectionMode_r1__entry_Default() { + this.enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle_default(); + } + react_main_region_AutomaticMode_r1_MotionDetectionMode_r1__entry_Default() { + this.enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle_default(); + } + react_main_region_AutomaticMode_r1__entry_Default() { + this.enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_default(); + } + react_main_region__entry_Default() { + this.enterSequence_main_region_AutomaticMode_default(); + } + react(transitioned_before) { + return transitioned_before; + } + main_region_AutomaticMode_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__user.on_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE, null, 0))); + this.exitSequence_main_region_AutomaticMode(); + this.enterSequence_main_region_ManualMode_default(); + this.react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_region_AutomaticMode_r1_TwilightDetectionMode_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__user.mode_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE, null, 0))); + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode(); + this.enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_default(); + this.main_region_AutomaticMode_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_AutomaticMode_react(transitioned_before); + } + return transitioned_after; + } + main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__lum_sensor.dark) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE, null, 0))); + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle(); + this.enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected_default(); + this.main_region_AutomaticMode_r1_TwilightDetectionMode_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_AutomaticMode_r1_TwilightDetectionMode_react(transitioned_before); + } + return transitioned_after; + } + main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__lum_sensor.bright) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED, null, 0))); + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected(); + this.enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle_default(); + this.main_region_AutomaticMode_r1_TwilightDetectionMode_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_AutomaticMode_r1_TwilightDetectionMode_react(transitioned_before); + } + return transitioned_after; + } + main_region_AutomaticMode_r1_MotionDetectionMode_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__user.mode_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE, null, 0))); + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode(); + this.enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_default(); + this.main_region_AutomaticMode_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_AutomaticMode_react(transitioned_before); + } + return transitioned_after; + } + main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__sensor.motion) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE, null, 0))); + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle(); + this.enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected_default(); + this.main_region_AutomaticMode_r1_MotionDetectionMode_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_AutomaticMode_r1_MotionDetectionMode_react(transitioned_before); + } + return transitioned_after; + } + main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.timeEvents[0]) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED, null, 0))); + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected(); + this.timeEvents[0] = false; + this.enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle_default(); + this.main_region_AutomaticMode_r1_MotionDetectionMode_react(0); + transitioned_after = 0; + } + else { + if (this.__sensor.motion) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED, null, 1))); + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected(); + this.enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected_default(); + this.main_region_AutomaticMode_r1_MotionDetectionMode_react(0); + transitioned_after = 0; + } + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_AutomaticMode_r1_MotionDetectionMode_react(transitioned_before); + } + return transitioned_after; + } + main_region_ManualMode_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__user.off_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_MANUALMODE, null, 0))); + this.exitSequence_main_region_ManualMode(); + this.enterSequence_main_region_AutomaticMode_default(); + this.react(0); + transitioned_after = 0; + } + else { + if (((this.__user.on_button) && (this.getBrightness() < 10))) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_MANUALMODE, null, 1))); + this.exitSequence_main_region_ManualMode(); + this.enterSequence_main_region_ManualMode_default(); + this.react(0); + transitioned_after = 0; + } + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + } + io.Statemachine = Statemachine; + Statemachine["__class"] = "sct.yakindu.io.Statemachine"; + Statemachine["__interfaces"] = ["com.yakindu.core.IStatemachine", "com.yakindu.core.ITimed"]; + (function (Statemachine) { + class User { + constructor(parent) { + if (this.parent === undefined) { + this.parent = null; + } + if (this.on_button === undefined) { + this.on_button = false; + } + if (this.off_button === undefined) { + this.off_button = false; + } + if (this.mode_button === undefined) { + this.mode_button = false; + } + this.parent = parent; + } + raiseOn_button() { + /* add */ (this.parent.inEventQueue.push(() => { + this.on_button = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.USER_ON_BUTTON, null))); + this.parent.runCycle(); + } + raiseOff_button() { + /* add */ (this.parent.inEventQueue.push(() => { + this.off_button = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.USER_OFF_BUTTON, null))); + this.parent.runCycle(); + } + raiseMode_button() { + /* add */ (this.parent.inEventQueue.push(() => { + this.mode_button = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.USER_MODE_BUTTON, null))); + this.parent.runCycle(); + } + } + Statemachine.User = User; + User["__class"] = "sct.yakindu.io.Statemachine.User"; + class Sensor { + constructor(parent) { + if (this.parent === undefined) { + this.parent = null; + } + if (this.motion === undefined) { + this.motion = false; + } + this.parent = parent; + } + raiseMotion() { + /* add */ (this.parent.inEventQueue.push(() => { + this.motion = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.SENSOR_MOTION, null))); + this.parent.runCycle(); + } + } + Statemachine.Sensor = Sensor; + Sensor["__class"] = "sct.yakindu.io.Statemachine.Sensor"; + class Lum_sensor { + constructor(parent) { + if (this.parent === undefined) { + this.parent = null; + } + if (this.bright === undefined) { + this.bright = false; + } + if (this.dark === undefined) { + this.dark = false; + } + this.parent = parent; + } + raiseBright() { + /* add */ (this.parent.inEventQueue.push(() => { + this.bright = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.LUM_SENSOR_BRIGHT, null))); + this.parent.runCycle(); + } + raiseDark() { + /* add */ (this.parent.inEventQueue.push(() => { + this.dark = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.LUM_SENSOR_DARK, null))); + this.parent.runCycle(); + } + } + Statemachine.Lum_sensor = Lum_sensor; + Lum_sensor["__class"] = "sct.yakindu.io.Statemachine.Lum_sensor"; + let State; + (function (State) { + State[State["MAIN_REGION_AUTOMATICMODE"] = 0] = "MAIN_REGION_AUTOMATICMODE"; + State[State["MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE"] = 1] = "MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE"; + State[State["MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE"] = 2] = "MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE"; + State[State["MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED"] = 3] = "MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED"; + State[State["MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE"] = 4] = "MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE"; + State[State["MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE"] = 5] = "MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE"; + State[State["MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED"] = 6] = "MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED"; + State[State["MAIN_REGION_MANUALMODE"] = 7] = "MAIN_REGION_MANUALMODE"; + State[State["$NULLSTATE$"] = 8] = "$NULLSTATE$"; + })(State = Statemachine.State || (Statemachine.State = {})); + /** + * Enumeration of all features of the statechart + * @enum + * @property {sct.yakindu.io.Statemachine.Feature} NO_FEATURE + * @property {sct.yakindu.io.Statemachine.Feature} INTERNAL_BRIGHTNESS + * @property {sct.yakindu.io.Statemachine.Feature} USER_ON_BUTTON + * @property {sct.yakindu.io.Statemachine.Feature} USER_OFF_BUTTON + * @property {sct.yakindu.io.Statemachine.Feature} USER_MODE_BUTTON + * @property {sct.yakindu.io.Statemachine.Feature} SENSOR_MOTION + * @property {sct.yakindu.io.Statemachine.Feature} LUM_SENSOR_BRIGHT + * @property {sct.yakindu.io.Statemachine.Feature} LUM_SENSOR_DARK + * @class + */ + let Feature; + (function (Feature) { + Feature[Feature["NO_FEATURE"] = 0] = "NO_FEATURE"; + Feature[Feature["INTERNAL_BRIGHTNESS"] = 1] = "INTERNAL_BRIGHTNESS"; + Feature[Feature["USER_ON_BUTTON"] = 2] = "USER_ON_BUTTON"; + Feature[Feature["USER_OFF_BUTTON"] = 3] = "USER_OFF_BUTTON"; + Feature[Feature["USER_MODE_BUTTON"] = 4] = "USER_MODE_BUTTON"; + Feature[Feature["SENSOR_MOTION"] = 5] = "SENSOR_MOTION"; + Feature[Feature["LUM_SENSOR_BRIGHT"] = 6] = "LUM_SENSOR_BRIGHT"; + Feature[Feature["LUM_SENSOR_DARK"] = 7] = "LUM_SENSOR_DARK"; + })(Feature = Statemachine.Feature || (Statemachine.Feature = {})); + })(Statemachine = io.Statemachine || (io.Statemachine = {})); + })(io = yakindu.io || (yakindu.io = {})); + })(yakindu = sct.yakindu || (sct.yakindu = {})); +})(sct || (sct = {})); diff --git a/org.yakindu.sct.examples.basic.hierarchical/nested_composite_states/assets/context.json.js b/org.yakindu.sct.examples.basic.hierarchical/nested_composite_states/assets/context.json.js new file mode 100644 index 00000000..93511607 --- /dev/null +++ b/org.yakindu.sct.examples.basic.hierarchical/nested_composite_states/assets/context.json.js @@ -0,0 +1 @@ +const contextJson = {"elements":[{"elements":[{"kind":"variable","type":"integer","name":"brightness","fqName":"brightness","featureId":"INTERNAL_BRIGHTNESS","writable":true,"value":0}],"kind":"composite","name":"internal","featureId":"","writable":true},{"elements":[{"kind":"event","name":"on_button","fqName":"user.on_button","featureId":"USER_ON_BUTTON","writable":true},{"kind":"event","name":"off_button","fqName":"user.off_button","featureId":"USER_OFF_BUTTON","writable":true},{"kind":"event","name":"mode_button","fqName":"user.mode_button","featureId":"USER_MODE_BUTTON","writable":true}],"kind":"composite","name":"user","fqName":"user","featureId":"","writable":true},{"elements":[{"kind":"event","name":"motion","fqName":"sensor.motion","featureId":"SENSOR_MOTION","writable":true}],"kind":"composite","name":"sensor","fqName":"sensor","featureId":"","writable":true},{"elements":[{"kind":"event","name":"bright","fqName":"lum_sensor.bright","featureId":"LUM_SENSOR_BRIGHT","writable":true},{"kind":"event","name":"dark","fqName":"lum_sensor.dark","featureId":"LUM_SENSOR_DARK","writable":true}],"kind":"composite","name":"lum_sensor","fqName":"lum_sensor","featureId":"","writable":true},{"elements":[{"kind":"event","type":"integer","name":"MotionDetected_time_event_0","fqName":"LightSwitch.main_region.AutomaticMode.r1.MotionDetectionMode.r1.MotionDetected_time_event_0","featureId":"MOTIONDETECTED_TIME_EVENT_0","writable":true,"value":0}],"kind":"composite","name":"time events","featureId":"","writable":true}]} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.hierarchical/nested_composite_states/assets/hashes.json.js b/org.yakindu.sct.examples.basic.hierarchical/nested_composite_states/assets/hashes.json.js new file mode 100644 index 00000000..0a984db6 --- /dev/null +++ b/org.yakindu.sct.examples.basic.hierarchical/nested_composite_states/assets/hashes.json.js @@ -0,0 +1 @@ +const hashesJson = {"MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED_tr0":"d209a21d-0c0a-4879-85db-a8d079e27802","MAIN_REGION_AUTOMATICMODE_tr0":"6dfb85d1-173c-4abd-a31a-0972a0213968","MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED":"2c0c5823-9054-4a81-baf2-bf005c2d3f34","MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE_tr0":"6d0fdaa3-9fd4-46b6-b77b-97a1f1074e12","MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED":"025152a7-c108-45fa-ae15-9ee87921d5e8","MAIN_REGION_MANUALMODE":"f44779d7-da73-4685-9f51-bada251d825a","MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE":"bd48ee95-5e61-4553-89db-d38460d4b218","MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_tr0":"d2406335-80dd-410d-8fa8-db1ad15cd7b0","MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_tr0":"c5c4079a-e18f-464f-9f34-97b7b6bf1650","MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE":"f9c8e2b8-e1bb-4dca-84d2-81c7bd3d9658","MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE":"92bc1788-79db-4ea6-bf07-286f7a7bb50b","MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED_tr0":"ba687d5c-f250-45e0-9d04-3577c632a261","MAIN_REGION_AUTOMATICMODE":"c4be5617-4112-4cd4-8864-21df92f99343","MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED_tr1":"794a799f-3826-4427-864b-b04d0780d698","MAIN_REGION_MANUALMODE_tr0":"4f08040a-1618-41c2-b01b-24d368178a6d","MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE":"22f90178-eae7-4489-badc-0ce41f65a213","MAIN_REGION_MANUALMODE_tr1":"fbae5ca5-424d-406b-bcbe-968a8d5b7213","MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE_tr0":"0d60d0d1-fa2a-49ab-8344-de12a641ec88"} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.hierarchical/nested_composite_states/assets/statemachine.svg.js b/org.yakindu.sct.examples.basic.hierarchical/nested_composite_states/assets/statemachine.svg.js new file mode 100644 index 00000000..00a1f6ac --- /dev/null +++ b/org.yakindu.sct.examples.basic.hierarchical/nested_composite_states/assets/statemachine.svg.js @@ -0,0 +1 @@ +let svg = `main region1AutomaticModer1-TwilightDetectionModer1-Idleentry / brightness = 0TwilightDetectedentry / brightness = 1-MotionDetectionModer1-Idleentry / brightness = 0MotionDetectedentry / brightness = 1--sensor.motionsensor.motion1after 30safter 30s1sensor.motionsensor.motion2lum_sensor.darklum_sensor.dark1lum_sensor.brightlum_sensor.bright1user.mode_buttonuser.mode_button1user.mode_buttonuser.mode_button1-1-1ManualModeentry / brightness += 1user.off_buttonuser.off_button1user.on_button [brightness < 10]user.on_button [brightness < 10]2user.on_buttonuser.on_button1-1--1` \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.hierarchical/nested_composite_states/assets/ypi.css b/org.yakindu.sct.examples.basic.hierarchical/nested_composite_states/assets/ypi.css new file mode 100644 index 00000000..771aaa11 --- /dev/null +++ b/org.yakindu.sct.examples.basic.hierarchical/nested_composite_states/assets/ypi.css @@ -0,0 +1,113 @@ +/*! + * itemis CREATE Player Styles + * Copyright 2021 itemis AG + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ + + + /*! + * Style definitions follow BEM pattern using and additional 'y' namespace (for itemis CREATE). + */ +.y-declaration { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; + background-color: #eee; + font-family: 'Courier New', Courier, monospace; +} + + +.y-entry { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; +} + +.y-entry:after { + content: ' \25CF '; + font-size: larger; +} + +.y-state { + background-color: rgb(209, 223, 238); + padding: 3px; + border: 0.5pt;; + border: 0.5pt; + border-radius: 4px; + border-color: #bbb; + font-family: 'Courier New', Courier, monospace; +} + +.y-state--active { + background-color: rgb(244, 215, 66); +} + +.y-state--inactive { + background-color: rgb(209, 223, 238); +} + +.y-variable{ + background-color: #eee; + border-color: #aaa; + border: 0.5pt; + border: 0.5pt; + border-radius: 2px; + font-family: 'Courier New', Courier, monospace; +} + +.y-variable::after { + color: #aaa; + content: attr(value); + font-family: 'Courier New', Courier, monospace; +} + +.y-do-enter { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; +} + +.y-do-enter:before { + content: ' \2192 '; +} + +.y-do-exit { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer +} + +.y-do-exit:before { + content: ' \2192 '; +} + +.y-do-raise { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; + white-space: nowrap; +} + +.y-do-raise:before { + content: ' \2192 '; +} + +button.y-do-raise:before { + content: ''; +} + +button.y-do-raise { + cursor: pointer; +} + +.y-do--over { + color: blue; + background-color: #eee; + cursor: pointer; +} + +.y-player { + border-style: solid; + border-width: 1px; + border-color: ; +} diff --git a/org.yakindu.sct.examples.basic.hierarchical/nested_composite_states/model.scm b/org.yakindu.sct.examples.basic.hierarchical/nested_composite_states/model.scm new file mode 100644 index 00000000..b0521195 --- /dev/null +++ b/org.yakindu.sct.examples.basic.hierarchical/nested_composite_states/model.scm @@ -0,0 +1,1256 @@ +{ + "cells": [ + { + "position": { + "x": 0, + "y": 0 + }, + "size": { + "height": 10, + "width": 10 + }, + "angle": 0, + "type": "Statechart", + "id": "835f6fbe-a4b3-4705-a4df-182a7b377603", + "linkable": false, + "z": 1, + "attrs": { + "name": { + "text": "LightSwitch" + }, + "specification": { + "text": "@CycleBased(200)\n\ninternal:\n\tvar brightness: integer\n\t\ninterface user:\n\tin event on_button\n\tin event off_button\n\tin event mode_button\n\t\ninterface sensor:\n\tin event motion\n\t\ninterface lum_sensor:\n \tin event bright\n \tin event dark" + } + } + }, + { + "type": "Region", + "position": { + "x": 0, + "y": 0 + }, + "size": { + "width": 1204, + "height": 560 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "8c2fb755-a4cc-4cec-b172-ecdec8552a2f", + "z": 2, + "embeds": [ + "3a75bc1c-52d9-42eb-8e4c-349df626af14", + "6dfb85d1-173c-4abd-a31a-0972a0213968", + "4f08040a-1618-41c2-b01b-24d368178a6d", + "c4be5617-4112-4cd4-8864-21df92f99343", + "9e3ad33b-bbd7-424f-9168-111d646c3e57", + "f44779d7-da73-4685-9f51-bada251d825a" + ], + "attrs": { + "priority": { + "text": 1 + }, + "name": { + "fontSize": "9", + "text": "main region" + } + } + }, + { + "type": "State", + "position": { + "x": 36, + "y": 84 + }, + "size": { + "width": 1118, + "height": 306 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "c4be5617-4112-4cd4-8864-21df92f99343", + "parent": "8c2fb755-a4cc-4cec-b172-ecdec8552a2f", + "z": 4, + "embeds": [ + "7ded07df-840f-454b-92cc-1c70444b682c" + ], + "attrs": { + "body": { + "fill": "#F5D82C", + "oldFill": "#CEDCEA", + "oldStroke": "#F2F2F2" + }, + "name": { + "text": "AutomaticMode" + } + } + }, + { + "type": "Region", + "position": { + "x": 36, + "y": 124 + }, + "size": { + "width": 1116, + "height": 265 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "7ded07df-840f-454b-92cc-1c70444b682c", + "z": 5, + "parent": "c4be5617-4112-4cd4-8864-21df92f99343", + "embeds": [ + "c42df543-c1e2-4fa8-acbd-55e49aff2bf5", + "d2406335-80dd-410d-8fa8-db1ad15cd7b0", + "c5c4079a-e18f-464f-9f34-97b7b6bf1650", + "bd48ee95-5e61-4553-89db-d38460d4b218", + "92bc1788-79db-4ea6-bf07-286f7a7bb50b", + "e1f5d3b8-c903-444b-9dab-5990626b15b5" + ], + "attrs": { + "name": { + "fontSize": "9", + "text": "r1" + } + } + }, + { + "type": "State", + "position": { + "x": 61, + "y": 171 + }, + "size": { + "width": 461, + "height": 198 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "bd48ee95-5e61-4553-89db-d38460d4b218", + "parent": "7ded07df-840f-454b-92cc-1c70444b682c", + "z": 6, + "embeds": [ + "02fdd10b-dfd4-4f39-b1db-a16d8097f781" + ], + "attrs": { + "name": { + "text": "TwilightDetectionMode" + } + } + }, + { + "type": "Region", + "position": { + "x": 62, + "y": 211 + }, + "size": { + "width": 459, + "height": 157 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "02fdd10b-dfd4-4f39-b1db-a16d8097f781", + "z": 7, + "parent": "bd48ee95-5e61-4553-89db-d38460d4b218", + "embeds": [ + "b41d9b40-a4e9-44a0-931f-c46d51f9357e", + "d209a21d-0c0a-4879-85db-a8d079e27802", + "0d60d0d1-fa2a-49ab-8344-de12a641ec88", + "f9c8e2b8-e1bb-4dca-84d2-81c7bd3d9658", + "025152a7-c108-45fa-ae15-9ee87921d5e8", + "9fc745c6-592a-4d07-96a3-2180f8c63353" + ], + "attrs": { + "name": { + "fontSize": "9", + "text": "r1" + } + } + }, + { + "type": "State", + "position": { + "x": 122, + "y": 260 + }, + "size": { + "width": 139, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "f9c8e2b8-e1bb-4dca-84d2-81c7bd3d9658", + "parent": "02fdd10b-dfd4-4f39-b1db-a16d8097f781", + "z": 8, + "attrs": { + "name": { + "text": "Idle" + }, + "specification": { + "text": "entry / brightness = 0", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 342, + "y": 260 + }, + "size": { + "width": 139, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "025152a7-c108-45fa-ae15-9ee87921d5e8", + "parent": "02fdd10b-dfd4-4f39-b1db-a16d8097f781", + "z": 9, + "attrs": { + "name": { + "text": "TwilightDetected" + }, + "specification": { + "text": "entry / brightness = 1", + "fontSize": "9" + } + } + }, + { + "type": "Entry", + "position": { + "x": 77, + "y": 273 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "9fc745c6-592a-4d07-96a3-2180f8c63353", + "parent": "02fdd10b-dfd4-4f39-b1db-a16d8097f781", + "z": 10, + "embeds": [ + "fd57b6c0-6665-4c1d-ae29-ffba4515f1ff" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 77, + "y": 288 + }, + "id": "fd57b6c0-6665-4c1d-ae29-ffba4515f1ff", + "z": 11, + "parent": "9fc745c6-592a-4d07-96a3-2180f8c63353", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 641, + "y": 169 + }, + "size": { + "width": 493, + "height": 204 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "92bc1788-79db-4ea6-bf07-286f7a7bb50b", + "parent": "7ded07df-840f-454b-92cc-1c70444b682c", + "z": 12, + "embeds": [ + "cec79be6-18c6-497b-8fea-2ccb87b4a42b" + ], + "attrs": { + "body": { + "fill": "#F5D82C", + "oldFill": "#CEDCEA", + "oldStroke": "#F2F2F2" + }, + "name": { + "text": "MotionDetectionMode" + } + } + }, + { + "type": "Region", + "position": { + "x": 642, + "y": 209 + }, + "size": { + "width": 491, + "height": 163 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "cec79be6-18c6-497b-8fea-2ccb87b4a42b", + "z": 13, + "parent": "92bc1788-79db-4ea6-bf07-286f7a7bb50b", + "embeds": [ + "f9137752-b456-435d-b129-ed03fd97ffe8", + "794a799f-3826-4427-864b-b04d0780d698", + "ba687d5c-f250-45e0-9d04-3577c632a261", + "6d0fdaa3-9fd4-46b6-b77b-97a1f1074e12", + "22f90178-eae7-4489-badc-0ce41f65a213", + "2c0c5823-9054-4a81-baf2-bf005c2d3f34", + "66186c10-ca44-414e-83c2-5982ec22f19e" + ], + "attrs": { + "name": { + "fontSize": "9", + "text": "r1" + } + } + }, + { + "type": "State", + "position": { + "x": 685, + "y": 258 + }, + "size": { + "width": 157, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "22f90178-eae7-4489-badc-0ce41f65a213", + "parent": "cec79be6-18c6-497b-8fea-2ccb87b4a42b", + "z": 14, + "attrs": { + "body": { + "oldFill": "#CEDCEA", + "oldStroke": "#F2F2F2" + }, + "name": { + "text": "Idle" + }, + "specification": { + "text": "entry / brightness = 0", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 937, + "y": 258 + }, + "size": { + "width": 157, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "2c0c5823-9054-4a81-baf2-bf005c2d3f34", + "parent": "cec79be6-18c6-497b-8fea-2ccb87b4a42b", + "z": 15, + "attrs": { + "body": { + "fill": "#F5D82C", + "oldFill": "#CEDCEA", + "oldStroke": "#F2F2F2" + }, + "name": { + "text": "MotionDetected" + }, + "specification": { + "text": "entry / brightness = 1", + "fontSize": "9" + } + } + }, + { + "type": "Entry", + "position": { + "x": 717, + "y": 131 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "e1f5d3b8-c903-444b-9dab-5990626b15b5", + "parent": "7ded07df-840f-454b-92cc-1c70444b682c", + "z": 18, + "embeds": [ + "88b612f1-d078-4227-9c20-849e8fd687a7" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 717, + "y": 146 + }, + "id": "88b612f1-d078-4227-9c20-849e8fd687a7", + "z": 19, + "parent": "e1f5d3b8-c903-444b-9dab-5990626b15b5", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "Entry", + "position": { + "x": 149, + "y": 34 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "9e3ad33b-bbd7-424f-9168-111d646c3e57", + "parent": "8c2fb755-a4cc-4cec-b172-ecdec8552a2f", + "z": 20, + "embeds": [ + "ff8762af-27b8-43ab-9871-9b3a4e11af7e" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 149, + "y": 49 + }, + "id": "ff8762af-27b8-43ab-9871-9b3a4e11af7e", + "z": 21, + "parent": "9e3ad33b-bbd7-424f-9168-111d646c3e57", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "22.641509433962266%", + "rotate": true + } + }, + "id": "22f90178-eae7-4489-badc-0ce41f65a213" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.3300835943975332%", + "dy": "22.641509433962266%", + "rotate": true + } + }, + "id": "2c0c5823-9054-4a81-baf2-bf005c2d3f34" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "sensor.motion", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "6d0fdaa3-9fd4-46b6-b77b-97a1f1074e12", + "z": 22, + "parent": "cec79be6-18c6-497b-8fea-2ccb87b4a42b", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "32.72128044177371%", + "dy": "50%", + "rotate": true + } + }, + "id": "2c0c5823-9054-4a81-baf2-bf005c2d3f34" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "55.538778704552314%", + "dy": "50%", + "rotate": true + } + }, + "id": "22f90178-eae7-4489-badc-0ce41f65a213" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "after 30s", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "ba687d5c-f250-45e0-9d04-3577c632a261", + "z": 23, + "parent": "cec79be6-18c6-497b-8fea-2ccb87b4a42b", + "vertices": [ + { + "x": 988.3724102935847, + "y": 336 + }, + { + "x": 772.1958825661471, + "y": 336 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "94.8140538319294%", + "dy": "50%", + "rotate": true + } + }, + "id": "2c0c5823-9054-4a81-baf2-bf005c2d3f34" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "60.41914937333067%", + "dy": "50%", + "rotate": true + } + }, + "id": "2c0c5823-9054-4a81-baf2-bf005c2d3f34" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "sensor.motion", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "2" + } + } + } + ], + "id": "794a799f-3826-4427-864b-b04d0780d698", + "z": 26, + "parent": "cec79be6-18c6-497b-8fea-2ccb87b4a42b", + "vertices": [ + { + "x": 1085.8580645161292, + "y": 338 + }, + { + "x": 1031.8580645161292, + "y": 338 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "89.12470023980816%", + "dy": "58.1761006289309%", + "rotate": true + } + }, + "id": "f9c8e2b8-e1bb-4dca-84d2-81c7bd3d9658" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "53.375299760191886%", + "dy": "58.1761006289309%", + "rotate": true + } + }, + "id": "025152a7-c108-45fa-ae15-9ee87921d5e8" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "lum_sensor.dark", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "0d60d0d1-fa2a-49ab-8344-de12a641ec88", + "z": 27, + "parent": "02fdd10b-dfd4-4f39-b1db-a16d8097f781", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "56.381402340813935%", + "dy": "98.49056603773593%", + "rotate": true + } + }, + "id": "025152a7-c108-45fa-ae15-9ee87921d5e8" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "39.32567378932674%", + "dy": "99.62264150943399%", + "rotate": true + } + }, + "id": "f9c8e2b8-e1bb-4dca-84d2-81c7bd3d9658" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "lum_sensor.bright", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "d209a21d-0c0a-4879-85db-a8d079e27802", + "z": 28, + "parent": "02fdd10b-dfd4-4f39-b1db-a16d8097f781", + "vertices": [ + { + "x": 420.37014925373137, + "y": 332.4 + }, + { + "x": 176.66268656716417, + "y": 332.4 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "30.053447062983203%", + "rotate": true + } + }, + "id": "bd48ee95-5e61-4553-89db-d38460d4b218" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.03457812390638491%", + "dy": "30.14991430622879%", + "rotate": true + } + }, + "id": "92bc1788-79db-4ea6-bf07-286f7a7bb50b" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.mode_button", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "c5c4079a-e18f-464f-9f34-97b7b6bf1650", + "z": 29, + "parent": "7ded07df-840f-454b-92cc-1c70444b682c", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.15330697946914143%", + "dy": "16.348717764819437%", + "rotate": true + } + }, + "id": "92bc1788-79db-4ea6-bf07-286f7a7bb50b" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "15.83403244456144%", + "rotate": true + } + }, + "id": "bd48ee95-5e61-4553-89db-d38460d4b218" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.mode_button", + "fontSize": "9" + } + }, + "position": { + "distance": 0.48739495798319327, + "offset": -37.650000000000006, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "d2406335-80dd-410d-8fa8-db1ad15cd7b0", + "z": 30, + "parent": "7ded07df-840f-454b-92cc-1c70444b682c", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "94.24543946932015%", + "dy": "48.88888888888914%", + "rotate": true + } + }, + "id": "9fc745c6-592a-4d07-96a3-2180f8c63353" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "38.36477987421391%", + "rotate": true + } + }, + "id": "f9c8e2b8-e1bb-4dca-84d2-81c7bd3d9658" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "b41d9b40-a4e9-44a0-931f-c46d51f9357e", + "z": 32, + "parent": "02fdd10b-dfd4-4f39-b1db-a16d8097f781", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "49.72882331416107%", + "dy": "96.36363636363645%", + "rotate": true + } + }, + "id": "e1f5d3b8-c903-444b-9dab-5990626b15b5" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "16.92886886351403%", + "dy": "0.20053475935830145%", + "rotate": true + } + }, + "id": "92bc1788-79db-4ea6-bf07-286f7a7bb50b" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "c42df543-c1e2-4fa8-acbd-55e49aff2bf5", + "z": 34, + "parent": "7ded07df-840f-454b-92cc-1c70444b682c", + "attrs": {} + }, + { + "type": "State", + "position": { + "x": 531, + "y": 446 + }, + "size": { + "width": 144, + "height": 62 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "f44779d7-da73-4685-9f51-bada251d825a", + "z": 36, + "parent": "8c2fb755-a4cc-4cec-b172-ecdec8552a2f", + "embeds": [ + "fbae5ca5-424d-406b-bcbe-968a8d5b7213" + ], + "attrs": { + "name": { + "text": "ManualMode" + }, + "specification": { + "text": "entry / brightness += 1", + "fontSize": "9" + } + } + }, + { + "type": "Transition", + "source": { + "id": "f44779d7-da73-4685-9f51-bada251d825a", + "anchor": { + "name": "topLeft", + "args": { + "dx": "74.98373599259793%", + "dy": "50%", + "rotate": true + } + } + }, + "target": { + "id": "f44779d7-da73-4685-9f51-bada251d825a", + "anchor": { + "name": "topLeft", + "args": { + "dx": "29.913313457386657%", + "dy": "50%", + "rotate": true + } + } + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.on_button [brightness < 10]", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "2" + } + } + } + ], + "id": "fbae5ca5-424d-406b-bcbe-968a8d5b7213", + "z": 37, + "vertices": [ + { + "x": 638.98, + "y": 526 + }, + { + "x": 574.08, + "y": 526 + } + ], + "parent": "f44779d7-da73-4685-9f51-bada251d825a", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "31.987731707884425%", + "dy": "0.3001517250478144%", + "rotate": true + } + }, + "id": "f44779d7-da73-4685-9f51-bada251d825a" + }, + "target": { + "id": "c4be5617-4112-4cd4-8864-21df92f99343", + "anchor": { + "name": "topLeft", + "args": { + "dx": "48%", + "dy": "27%", + "rotate": true + } + } + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.off_button", + "fontSize": "9" + } + }, + "position": { + "distance": 0.44, + "offset": -61.419999999999966, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "4f08040a-1618-41c2-b01b-24d368178a6d", + "z": 37, + "parent": "8c2fb755-a4cc-4cec-b172-ecdec8552a2f", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "53.3928248663087%", + "dy": "50%", + "rotate": true + } + }, + "id": "c4be5617-4112-4cd4-8864-21df92f99343" + }, + "target": { + "id": "f44779d7-da73-4685-9f51-bada251d825a" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.on_button", + "fontSize": "9" + } + }, + "position": { + "distance": 0.4, + "offset": -59.919999999999966, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "6dfb85d1-173c-4abd-a31a-0972a0213968", + "z": 38, + "parent": "8c2fb755-a4cc-4cec-b172-ecdec8552a2f", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "49.434346879771354%", + "dy": "96.53715064758008%", + "rotate": true + } + }, + "id": "9e3ad33b-bbd7-424f-9168-111d646c3e57" + }, + "target": { + "id": "c4be5617-4112-4cd4-8864-21df92f99343" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "3a75bc1c-52d9-42eb-8e4c-349df626af14", + "z": 39, + "parent": "8c2fb755-a4cc-4cec-b172-ecdec8552a2f", + "attrs": {} + }, + { + "type": "Entry", + "position": { + "x": 685, + "y": 211 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "66186c10-ca44-414e-83c2-5982ec22f19e", + "z": 46, + "embeds": [ + "9d562030-7aff-496e-954e-3ca1443c5d64" + ], + "parent": "cec79be6-18c6-497b-8fea-2ccb87b4a42b", + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 685, + "y": 226 + }, + "id": "9d562030-7aff-496e-954e-3ca1443c5d64", + "z": 47, + "parent": "66186c10-ca44-414e-83c2-5982ec22f19e", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "Transition", + "source": { + "id": "66186c10-ca44-414e-83c2-5982ec22f19e" + }, + "target": { + "id": "22f90178-eae7-4489-badc-0ce41f65a213" + }, + "router": { + "name": "orthogonal", + "args": { + "padding": 8 + } + }, + "connector": { + "name": "rounded" + }, + "labels": [ + { + "attrs": {}, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "f9137752-b456-435d-b129-ed03fd97ffe8", + "z": 48, + "parent": "cec79be6-18c6-497b-8fea-2ccb87b4a42b", + "attrs": {} + } + ] +} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.hierarchical/nested_composite_states/player.html b/org.yakindu.sct.examples.basic.hierarchical/nested_composite_states/player.html new file mode 100644 index 00000000..a40d8757 --- /dev/null +++ b/org.yakindu.sct.examples.basic.hierarchical/nested_composite_states/player.html @@ -0,0 +1,52 @@ + +sct-web-player demo + + + + + + + + + + + + + + + +
+ +
+ + + + + \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.hierarchical/no_hierarchy/lightswitch-player/assets/bundle.js b/org.yakindu.sct.examples.basic.hierarchical/no_hierarchy/lightswitch-player/assets/bundle.js new file mode 100644 index 00000000..3e57e36b --- /dev/null +++ b/org.yakindu.sct.examples.basic.hierarchical/no_hierarchy/lightswitch-player/assets/bundle.js @@ -0,0 +1,788 @@ +var com; +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Instances represent state machine trace events. + * @param {com.yakindu.core.TraceEventType} type + * @param {*} machine + * @param {*} state + * @param {*} feature + * @param {*} value + * @class + */ + class TraceEvent { + constructor(type, machine, state, feature, value) { + if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && ((state != null) || state === null) && ((feature != null) || feature === null) && ((value != null) || value === null)) { + let __args = arguments; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + else if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && state === undefined && feature === undefined && value === undefined) { + let __args = arguments; + { + let __args = arguments; + let state = null; + let feature = null; + let value = null; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + } + else + throw new Error('invalid overload'); + } + getType() { + return this.type; + } + getMachine() { + return this.machine; + } + getState() { + return this.state; + } + getFeature() { + return this.feature; + } + getValue() { + return this.value; + } + } + core.TraceEvent = TraceEvent; + TraceEvent["__class"] = "com.yakindu.core.TraceEvent"; + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Trace event type enumeration. + * @enum + * @property {com.yakindu.core.TraceEventType} MACHINE_ENTER + * @property {com.yakindu.core.TraceEventType} MACHINE_EXIT + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_START + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_STOP + * @property {com.yakindu.core.TraceEventType} STATE_ENTERED + * @property {com.yakindu.core.TraceEventType} STATE_EXITED + * @property {com.yakindu.core.TraceEventType} STATE_TRANSITION + * @property {com.yakindu.core.TraceEventType} EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} VARIABLE_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_UNSET + * @class + */ + let TraceEventType; + (function (TraceEventType) { + TraceEventType[TraceEventType["MACHINE_ENTER"] = 0] = "MACHINE_ENTER"; + TraceEventType[TraceEventType["MACHINE_EXIT"] = 1] = "MACHINE_EXIT"; + TraceEventType[TraceEventType["MACHINE_RTS_START"] = 2] = "MACHINE_RTS_START"; + TraceEventType[TraceEventType["MACHINE_RTS_STOP"] = 3] = "MACHINE_RTS_STOP"; + TraceEventType[TraceEventType["STATE_ENTERED"] = 4] = "STATE_ENTERED"; + TraceEventType[TraceEventType["STATE_EXITED"] = 5] = "STATE_EXITED"; + TraceEventType[TraceEventType["STATE_TRANSITION"] = 6] = "STATE_TRANSITION"; + TraceEventType[TraceEventType["EVENT_RAISED"] = 7] = "EVENT_RAISED"; + TraceEventType[TraceEventType["VARIABLE_SET"] = 8] = "VARIABLE_SET"; + TraceEventType[TraceEventType["TIME_EVENT_RAISED"] = 9] = "TIME_EVENT_RAISED"; + TraceEventType[TraceEventType["TIME_EVENT_SET"] = 10] = "TIME_EVENT_SET"; + TraceEventType[TraceEventType["TIME_EVENT_UNSET"] = 11] = "TIME_EVENT_UNSET"; + })(TraceEventType = core.TraceEventType || (core.TraceEventType = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + var rx; + (function (rx) { + class Observable { + constructor() { + this.observers = ([]); + } + next(value) { + for (let index = 0; index < this.observers.length; index++) { + let observer = this.observers[index]; + { + observer.next(value); + } + } + } + subscribe(observer) { + return observer != null ? /* add */ (this.observers.push(observer) > 0) : false; + } + unsubscribe(observer) { + return observer != null ? /* remove */ (a => { let index = a.indexOf(observer); if (index >= 0) { + a.splice(index, 1); + return true; + } + else { + return false; + } })(this.observers) : false; + } + } + rx.Observable = Observable; + Observable["__class"] = "com.yakindu.core.rx.Observable"; + })(rx = core.rx || (core.rx = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +var sct; +(function (sct) { + var yakindu; + (function (yakindu) { + var io; + (function (io) { + class Statemachine { + constructor() { + if (this.__user === undefined) { + this.__user = null; + } + if (this.__sensor === undefined) { + this.__sensor = null; + } + if (this.__lum_sensor === undefined) { + this.__lum_sensor = null; + } + this.stateVector = [null]; + this.trace = (new com.yakindu.core.rx.Observable()); + if (this.timerService === undefined) { + this.timerService = null; + } + this.timeEvents = [false]; + this.inEventQueue = ([]); + if (this.brightness === undefined) { + this.brightness = 0; + } + if (this.isExecuting === undefined) { + this.isExecuting = false; + } + this.__user = new Statemachine.User(this); + this.__sensor = new Statemachine.Sensor(this); + this.__lum_sensor = new Statemachine.Lum_sensor(this); + for (let i = 0; i < 1; i++) { + { + this.stateVector[i] = Statemachine.State.$NULLSTATE$; + } + ; + } + this.clearInEvents(); + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + this.isExecuting = false; + } + getBrightness() { + return this.brightness; + } + setBrightness(value) { + this.brightness = value; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + getIsExecuting() { + return this.isExecuting; + } + setIsExecuting(value) { + this.isExecuting = value; + } + enter() { + if (this.timerService == null) { + throw Object.defineProperty(new Error("Timer service must be set."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.IllegalStateException', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.Exception'] }); + } + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_ENTER, this))); + this.enterSequence_main_region_default(); + this.isExecuting = false; + } + exit() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_EXIT, this))); + this.exitSequence_main_region(); + this.isExecuting = false; + } + /** + * @see IStatemachine#isActive() + * @return {boolean} + */ + isActive() { + return this.stateVector[0] !== Statemachine.State.$NULLSTATE$; + } + /** + * + * Always returns 'false' since this state machine can never become final. + * + * @see IStatemachine#isFinal() + * @return {boolean} + */ + isFinal() { + return false; + } + clearInEvents() { + this.__user.on_button = false; + this.__user.off_button = false; + this.__user.mode_button = false; + this.__sensor.motion = false; + this.__lum_sensor.bright = false; + this.__lum_sensor.dark = false; + this.timeEvents[0] = false; + } + microStep() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MOTIONDETECTED: + this.main_region_MotionDetected_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE: + this.main_region_MotionDetectionMode_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE: + this.main_region_TwilightDetectionMode_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_TWILIGHTDETECTED: + this.main_region_TwilightDetected_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MANUALMODE: + this.main_region_ManualMode_react(-1); + break; + default: + break; + } + } + runCycle() { + if (this.timerService == null) { + throw Object.defineProperty(new Error("Timer service must be set."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.IllegalStateException', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.Exception'] }); + } + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_START, this))); + this.nextEvent(); + do { + { + this.microStep(); + this.clearInEvents(); + this.nextEvent(); + } + } while ((((((((this.__user.on_button || this.__user.off_button) || this.__user.mode_button) || this.__sensor.motion) || this.__lum_sensor.bright) || this.__lum_sensor.dark) || this.timeEvents[0]))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_STOP, this))); + this.isExecuting = false; + } + nextEvent() { + if (!(this.inEventQueue.length == 0)) { + (target => (typeof target === 'function') ? target() : target.run())(/* poll */ (a => a.length == 0 ? null : a.shift())(this.inEventQueue)); + return; + } + } + /** + * Returns true if the given state is currently active otherwise false. + * @param {sct.yakindu.io.Statemachine.State} state + * @return {boolean} + */ + isStateActive(state) { + switch ((state)) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MOTIONDETECTED: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_MOTIONDETECTED; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_TWILIGHTDETECTED: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_TWILIGHTDETECTED; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MANUALMODE: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_MANUALMODE; + default: + return false; + } + } + setTimerService(timerService) { + this.timerService = timerService; + } + getTimerService() { + return this.timerService; + } + raiseTimeEvent(eventID) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_RAISED, this, null, null, eventID))); + /* add */ (this.inEventQueue.push(() => { + this.timeEvents[eventID] = true; + }) > 0); + this.runCycle(); + } + user() { + return this.__user; + } + sensor() { + return this.__sensor; + } + lum_sensor() { + return this.__lum_sensor; + } + getTrace() { + return this.trace; + } + entryAction_main_region_MotionDetected() { + this.timerService.setTimer(this, 0, (30 * 1000), false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_SET, this, null, null, 0))); + this.setBrightness(1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + entryAction_main_region_MotionDetectionMode() { + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + entryAction_main_region_TwilightDetectionMode() { + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + entryAction_main_region_TwilightDetected() { + this.setBrightness(1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + entryAction_main_region_ManualMode() { + this.setBrightness(this.getBrightness() + 1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + exitAction_main_region_MotionDetected() { + this.timerService.unsetTimer(this, 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_UNSET, this, null, null, 0))); + } + enterSequence_main_region_MotionDetected_default() { + this.entryAction_main_region_MotionDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_MOTIONDETECTED, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_MOTIONDETECTED; + } + enterSequence_main_region_MotionDetectionMode_default() { + this.entryAction_main_region_MotionDetectionMode(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE; + } + enterSequence_main_region_TwilightDetectionMode_default() { + this.entryAction_main_region_TwilightDetectionMode(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE; + } + enterSequence_main_region_TwilightDetected_default() { + this.entryAction_main_region_TwilightDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_TWILIGHTDETECTED, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_TWILIGHTDETECTED; + } + enterSequence_main_region_ManualMode_default() { + this.entryAction_main_region_ManualMode(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_MANUALMODE, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_MANUALMODE; + } + enterSequence_main_region_default() { + this.react_main_region__entry_Default(); + } + exitSequence_main_region_MotionDetected() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.exitAction_main_region_MotionDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_MOTIONDETECTED, null, null))); + } + exitSequence_main_region_MotionDetectionMode() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE, null, null))); + } + exitSequence_main_region_TwilightDetectionMode() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE, null, null))); + } + exitSequence_main_region_TwilightDetected() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_TWILIGHTDETECTED, null, null))); + } + exitSequence_main_region_ManualMode() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_MANUALMODE, null, null))); + } + exitSequence_main_region() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MOTIONDETECTED: + this.exitSequence_main_region_MotionDetected(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE: + this.exitSequence_main_region_MotionDetectionMode(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE: + this.exitSequence_main_region_TwilightDetectionMode(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_TWILIGHTDETECTED: + this.exitSequence_main_region_TwilightDetected(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MANUALMODE: + this.exitSequence_main_region_ManualMode(); + break; + default: + break; + } + } + react_main_region__entry_Default() { + this.enterSequence_main_region_MotionDetectionMode_default(); + } + react(transitioned_before) { + return transitioned_before; + } + main_region_MotionDetected_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.timeEvents[0]) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_MOTIONDETECTED, null, 0))); + this.exitSequence_main_region_MotionDetected(); + this.timeEvents[0] = false; + this.enterSequence_main_region_MotionDetectionMode_default(); + this.react(0); + transitioned_after = 0; + } + else { + if (this.__user.on_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_MOTIONDETECTED, null, 1))); + this.exitSequence_main_region_MotionDetected(); + this.enterSequence_main_region_ManualMode_default(); + this.react(0); + transitioned_after = 0; + } + else { + if (this.__sensor.motion) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_MOTIONDETECTED, null, 2))); + this.exitSequence_main_region_MotionDetected(); + this.enterSequence_main_region_MotionDetected_default(); + this.react(0); + transitioned_after = 0; + } + else { + if (this.__user.mode_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_MOTIONDETECTED, null, 3))); + this.exitSequence_main_region_MotionDetected(); + this.enterSequence_main_region_TwilightDetectionMode_default(); + this.react(0); + transitioned_after = 0; + } + } + } + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_region_MotionDetectionMode_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__sensor.motion) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE, null, 0))); + this.exitSequence_main_region_MotionDetectionMode(); + this.enterSequence_main_region_MotionDetected_default(); + this.react(0); + transitioned_after = 0; + } + else { + if (this.__user.on_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE, null, 1))); + this.exitSequence_main_region_MotionDetectionMode(); + this.enterSequence_main_region_ManualMode_default(); + this.react(0); + transitioned_after = 0; + } + else { + if (this.__user.mode_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_MOTIONDETECTIONMODE, null, 2))); + this.exitSequence_main_region_MotionDetectionMode(); + this.enterSequence_main_region_TwilightDetectionMode_default(); + this.react(0); + transitioned_after = 0; + } + } + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_region_TwilightDetectionMode_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__lum_sensor.dark) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE, null, 0))); + this.exitSequence_main_region_TwilightDetectionMode(); + this.enterSequence_main_region_TwilightDetected_default(); + this.react(0); + transitioned_after = 0; + } + else { + if (this.__user.mode_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE, null, 1))); + this.exitSequence_main_region_TwilightDetectionMode(); + this.enterSequence_main_region_MotionDetectionMode_default(); + this.react(0); + transitioned_after = 0; + } + else { + if (this.__user.on_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_TWILIGHTDETECTIONMODE, null, 2))); + this.exitSequence_main_region_TwilightDetectionMode(); + this.enterSequence_main_region_ManualMode_default(); + this.react(0); + transitioned_after = 0; + } + } + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_region_TwilightDetected_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__lum_sensor.bright) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_TWILIGHTDETECTED, null, 0))); + this.exitSequence_main_region_TwilightDetected(); + this.enterSequence_main_region_TwilightDetectionMode_default(); + this.react(0); + transitioned_after = 0; + } + else { + if (this.__user.mode_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_TWILIGHTDETECTED, null, 1))); + this.exitSequence_main_region_TwilightDetected(); + this.enterSequence_main_region_MotionDetectionMode_default(); + this.react(0); + transitioned_after = 0; + } + else { + if (this.__user.on_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_TWILIGHTDETECTED, null, 2))); + this.exitSequence_main_region_TwilightDetected(); + this.enterSequence_main_region_ManualMode_default(); + this.react(0); + transitioned_after = 0; + } + } + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_region_ManualMode_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__user.off_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_MANUALMODE, null, 0))); + this.exitSequence_main_region_ManualMode(); + this.enterSequence_main_region_MotionDetectionMode_default(); + this.react(0); + transitioned_after = 0; + } + else { + if (((this.__user.on_button) && (this.getBrightness() < 10))) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_MANUALMODE, null, 1))); + this.exitSequence_main_region_ManualMode(); + this.enterSequence_main_region_ManualMode_default(); + this.react(0); + transitioned_after = 0; + } + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + } + io.Statemachine = Statemachine; + Statemachine["__class"] = "sct.yakindu.io.Statemachine"; + Statemachine["__interfaces"] = ["com.yakindu.core.IStatemachine", "com.yakindu.core.ITimed"]; + (function (Statemachine) { + class User { + constructor(parent) { + if (this.parent === undefined) { + this.parent = null; + } + if (this.on_button === undefined) { + this.on_button = false; + } + if (this.off_button === undefined) { + this.off_button = false; + } + if (this.mode_button === undefined) { + this.mode_button = false; + } + this.parent = parent; + } + raiseOn_button() { + /* add */ (this.parent.inEventQueue.push(() => { + this.on_button = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.USER_ON_BUTTON, null))); + this.parent.runCycle(); + } + raiseOff_button() { + /* add */ (this.parent.inEventQueue.push(() => { + this.off_button = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.USER_OFF_BUTTON, null))); + this.parent.runCycle(); + } + raiseMode_button() { + /* add */ (this.parent.inEventQueue.push(() => { + this.mode_button = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.USER_MODE_BUTTON, null))); + this.parent.runCycle(); + } + } + Statemachine.User = User; + User["__class"] = "sct.yakindu.io.Statemachine.User"; + class Sensor { + constructor(parent) { + if (this.parent === undefined) { + this.parent = null; + } + if (this.motion === undefined) { + this.motion = false; + } + this.parent = parent; + } + raiseMotion() { + /* add */ (this.parent.inEventQueue.push(() => { + this.motion = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.SENSOR_MOTION, null))); + this.parent.runCycle(); + } + } + Statemachine.Sensor = Sensor; + Sensor["__class"] = "sct.yakindu.io.Statemachine.Sensor"; + class Lum_sensor { + constructor(parent) { + if (this.parent === undefined) { + this.parent = null; + } + if (this.bright === undefined) { + this.bright = false; + } + if (this.dark === undefined) { + this.dark = false; + } + this.parent = parent; + } + raiseBright() { + /* add */ (this.parent.inEventQueue.push(() => { + this.bright = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.LUM_SENSOR_BRIGHT, null))); + this.parent.runCycle(); + } + raiseDark() { + /* add */ (this.parent.inEventQueue.push(() => { + this.dark = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.LUM_SENSOR_DARK, null))); + this.parent.runCycle(); + } + } + Statemachine.Lum_sensor = Lum_sensor; + Lum_sensor["__class"] = "sct.yakindu.io.Statemachine.Lum_sensor"; + let State; + (function (State) { + State[State["MAIN_REGION_MOTIONDETECTED"] = 0] = "MAIN_REGION_MOTIONDETECTED"; + State[State["MAIN_REGION_MOTIONDETECTIONMODE"] = 1] = "MAIN_REGION_MOTIONDETECTIONMODE"; + State[State["MAIN_REGION_TWILIGHTDETECTIONMODE"] = 2] = "MAIN_REGION_TWILIGHTDETECTIONMODE"; + State[State["MAIN_REGION_TWILIGHTDETECTED"] = 3] = "MAIN_REGION_TWILIGHTDETECTED"; + State[State["MAIN_REGION_MANUALMODE"] = 4] = "MAIN_REGION_MANUALMODE"; + State[State["$NULLSTATE$"] = 5] = "$NULLSTATE$"; + })(State = Statemachine.State || (Statemachine.State = {})); + /** + * Enumeration of all features of the statechart + * @enum + * @property {sct.yakindu.io.Statemachine.Feature} NO_FEATURE + * @property {sct.yakindu.io.Statemachine.Feature} INTERNAL_BRIGHTNESS + * @property {sct.yakindu.io.Statemachine.Feature} USER_ON_BUTTON + * @property {sct.yakindu.io.Statemachine.Feature} USER_OFF_BUTTON + * @property {sct.yakindu.io.Statemachine.Feature} USER_MODE_BUTTON + * @property {sct.yakindu.io.Statemachine.Feature} SENSOR_MOTION + * @property {sct.yakindu.io.Statemachine.Feature} LUM_SENSOR_BRIGHT + * @property {sct.yakindu.io.Statemachine.Feature} LUM_SENSOR_DARK + * @class + */ + let Feature; + (function (Feature) { + Feature[Feature["NO_FEATURE"] = 0] = "NO_FEATURE"; + Feature[Feature["INTERNAL_BRIGHTNESS"] = 1] = "INTERNAL_BRIGHTNESS"; + Feature[Feature["USER_ON_BUTTON"] = 2] = "USER_ON_BUTTON"; + Feature[Feature["USER_OFF_BUTTON"] = 3] = "USER_OFF_BUTTON"; + Feature[Feature["USER_MODE_BUTTON"] = 4] = "USER_MODE_BUTTON"; + Feature[Feature["SENSOR_MOTION"] = 5] = "SENSOR_MOTION"; + Feature[Feature["LUM_SENSOR_BRIGHT"] = 6] = "LUM_SENSOR_BRIGHT"; + Feature[Feature["LUM_SENSOR_DARK"] = 7] = "LUM_SENSOR_DARK"; + })(Feature = Statemachine.Feature || (Statemachine.Feature = {})); + })(Statemachine = io.Statemachine || (io.Statemachine = {})); + })(io = yakindu.io || (yakindu.io = {})); + })(yakindu = sct.yakindu || (sct.yakindu = {})); +})(sct || (sct = {})); diff --git a/org.yakindu.sct.examples.basic.hierarchical/no_hierarchy/lightswitch-player/assets/context.json.js b/org.yakindu.sct.examples.basic.hierarchical/no_hierarchy/lightswitch-player/assets/context.json.js new file mode 100644 index 00000000..9ef4cd75 --- /dev/null +++ b/org.yakindu.sct.examples.basic.hierarchical/no_hierarchy/lightswitch-player/assets/context.json.js @@ -0,0 +1 @@ +const contextJson = {"elements":[{"elements":[{"kind":"variable","type":"integer","name":"brightness","fqName":"brightness","featureId":"INTERNAL_BRIGHTNESS","writable":true,"value":0}],"kind":"composite","name":"internal","featureId":"","writable":true},{"elements":[{"kind":"event","name":"on_button","fqName":"user.on_button","featureId":"USER_ON_BUTTON","writable":true},{"kind":"event","name":"off_button","fqName":"user.off_button","featureId":"USER_OFF_BUTTON","writable":true},{"kind":"event","name":"mode_button","fqName":"user.mode_button","featureId":"USER_MODE_BUTTON","writable":true}],"kind":"composite","name":"user","fqName":"user","featureId":"","writable":true},{"elements":[{"kind":"event","name":"motion","fqName":"sensor.motion","featureId":"SENSOR_MOTION","writable":true}],"kind":"composite","name":"sensor","fqName":"sensor","featureId":"","writable":true},{"elements":[{"kind":"event","name":"bright","fqName":"lum_sensor.bright","featureId":"LUM_SENSOR_BRIGHT","writable":true},{"kind":"event","name":"dark","fqName":"lum_sensor.dark","featureId":"LUM_SENSOR_DARK","writable":true}],"kind":"composite","name":"lum_sensor","fqName":"lum_sensor","featureId":"","writable":true},{"elements":[{"kind":"event","type":"integer","name":"MotionDetected_time_event_0","fqName":"LightSwitch.main_region.MotionDetected_time_event_0","featureId":"MOTIONDETECTED_TIME_EVENT_0","writable":true,"value":0}],"kind":"composite","name":"time events","featureId":"","writable":true}]} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.hierarchical/no_hierarchy/lightswitch-player/assets/hashes.json.js b/org.yakindu.sct.examples.basic.hierarchical/no_hierarchy/lightswitch-player/assets/hashes.json.js new file mode 100644 index 00000000..14ed7283 --- /dev/null +++ b/org.yakindu.sct.examples.basic.hierarchical/no_hierarchy/lightswitch-player/assets/hashes.json.js @@ -0,0 +1 @@ +const hashesJson = {"MAIN_REGION_MOTIONDETECTED":"0b32fa87-34ac-4cc1-8bcf-fb33e799525b","MAIN_REGION_MOTIONDETECTIONMODE_tr0":"28bb3bf8-1ba0-4dcd-96d5-f92e93036a90","MAIN_REGION_MOTIONDETECTIONMODE_tr1":"8a7d27a9-30b0-4074-b8e8-046fcc09798a","MAIN_REGION_MOTIONDETECTIONMODE_tr2":"96ba0afe-cc95-4154-bab3-d4e2b1e1141b","MAIN_REGION_MOTIONDETECTIONMODE":"a5eb2228-225b-4a36-b478-b4d601c2491a","MAIN_REGION_MANUALMODE":"69a600a9-e43b-49a9-9819-d0e4ecda6693","MAIN_REGION_TWILIGHTDETECTIONMODE_tr2":"7e155c54-4aca-42d5-820c-9867ef7b16af","MAIN_REGION_TWILIGHTDETECTIONMODE":"efb60804-c1a1-46da-9e30-bdebf80f8b7e","MAIN_REGION_TWILIGHTDETECTED":"b7c3d99e-df16-49dd-a606-c0af5ad6137c","MAIN_REGION_TWILIGHTDETECTED_tr1":"a5e47415-f40d-4b8d-bf47-5a458046dd53","MAIN_REGION_TWILIGHTDETECTED_tr0":"35666f1e-65b9-46f7-8bc7-b3189a46def9","MAIN_REGION_TWILIGHTDETECTIONMODE_tr1":"18df1bea-fcc6-4e9a-aa62-8cfedee05db4","MAIN_REGION_TWILIGHTDETECTIONMODE_tr0":"0a03e25b-a3cc-4962-9a7e-6ea3b1cb1ca4","MAIN_REGION_MOTIONDETECTED_tr0":"c32a0b28-b1a3-4c00-9654-1d5d8f14ec46","MAIN_REGION_MOTIONDETECTED_tr1":"4ea2e87f-9202-484c-9a78-53aba020b1be","MAIN_REGION_MANUALMODE_tr0":"bcc05d20-fafc-43b8-bf35-aa864ce1b1a4","MAIN_REGION_MOTIONDETECTED_tr2":"e24c25c2-efaf-42ca-9292-d9c5fec2a8ad","MAIN_REGION_MANUALMODE_tr1":"448dbd20-cc73-4fe1-96d3-e25b232e38d0","MAIN_REGION_TWILIGHTDETECTED_tr2":"2e19f484-dbe8-4e11-a5ff-da0f7d187779","MAIN_REGION_MOTIONDETECTED_tr3":"4b523e60-7727-4fe3-b87f-e146f5e9f02c"} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.hierarchical/no_hierarchy/lightswitch-player/assets/statemachine.svg.js b/org.yakindu.sct.examples.basic.hierarchical/no_hierarchy/lightswitch-player/assets/statemachine.svg.js new file mode 100644 index 00000000..168faa82 --- /dev/null +++ b/org.yakindu.sct.examples.basic.hierarchical/no_hierarchy/lightswitch-player/assets/statemachine.svg.js @@ -0,0 +1 @@ +let svg = `main region1MotionDetectedentry / brightness = 1MotionDetectionModeentry / brightness = 0TwilightDetectionModeentry / brightness = 0TwilightDetectedentry / brightness = 1-user.mode_buttonuser.mode_button4user.mode_buttonuser.mode_button3user.mode_buttonuser.mode_button2lum_sensor.brightlum_sensor.bright1after 30safter 30s1-1sensor.motionsensor.motion3sensor.motionsensor.motion1user.mode_buttonuser.mode_button2lum_sensor.darklum_sensor.dark1ManualModeentry / brightness += 1user.off_buttonuser.off_button1user.on_button [brightness < 10]user.on_button [brightness < 10]2user.on_buttonuser.on_button2user.on_buttonuser.on_button2user.on_buttonuser.on_button3user.on_buttonuser.on_button3` \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.hierarchical/no_hierarchy/lightswitch-player/assets/ypi.css b/org.yakindu.sct.examples.basic.hierarchical/no_hierarchy/lightswitch-player/assets/ypi.css new file mode 100644 index 00000000..771aaa11 --- /dev/null +++ b/org.yakindu.sct.examples.basic.hierarchical/no_hierarchy/lightswitch-player/assets/ypi.css @@ -0,0 +1,113 @@ +/*! + * itemis CREATE Player Styles + * Copyright 2021 itemis AG + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ + + + /*! + * Style definitions follow BEM pattern using and additional 'y' namespace (for itemis CREATE). + */ +.y-declaration { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; + background-color: #eee; + font-family: 'Courier New', Courier, monospace; +} + + +.y-entry { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; +} + +.y-entry:after { + content: ' \25CF '; + font-size: larger; +} + +.y-state { + background-color: rgb(209, 223, 238); + padding: 3px; + border: 0.5pt;; + border: 0.5pt; + border-radius: 4px; + border-color: #bbb; + font-family: 'Courier New', Courier, monospace; +} + +.y-state--active { + background-color: rgb(244, 215, 66); +} + +.y-state--inactive { + background-color: rgb(209, 223, 238); +} + +.y-variable{ + background-color: #eee; + border-color: #aaa; + border: 0.5pt; + border: 0.5pt; + border-radius: 2px; + font-family: 'Courier New', Courier, monospace; +} + +.y-variable::after { + color: #aaa; + content: attr(value); + font-family: 'Courier New', Courier, monospace; +} + +.y-do-enter { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; +} + +.y-do-enter:before { + content: ' \2192 '; +} + +.y-do-exit { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer +} + +.y-do-exit:before { + content: ' \2192 '; +} + +.y-do-raise { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; + white-space: nowrap; +} + +.y-do-raise:before { + content: ' \2192 '; +} + +button.y-do-raise:before { + content: ''; +} + +button.y-do-raise { + cursor: pointer; +} + +.y-do--over { + color: blue; + background-color: #eee; + cursor: pointer; +} + +.y-player { + border-style: solid; + border-width: 1px; + border-color: ; +} diff --git a/org.yakindu.sct.examples.basic.hierarchical/no_hierarchy/lightswitch-player/model.scm b/org.yakindu.sct.examples.basic.hierarchical/no_hierarchy/lightswitch-player/model.scm new file mode 100644 index 00000000..3a216c41 --- /dev/null +++ b/org.yakindu.sct.examples.basic.hierarchical/no_hierarchy/lightswitch-player/model.scm @@ -0,0 +1,1121 @@ +{ + "cells": [ + { + "position": { + "x": 0, + "y": 0 + }, + "size": { + "height": 10, + "width": 10 + }, + "angle": 0, + "type": "Statechart", + "id": "210140e4-dea2-49c0-ab77-ca5ee77650be", + "linkable": false, + "z": 1, + "attrs": { + "name": { + "text": "LightSwitch" + }, + "specification": { + "text": "@CycleBased(200)\n\ninternal:\n\tvar brightness: integer\n\t\ninterface user:\n\tin event on_button\n\tin event off_button\n\tin event mode_button\n\t\ninterface sensor:\n\tin event motion\n\t\ninterface lum_sensor:\n \tin event bright\n \tin event dark" + } + } + }, + { + "type": "Region", + "position": { + "x": 23, + "y": 10 + }, + "size": { + "width": 1065, + "height": 451 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "cce7fb80-b632-4d93-95fc-908bea554909", + "z": 27, + "embeds": [ + "7e155c54-4aca-42d5-820c-9867ef7b16af", + "2e19f484-dbe8-4e11-a5ff-da0f7d187779", + "4ea2e87f-9202-484c-9a78-53aba020b1be", + "8a7d27a9-30b0-4074-b8e8-046fcc09798a", + "bcc05d20-fafc-43b8-bf35-aa864ce1b1a4", + "4b523e60-7727-4fe3-b87f-e146f5e9f02c", + "96ba0afe-cc95-4154-bab3-d4e2b1e1141b", + "18df1bea-fcc6-4e9a-aa62-8cfedee05db4", + "a5e47415-f40d-4b8d-bf47-5a458046dd53", + "35666f1e-65b9-46f7-8bc7-b3189a46def9", + "0a03e25b-a3cc-4962-9a7e-6ea3b1cb1ca4", + "c32a0b28-b1a3-4c00-9654-1d5d8f14ec46", + "28bb3bf8-1ba0-4dcd-96d5-f92e93036a90", + "448106b0-41bf-4b1c-a036-819f73cc8bff", + "fb23e078-1ea7-4ccf-b8c9-e907cda4e320", + "0b32fa87-34ac-4cc1-8bcf-fb33e799525b", + "a5eb2228-225b-4a36-b478-b4d601c2491a", + "efb60804-c1a1-46da-9e30-bdebf80f8b7e", + "b7c3d99e-df16-49dd-a606-c0af5ad6137c", + "69a600a9-e43b-49a9-9819-d0e4ecda6693" + ], + "attrs": { + "priority": { + "text": 1 + }, + "name": { + "fontSize": "9", + "text": "main region" + } + } + }, + { + "type": "Entry", + "position": { + "x": 643, + "y": 121 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "fb23e078-1ea7-4ccf-b8c9-e907cda4e320", + "parent": "cce7fb80-b632-4d93-95fc-908bea554909", + "z": 43, + "embeds": [ + "179c720d-48b3-4bd7-9be3-5a7c8b30789c" + ], + "attrs": {} + }, + { + "type": "State", + "position": { + "x": 836, + "y": 169 + }, + "size": { + "width": 139, + "height": 60 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "0b32fa87-34ac-4cc1-8bcf-fb33e799525b", + "parent": "cce7fb80-b632-4d93-95fc-908bea554909", + "z": 45, + "embeds": [ + "e24c25c2-efaf-42ca-9292-d9c5fec2a8ad" + ], + "attrs": { + "name": { + "text": "MotionDetected" + }, + "specification": { + "text": "entry / brightness = 1", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 576, + "y": 169 + }, + "size": { + "width": 139, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "a5eb2228-225b-4a36-b478-b4d601c2491a", + "parent": "cce7fb80-b632-4d93-95fc-908bea554909", + "z": 46, + "attrs": { + "name": { + "text": "MotionDetectionMode" + }, + "specification": { + "text": "entry / brightness = 0", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 72, + "y": 169 + }, + "size": { + "width": 139, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "efb60804-c1a1-46da-9e30-bdebf80f8b7e", + "parent": "cce7fb80-b632-4d93-95fc-908bea554909", + "z": 47, + "attrs": { + "name": { + "text": "TwilightDetectionMode" + }, + "specification": { + "text": "entry / brightness = 0", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 336, + "y": 169 + }, + "size": { + "width": 139, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "b7c3d99e-df16-49dd-a606-c0af5ad6137c", + "parent": "cce7fb80-b632-4d93-95fc-908bea554909", + "z": 48, + "attrs": { + "name": { + "text": "TwilightDetected" + }, + "specification": { + "text": "entry / brightness = 1", + "fontSize": "9" + } + } + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 643, + "y": 136 + }, + "id": "179c720d-48b3-4bd7-9be3-5a7c8b30789c", + "z": 49, + "parent": "fb23e078-1ea7-4ccf-b8c9-e907cda4e320", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "38.68356061419521%", + "dy": "50%", + "rotate": true + } + }, + "id": "b7c3d99e-df16-49dd-a606-c0af5ad6137c" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "81.19617738644904%", + "dy": "50%", + "rotate": true + } + }, + "id": "efb60804-c1a1-46da-9e30-bdebf80f8b7e" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "lum_sensor.bright", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "35666f1e-65b9-46f7-8bc7-b3189a46def9", + "z": 50, + "parent": "cce7fb80-b632-4d93-95fc-908bea554909", + "vertices": [ + { + "x": 389.77014925373135, + "y": 241 + }, + { + "x": 184.86268656716416, + "y": 241 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "99.67625899280577%", + "dy": "58.17610062893084%", + "rotate": true + } + }, + "id": "efb60804-c1a1-46da-9e30-bdebf80f8b7e" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "42.82374100719427%", + "dy": "58.17610062893084%", + "rotate": true + } + }, + "id": "b7c3d99e-df16-49dd-a606-c0af5ad6137c" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "lum_sensor.dark", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "0a03e25b-a3cc-4962-9a7e-6ea3b1cb1ca4", + "z": 50, + "parent": "cce7fb80-b632-4d93-95fc-908bea554909", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "53.195533125738216%", + "dy": "0.18867924528306176%", + "rotate": true + } + }, + "id": "efb60804-c1a1-46da-9e30-bdebf80f8b7e" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "1.9574787930848856%", + "dy": "0.7547169811320862%", + "rotate": true + } + }, + "id": "a5eb2228-225b-4a36-b478-b4d601c2491a" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.mode_button", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "2" + } + } + } + ], + "id": "18df1bea-fcc6-4e9a-aa62-8cfedee05db4", + "z": 50, + "parent": "cce7fb80-b632-4d93-95fc-908bea554909", + "vertices": [ + { + "x": 145.94179104477612, + "y": 138.2 + }, + { + "x": 578.720895522388, + "y": 138.2 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "97.84172661870507%", + "dy": "28.301886792452883%", + "rotate": true + } + }, + "id": "b7c3d99e-df16-49dd-a606-c0af5ad6137c" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "3.119295608289478%", + "dy": "28.301886792452883%", + "rotate": true + } + }, + "id": "a5eb2228-225b-4a36-b478-b4d601c2491a" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.mode_button", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "2" + } + } + } + ], + "id": "a5e47415-f40d-4b8d-bf47-5a458046dd53", + "z": 50, + "parent": "cce7fb80-b632-4d93-95fc-908bea554909", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "id": "a5eb2228-225b-4a36-b478-b4d601c2491a", + "anchor": { + "name": "topLeft", + "args": { + "dx": "27.657038548265923%", + "dy": "7.924528301886771%", + "rotate": true + } + } + }, + "target": { + "id": "efb60804-c1a1-46da-9e30-bdebf80f8b7e", + "anchor": { + "name": "topLeft", + "args": { + "dx": "38.04466874261786%", + "dy": "9.056603773584927%", + "rotate": true + } + } + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.mode_button", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "3" + } + } + } + ], + "id": "96ba0afe-cc95-4154-bab3-d4e2b1e1141b", + "z": 50, + "parent": "cce7fb80-b632-4d93-95fc-908bea554909", + "vertices": [ + { + "x": 614.4432835820896, + "y": 81 + }, + { + "x": 124.88208955223882, + "y": 81 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "26.41509433962264%", + "rotate": true + } + }, + "id": "a5eb2228-225b-4a36-b478-b4d601c2491a" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "26.41509433962264%", + "rotate": true + } + }, + "id": "0b32fa87-34ac-4cc1-8bcf-fb33e799525b" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "sensor.motion", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "28bb3bf8-1ba0-4dcd-96d5-f92e93036a90", + "z": 50, + "parent": "cce7fb80-b632-4d93-95fc-908bea554909", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "id": "0b32fa87-34ac-4cc1-8bcf-fb33e799525b", + "anchor": { + "name": "topLeft", + "args": { + "dx": "49.800279179641386%", + "dy": "1.8867924528302424%", + "rotate": true + } + } + }, + "target": { + "id": "efb60804-c1a1-46da-9e30-bdebf80f8b7e", + "anchor": { + "name": "topLeft", + "args": { + "dx": "24.983356598303455%", + "dy": "1.8867924528301887%", + "rotate": true + } + } + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.mode_button", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "4" + } + } + } + ], + "id": "4b523e60-7727-4fe3-b87f-e146f5e9f02c", + "z": 50, + "parent": "cce7fb80-b632-4d93-95fc-908bea554909", + "vertices": [ + { + "x": 905.2223880597015, + "y": 40 + }, + { + "x": 106.7268656716418, + "y": 40 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "35.331370713505365%", + "dy": "50%", + "rotate": true + } + }, + "id": "0b32fa87-34ac-4cc1-8bcf-fb33e799525b" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "88.83300956190462%", + "dy": "50%", + "rotate": true + } + }, + "id": "a5eb2228-225b-4a36-b478-b4d601c2491a" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "after 30s", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "c32a0b28-b1a3-4c00-9654-1d5d8f14ec46", + "z": 50, + "parent": "cce7fb80-b632-4d93-95fc-908bea554909", + "vertices": [ + { + "x": 885.1106052917725, + "y": 248 + }, + { + "x": 699.4778832910474, + "y": 248 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "29.55938697317985%", + "dy": "95.55555555555561%", + "rotate": true + } + }, + "id": "fb23e078-1ea7-4ccf-b8c9-e907cda4e320" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "51.39130075250142%", + "dy": "0.3144654088050672%", + "rotate": true + } + }, + "id": "a5eb2228-225b-4a36-b478-b4d601c2491a" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "448106b0-41bf-4b1c-a036-819f73cc8bff", + "z": 50, + "parent": "cce7fb80-b632-4d93-95fc-908bea554909", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "id": "0b32fa87-34ac-4cc1-8bcf-fb33e799525b", + "anchor": { + "name": "topLeft", + "args": { + "dx": "42%", + "dy": "62%", + "rotate": true + } + } + }, + "target": { + "id": "0b32fa87-34ac-4cc1-8bcf-fb33e799525b", + "anchor": { + "name": "topLeft", + "args": { + "dx": "92%", + "dy": "22%", + "rotate": true + } + } + }, + "labels": [ + { + "attrs": { + "text": { + "text": "sensor.motion", + "fontSize": "9" + } + }, + "position": { + "distance": 0.695882957002174, + "offset": -12, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "3" + } + } + } + ], + "id": "e24c25c2-efaf-42ca-9292-d9c5fec2a8ad", + "z": 50, + "vertices": [ + { + "x": 1036.1354838709678, + "y": 206 + }, + { + "x": 1036.1354838709678, + "y": 251 + }, + { + "x": 964.1354838709677, + "y": 251 + } + ], + "parent": "0b32fa87-34ac-4cc1-8bcf-fb33e799525b", + "attrs": {} + }, + { + "type": "State", + "position": { + "x": 515, + "y": 351 + }, + "size": { + "width": 181, + "height": 60 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "69a600a9-e43b-49a9-9819-d0e4ecda6693", + "z": 51, + "parent": "cce7fb80-b632-4d93-95fc-908bea554909", + "embeds": [ + "448dbd20-cc73-4fe1-96d3-e25b232e38d0" + ], + "attrs": { + "name": { + "text": "ManualMode" + }, + "specification": { + "text": "entry / brightness += 1", + "fontSize": "9" + } + } + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "25.85116079045368%", + "dy": "99.57927571515522%", + "rotate": true + } + }, + "id": "efb60804-c1a1-46da-9e30-bdebf80f8b7e" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "4.2842897109330575%", + "dy": "72.74345709068778%", + "rotate": true + } + }, + "id": "69a600a9-e43b-49a9-9819-d0e4ecda6693" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.on_button", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "3" + } + } + } + ], + "id": "7e155c54-4aca-42d5-820c-9867ef7b16af", + "z": 52, + "parent": "cce7fb80-b632-4d93-95fc-908bea554909", + "vertices": [ + { + "x": 107.93, + "y": 394.65 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "49.182741459037636%", + "dy": "50%", + "rotate": true + } + }, + "id": "b7c3d99e-df16-49dd-a606-c0af5ad6137c" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "27.06999391357278%", + "rotate": true + } + }, + "id": "69a600a9-e43b-49a9-9819-d0e4ecda6693" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.on_button", + "fontSize": "9" + } + }, + "position": { + "distance": 0.29326653143350834, + "offset": 61.361748706044644, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "3" + } + } + } + ], + "id": "2e19f484-dbe8-4e11-a5ff-da0f7d187779", + "z": 52, + "parent": "cce7fb80-b632-4d93-95fc-908bea554909", + "vertices": [ + { + "x": 404.36, + "y": 367.24 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "69.34529840916001%", + "dy": "50%", + "rotate": true + } + }, + "id": "0b32fa87-34ac-4cc1-8bcf-fb33e799525b" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "87.38668197027467%", + "dy": "41.235849056603804%", + "rotate": true + } + }, + "id": "69a600a9-e43b-49a9-9819-d0e4ecda6693" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.on_button", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "2" + } + } + } + ], + "id": "4ea2e87f-9202-484c-9a78-53aba020b1be", + "z": 52, + "parent": "cce7fb80-b632-4d93-95fc-908bea554909", + "vertices": [ + { + "x": 932.39, + "y": 375.74 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50.91118643476859%", + "dy": "50%", + "rotate": true + } + }, + "id": "a5eb2228-225b-4a36-b478-b4d601c2491a" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "72.24671223443555%", + "dy": "1.2014607425441064%", + "rotate": true + } + }, + "id": "69a600a9-e43b-49a9-9819-d0e4ecda6693" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.on_button", + "fontSize": "9" + } + }, + "position": { + "distance": 0.3581395348837209, + "offset": -55.23000000000002, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "2" + } + } + } + ], + "id": "8a7d27a9-30b0-4074-b8e8-046fcc09798a", + "z": 52, + "parent": "cce7fb80-b632-4d93-95fc-908bea554909", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "id": "69a600a9-e43b-49a9-9819-d0e4ecda6693", + "anchor": { + "name": "topLeft", + "args": { + "dx": "75.50792934401991%", + "dy": "50%", + "rotate": true + } + } + }, + "target": { + "id": "69a600a9-e43b-49a9-9819-d0e4ecda6693", + "anchor": { + "name": "topLeft", + "args": { + "dx": "40.14881332192047%", + "dy": "50%", + "rotate": true + } + } + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.on_button [brightness < 10]", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "2" + } + } + } + ], + "id": "448dbd20-cc73-4fe1-96d3-e25b232e38d0", + "z": 52, + "vertices": [ + { + "x": 652.669352112676, + "y": 432 + }, + { + "x": 588.669352112676, + "y": 432 + } + ], + "parent": "69a600a9-e43b-49a9-9819-d0e4ecda6693", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "40.95847074366835%", + "dy": "1.0014201663623998%", + "rotate": true + } + }, + "id": "69a600a9-e43b-49a9-9819-d0e4ecda6693" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "10.168943918014186%", + "dy": "50%", + "rotate": true + } + }, + "id": "a5eb2228-225b-4a36-b478-b4d601c2491a" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.off_button", + "fontSize": "9" + } + }, + "position": { + "distance": 0.6232558139534884, + "offset": -53.129999999999995, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "bcc05d20-fafc-43b8-bf35-aa864ce1b1a4", + "z": 52, + "parent": "cce7fb80-b632-4d93-95fc-908bea554909", + "attrs": {} + } + ] +} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.hierarchical/no_hierarchy/lightswitch-player/player.html b/org.yakindu.sct.examples.basic.hierarchical/no_hierarchy/lightswitch-player/player.html new file mode 100644 index 00000000..a40d8757 --- /dev/null +++ b/org.yakindu.sct.examples.basic.hierarchical/no_hierarchy/lightswitch-player/player.html @@ -0,0 +1,52 @@ + +sct-web-player demo + + + + + + + + + + + + + + + +
+ +
+ + + + + \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.historystates/index.html b/org.yakindu.sct.examples.basic.historystates/index.html index 436ce473..9f234c13 100644 --- a/org.yakindu.sct.examples.basic.historystates/index.html +++ b/org.yakindu.sct.examples.basic.historystates/index.html @@ -1,71 +1,133 @@ + - -History States - + + History States + + -
- -

History States

- -

This example demonstrates the usage of history states and explains the difference between a shallow and a deep history.

- -

Starting Point

- -

Let's revisit the light switch example of the Basic Tutorial. To be more concrete, let's start at the point where our light switch can be in one of three possible modes: -

    -
  1. a twilight / luminosity mode in which the light automatically turns on when it is dark,
  2. -
  3. a motion sensing mode in which the light automatically turns on when motion is detected, and
  4. -
  5. a manual mode in which the user can change the brightness manually.
  6. -
- The user can enable the manual mode by pressing the On button. Pressing the Off button enables the motion sensing mode. With a Mode button the user can switch between the motion sensing and the twilight mode. -

-

- The following statechart reflects these requirements: -

- Light switch without history state -

- -

Shallow history states

-

- Consider the following additional requirement: When the user switches from manual to automatic mode, the last active mode shall be activated. -

-

- In order to fulfill this requirement, we need to store which state was active before the user switched to manual mode. And this is exactly where history states come in handy. -

-

-A shallow history state is a pseudo state that is placed inside the region of a composite state. It is used to remember the last active state inside a composite state. This makes it possible to jump back to the remembered state instead of starting at the inner initial state again. -

-

-A history state saves the current state exactly when its containing region is left. A shallow history state saves the state of the current level only. If you need to save the status of multiple nested composite states, use a deep history state instead. -

-

-Let's go back to our light switch example. You can easily change the initial state that points to the MotionDetectionMode state into a history node: -

-

- Switch entry kind -

-

-Using a shallow history node changes the behavior of the light switch to the following: Whenever the AutomaticMode is entered, the last active state will be activated. For example, if the light switch was in twilight mode when the user pressed the On button, pressing the Off button will set it again into twilight mode, instead of the motion detection mode. -

-

-However, the shallow history does not store the inner state of the respective mode state. As the name already says, it only stores the active state on one level, namely the region in which the shallow history node is placed. Regarding our light switch example, this means that switching back to automatic mode will always activate one of the Idle states. -

- -

Deep history states

-

-A deep history state is similar to a shallow history state, but more complex. With a deep history state, the latest status of all nested states is remembered. -

-

- Deep history state -

-

-Let's take a look at our light switch example again. When the light switch is in TwilightDetected state, and the user presses the On button, this state is stored by the deep history and will be activated again when the user switches back to automatic mode. Please note, that already passed time in time triggers is not stored by a history state. When the light switch is in MotionDetected state and stays there for 20 seconds without any motion being registered, switching to manual mode and back, will start the timer at 0 again, i.e. it will take another 30 seconds for the state being switched to Idle. -

- -
+
+ +

History States

+ +

This example demonstrates the usage of history states and explains the difference between a shallow and a + deep history.

+ +

Starting Point

+ +

Let's revisit the light switch example of the Basic + Tutorial. To be more concrete, let's start at the point where our light switch can be in one of + three possible modes: +

    +
  1. a twilight / luminosity mode in which the light automatically turns on when it is dark, +
  2. +
  3. a motion sensing mode in which the light automatically turns on when motion is + detected, and
  4. +
  5. a manual mode in which the user can change the brightness manually.
  6. +
+ The user can enable the manual mode by pressing the On button. Pressing the + Off button enables the motion sensing mode. With a Mode button the user can + switch between the motion sensing and the twilight mode. +

+

+ The following statechart reflects these requirements: +

+

+

+ +

Shallow history states

+

+ Consider the following additional requirement: When the user switches from manual to automatic mode, the + last active mode shall be activated. +

+

+ In order to fulfill this requirement, we need to store which state was active before the user switched to + manual mode. And this is exactly where history states come in handy. +

+

+ A shallow history state is a pseudo state that is placed inside the region of a composite state. It + is used to remember the last active state inside a composite state. This makes it possible to jump back to + the remembered state instead of starting at the inner initial state again. +

+

+ A history state saves the current state exactly when its containing region is left. A shallow history state + saves the state of the current level only. If you need to save the status of multiple nested composite + states, use a deep history state instead. +

+

+ Let's go back to our light switch example. You can easily change the initial state that points to the + MotionDetectionMode state into a history node: +

+

+ Switch entry kind +

+

+ Using a shallow history node changes the behavior of the light switch to the following: Whenever the + AutomaticMode is entered, the last active state will be activated. For example, if the + light switch was in twilight mode when the user pressed the On button, pressing the + Off button will set it again into twilight mode, instead of the motion detection mode. +

+

+ However, the shallow history does not store the inner state of the respective mode state. As the name + already says, it only stores the active state on one level, namely the region in which the shallow history + node is placed. Regarding our light switch example, this means that switching back to automatic mode will + always activate one of the Idle states. +

+ +

Deep history states

+

+ A deep history state is similar to a shallow history state, but more complex. With a deep history + state, the latest status of all nested states is remembered. +

+

+

+

+

+ Let's take a look at our light switch example again. When the light switch is in + TwilightDetected state, and the user presses the On button, this state is + stored by the deep history and will be activated again when the user switches back to automatic mode. Please + note, that already passed time in time triggers is not stored by a history state. When the light switch is + in MotionDetected state and stays there for 20 seconds without any motion being registered, + switching to manual mode and back, will start the timer at 0 again, i.e. it will take another 30 seconds for + the state being switched to Idle. +

+ +
+ - + + \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.historystates/lightswitch_deep_history-player/assets/bundle.js b/org.yakindu.sct.examples.basic.historystates/lightswitch_deep_history-player/assets/bundle.js new file mode 100644 index 00000000..7253ff4b --- /dev/null +++ b/org.yakindu.sct.examples.basic.historystates/lightswitch_deep_history-player/assets/bundle.js @@ -0,0 +1,933 @@ +var com; +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Instances represent state machine trace events. + * @param {com.yakindu.core.TraceEventType} type + * @param {*} machine + * @param {*} state + * @param {*} feature + * @param {*} value + * @class + */ + class TraceEvent { + constructor(type, machine, state, feature, value) { + if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && ((state != null) || state === null) && ((feature != null) || feature === null) && ((value != null) || value === null)) { + let __args = arguments; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + else if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && state === undefined && feature === undefined && value === undefined) { + let __args = arguments; + { + let __args = arguments; + let state = null; + let feature = null; + let value = null; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + } + else + throw new Error('invalid overload'); + } + getType() { + return this.type; + } + getMachine() { + return this.machine; + } + getState() { + return this.state; + } + getFeature() { + return this.feature; + } + getValue() { + return this.value; + } + } + core.TraceEvent = TraceEvent; + TraceEvent["__class"] = "com.yakindu.core.TraceEvent"; + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Trace event type enumeration. + * @enum + * @property {com.yakindu.core.TraceEventType} MACHINE_ENTER + * @property {com.yakindu.core.TraceEventType} MACHINE_EXIT + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_START + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_STOP + * @property {com.yakindu.core.TraceEventType} STATE_ENTERED + * @property {com.yakindu.core.TraceEventType} STATE_EXITED + * @property {com.yakindu.core.TraceEventType} STATE_TRANSITION + * @property {com.yakindu.core.TraceEventType} EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} VARIABLE_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_UNSET + * @class + */ + let TraceEventType; + (function (TraceEventType) { + TraceEventType[TraceEventType["MACHINE_ENTER"] = 0] = "MACHINE_ENTER"; + TraceEventType[TraceEventType["MACHINE_EXIT"] = 1] = "MACHINE_EXIT"; + TraceEventType[TraceEventType["MACHINE_RTS_START"] = 2] = "MACHINE_RTS_START"; + TraceEventType[TraceEventType["MACHINE_RTS_STOP"] = 3] = "MACHINE_RTS_STOP"; + TraceEventType[TraceEventType["STATE_ENTERED"] = 4] = "STATE_ENTERED"; + TraceEventType[TraceEventType["STATE_EXITED"] = 5] = "STATE_EXITED"; + TraceEventType[TraceEventType["STATE_TRANSITION"] = 6] = "STATE_TRANSITION"; + TraceEventType[TraceEventType["EVENT_RAISED"] = 7] = "EVENT_RAISED"; + TraceEventType[TraceEventType["VARIABLE_SET"] = 8] = "VARIABLE_SET"; + TraceEventType[TraceEventType["TIME_EVENT_RAISED"] = 9] = "TIME_EVENT_RAISED"; + TraceEventType[TraceEventType["TIME_EVENT_SET"] = 10] = "TIME_EVENT_SET"; + TraceEventType[TraceEventType["TIME_EVENT_UNSET"] = 11] = "TIME_EVENT_UNSET"; + })(TraceEventType = core.TraceEventType || (core.TraceEventType = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + var rx; + (function (rx) { + class Observable { + constructor() { + this.observers = ([]); + } + next(value) { + for (let index = 0; index < this.observers.length; index++) { + let observer = this.observers[index]; + { + observer.next(value); + } + } + } + subscribe(observer) { + return observer != null ? /* add */ (this.observers.push(observer) > 0) : false; + } + unsubscribe(observer) { + return observer != null ? /* remove */ (a => { let index = a.indexOf(observer); if (index >= 0) { + a.splice(index, 1); + return true; + } + else { + return false; + } })(this.observers) : false; + } + } + rx.Observable = Observable; + Observable["__class"] = "com.yakindu.core.rx.Observable"; + })(rx = core.rx || (core.rx = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +var sct; +(function (sct) { + var yakindu; + (function (yakindu) { + var io; + (function (io) { + class Statemachine { + constructor() { + if (this.__user === undefined) { + this.__user = null; + } + if (this.__sensor === undefined) { + this.__sensor = null; + } + if (this.__lum_sensor === undefined) { + this.__lum_sensor = null; + } + this.historyVector = [null, null, null]; + this.stateVector = [null]; + this.trace = (new com.yakindu.core.rx.Observable()); + if (this.timerService === undefined) { + this.timerService = null; + } + this.timeEvents = [false]; + this.inEventQueue = ([]); + if (this.brightness === undefined) { + this.brightness = 0; + } + if (this.isExecuting === undefined) { + this.isExecuting = false; + } + this.__user = new Statemachine.User(this); + this.__sensor = new Statemachine.Sensor(this); + this.__lum_sensor = new Statemachine.Lum_sensor(this); + for (let i = 0; i < 1; i++) { + { + this.stateVector[i] = Statemachine.State.$NULLSTATE$; + } + ; + } + for (let i = 0; i < 3; i++) { + { + this.historyVector[i] = Statemachine.State.$NULLSTATE$; + } + ; + } + this.clearInEvents(); + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + this.isExecuting = false; + } + getBrightness() { + return this.brightness; + } + setBrightness(value) { + this.brightness = value; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + getIsExecuting() { + return this.isExecuting; + } + setIsExecuting(value) { + this.isExecuting = value; + } + enter() { + if (this.timerService == null) { + throw Object.defineProperty(new Error("Timer service must be set."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.IllegalStateException', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.Exception'] }); + } + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_ENTER, this))); + this.enterSequence_main_region_default(); + this.isExecuting = false; + } + exit() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_EXIT, this))); + this.exitSequence_main_region(); + this.isExecuting = false; + } + /** + * @see IStatemachine#isActive() + * @return {boolean} + */ + isActive() { + return this.stateVector[0] !== Statemachine.State.$NULLSTATE$; + } + /** + * + * Always returns 'false' since this state machine can never become final. + * + * @see IStatemachine#isFinal() + * @return {boolean} + */ + isFinal() { + return false; + } + clearInEvents() { + this.__user.on_button = false; + this.__user.off_button = false; + this.__user.mode_button = false; + this.__sensor.motion = false; + this.__lum_sensor.bright = false; + this.__lum_sensor.dark = false; + this.timeEvents[0] = false; + } + microStep() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MANUALMODE: + this.main_region_ManualMode_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE: + this.main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED: + this.main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE: + this.main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED: + this.main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected_react(-1); + break; + default: + break; + } + } + runCycle() { + if (this.timerService == null) { + throw Object.defineProperty(new Error("Timer service must be set."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.IllegalStateException', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.Exception'] }); + } + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_START, this))); + this.nextEvent(); + do { + { + this.microStep(); + this.clearInEvents(); + this.nextEvent(); + } + } while ((((((((this.__user.on_button || this.__user.off_button) || this.__user.mode_button) || this.__sensor.motion) || this.__lum_sensor.bright) || this.__lum_sensor.dark) || this.timeEvents[0]))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_STOP, this))); + this.isExecuting = false; + } + nextEvent() { + if (!(this.inEventQueue.length == 0)) { + (target => (typeof target === 'function') ? target() : target.run())(/* poll */ (a => a.length == 0 ? null : a.shift())(this.inEventQueue)); + return; + } + } + /** + * Returns true if the given state is currently active otherwise false. + * @param {sct.yakindu.io.Statemachine.State} state + * @return {boolean} + */ + isStateActive(state) { + switch ((state)) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MANUALMODE: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_MANUALMODE; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_AUTOMATICMODE]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED]]; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED]]; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED]]; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED; + default: + return false; + } + } + setTimerService(timerService) { + this.timerService = timerService; + } + getTimerService() { + return this.timerService; + } + raiseTimeEvent(eventID) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_RAISED, this, null, null, eventID))); + /* add */ (this.inEventQueue.push(() => { + this.timeEvents[eventID] = true; + }) > 0); + this.runCycle(); + } + user() { + return this.__user; + } + sensor() { + return this.__sensor; + } + lum_sensor() { + return this.__lum_sensor; + } + getTrace() { + return this.trace; + } + entryAction_main_region_ManualMode() { + this.setBrightness(this.getBrightness() + 1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + entryAction_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle() { + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + entryAction_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected() { + this.setBrightness(1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + entryAction_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle() { + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + entryAction_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected() { + this.timerService.setTimer(this, 0, (30 * 1000), false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_SET, this, null, null, 0))); + this.setBrightness(1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + exitAction_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected() { + this.timerService.unsetTimer(this, 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_UNSET, this, null, null, 0))); + } + enterSequence_main_region_ManualMode_default() { + this.entryAction_main_region_ManualMode(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_MANUALMODE, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_MANUALMODE; + } + enterSequence_main_region_AutomaticMode_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE, null, null))); + this.enterSequence_main_region_AutomaticMode_r1_default(); + } + enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE, null, null))); + this.enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_default(); + this.historyVector[0] = this.stateVector[0]; + } + enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle_default() { + this.entryAction_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE; + this.historyVector[1] = this.stateVector[0]; + } + enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected_default() { + this.entryAction_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED; + this.historyVector[1] = this.stateVector[0]; + } + enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE, null, null))); + this.enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_default(); + this.historyVector[0] = this.stateVector[0]; + } + enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle_default() { + this.entryAction_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE; + this.historyVector[2] = this.stateVector[0]; + } + enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected_default() { + this.entryAction_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED; + this.historyVector[2] = this.stateVector[0]; + } + enterSequence_main_region_default() { + this.react_main_region__entry_Default(); + } + enterSequence_main_region_AutomaticMode_r1_default() { + this.react_main_region_AutomaticMode_r1__entry_Default(); + } + deepEnterSequence_main_region_AutomaticMode_r1() { + switch ((this.historyVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE: + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE, null, null))); + this.deepEnterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED: + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE, null, null))); + this.deepEnterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE: + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE, null, null))); + this.deepEnterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED: + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE, null, null))); + this.deepEnterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1(); + break; + default: + break; + } + } + enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_default() { + this.react_main_region_AutomaticMode_r1_TwilightDetectionMode_r1__entry_Default(); + } + deepEnterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1() { + switch ((this.historyVector[1])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE: + this.enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle_default(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED: + this.enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected_default(); + break; + default: + break; + } + } + enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_default() { + this.react_main_region_AutomaticMode_r1_MotionDetectionMode_r1__entry_Default(); + } + deepEnterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1() { + switch ((this.historyVector[2])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE: + this.enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle_default(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED: + this.enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected_default(); + break; + default: + break; + } + } + exitSequence_main_region_ManualMode() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_MANUALMODE, null, null))); + } + exitSequence_main_region_AutomaticMode() { + this.exitSequence_main_region_AutomaticMode_r1(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE, null, null))); + } + exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode() { + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE, null, null))); + } + exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE, null, null))); + } + exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED, null, null))); + } + exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode() { + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE, null, null))); + } + exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE, null, null))); + } + exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.exitAction_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED, null, null))); + } + exitSequence_main_region() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MANUALMODE: + this.exitSequence_main_region_ManualMode(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE: + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE, null, null))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED: + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE, null, null))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE: + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE, null, null))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED: + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE, null, null))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE, null, null))); + break; + default: + break; + } + } + exitSequence_main_region_AutomaticMode_r1() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE: + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED: + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE: + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED: + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE, null, null))); + break; + default: + break; + } + } + exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE: + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED: + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected(); + break; + default: + break; + } + } + exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE: + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED: + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected(); + break; + default: + break; + } + } + react_main_region_AutomaticMode_r1_TwilightDetectionMode_r1__entry_Default() { + this.enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle_default(); + } + react_main_region_AutomaticMode_r1_MotionDetectionMode_r1__entry_Default() { + this.enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle_default(); + } + react_main_region_AutomaticMode_r1__entry_Default() { + if (this.historyVector[0] !== Statemachine.State.$NULLSTATE$) { + this.deepEnterSequence_main_region_AutomaticMode_r1(); + } + else { + this.enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_default(); + } + } + react_main_region__entry_Default() { + this.enterSequence_main_region_AutomaticMode_default(); + } + react(transitioned_before) { + return transitioned_before; + } + main_region_ManualMode_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__user.off_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_MANUALMODE, null, 0))); + this.exitSequence_main_region_ManualMode(); + this.enterSequence_main_region_AutomaticMode_default(); + this.react(0); + transitioned_after = 0; + } + else { + if (((this.__user.on_button) && (this.getBrightness() < 10))) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_MANUALMODE, null, 1))); + this.exitSequence_main_region_ManualMode(); + this.enterSequence_main_region_ManualMode_default(); + this.react(0); + transitioned_after = 0; + } + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_region_AutomaticMode_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__user.on_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE, null, 0))); + this.exitSequence_main_region_AutomaticMode(); + this.enterSequence_main_region_ManualMode_default(); + this.react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_region_AutomaticMode_r1_TwilightDetectionMode_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__user.mode_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE, null, 0))); + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode(); + this.enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_default(); + this.main_region_AutomaticMode_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_AutomaticMode_react(transitioned_before); + } + return transitioned_after; + } + main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__lum_sensor.dark) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE, null, 0))); + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle(); + this.enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected_default(); + this.main_region_AutomaticMode_r1_TwilightDetectionMode_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_AutomaticMode_r1_TwilightDetectionMode_react(transitioned_before); + } + return transitioned_after; + } + main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__lum_sensor.bright) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED, null, 0))); + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected(); + this.enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle_default(); + this.main_region_AutomaticMode_r1_TwilightDetectionMode_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_AutomaticMode_r1_TwilightDetectionMode_react(transitioned_before); + } + return transitioned_after; + } + main_region_AutomaticMode_r1_MotionDetectionMode_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__user.mode_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE, null, 0))); + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode(); + this.enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_default(); + this.main_region_AutomaticMode_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_AutomaticMode_react(transitioned_before); + } + return transitioned_after; + } + main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__sensor.motion) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE, null, 0))); + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle(); + this.enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected_default(); + this.main_region_AutomaticMode_r1_MotionDetectionMode_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_AutomaticMode_r1_MotionDetectionMode_react(transitioned_before); + } + return transitioned_after; + } + main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.timeEvents[0]) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED, null, 0))); + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected(); + this.timeEvents[0] = false; + this.enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle_default(); + this.main_region_AutomaticMode_r1_MotionDetectionMode_react(0); + transitioned_after = 0; + } + else { + if (this.__sensor.motion) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED, null, 1))); + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected(); + this.enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected_default(); + this.main_region_AutomaticMode_r1_MotionDetectionMode_react(0); + transitioned_after = 0; + } + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_AutomaticMode_r1_MotionDetectionMode_react(transitioned_before); + } + return transitioned_after; + } + } + io.Statemachine = Statemachine; + Statemachine["__class"] = "sct.yakindu.io.Statemachine"; + Statemachine["__interfaces"] = ["com.yakindu.core.IStatemachine", "com.yakindu.core.ITimed"]; + (function (Statemachine) { + class User { + constructor(parent) { + if (this.parent === undefined) { + this.parent = null; + } + if (this.on_button === undefined) { + this.on_button = false; + } + if (this.off_button === undefined) { + this.off_button = false; + } + if (this.mode_button === undefined) { + this.mode_button = false; + } + this.parent = parent; + } + raiseOn_button() { + /* add */ (this.parent.inEventQueue.push(() => { + this.on_button = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.USER_ON_BUTTON, null))); + this.parent.runCycle(); + } + raiseOff_button() { + /* add */ (this.parent.inEventQueue.push(() => { + this.off_button = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.USER_OFF_BUTTON, null))); + this.parent.runCycle(); + } + raiseMode_button() { + /* add */ (this.parent.inEventQueue.push(() => { + this.mode_button = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.USER_MODE_BUTTON, null))); + this.parent.runCycle(); + } + } + Statemachine.User = User; + User["__class"] = "sct.yakindu.io.Statemachine.User"; + class Sensor { + constructor(parent) { + if (this.parent === undefined) { + this.parent = null; + } + if (this.motion === undefined) { + this.motion = false; + } + this.parent = parent; + } + raiseMotion() { + /* add */ (this.parent.inEventQueue.push(() => { + this.motion = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.SENSOR_MOTION, null))); + this.parent.runCycle(); + } + } + Statemachine.Sensor = Sensor; + Sensor["__class"] = "sct.yakindu.io.Statemachine.Sensor"; + class Lum_sensor { + constructor(parent) { + if (this.parent === undefined) { + this.parent = null; + } + if (this.bright === undefined) { + this.bright = false; + } + if (this.dark === undefined) { + this.dark = false; + } + this.parent = parent; + } + raiseBright() { + /* add */ (this.parent.inEventQueue.push(() => { + this.bright = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.LUM_SENSOR_BRIGHT, null))); + this.parent.runCycle(); + } + raiseDark() { + /* add */ (this.parent.inEventQueue.push(() => { + this.dark = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.LUM_SENSOR_DARK, null))); + this.parent.runCycle(); + } + } + Statemachine.Lum_sensor = Lum_sensor; + Lum_sensor["__class"] = "sct.yakindu.io.Statemachine.Lum_sensor"; + let State; + (function (State) { + State[State["MAIN_REGION_MANUALMODE"] = 0] = "MAIN_REGION_MANUALMODE"; + State[State["MAIN_REGION_AUTOMATICMODE"] = 1] = "MAIN_REGION_AUTOMATICMODE"; + State[State["MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE"] = 2] = "MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE"; + State[State["MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE"] = 3] = "MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE"; + State[State["MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED"] = 4] = "MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED"; + State[State["MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE"] = 5] = "MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE"; + State[State["MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE"] = 6] = "MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE"; + State[State["MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED"] = 7] = "MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED"; + State[State["$NULLSTATE$"] = 8] = "$NULLSTATE$"; + })(State = Statemachine.State || (Statemachine.State = {})); + /** + * Enumeration of all features of the statechart + * @enum + * @property {sct.yakindu.io.Statemachine.Feature} NO_FEATURE + * @property {sct.yakindu.io.Statemachine.Feature} INTERNAL_BRIGHTNESS + * @property {sct.yakindu.io.Statemachine.Feature} USER_ON_BUTTON + * @property {sct.yakindu.io.Statemachine.Feature} USER_OFF_BUTTON + * @property {sct.yakindu.io.Statemachine.Feature} USER_MODE_BUTTON + * @property {sct.yakindu.io.Statemachine.Feature} SENSOR_MOTION + * @property {sct.yakindu.io.Statemachine.Feature} LUM_SENSOR_BRIGHT + * @property {sct.yakindu.io.Statemachine.Feature} LUM_SENSOR_DARK + * @class + */ + let Feature; + (function (Feature) { + Feature[Feature["NO_FEATURE"] = 0] = "NO_FEATURE"; + Feature[Feature["INTERNAL_BRIGHTNESS"] = 1] = "INTERNAL_BRIGHTNESS"; + Feature[Feature["USER_ON_BUTTON"] = 2] = "USER_ON_BUTTON"; + Feature[Feature["USER_OFF_BUTTON"] = 3] = "USER_OFF_BUTTON"; + Feature[Feature["USER_MODE_BUTTON"] = 4] = "USER_MODE_BUTTON"; + Feature[Feature["SENSOR_MOTION"] = 5] = "SENSOR_MOTION"; + Feature[Feature["LUM_SENSOR_BRIGHT"] = 6] = "LUM_SENSOR_BRIGHT"; + Feature[Feature["LUM_SENSOR_DARK"] = 7] = "LUM_SENSOR_DARK"; + })(Feature = Statemachine.Feature || (Statemachine.Feature = {})); + })(Statemachine = io.Statemachine || (io.Statemachine = {})); + })(io = yakindu.io || (yakindu.io = {})); + })(yakindu = sct.yakindu || (sct.yakindu = {})); +})(sct || (sct = {})); diff --git a/org.yakindu.sct.examples.basic.historystates/lightswitch_deep_history-player/assets/context.json.js b/org.yakindu.sct.examples.basic.historystates/lightswitch_deep_history-player/assets/context.json.js new file mode 100644 index 00000000..059fa799 --- /dev/null +++ b/org.yakindu.sct.examples.basic.historystates/lightswitch_deep_history-player/assets/context.json.js @@ -0,0 +1 @@ +const contextJson = {"elements":[{"elements":[{"kind":"variable","type":"integer","name":"brightness","fqName":"brightness","featureId":"INTERNAL_BRIGHTNESS","writable":true,"value":0}],"kind":"composite","name":"internal","featureId":"","writable":true},{"elements":[{"kind":"event","name":"on_button","fqName":"user.on_button","featureId":"USER_ON_BUTTON","writable":true},{"kind":"event","name":"off_button","fqName":"user.off_button","featureId":"USER_OFF_BUTTON","writable":true},{"kind":"event","name":"mode_button","fqName":"user.mode_button","featureId":"USER_MODE_BUTTON","writable":true}],"kind":"composite","name":"user","fqName":"user","featureId":"","writable":true},{"elements":[{"kind":"event","name":"motion","fqName":"sensor.motion","featureId":"SENSOR_MOTION","writable":true}],"kind":"composite","name":"sensor","fqName":"sensor","featureId":"","writable":true},{"elements":[{"kind":"event","name":"bright","fqName":"lum_sensor.bright","featureId":"LUM_SENSOR_BRIGHT","writable":true},{"kind":"event","name":"dark","fqName":"lum_sensor.dark","featureId":"LUM_SENSOR_DARK","writable":true}],"kind":"composite","name":"lum_sensor","fqName":"lum_sensor","featureId":"","writable":true},{"elements":[{"kind":"event","type":"integer","name":"MotionDetected_time_event_0","fqName":"LightSwitch_Deep_History.main_region.AutomaticMode.r1.MotionDetectionMode.r1.MotionDetected_time_event_0","featureId":"MOTIONDETECTED_TIME_EVENT_0","writable":true,"value":0}],"kind":"composite","name":"time events","featureId":"","writable":true}]} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.historystates/lightswitch_deep_history-player/assets/hashes.json.js b/org.yakindu.sct.examples.basic.historystates/lightswitch_deep_history-player/assets/hashes.json.js new file mode 100644 index 00000000..bfc4a7b5 --- /dev/null +++ b/org.yakindu.sct.examples.basic.historystates/lightswitch_deep_history-player/assets/hashes.json.js @@ -0,0 +1 @@ +const hashesJson = {"MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED_tr0":"0ea258f9-145c-45b5-8000-9a2c031e1023","MAIN_REGION_AUTOMATICMODE_tr0":"e00f83fd-15e3-484a-a775-742a7534174e","MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED":"d0da9c32-d170-4291-9c15-caacf5c0a2eb","MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE_tr0":"07983b61-15cc-4851-9f26-ba90d8cb62ce","MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED":"0c275457-ae4c-4db4-8c6b-18b8195e9a47","MAIN_REGION_MANUALMODE":"05c9b5c2-709b-434f-ab8d-27370ee3cb84","MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE":"cd21cfa5-b802-46a0-aa47-747a17120b86","MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_tr0":"1bb51cbf-6a43-40a2-b042-3ba3930e415c","MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_tr0":"2a9747dd-93b9-4a4a-a902-c0c70f6a6767","MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE":"fcb2ff9f-e851-48df-8f91-b4675ba737c0","MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE":"04213d82-3642-4b3c-8170-406bb993c05e","MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED_tr0":"008952f7-25e5-4c60-85f8-d3334548bc74","MAIN_REGION_AUTOMATICMODE":"1a3218a8-48ef-4e4d-a6a3-6c13e7ddb64f","MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED_tr1":"fa1fd841-b052-4330-b4a3-06387e63972c","MAIN_REGION_MANUALMODE_tr0":"5e31d1b5-c278-4356-8454-194f2419a913","MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE":"8523eae5-21fd-4a0b-ae63-02a22df9843d","MAIN_REGION_MANUALMODE_tr1":"6ed50a25-4a0b-4b56-ac4d-55b43daf10de","MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE_tr0":"e65f10e9-2b77-42aa-958f-a3d4fceec909"} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.historystates/lightswitch_deep_history-player/assets/statemachine.svg.js b/org.yakindu.sct.examples.basic.historystates/lightswitch_deep_history-player/assets/statemachine.svg.js new file mode 100644 index 00000000..faf0bbc9 --- /dev/null +++ b/org.yakindu.sct.examples.basic.historystates/lightswitch_deep_history-player/assets/statemachine.svg.js @@ -0,0 +1 @@ +let svg = `main region1ManualModeentry / brightness += 1AutomaticModer1-TwilightDetectionModer1-Idleentry / brightness = 0TwilightDetectedentry / brightness = 1-MotionDetectionModer1-Idleentry / brightness = 0MotionDetectedentry / brightness = 1---sensor.motionsensor.motion1after 30safter 30s1user.off_buttonuser.off_button1user.on_button [brightness < 10]user.on_button [brightness < 10]2sensor.motionsensor.motion2lum_sensor.darklum_sensor.dark1lum_sensor.brightlum_sensor.bright1user.mode_buttonuser.mode_button1user.mode_buttonuser.mode_button1user.on_buttonuser.on_button1-1-1-1-1` \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.historystates/lightswitch_deep_history-player/assets/ypi.css b/org.yakindu.sct.examples.basic.historystates/lightswitch_deep_history-player/assets/ypi.css new file mode 100644 index 00000000..771aaa11 --- /dev/null +++ b/org.yakindu.sct.examples.basic.historystates/lightswitch_deep_history-player/assets/ypi.css @@ -0,0 +1,113 @@ +/*! + * itemis CREATE Player Styles + * Copyright 2021 itemis AG + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ + + + /*! + * Style definitions follow BEM pattern using and additional 'y' namespace (for itemis CREATE). + */ +.y-declaration { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; + background-color: #eee; + font-family: 'Courier New', Courier, monospace; +} + + +.y-entry { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; +} + +.y-entry:after { + content: ' \25CF '; + font-size: larger; +} + +.y-state { + background-color: rgb(209, 223, 238); + padding: 3px; + border: 0.5pt;; + border: 0.5pt; + border-radius: 4px; + border-color: #bbb; + font-family: 'Courier New', Courier, monospace; +} + +.y-state--active { + background-color: rgb(244, 215, 66); +} + +.y-state--inactive { + background-color: rgb(209, 223, 238); +} + +.y-variable{ + background-color: #eee; + border-color: #aaa; + border: 0.5pt; + border: 0.5pt; + border-radius: 2px; + font-family: 'Courier New', Courier, monospace; +} + +.y-variable::after { + color: #aaa; + content: attr(value); + font-family: 'Courier New', Courier, monospace; +} + +.y-do-enter { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; +} + +.y-do-enter:before { + content: ' \2192 '; +} + +.y-do-exit { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer +} + +.y-do-exit:before { + content: ' \2192 '; +} + +.y-do-raise { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; + white-space: nowrap; +} + +.y-do-raise:before { + content: ' \2192 '; +} + +button.y-do-raise:before { + content: ''; +} + +button.y-do-raise { + cursor: pointer; +} + +.y-do--over { + color: blue; + background-color: #eee; + cursor: pointer; +} + +.y-player { + border-style: solid; + border-width: 1px; + border-color: ; +} diff --git a/org.yakindu.sct.examples.basic.historystates/lightswitch_deep_history-player/model.scm b/org.yakindu.sct.examples.basic.historystates/lightswitch_deep_history-player/model.scm new file mode 100644 index 00000000..0b0ed3b6 --- /dev/null +++ b/org.yakindu.sct.examples.basic.historystates/lightswitch_deep_history-player/model.scm @@ -0,0 +1,1264 @@ +{ + "cells": [ + { + "position": { + "x": 0, + "y": 0 + }, + "size": { + "height": 10, + "width": 10 + }, + "angle": 0, + "type": "Statechart", + "id": "1d350dda-03cf-4aae-9d64-11e330724541", + "linkable": false, + "z": 1, + "attrs": { + "name": { + "text": "LightSwitch_Deep_History" + }, + "specification": { + "text": "@CycleBased(200)\n\ninternal:\n\tvar brightness: integer\n\t\ninterface user:\n\tin event on_button\n\tin event off_button\n\tin event mode_button\n\t\ninterface sensor:\n\tin event motion\n\t\ninterface lum_sensor:\n \tin event bright\n \tin event dark" + } + } + }, + { + "type": "Region", + "position": { + "x": 0, + "y": 0 + }, + "size": { + "width": 1275, + "height": 625 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "53eecf17-baef-4a8e-96cb-ebe112ec4acd", + "z": 2, + "embeds": [ + "552b5e84-04f1-43ab-af9a-bb85363f894e", + "e00f83fd-15e3-484a-a775-742a7534174e", + "6ed50a25-4a0b-4b56-ac4d-55b43daf10de", + "5e31d1b5-c278-4356-8454-194f2419a913", + "05c9b5c2-709b-434f-ab8d-27370ee3cb84", + "1a3218a8-48ef-4e4d-a6a3-6c13e7ddb64f", + "3a6adaf5-2143-4174-a75d-8b10c80ee021" + ], + "attrs": { + "priority": { + "text": 1 + }, + "name": { + "fontSize": "9", + "text": "main region" + } + } + }, + { + "type": "State", + "position": { + "x": 533, + "y": 491 + }, + "size": { + "width": 142, + "height": 62 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "05c9b5c2-709b-434f-ab8d-27370ee3cb84", + "parent": "53eecf17-baef-4a8e-96cb-ebe112ec4acd", + "z": 3, + "attrs": { + "name": { + "text": "ManualMode" + }, + "specification": { + "text": "entry / brightness += 1", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 17, + "y": 83 + }, + "size": { + "width": 1208, + "height": 336 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "1a3218a8-48ef-4e4d-a6a3-6c13e7ddb64f", + "parent": "53eecf17-baef-4a8e-96cb-ebe112ec4acd", + "z": 4, + "embeds": [ + "5b921f50-4a71-46bc-b720-61db59b2b17c" + ], + "attrs": { + "name": { + "text": "AutomaticMode" + } + } + }, + { + "type": "Region", + "position": { + "x": 18, + "y": 123 + }, + "size": { + "width": 1206, + "height": 295 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "5b921f50-4a71-46bc-b720-61db59b2b17c", + "z": 5, + "parent": "1a3218a8-48ef-4e4d-a6a3-6c13e7ddb64f", + "embeds": [ + "5f666b70-050a-4573-bdbe-d9f8c96fef37", + "1bb51cbf-6a43-40a2-b042-3ba3930e415c", + "2a9747dd-93b9-4a4a-a902-c0c70f6a6767", + "cd21cfa5-b802-46a0-aa47-747a17120b86", + "04213d82-3642-4b3c-8170-406bb993c05e", + "e889c5f1-af91-4d91-83dd-30e672addb84" + ], + "attrs": { + "name": { + "fontSize": "9", + "text": "r1" + } + } + }, + { + "type": "State", + "position": { + "x": 41, + "y": 187 + }, + "size": { + "width": 467, + "height": 178 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "cd21cfa5-b802-46a0-aa47-747a17120b86", + "parent": "5b921f50-4a71-46bc-b720-61db59b2b17c", + "z": 6, + "embeds": [ + "be497a1a-ba40-4ba7-b4f9-bbcaee3f12ac" + ], + "attrs": { + "name": { + "text": "TwilightDetectionMode" + } + } + }, + { + "type": "Region", + "position": { + "x": 42, + "y": 227 + }, + "size": { + "width": 465, + "height": 137 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "be497a1a-ba40-4ba7-b4f9-bbcaee3f12ac", + "z": 7, + "parent": "cd21cfa5-b802-46a0-aa47-747a17120b86", + "embeds": [ + "0dd9c41d-6a57-45ef-9aed-fc22041ebcb2", + "0ea258f9-145c-45b5-8000-9a2c031e1023", + "e65f10e9-2b77-42aa-958f-a3d4fceec909", + "fcb2ff9f-e851-48df-8f91-b4675ba737c0", + "0c275457-ae4c-4db4-8c6b-18b8195e9a47", + "3fdf1a92-cb3b-4561-924d-3af2b7680e19" + ], + "attrs": { + "name": { + "fontSize": "9", + "text": "r1" + } + } + }, + { + "type": "State", + "position": { + "x": 102, + "y": 276 + }, + "size": { + "width": 139, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "fcb2ff9f-e851-48df-8f91-b4675ba737c0", + "parent": "be497a1a-ba40-4ba7-b4f9-bbcaee3f12ac", + "z": 8, + "attrs": { + "name": { + "text": "Idle" + }, + "specification": { + "text": "entry / brightness = 0", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 322, + "y": 276 + }, + "size": { + "width": 139, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "0c275457-ae4c-4db4-8c6b-18b8195e9a47", + "parent": "be497a1a-ba40-4ba7-b4f9-bbcaee3f12ac", + "z": 9, + "attrs": { + "name": { + "text": "TwilightDetected" + }, + "specification": { + "text": "entry / brightness = 1", + "fontSize": "9" + } + } + }, + { + "type": "Entry", + "position": { + "x": 57, + "y": 289 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "3fdf1a92-cb3b-4561-924d-3af2b7680e19", + "parent": "be497a1a-ba40-4ba7-b4f9-bbcaee3f12ac", + "z": 10, + "embeds": [ + "d866c07d-2036-482c-836e-4dd1b9b31389" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 57, + "y": 304 + }, + "id": "d866c07d-2036-482c-836e-4dd1b9b31389", + "z": 11, + "parent": "3fdf1a92-cb3b-4561-924d-3af2b7680e19", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 654, + "y": 191 + }, + "size": { + "width": 531, + "height": 198 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "04213d82-3642-4b3c-8170-406bb993c05e", + "parent": "5b921f50-4a71-46bc-b720-61db59b2b17c", + "z": 12, + "embeds": [ + "f41e2e60-e027-49f9-846d-3756e06d905b" + ], + "attrs": { + "name": { + "text": "MotionDetectionMode" + } + } + }, + { + "type": "Region", + "position": { + "x": 655, + "y": 231 + }, + "size": { + "width": 529, + "height": 157 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "f41e2e60-e027-49f9-846d-3756e06d905b", + "z": 13, + "parent": "04213d82-3642-4b3c-8170-406bb993c05e", + "embeds": [ + "00464ad9-f9a5-44e5-8799-a9b7e9e0d620", + "fa1fd841-b052-4330-b4a3-06387e63972c", + "008952f7-25e5-4c60-85f8-d3334548bc74", + "07983b61-15cc-4851-9f26-ba90d8cb62ce", + "8523eae5-21fd-4a0b-ae63-02a22df9843d", + "d0da9c32-d170-4291-9c15-caacf5c0a2eb", + "d6dbac91-34ea-4ee8-aa0d-79d145dd753a" + ], + "attrs": { + "name": { + "fontSize": "9", + "text": "r1" + } + } + }, + { + "type": "State", + "position": { + "x": 715, + "y": 280 + }, + "size": { + "width": 139, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "8523eae5-21fd-4a0b-ae63-02a22df9843d", + "parent": "f41e2e60-e027-49f9-846d-3756e06d905b", + "z": 14, + "attrs": { + "name": { + "text": "Idle" + }, + "specification": { + "text": "entry / brightness = 0", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 934, + "y": 280 + }, + "size": { + "width": 139, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "d0da9c32-d170-4291-9c15-caacf5c0a2eb", + "parent": "f41e2e60-e027-49f9-846d-3756e06d905b", + "z": 15, + "attrs": { + "name": { + "text": "MotionDetected" + }, + "specification": { + "text": "entry / brightness = 1", + "fontSize": "9" + } + } + }, + { + "type": "Entry", + "position": { + "x": 676, + "y": 293 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "d6dbac91-34ea-4ee8-aa0d-79d145dd753a", + "parent": "f41e2e60-e027-49f9-846d-3756e06d905b", + "z": 16, + "embeds": [ + "173cdec2-da00-4804-bd18-e5244771a7bc" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 676, + "y": 308 + }, + "id": "173cdec2-da00-4804-bd18-e5244771a7bc", + "z": 17, + "parent": "d6dbac91-34ea-4ee8-aa0d-79d145dd753a", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "DeepHistory", + "position": { + "x": 697, + "y": 149 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "e889c5f1-af91-4d91-83dd-30e672addb84", + "parent": "5b921f50-4a71-46bc-b720-61db59b2b17c", + "z": 18, + "embeds": [ + "b5b3ffdd-8f3a-4beb-aeef-4cb6ecf5df21" + ], + "attrs": { + "name": { + "fill": "#333333" + } + } + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 697, + "y": 164 + }, + "id": "b5b3ffdd-8f3a-4beb-aeef-4cb6ecf5df21", + "z": 19, + "parent": "e889c5f1-af91-4d91-83dd-30e672addb84", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "Entry", + "position": { + "x": 81, + "y": 39 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "3a6adaf5-2143-4174-a75d-8b10c80ee021", + "parent": "53eecf17-baef-4a8e-96cb-ebe112ec4acd", + "z": 20, + "embeds": [ + "2f633c76-3b14-47d3-8489-dd142461451a" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 81, + "y": 54 + }, + "id": "2f633c76-3b14-47d3-8489-dd142461451a", + "z": 21, + "parent": "3a6adaf5-2143-4174-a75d-8b10c80ee021", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "26.41509433962264%", + "rotate": true + } + }, + "id": "8523eae5-21fd-4a0b-ae63-02a22df9843d" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "3.3574706019888962%", + "dy": "26.41509433962264%", + "rotate": true + } + }, + "id": "d0da9c32-d170-4291-9c15-caacf5c0a2eb" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "sensor.motion", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "07983b61-15cc-4851-9f26-ba90d8cb62ce", + "z": 22, + "parent": "f41e2e60-e027-49f9-846d-3756e06d905b", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "40.51122682861331%", + "dy": "98.49056603773593%", + "rotate": true + } + }, + "id": "d0da9c32-d170-4291-9c15-caacf5c0a2eb" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "43.22149877053773%", + "dy": "99.62264150943399%", + "rotate": true + } + }, + "id": "8523eae5-21fd-4a0b-ae63-02a22df9843d" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "after 30s", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "008952f7-25e5-4c60-85f8-d3334548bc74", + "z": 23, + "parent": "f41e2e60-e027-49f9-846d-3756e06d905b", + "vertices": [ + { + "x": 990.3106052917725, + "y": 357.4 + }, + { + "x": 775.0778832910474, + "y": 357.4 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "28.51116077394466%", + "dy": "0.45517514347915455%", + "rotate": true + } + }, + "id": "05c9b5c2-709b-434f-ab8d-27370ee3cb84" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "46.06670929627495%", + "dy": "50%", + "rotate": true + } + }, + "id": "1a3218a8-48ef-4e4d-a6a3-6c13e7ddb64f" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.off_button", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "5e31d1b5-c278-4356-8454-194f2419a913", + "z": 24, + "parent": "53eecf17-baef-4a8e-96cb-ebe112ec4acd", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "74.98373599259793%", + "dy": "50%", + "rotate": true + } + }, + "id": "05c9b5c2-709b-434f-ab8d-27370ee3cb84" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "29.913313457386657%", + "dy": "50%", + "rotate": true + } + }, + "id": "05c9b5c2-709b-434f-ab8d-27370ee3cb84" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.on_button [brightness < 10]", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "2" + } + } + } + ], + "id": "6ed50a25-4a0b-4b56-ac4d-55b43daf10de", + "z": 25, + "parent": "53eecf17-baef-4a8e-96cb-ebe112ec4acd", + "vertices": [ + { + "x": 639.476905109489, + "y": 593 + }, + { + "x": 575.476905109489, + "y": 593 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "75.47169811320755%", + "rotate": true + } + }, + "id": "d0da9c32-d170-4291-9c15-caacf5c0a2eb" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "96.50034810860996%", + "dy": "92.45283018867924%", + "rotate": true + } + }, + "id": "d0da9c32-d170-4291-9c15-caacf5c0a2eb" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "sensor.motion", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "2" + } + } + } + ], + "id": "fa1fd841-b052-4330-b4a3-06387e63972c", + "z": 26, + "parent": "f41e2e60-e027-49f9-846d-3756e06d905b", + "vertices": [ + { + "x": 1140.1354838709678, + "y": 320 + }, + { + "x": 1140.1354838709678, + "y": 353 + }, + { + "x": 1068.1354838709678, + "y": 353 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "89.12470023980816%", + "dy": "58.1761006289309%", + "rotate": true + } + }, + "id": "fcb2ff9f-e851-48df-8f91-b4675ba737c0" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "53.375299760191886%", + "dy": "58.1761006289309%", + "rotate": true + } + }, + "id": "0c275457-ae4c-4db4-8c6b-18b8195e9a47" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "lum_sensor.dark", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "e65f10e9-2b77-42aa-958f-a3d4fceec909", + "z": 27, + "parent": "be497a1a-ba40-4ba7-b4f9-bbcaee3f12ac", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "56.381402340813935%", + "dy": "98.49056603773593%", + "rotate": true + } + }, + "id": "0c275457-ae4c-4db4-8c6b-18b8195e9a47" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "39.32567378932674%", + "dy": "99.62264150943388%", + "rotate": true + } + }, + "id": "fcb2ff9f-e851-48df-8f91-b4675ba737c0" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "lum_sensor.bright", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "0ea258f9-145c-45b5-8000-9a2c031e1023", + "z": 28, + "parent": "be497a1a-ba40-4ba7-b4f9-bbcaee3f12ac", + "vertices": [ + { + "x": 400.37014925373137, + "y": 348.4 + }, + { + "x": 156.66268656716417, + "y": 348.4 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "36.96613239409154%", + "rotate": true + } + }, + "id": "cd21cfa5-b802-46a0-aa47-747a17120b86" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.017134164975107946%", + "dy": "31.211977606809565%", + "rotate": true + } + }, + "id": "04213d82-3642-4b3c-8170-406bb993c05e" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.mode_button", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "2a9747dd-93b9-4a4a-a902-c0c70f6a6767", + "z": 29, + "parent": "5b921f50-4a71-46bc-b720-61db59b2b17c", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.10493515937317902%", + "dy": "17.38701692537912%", + "rotate": true + } + }, + "id": "04213d82-3642-4b3c-8170-406bb993c05e" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "21.58780534396104%", + "rotate": true + } + }, + "id": "cd21cfa5-b802-46a0-aa47-747a17120b86" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.mode_button", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "1bb51cbf-6a43-40a2-b042-3ba3930e415c", + "z": 30, + "parent": "5b921f50-4a71-46bc-b720-61db59b2b17c", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50.280303746567924%", + "dy": "50%", + "rotate": true + } + }, + "id": "1a3218a8-48ef-4e4d-a6a3-6c13e7ddb64f" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "64.35638680178909%", + "dy": "0.3727158783560973%", + "rotate": true + } + }, + "id": "05c9b5c2-709b-434f-ab8d-27370ee3cb84" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.on_button", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "e00f83fd-15e3-484a-a775-742a7534174e", + "z": 31, + "parent": "53eecf17-baef-4a8e-96cb-ebe112ec4acd", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "92.02321724709786%", + "dy": "60%", + "rotate": true + } + }, + "id": "3fdf1a92-cb3b-4561-924d-3af2b7680e19" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "8.710046887862847%", + "dy": "41.509433962264154%", + "rotate": true + } + }, + "id": "fcb2ff9f-e851-48df-8f91-b4675ba737c0" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "0dd9c41d-6a57-45ef-9aed-fc22041ebcb2", + "z": 32, + "parent": "be497a1a-ba40-4ba7-b4f9-bbcaee3f12ac", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "98.27529021558878%", + "dy": "53.333333333333336%", + "rotate": true + } + }, + "id": "d6dbac91-34ea-4ee8-aa0d-79d145dd753a" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "5.02344393142204%", + "dy": "39.62264150943396%", + "rotate": true + } + }, + "id": "8523eae5-21fd-4a0b-ae63-02a22df9843d" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "00464ad9-f9a5-44e5-8799-a9b7e9e0d620", + "z": 33, + "parent": "f41e2e60-e027-49f9-846d-3756e06d905b", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "57.52401321126324%", + "dy": "88.88888888888896%", + "rotate": true + } + }, + "id": "e889c5f1-af91-4d91-83dd-30e672addb84" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "9.722900561523444%", + "dy": "0.08417508417509374%", + "rotate": true + } + }, + "id": "04213d82-3642-4b3c-8170-406bb993c05e" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "5f666b70-050a-4573-bdbe-d9f8c96fef37", + "z": 34, + "parent": "5b921f50-4a71-46bc-b720-61db59b2b17c", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "97.0873804805683%", + "dy": "49.42229038854805%", + "rotate": true + } + }, + "id": "3a6adaf5-2143-4174-a75d-8b10c80ee021" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "11.641242892729345%", + "dy": "0.07143770084720895%", + "rotate": true + } + }, + "id": "1a3218a8-48ef-4e4d-a6a3-6c13e7ddb64f" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "552b5e84-04f1-43ab-af9a-bb85363f894e", + "z": 35, + "parent": "53eecf17-baef-4a8e-96cb-ebe112ec4acd", + "vertices": [ + { + "x": 157.6262141441705, + "y": 46.41334355828221 + } + ], + "attrs": {} + } + ] +} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.historystates/lightswitch_deep_history-player/player.html b/org.yakindu.sct.examples.basic.historystates/lightswitch_deep_history-player/player.html new file mode 100644 index 00000000..a40d8757 --- /dev/null +++ b/org.yakindu.sct.examples.basic.historystates/lightswitch_deep_history-player/player.html @@ -0,0 +1,52 @@ + +sct-web-player demo + + + + + + + + + + + + + + + +
+ +
+ + + + + \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.historystates/lightswitch_no_history-player/assets/bundle.js b/org.yakindu.sct.examples.basic.historystates/lightswitch_no_history-player/assets/bundle.js new file mode 100644 index 00000000..59335031 --- /dev/null +++ b/org.yakindu.sct.examples.basic.historystates/lightswitch_no_history-player/assets/bundle.js @@ -0,0 +1,869 @@ +var com; +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Instances represent state machine trace events. + * @param {com.yakindu.core.TraceEventType} type + * @param {*} machine + * @param {*} state + * @param {*} feature + * @param {*} value + * @class + */ + class TraceEvent { + constructor(type, machine, state, feature, value) { + if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && ((state != null) || state === null) && ((feature != null) || feature === null) && ((value != null) || value === null)) { + let __args = arguments; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + else if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && state === undefined && feature === undefined && value === undefined) { + let __args = arguments; + { + let __args = arguments; + let state = null; + let feature = null; + let value = null; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + } + else + throw new Error('invalid overload'); + } + getType() { + return this.type; + } + getMachine() { + return this.machine; + } + getState() { + return this.state; + } + getFeature() { + return this.feature; + } + getValue() { + return this.value; + } + } + core.TraceEvent = TraceEvent; + TraceEvent["__class"] = "com.yakindu.core.TraceEvent"; + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Trace event type enumeration. + * @enum + * @property {com.yakindu.core.TraceEventType} MACHINE_ENTER + * @property {com.yakindu.core.TraceEventType} MACHINE_EXIT + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_START + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_STOP + * @property {com.yakindu.core.TraceEventType} STATE_ENTERED + * @property {com.yakindu.core.TraceEventType} STATE_EXITED + * @property {com.yakindu.core.TraceEventType} STATE_TRANSITION + * @property {com.yakindu.core.TraceEventType} EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} VARIABLE_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_UNSET + * @class + */ + let TraceEventType; + (function (TraceEventType) { + TraceEventType[TraceEventType["MACHINE_ENTER"] = 0] = "MACHINE_ENTER"; + TraceEventType[TraceEventType["MACHINE_EXIT"] = 1] = "MACHINE_EXIT"; + TraceEventType[TraceEventType["MACHINE_RTS_START"] = 2] = "MACHINE_RTS_START"; + TraceEventType[TraceEventType["MACHINE_RTS_STOP"] = 3] = "MACHINE_RTS_STOP"; + TraceEventType[TraceEventType["STATE_ENTERED"] = 4] = "STATE_ENTERED"; + TraceEventType[TraceEventType["STATE_EXITED"] = 5] = "STATE_EXITED"; + TraceEventType[TraceEventType["STATE_TRANSITION"] = 6] = "STATE_TRANSITION"; + TraceEventType[TraceEventType["EVENT_RAISED"] = 7] = "EVENT_RAISED"; + TraceEventType[TraceEventType["VARIABLE_SET"] = 8] = "VARIABLE_SET"; + TraceEventType[TraceEventType["TIME_EVENT_RAISED"] = 9] = "TIME_EVENT_RAISED"; + TraceEventType[TraceEventType["TIME_EVENT_SET"] = 10] = "TIME_EVENT_SET"; + TraceEventType[TraceEventType["TIME_EVENT_UNSET"] = 11] = "TIME_EVENT_UNSET"; + })(TraceEventType = core.TraceEventType || (core.TraceEventType = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + var rx; + (function (rx) { + class Observable { + constructor() { + this.observers = ([]); + } + next(value) { + for (let index = 0; index < this.observers.length; index++) { + let observer = this.observers[index]; + { + observer.next(value); + } + } + } + subscribe(observer) { + return observer != null ? /* add */ (this.observers.push(observer) > 0) : false; + } + unsubscribe(observer) { + return observer != null ? /* remove */ (a => { let index = a.indexOf(observer); if (index >= 0) { + a.splice(index, 1); + return true; + } + else { + return false; + } })(this.observers) : false; + } + } + rx.Observable = Observable; + Observable["__class"] = "com.yakindu.core.rx.Observable"; + })(rx = core.rx || (core.rx = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +var sct; +(function (sct) { + var yakindu; + (function (yakindu) { + var io; + (function (io) { + class Statemachine { + constructor() { + if (this.__user === undefined) { + this.__user = null; + } + if (this.__sensor === undefined) { + this.__sensor = null; + } + if (this.__lum_sensor === undefined) { + this.__lum_sensor = null; + } + this.stateVector = [null]; + this.trace = (new com.yakindu.core.rx.Observable()); + if (this.timerService === undefined) { + this.timerService = null; + } + this.timeEvents = [false]; + this.inEventQueue = ([]); + if (this.brightness === undefined) { + this.brightness = 0; + } + if (this.isExecuting === undefined) { + this.isExecuting = false; + } + this.__user = new Statemachine.User(this); + this.__sensor = new Statemachine.Sensor(this); + this.__lum_sensor = new Statemachine.Lum_sensor(this); + for (let i = 0; i < 1; i++) { + { + this.stateVector[i] = Statemachine.State.$NULLSTATE$; + } + ; + } + this.clearInEvents(); + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + this.isExecuting = false; + } + getBrightness() { + return this.brightness; + } + setBrightness(value) { + this.brightness = value; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + getIsExecuting() { + return this.isExecuting; + } + setIsExecuting(value) { + this.isExecuting = value; + } + enter() { + if (this.timerService == null) { + throw Object.defineProperty(new Error("Timer service must be set."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.IllegalStateException', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.Exception'] }); + } + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_ENTER, this))); + this.enterSequence_main_region_default(); + this.isExecuting = false; + } + exit() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_EXIT, this))); + this.exitSequence_main_region(); + this.isExecuting = false; + } + /** + * @see IStatemachine#isActive() + * @return {boolean} + */ + isActive() { + return this.stateVector[0] !== Statemachine.State.$NULLSTATE$; + } + /** + * + * Always returns 'false' since this state machine can never become final. + * + * @see IStatemachine#isFinal() + * @return {boolean} + */ + isFinal() { + return false; + } + clearInEvents() { + this.__user.on_button = false; + this.__user.off_button = false; + this.__user.mode_button = false; + this.__sensor.motion = false; + this.__lum_sensor.bright = false; + this.__lum_sensor.dark = false; + this.timeEvents[0] = false; + } + microStep() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MANUALMODE: + this.main_region_ManualMode_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE: + this.main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED: + this.main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE: + this.main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED: + this.main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected_react(-1); + break; + default: + break; + } + } + runCycle() { + if (this.timerService == null) { + throw Object.defineProperty(new Error("Timer service must be set."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.IllegalStateException', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.Exception'] }); + } + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_START, this))); + this.nextEvent(); + do { + { + this.microStep(); + this.clearInEvents(); + this.nextEvent(); + } + } while ((((((((this.__user.on_button || this.__user.off_button) || this.__user.mode_button) || this.__sensor.motion) || this.__lum_sensor.bright) || this.__lum_sensor.dark) || this.timeEvents[0]))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_STOP, this))); + this.isExecuting = false; + } + nextEvent() { + if (!(this.inEventQueue.length == 0)) { + (target => (typeof target === 'function') ? target() : target.run())(/* poll */ (a => a.length == 0 ? null : a.shift())(this.inEventQueue)); + return; + } + } + /** + * Returns true if the given state is currently active otherwise false. + * @param {sct.yakindu.io.Statemachine.State} state + * @return {boolean} + */ + isStateActive(state) { + switch ((state)) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MANUALMODE: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_MANUALMODE; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_AUTOMATICMODE]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED]]; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED]]; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED]]; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED; + default: + return false; + } + } + setTimerService(timerService) { + this.timerService = timerService; + } + getTimerService() { + return this.timerService; + } + raiseTimeEvent(eventID) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_RAISED, this, null, null, eventID))); + /* add */ (this.inEventQueue.push(() => { + this.timeEvents[eventID] = true; + }) > 0); + this.runCycle(); + } + user() { + return this.__user; + } + sensor() { + return this.__sensor; + } + lum_sensor() { + return this.__lum_sensor; + } + getTrace() { + return this.trace; + } + entryAction_main_region_ManualMode() { + this.setBrightness(this.getBrightness() + 1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + entryAction_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle() { + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + entryAction_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected() { + this.setBrightness(1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + entryAction_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle() { + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + entryAction_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected() { + this.timerService.setTimer(this, 0, (30 * 1000), false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_SET, this, null, null, 0))); + this.setBrightness(1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_BRIGHTNESS, this.brightness))); + } + exitAction_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected() { + this.timerService.unsetTimer(this, 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_UNSET, this, null, null, 0))); + } + enterSequence_main_region_ManualMode_default() { + this.entryAction_main_region_ManualMode(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_MANUALMODE, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_MANUALMODE; + } + enterSequence_main_region_AutomaticMode_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE, null, null))); + this.enterSequence_main_region_AutomaticMode_r1_default(); + } + enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE, null, null))); + this.enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_default(); + } + enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle_default() { + this.entryAction_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE; + } + enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected_default() { + this.entryAction_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED; + } + enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE, null, null))); + this.enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_default(); + } + enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle_default() { + this.entryAction_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE; + } + enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected_default() { + this.entryAction_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED; + } + enterSequence_main_region_default() { + this.react_main_region__entry_Default(); + } + enterSequence_main_region_AutomaticMode_r1_default() { + this.react_main_region_AutomaticMode_r1__entry_Default(); + } + enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_default() { + this.react_main_region_AutomaticMode_r1_TwilightDetectionMode_r1__entry_Default(); + } + enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_default() { + this.react_main_region_AutomaticMode_r1_MotionDetectionMode_r1__entry_Default(); + } + exitSequence_main_region_ManualMode() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_MANUALMODE, null, null))); + } + exitSequence_main_region_AutomaticMode() { + this.exitSequence_main_region_AutomaticMode_r1(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE, null, null))); + } + exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode() { + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE, null, null))); + } + exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE, null, null))); + } + exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED, null, null))); + } + exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode() { + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE, null, null))); + } + exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE, null, null))); + } + exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.exitAction_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED, null, null))); + } + exitSequence_main_region() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_MANUALMODE: + this.exitSequence_main_region_ManualMode(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE: + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE, null, null))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED: + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE, null, null))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE: + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE, null, null))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED: + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE, null, null))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE, null, null))); + break; + default: + break; + } + } + exitSequence_main_region_AutomaticMode_r1() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE: + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED: + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE: + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED: + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE, null, null))); + break; + default: + break; + } + } + exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE: + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED: + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected(); + break; + default: + break; + } + } + exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE: + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED: + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected(); + break; + default: + break; + } + } + react_main_region_AutomaticMode_r1_TwilightDetectionMode_r1__entry_Default() { + this.enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle_default(); + } + react_main_region_AutomaticMode_r1_MotionDetectionMode_r1__entry_Default() { + this.enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle_default(); + } + react_main_region_AutomaticMode_r1__entry_Default() { + this.enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_default(); + } + react_main_region__entry_Default() { + this.enterSequence_main_region_AutomaticMode_default(); + } + react(transitioned_before) { + return transitioned_before; + } + main_region_ManualMode_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__user.off_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_MANUALMODE, null, 0))); + this.exitSequence_main_region_ManualMode(); + this.enterSequence_main_region_AutomaticMode_default(); + this.react(0); + transitioned_after = 0; + } + else { + if (((this.__user.on_button) && (this.getBrightness() < 10))) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_MANUALMODE, null, 1))); + this.exitSequence_main_region_ManualMode(); + this.enterSequence_main_region_ManualMode_default(); + this.react(0); + transitioned_after = 0; + } + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_region_AutomaticMode_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__user.on_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE, null, 0))); + this.exitSequence_main_region_AutomaticMode(); + this.enterSequence_main_region_ManualMode_default(); + this.react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_region_AutomaticMode_r1_TwilightDetectionMode_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__user.mode_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE, null, 0))); + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode(); + this.enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_default(); + this.main_region_AutomaticMode_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_AutomaticMode_react(transitioned_before); + } + return transitioned_after; + } + main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__lum_sensor.dark) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE, null, 0))); + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle(); + this.enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected_default(); + this.main_region_AutomaticMode_r1_TwilightDetectionMode_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_AutomaticMode_r1_TwilightDetectionMode_react(transitioned_before); + } + return transitioned_after; + } + main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__lum_sensor.bright) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED, null, 0))); + this.exitSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_TwilightDetected(); + this.enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_r1_Idle_default(); + this.main_region_AutomaticMode_r1_TwilightDetectionMode_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_AutomaticMode_r1_TwilightDetectionMode_react(transitioned_before); + } + return transitioned_after; + } + main_region_AutomaticMode_r1_MotionDetectionMode_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__user.mode_button) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE, null, 0))); + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode(); + this.enterSequence_main_region_AutomaticMode_r1_TwilightDetectionMode_default(); + this.main_region_AutomaticMode_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_AutomaticMode_react(transitioned_before); + } + return transitioned_after; + } + main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__sensor.motion) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE, null, 0))); + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle(); + this.enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected_default(); + this.main_region_AutomaticMode_r1_MotionDetectionMode_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_AutomaticMode_r1_MotionDetectionMode_react(transitioned_before); + } + return transitioned_after; + } + main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.timeEvents[0]) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED, null, 0))); + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected(); + this.timeEvents[0] = false; + this.enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_Idle_default(); + this.main_region_AutomaticMode_r1_MotionDetectionMode_react(0); + transitioned_after = 0; + } + else { + if (this.__sensor.motion) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED, null, 1))); + this.exitSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected(); + this.enterSequence_main_region_AutomaticMode_r1_MotionDetectionMode_r1_MotionDetected_default(); + this.main_region_AutomaticMode_r1_MotionDetectionMode_react(0); + transitioned_after = 0; + } + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_AutomaticMode_r1_MotionDetectionMode_react(transitioned_before); + } + return transitioned_after; + } + } + io.Statemachine = Statemachine; + Statemachine["__class"] = "sct.yakindu.io.Statemachine"; + Statemachine["__interfaces"] = ["com.yakindu.core.IStatemachine", "com.yakindu.core.ITimed"]; + (function (Statemachine) { + class User { + constructor(parent) { + if (this.parent === undefined) { + this.parent = null; + } + if (this.on_button === undefined) { + this.on_button = false; + } + if (this.off_button === undefined) { + this.off_button = false; + } + if (this.mode_button === undefined) { + this.mode_button = false; + } + this.parent = parent; + } + raiseOn_button() { + /* add */ (this.parent.inEventQueue.push(() => { + this.on_button = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.USER_ON_BUTTON, null))); + this.parent.runCycle(); + } + raiseOff_button() { + /* add */ (this.parent.inEventQueue.push(() => { + this.off_button = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.USER_OFF_BUTTON, null))); + this.parent.runCycle(); + } + raiseMode_button() { + /* add */ (this.parent.inEventQueue.push(() => { + this.mode_button = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.USER_MODE_BUTTON, null))); + this.parent.runCycle(); + } + } + Statemachine.User = User; + User["__class"] = "sct.yakindu.io.Statemachine.User"; + class Sensor { + constructor(parent) { + if (this.parent === undefined) { + this.parent = null; + } + if (this.motion === undefined) { + this.motion = false; + } + this.parent = parent; + } + raiseMotion() { + /* add */ (this.parent.inEventQueue.push(() => { + this.motion = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.SENSOR_MOTION, null))); + this.parent.runCycle(); + } + } + Statemachine.Sensor = Sensor; + Sensor["__class"] = "sct.yakindu.io.Statemachine.Sensor"; + class Lum_sensor { + constructor(parent) { + if (this.parent === undefined) { + this.parent = null; + } + if (this.bright === undefined) { + this.bright = false; + } + if (this.dark === undefined) { + this.dark = false; + } + this.parent = parent; + } + raiseBright() { + /* add */ (this.parent.inEventQueue.push(() => { + this.bright = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.LUM_SENSOR_BRIGHT, null))); + this.parent.runCycle(); + } + raiseDark() { + /* add */ (this.parent.inEventQueue.push(() => { + this.dark = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.LUM_SENSOR_DARK, null))); + this.parent.runCycle(); + } + } + Statemachine.Lum_sensor = Lum_sensor; + Lum_sensor["__class"] = "sct.yakindu.io.Statemachine.Lum_sensor"; + let State; + (function (State) { + State[State["MAIN_REGION_MANUALMODE"] = 0] = "MAIN_REGION_MANUALMODE"; + State[State["MAIN_REGION_AUTOMATICMODE"] = 1] = "MAIN_REGION_AUTOMATICMODE"; + State[State["MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE"] = 2] = "MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE"; + State[State["MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE"] = 3] = "MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE"; + State[State["MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED"] = 4] = "MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED"; + State[State["MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE"] = 5] = "MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE"; + State[State["MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE"] = 6] = "MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE"; + State[State["MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED"] = 7] = "MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED"; + State[State["$NULLSTATE$"] = 8] = "$NULLSTATE$"; + })(State = Statemachine.State || (Statemachine.State = {})); + /** + * Enumeration of all features of the statechart + * @enum + * @property {sct.yakindu.io.Statemachine.Feature} NO_FEATURE + * @property {sct.yakindu.io.Statemachine.Feature} INTERNAL_BRIGHTNESS + * @property {sct.yakindu.io.Statemachine.Feature} USER_ON_BUTTON + * @property {sct.yakindu.io.Statemachine.Feature} USER_OFF_BUTTON + * @property {sct.yakindu.io.Statemachine.Feature} USER_MODE_BUTTON + * @property {sct.yakindu.io.Statemachine.Feature} SENSOR_MOTION + * @property {sct.yakindu.io.Statemachine.Feature} LUM_SENSOR_BRIGHT + * @property {sct.yakindu.io.Statemachine.Feature} LUM_SENSOR_DARK + * @class + */ + let Feature; + (function (Feature) { + Feature[Feature["NO_FEATURE"] = 0] = "NO_FEATURE"; + Feature[Feature["INTERNAL_BRIGHTNESS"] = 1] = "INTERNAL_BRIGHTNESS"; + Feature[Feature["USER_ON_BUTTON"] = 2] = "USER_ON_BUTTON"; + Feature[Feature["USER_OFF_BUTTON"] = 3] = "USER_OFF_BUTTON"; + Feature[Feature["USER_MODE_BUTTON"] = 4] = "USER_MODE_BUTTON"; + Feature[Feature["SENSOR_MOTION"] = 5] = "SENSOR_MOTION"; + Feature[Feature["LUM_SENSOR_BRIGHT"] = 6] = "LUM_SENSOR_BRIGHT"; + Feature[Feature["LUM_SENSOR_DARK"] = 7] = "LUM_SENSOR_DARK"; + })(Feature = Statemachine.Feature || (Statemachine.Feature = {})); + })(Statemachine = io.Statemachine || (io.Statemachine = {})); + })(io = yakindu.io || (yakindu.io = {})); + })(yakindu = sct.yakindu || (sct.yakindu = {})); +})(sct || (sct = {})); diff --git a/org.yakindu.sct.examples.basic.historystates/lightswitch_no_history-player/assets/context.json.js b/org.yakindu.sct.examples.basic.historystates/lightswitch_no_history-player/assets/context.json.js new file mode 100644 index 00000000..e20cf563 --- /dev/null +++ b/org.yakindu.sct.examples.basic.historystates/lightswitch_no_history-player/assets/context.json.js @@ -0,0 +1 @@ +const contextJson = {"elements":[{"elements":[{"kind":"variable","type":"integer","name":"brightness","fqName":"brightness","featureId":"INTERNAL_BRIGHTNESS","writable":true,"value":0}],"kind":"composite","name":"internal","featureId":"","writable":true},{"elements":[{"kind":"event","name":"on_button","fqName":"user.on_button","featureId":"USER_ON_BUTTON","writable":true},{"kind":"event","name":"off_button","fqName":"user.off_button","featureId":"USER_OFF_BUTTON","writable":true},{"kind":"event","name":"mode_button","fqName":"user.mode_button","featureId":"USER_MODE_BUTTON","writable":true}],"kind":"composite","name":"user","fqName":"user","featureId":"","writable":true},{"elements":[{"kind":"event","name":"motion","fqName":"sensor.motion","featureId":"SENSOR_MOTION","writable":true}],"kind":"composite","name":"sensor","fqName":"sensor","featureId":"","writable":true},{"elements":[{"kind":"event","name":"bright","fqName":"lum_sensor.bright","featureId":"LUM_SENSOR_BRIGHT","writable":true},{"kind":"event","name":"dark","fqName":"lum_sensor.dark","featureId":"LUM_SENSOR_DARK","writable":true}],"kind":"composite","name":"lum_sensor","fqName":"lum_sensor","featureId":"","writable":true},{"elements":[{"kind":"event","type":"integer","name":"MotionDetected_time_event_0","fqName":"LightSwitch_No_History.main_region.AutomaticMode.r1.MotionDetectionMode.r1.MotionDetected_time_event_0","featureId":"MOTIONDETECTED_TIME_EVENT_0","writable":true,"value":0}],"kind":"composite","name":"time events","featureId":"","writable":true}]} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.historystates/lightswitch_no_history-player/assets/hashes.json.js b/org.yakindu.sct.examples.basic.historystates/lightswitch_no_history-player/assets/hashes.json.js new file mode 100644 index 00000000..e4fc8f87 --- /dev/null +++ b/org.yakindu.sct.examples.basic.historystates/lightswitch_no_history-player/assets/hashes.json.js @@ -0,0 +1 @@ +const hashesJson = {"MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED_tr0":"53e27ccd-938d-454e-8ae1-2834804b794e","MAIN_REGION_AUTOMATICMODE_tr0":"cc05b9c6-8e4a-4b95-b035-22b682303fe7","MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED":"d38f4ed6-20f5-4262-ae2f-3bfddc7ce6b6","MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE_tr0":"46aad98b-5595-4d86-9875-5a458cfe728a","MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_TWILIGHTDETECTED":"cf29d38b-f8f2-447e-92c0-f707a2a32189","MAIN_REGION_MANUALMODE":"d18f0582-a359-477b-b1f2-759455997486","MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE":"6aa2fe43-83bb-45bf-9a87-760d5dde96a4","MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_tr0":"0b285518-4d4f-4851-8f76-1f7cf0a61927","MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_tr0":"323aca6a-dc49-43a7-a952-e7ff75644820","MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE":"3104eb5a-50d0-4e4f-b119-f4765ec7cd14","MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE":"7b0b0978-50b0-4a8f-8a0b-1ce8b0176465","MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED_tr0":"138769b5-830d-4a05-bc2f-596e4bf99bfa","MAIN_REGION_AUTOMATICMODE":"dc220bfe-4a71-445d-b925-b38f7bf2fdb6","MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_MOTIONDETECTED_tr1":"ab85be75-887d-4dcf-bc19-dc7c985ba7c0","MAIN_REGION_MANUALMODE_tr0":"55661118-ceb1-432b-997e-dbe2e5a5fb34","MAIN_REGION_AUTOMATICMODE_R1_MOTIONDETECTIONMODE_R1_IDLE":"2ffdf8d5-aeb8-46c3-b92d-432ac05a0e75","MAIN_REGION_MANUALMODE_tr1":"5c6a7c15-bfd9-4a43-9795-3f0b4a2d4803","MAIN_REGION_AUTOMATICMODE_R1_TWILIGHTDETECTIONMODE_R1_IDLE_tr0":"48d50c19-40de-4d09-afeb-ffbbf0953fa2"} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.historystates/lightswitch_no_history-player/assets/statemachine.svg.js b/org.yakindu.sct.examples.basic.historystates/lightswitch_no_history-player/assets/statemachine.svg.js new file mode 100644 index 00000000..862904f0 --- /dev/null +++ b/org.yakindu.sct.examples.basic.historystates/lightswitch_no_history-player/assets/statemachine.svg.js @@ -0,0 +1 @@ +let svg = `main region1ManualModeentry / brightness += 1AutomaticModer1-TwilightDetectionModer1-Idleentry / brightness = 0TwilightDetectedentry / brightness = 1-MotionDetectionModer1-Idleentry / brightness = 0MotionDetectedentry / brightness = 1---sensor.motionsensor.motion1after 30safter 30s1user.off_buttonuser.off_button1user.on_button [brightness < 10]user.on_button [brightness < 10]2sensor.motionsensor.motion2lum_sensor.darklum_sensor.dark1lum_sensor.brightlum_sensor.bright1user.mode_buttonuser.mode_button1user.mode_buttonuser.mode_button1user.on_buttonuser.on_button1-1-1-1-1` \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.historystates/lightswitch_no_history-player/assets/ypi.css b/org.yakindu.sct.examples.basic.historystates/lightswitch_no_history-player/assets/ypi.css new file mode 100644 index 00000000..771aaa11 --- /dev/null +++ b/org.yakindu.sct.examples.basic.historystates/lightswitch_no_history-player/assets/ypi.css @@ -0,0 +1,113 @@ +/*! + * itemis CREATE Player Styles + * Copyright 2021 itemis AG + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ + + + /*! + * Style definitions follow BEM pattern using and additional 'y' namespace (for itemis CREATE). + */ +.y-declaration { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; + background-color: #eee; + font-family: 'Courier New', Courier, monospace; +} + + +.y-entry { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; +} + +.y-entry:after { + content: ' \25CF '; + font-size: larger; +} + +.y-state { + background-color: rgb(209, 223, 238); + padding: 3px; + border: 0.5pt;; + border: 0.5pt; + border-radius: 4px; + border-color: #bbb; + font-family: 'Courier New', Courier, monospace; +} + +.y-state--active { + background-color: rgb(244, 215, 66); +} + +.y-state--inactive { + background-color: rgb(209, 223, 238); +} + +.y-variable{ + background-color: #eee; + border-color: #aaa; + border: 0.5pt; + border: 0.5pt; + border-radius: 2px; + font-family: 'Courier New', Courier, monospace; +} + +.y-variable::after { + color: #aaa; + content: attr(value); + font-family: 'Courier New', Courier, monospace; +} + +.y-do-enter { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; +} + +.y-do-enter:before { + content: ' \2192 '; +} + +.y-do-exit { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer +} + +.y-do-exit:before { + content: ' \2192 '; +} + +.y-do-raise { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; + white-space: nowrap; +} + +.y-do-raise:before { + content: ' \2192 '; +} + +button.y-do-raise:before { + content: ''; +} + +button.y-do-raise { + cursor: pointer; +} + +.y-do--over { + color: blue; + background-color: #eee; + cursor: pointer; +} + +.y-player { + border-style: solid; + border-width: 1px; + border-color: ; +} diff --git a/org.yakindu.sct.examples.basic.historystates/lightswitch_no_history-player/model.scm b/org.yakindu.sct.examples.basic.historystates/lightswitch_no_history-player/model.scm new file mode 100644 index 00000000..5510b595 --- /dev/null +++ b/org.yakindu.sct.examples.basic.historystates/lightswitch_no_history-player/model.scm @@ -0,0 +1,1260 @@ +{ + "cells": [ + { + "position": { + "x": 0, + "y": 0 + }, + "size": { + "height": 10, + "width": 10 + }, + "angle": 0, + "type": "Statechart", + "id": "c0f7ca08-79c4-4b63-93ef-7978243da2c6", + "linkable": false, + "z": 1, + "attrs": { + "name": { + "text": "LightSwitch_No_History" + }, + "specification": { + "text": "@CycleBased(200)\n\ninternal:\n\tvar brightness: integer\n\t\ninterface user:\n\tin event on_button\n\tin event off_button\n\tin event mode_button\n\t\ninterface sensor:\n\tin event motion\n\t\ninterface lum_sensor:\n \tin event bright\n \tin event dark" + } + } + }, + { + "type": "Region", + "position": { + "x": 0, + "y": 0 + }, + "size": { + "width": 1258, + "height": 625 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "e68682aa-a5dc-40ec-925d-58e170c05bf2", + "z": 2, + "embeds": [ + "c03ce275-a8dc-472f-b497-81165dbde55b", + "cc05b9c6-8e4a-4b95-b035-22b682303fe7", + "5c6a7c15-bfd9-4a43-9795-3f0b4a2d4803", + "55661118-ceb1-432b-997e-dbe2e5a5fb34", + "d18f0582-a359-477b-b1f2-759455997486", + "dc220bfe-4a71-445d-b925-b38f7bf2fdb6", + "e110bc12-cf68-4138-9b2a-9e64d5455676" + ], + "attrs": { + "priority": { + "text": 1 + }, + "name": { + "fontSize": "9", + "text": "main region" + } + } + }, + { + "type": "State", + "position": { + "x": 533, + "y": 491 + }, + "size": { + "width": 142, + "height": 62 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "d18f0582-a359-477b-b1f2-759455997486", + "parent": "e68682aa-a5dc-40ec-925d-58e170c05bf2", + "z": 3, + "attrs": { + "name": { + "text": "ManualMode" + }, + "specification": { + "text": "entry / brightness += 1", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 17, + "y": 83 + }, + "size": { + "width": 1197, + "height": 331 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "dc220bfe-4a71-445d-b925-b38f7bf2fdb6", + "parent": "e68682aa-a5dc-40ec-925d-58e170c05bf2", + "z": 4, + "embeds": [ + "1598b19c-1a20-4398-8dc3-885e36b5747e" + ], + "attrs": { + "name": { + "text": "AutomaticMode" + } + } + }, + { + "type": "Region", + "position": { + "x": 18, + "y": 123 + }, + "size": { + "width": 1195, + "height": 290 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "1598b19c-1a20-4398-8dc3-885e36b5747e", + "z": 5, + "parent": "dc220bfe-4a71-445d-b925-b38f7bf2fdb6", + "embeds": [ + "d7ef98be-16e6-4c70-aa04-5364fa29979f", + "323aca6a-dc49-43a7-a952-e7ff75644820", + "0b285518-4d4f-4851-8f76-1f7cf0a61927", + "6aa2fe43-83bb-45bf-9a87-760d5dde96a4", + "7b0b0978-50b0-4a8f-8a0b-1ce8b0176465", + "383dc32d-04af-45d2-ba13-2c6ba1219c09" + ], + "attrs": { + "name": { + "fontSize": "9", + "text": "r1" + } + } + }, + { + "type": "State", + "position": { + "x": 41, + "y": 187 + }, + "size": { + "width": 479, + "height": 188 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "6aa2fe43-83bb-45bf-9a87-760d5dde96a4", + "parent": "1598b19c-1a20-4398-8dc3-885e36b5747e", + "z": 6, + "embeds": [ + "e64f5a25-8a40-4369-ac95-676840c7d08c" + ], + "attrs": { + "name": { + "text": "TwilightDetectionMode" + } + } + }, + { + "type": "Region", + "position": { + "x": 42, + "y": 227 + }, + "size": { + "width": 477, + "height": 147 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "e64f5a25-8a40-4369-ac95-676840c7d08c", + "z": 7, + "parent": "6aa2fe43-83bb-45bf-9a87-760d5dde96a4", + "embeds": [ + "5ec0ad0b-ffbd-45f8-aa5b-baf8e1cf6037", + "53e27ccd-938d-454e-8ae1-2834804b794e", + "48d50c19-40de-4d09-afeb-ffbbf0953fa2", + "3104eb5a-50d0-4e4f-b119-f4765ec7cd14", + "cf29d38b-f8f2-447e-92c0-f707a2a32189", + "3e97cea1-50aa-479a-810b-7de05d3f0d2a" + ], + "attrs": { + "name": { + "fontSize": "9", + "text": "r1" + } + } + }, + { + "type": "State", + "position": { + "x": 102, + "y": 276 + }, + "size": { + "width": 139, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "3104eb5a-50d0-4e4f-b119-f4765ec7cd14", + "parent": "e64f5a25-8a40-4369-ac95-676840c7d08c", + "z": 8, + "attrs": { + "name": { + "text": "Idle" + }, + "specification": { + "text": "entry / brightness = 0", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 322, + "y": 276 + }, + "size": { + "width": 139, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "cf29d38b-f8f2-447e-92c0-f707a2a32189", + "parent": "e64f5a25-8a40-4369-ac95-676840c7d08c", + "z": 9, + "attrs": { + "name": { + "text": "TwilightDetected" + }, + "specification": { + "text": "entry / brightness = 1", + "fontSize": "9" + } + } + }, + { + "type": "Entry", + "position": { + "x": 57, + "y": 289 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "3e97cea1-50aa-479a-810b-7de05d3f0d2a", + "parent": "e64f5a25-8a40-4369-ac95-676840c7d08c", + "z": 10, + "embeds": [ + "d93f1f71-ed92-4771-be6e-3730bfcbb5e4" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 57, + "y": 304 + }, + "id": "d93f1f71-ed92-4771-be6e-3730bfcbb5e4", + "z": 11, + "parent": "3e97cea1-50aa-479a-810b-7de05d3f0d2a", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 664, + "y": 186 + }, + "size": { + "width": 522, + "height": 198 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "7b0b0978-50b0-4a8f-8a0b-1ce8b0176465", + "parent": "1598b19c-1a20-4398-8dc3-885e36b5747e", + "z": 12, + "embeds": [ + "0a5e80f0-2b3b-4e31-ad55-d79a52a1993d" + ], + "attrs": { + "name": { + "text": "MotionDetectionMode" + } + } + }, + { + "type": "Region", + "position": { + "x": 665, + "y": 226 + }, + "size": { + "width": 520, + "height": 157 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "0a5e80f0-2b3b-4e31-ad55-d79a52a1993d", + "z": 13, + "parent": "7b0b0978-50b0-4a8f-8a0b-1ce8b0176465", + "embeds": [ + "053c8814-ca7f-4ccc-acc4-e98f922977fd", + "ab85be75-887d-4dcf-bc19-dc7c985ba7c0", + "138769b5-830d-4a05-bc2f-596e4bf99bfa", + "46aad98b-5595-4d86-9875-5a458cfe728a", + "2ffdf8d5-aeb8-46c3-b92d-432ac05a0e75", + "d38f4ed6-20f5-4262-ae2f-3bfddc7ce6b6", + "3de40ce2-550b-41d4-a79e-48e6283dbf52" + ], + "attrs": { + "name": { + "fontSize": "9", + "text": "r1" + } + } + }, + { + "type": "State", + "position": { + "x": 725, + "y": 275 + }, + "size": { + "width": 139, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "2ffdf8d5-aeb8-46c3-b92d-432ac05a0e75", + "parent": "0a5e80f0-2b3b-4e31-ad55-d79a52a1993d", + "z": 14, + "attrs": { + "name": { + "text": "Idle" + }, + "specification": { + "text": "entry / brightness = 0", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 944, + "y": 275 + }, + "size": { + "width": 139, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "d38f4ed6-20f5-4262-ae2f-3bfddc7ce6b6", + "parent": "0a5e80f0-2b3b-4e31-ad55-d79a52a1993d", + "z": 15, + "attrs": { + "name": { + "text": "MotionDetected" + }, + "specification": { + "text": "entry / brightness = 1", + "fontSize": "9" + } + } + }, + { + "type": "Entry", + "position": { + "x": 686, + "y": 288 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "3de40ce2-550b-41d4-a79e-48e6283dbf52", + "parent": "0a5e80f0-2b3b-4e31-ad55-d79a52a1993d", + "z": 16, + "embeds": [ + "c852cab6-d984-445f-b8dc-7df2fbbdff56" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 686, + "y": 303 + }, + "id": "c852cab6-d984-445f-b8dc-7df2fbbdff56", + "z": 17, + "parent": "3de40ce2-550b-41d4-a79e-48e6283dbf52", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "Entry", + "position": { + "x": 697, + "y": 149 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "383dc32d-04af-45d2-ba13-2c6ba1219c09", + "parent": "1598b19c-1a20-4398-8dc3-885e36b5747e", + "z": 18, + "embeds": [ + "91d20e2a-630c-451c-9926-88b46ad8b949" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 697, + "y": 164 + }, + "id": "91d20e2a-630c-451c-9926-88b46ad8b949", + "z": 19, + "parent": "383dc32d-04af-45d2-ba13-2c6ba1219c09", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "Entry", + "position": { + "x": 81, + "y": 39 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "e110bc12-cf68-4138-9b2a-9e64d5455676", + "parent": "e68682aa-a5dc-40ec-925d-58e170c05bf2", + "z": 20, + "embeds": [ + "5d78a7cb-a736-4acd-ae8c-e6251969db5b" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 81, + "y": 54 + }, + "id": "5d78a7cb-a736-4acd-ae8c-e6251969db5b", + "z": 21, + "parent": "e110bc12-cf68-4138-9b2a-9e64d5455676", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "26.41509433962264%", + "rotate": true + } + }, + "id": "2ffdf8d5-aeb8-46c3-b92d-432ac05a0e75" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "3.3574706019888962%", + "dy": "26.41509433962264%", + "rotate": true + } + }, + "id": "d38f4ed6-20f5-4262-ae2f-3bfddc7ce6b6" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "sensor.motion", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "46aad98b-5595-4d86-9875-5a458cfe728a", + "z": 22, + "parent": "0a5e80f0-2b3b-4e31-ad55-d79a52a1993d", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "40.51122682861331%", + "dy": "98.49056603773593%", + "rotate": true + } + }, + "id": "d38f4ed6-20f5-4262-ae2f-3bfddc7ce6b6" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "43.22149877053773%", + "dy": "99.62264150943399%", + "rotate": true + } + }, + "id": "2ffdf8d5-aeb8-46c3-b92d-432ac05a0e75" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "after 30s", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "138769b5-830d-4a05-bc2f-596e4bf99bfa", + "z": 23, + "parent": "0a5e80f0-2b3b-4e31-ad55-d79a52a1993d", + "vertices": [ + { + "x": 1000.3106052917725, + "y": 352.4 + }, + { + "x": 785.0778832910474, + "y": 352.4 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "84.84889837218714%", + "dy": "0.4964047760407289%", + "rotate": true + } + }, + "id": "d18f0582-a359-477b-b1f2-759455997486" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "53.1733864401425%", + "dy": "50%", + "rotate": true + } + }, + "id": "dc220bfe-4a71-445d-b925-b38f7bf2fdb6" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.off_button", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "55661118-ceb1-432b-997e-dbe2e5a5fb34", + "z": 24, + "parent": "e68682aa-a5dc-40ec-925d-58e170c05bf2", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "74.98373599259793%", + "dy": "50%", + "rotate": true + } + }, + "id": "d18f0582-a359-477b-b1f2-759455997486" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "29.913313457386657%", + "dy": "50%", + "rotate": true + } + }, + "id": "d18f0582-a359-477b-b1f2-759455997486" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.on_button [brightness < 10]", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "2" + } + } + } + ], + "id": "5c6a7c15-bfd9-4a43-9795-3f0b4a2d4803", + "z": 25, + "parent": "e68682aa-a5dc-40ec-925d-58e170c05bf2", + "vertices": [ + { + "x": 639.476905109489, + "y": 593 + }, + { + "x": 575.476905109489, + "y": 593 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "75.47169811320755%", + "rotate": true + } + }, + "id": "d38f4ed6-20f5-4262-ae2f-3bfddc7ce6b6" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "96.50034810860996%", + "dy": "92.45283018867924%", + "rotate": true + } + }, + "id": "d38f4ed6-20f5-4262-ae2f-3bfddc7ce6b6" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "sensor.motion", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "2" + } + } + } + ], + "id": "ab85be75-887d-4dcf-bc19-dc7c985ba7c0", + "z": 26, + "parent": "0a5e80f0-2b3b-4e31-ad55-d79a52a1993d", + "vertices": [ + { + "x": 1150.1354838709678, + "y": 315 + }, + { + "x": 1150.1354838709678, + "y": 348 + }, + { + "x": 1078.1354838709678, + "y": 348 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "13.522012578616389%", + "rotate": true + } + }, + "id": "3104eb5a-50d0-4e4f-b119-f4765ec7cd14" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "13.522012578616389%", + "rotate": true + } + }, + "id": "cf29d38b-f8f2-447e-92c0-f707a2a32189" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "lum_sensor.dark", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "48d50c19-40de-4d09-afeb-ffbbf0953fa2", + "z": 27, + "parent": "e64f5a25-8a40-4369-ac95-676840c7d08c", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "56.381402340813935%", + "dy": "98.49056603773593%", + "rotate": true + } + }, + "id": "cf29d38b-f8f2-447e-92c0-f707a2a32189" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "39.32567378932674%", + "dy": "99.62264150943388%", + "rotate": true + } + }, + "id": "3104eb5a-50d0-4e4f-b119-f4765ec7cd14" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "lum_sensor.bright", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "53e27ccd-938d-454e-8ae1-2834804b794e", + "z": 28, + "parent": "e64f5a25-8a40-4369-ac95-676840c7d08c", + "vertices": [ + { + "x": 400.37014925373137, + "y": 348.4 + }, + { + "x": 156.66268656716417, + "y": 348.4 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "34.74053360872673%", + "rotate": true + } + }, + "id": "6aa2fe43-83bb-45bf-9a87-760d5dde96a4" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.05083147120114929%", + "dy": "33.49101170929609%", + "rotate": true + } + }, + "id": "7b0b0978-50b0-4a8f-8a0b-1ce8b0176465" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.mode_button", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "0b285518-4d4f-4851-8f76-1f7cf0a61927", + "z": 29, + "parent": "1598b19c-1a20-4398-8dc3-885e36b5747e", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.12155971484471627%", + "dy": "19.4467047494475%", + "rotate": true + } + }, + "id": "7b0b0978-50b0-4a8f-8a0b-1ce8b0176465" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "19.949189044630874%", + "rotate": true + } + }, + "id": "6aa2fe43-83bb-45bf-9a87-760d5dde96a4" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.mode_button", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "323aca6a-dc49-43a7-a952-e7ff75644820", + "z": 30, + "parent": "1598b19c-1a20-4398-8dc3-885e36b5747e", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "45.252024538900045%", + "dy": "50%", + "rotate": true + } + }, + "id": "dc220bfe-4a71-445d-b925-b38f7bf2fdb6" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "18.075164599037752%", + "dy": "0.45517514347906285%", + "rotate": true + } + }, + "id": "d18f0582-a359-477b-b1f2-759455997486" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "user.on_button", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "cc05b9c6-8e4a-4b95-b035-22b682303fe7", + "z": 31, + "parent": "e68682aa-a5dc-40ec-925d-58e170c05bf2", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "92.02321724709786%", + "dy": "60%", + "rotate": true + } + }, + "id": "3e97cea1-50aa-479a-810b-7de05d3f0d2a" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "8.710046887862847%", + "dy": "41.509433962264154%", + "rotate": true + } + }, + "id": "3104eb5a-50d0-4e4f-b119-f4765ec7cd14" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "5ec0ad0b-ffbd-45f8-aa5b-baf8e1cf6037", + "z": 32, + "parent": "e64f5a25-8a40-4369-ac95-676840c7d08c", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "98.27529021558955%", + "dy": "53.333333333333336%", + "rotate": true + } + }, + "id": "3de40ce2-550b-41d4-a79e-48e6283dbf52" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "5.02344393142204%", + "dy": "39.62264150943396%", + "rotate": true + } + }, + "id": "2ffdf8d5-aeb8-46c3-b92d-432ac05a0e75" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "053c8814-ca7f-4ccc-acc4-e98f922977fd", + "z": 33, + "parent": "0a5e80f0-2b3b-4e31-ad55-d79a52a1993d", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "57.49064952218305%", + "dy": "88.88888888888896%", + "rotate": true + } + }, + "id": "383dc32d-04af-45d2-ba13-2c6ba1219c09" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "7.973869239143191%", + "dy": "0.08417508417509374%", + "rotate": true + } + }, + "id": "7b0b0978-50b0-4a8f-8a0b-1ce8b0176465" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "d7ef98be-16e6-4c70-aa04-5364fa29979f", + "z": 34, + "parent": "1598b19c-1a20-4398-8dc3-885e36b5747e", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "96.29919517266026%", + "dy": "49.29447852760736%", + "rotate": true + } + }, + "id": "e110bc12-cf68-4138-9b2a-9e64d5455676" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "11.728467715271352%", + "dy": "0.05514058532426315%", + "rotate": true + } + }, + "id": "dc220bfe-4a71-445d-b925-b38f7bf2fdb6" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "c03ce275-a8dc-472f-b497-81165dbde55b", + "z": 35, + "parent": "e68682aa-a5dc-40ec-925d-58e170c05bf2", + "vertices": [ + { + "x": 157.38975855179808, + "y": 46.394171779141104 + } + ], + "attrs": {} + } + ] +} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.historystates/lightswitch_no_history-player/player.html b/org.yakindu.sct.examples.basic.historystates/lightswitch_no_history-player/player.html new file mode 100644 index 00000000..a40d8757 --- /dev/null +++ b/org.yakindu.sct.examples.basic.historystates/lightswitch_no_history-player/player.html @@ -0,0 +1,52 @@ + +sct-web-player demo + + + + + + + + + + + + + + + +
+ +
+ + + + + \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.orthogonality/index.html b/org.yakindu.sct.examples.basic.orthogonality/index.html index 74cdf6db..228a1215 100644 --- a/org.yakindu.sct.examples.basic.orthogonality/index.html +++ b/org.yakindu.sct.examples.basic.orthogonality/index.html @@ -1,45 +1,112 @@ - - -Orthogonal States - + + + Orthogonal States + + + +
-

Orthogonality

-

This example demonstrates the usage of orthogonal states as well as of forking and joining synchronization nodes. For more details, please also refer to our documentation.

- +

This example demonstrates the usage of orthogonal states as well as of forking and joining synchronization nodes. + For more details, please also refer to our documentation. +

+

The player toolbar

+

+ The embedded statechart's below can be controlled by the player's bottom toolbar. This toolbar allows to + start and stop the statechart with the play and stop buttons. The button to the right opens the + execution context which allows to raise events and set variables. +

+ + + + + + + + + + + + + + + + + + + + + +
ButtonsDescription
Start/stop the statechart execution.
Control the zoom level and open the statechart in fullscreen mode.
Open the execution context to watch/set variable values and to raise events.
+

Orthogonal regions

-

-YAKINDU Statechart Tools allows to specify orthogonal regions that are executed virtually concurrently. Orthogonal regions can be modeled either on top level, or within a composite state (or subdiagram). They allow to describe that the modeled system can be in multiple states simultaneously. -

-

-Let's take the simplified example of a keyboard controller. The user can enable caps lock and num lock. These are two independent functionalities, and the keyboard can have both enabled at the same time. -

-

- Orthogonal regions on top level. -

-

Forks and joins

- -

-Orthogonal regions can not only be defined on top level but also within composite states. The semantics explained above are the same. -The following example model uses a synchronization node to fork the execution flow into both orthogonal regions. After both regions have executed their state transitions, the execution flow is joined again by a synchronization node. A joining synchronization is only executed when all incoming transitions can be taken within the same run-to-completion cycle. For more details, please refer to our documentation on Synchronizations. -

-

- -

-

- Orthogonal states, forks and joins -

- +

+ itemis CREATE allows you to specify orthogonal regions that are executed virtually concurrently. Orthogonal + regions + can be modeled either on top level, or within a composite state (or subdiagram). They allow to describe that the + modeled system can be in multiple states simultaneously. +

+

+ Let's take the simplified example of a keyboard controller. The user can enable caps lock and num lock. These are + two independent functionalities, and the keyboard can have both enabled at the same time. +

+

+

+

+

Forks and joins

+ +

+ Orthogonal regions can not only be defined on top level but also within composite states. The semantics explained + above are the same. + The following example model uses a synchronization node to fork the execution flow into both orthogonal regions. + After both regions have executed their state transitions, the execution flow is joined again by a synchronization + node. A joining synchronization is only executed when all incoming transitions can be taken within the same + run-to-completion cycle. For more details, please refer to our documentation on Synchronizations. +

+

+ +

+

+

+

+ + - + \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/assets/bundle.js b/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/assets/bundle.js new file mode 100644 index 00000000..5404bf7c --- /dev/null +++ b/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/assets/bundle.js @@ -0,0 +1,522 @@ +var com; +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Instances represent state machine trace events. + * @param {com.yakindu.core.TraceEventType} type + * @param {*} machine + * @param {*} state + * @param {*} feature + * @param {*} value + * @class + */ + class TraceEvent { + constructor(type, machine, state, feature, value) { + if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && ((state != null) || state === null) && ((feature != null) || feature === null) && ((value != null) || value === null)) { + let __args = arguments; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + else if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && state === undefined && feature === undefined && value === undefined) { + let __args = arguments; + { + let __args = arguments; + let state = null; + let feature = null; + let value = null; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + } + else + throw new Error('invalid overload'); + } + getType() { + return this.type; + } + getMachine() { + return this.machine; + } + getState() { + return this.state; + } + getFeature() { + return this.feature; + } + getValue() { + return this.value; + } + } + core.TraceEvent = TraceEvent; + TraceEvent["__class"] = "com.yakindu.core.TraceEvent"; + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Trace event type enumeration. + * @enum + * @property {com.yakindu.core.TraceEventType} MACHINE_ENTER + * @property {com.yakindu.core.TraceEventType} MACHINE_EXIT + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_START + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_STOP + * @property {com.yakindu.core.TraceEventType} STATE_ENTERED + * @property {com.yakindu.core.TraceEventType} STATE_EXITED + * @property {com.yakindu.core.TraceEventType} STATE_TRANSITION + * @property {com.yakindu.core.TraceEventType} EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} VARIABLE_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_UNSET + * @class + */ + let TraceEventType; + (function (TraceEventType) { + TraceEventType[TraceEventType["MACHINE_ENTER"] = 0] = "MACHINE_ENTER"; + TraceEventType[TraceEventType["MACHINE_EXIT"] = 1] = "MACHINE_EXIT"; + TraceEventType[TraceEventType["MACHINE_RTS_START"] = 2] = "MACHINE_RTS_START"; + TraceEventType[TraceEventType["MACHINE_RTS_STOP"] = 3] = "MACHINE_RTS_STOP"; + TraceEventType[TraceEventType["STATE_ENTERED"] = 4] = "STATE_ENTERED"; + TraceEventType[TraceEventType["STATE_EXITED"] = 5] = "STATE_EXITED"; + TraceEventType[TraceEventType["STATE_TRANSITION"] = 6] = "STATE_TRANSITION"; + TraceEventType[TraceEventType["EVENT_RAISED"] = 7] = "EVENT_RAISED"; + TraceEventType[TraceEventType["VARIABLE_SET"] = 8] = "VARIABLE_SET"; + TraceEventType[TraceEventType["TIME_EVENT_RAISED"] = 9] = "TIME_EVENT_RAISED"; + TraceEventType[TraceEventType["TIME_EVENT_SET"] = 10] = "TIME_EVENT_SET"; + TraceEventType[TraceEventType["TIME_EVENT_UNSET"] = 11] = "TIME_EVENT_UNSET"; + })(TraceEventType = core.TraceEventType || (core.TraceEventType = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + var rx; + (function (rx) { + class Observable { + constructor() { + this.observers = ([]); + } + next(value) { + for (let index = 0; index < this.observers.length; index++) { + let observer = this.observers[index]; + { + observer.next(value); + } + } + } + subscribe(observer) { + return observer != null ? /* add */ (this.observers.push(observer) > 0) : false; + } + unsubscribe(observer) { + return observer != null ? /* remove */ (a => { let index = a.indexOf(observer); if (index >= 0) { + a.splice(index, 1); + return true; + } + else { + return false; + } })(this.observers) : false; + } + } + rx.Observable = Observable; + Observable["__class"] = "com.yakindu.core.rx.Observable"; + })(rx = core.rx || (core.rx = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +var sct; +(function (sct) { + var yakindu; + (function (yakindu) { + var io; + (function (io) { + class Statemachine { + constructor() { + this.stateVector = [null, null]; + this.trace = (new com.yakindu.core.rx.Observable()); + this.inEventQueue = ([]); + if (this.isExecuting === undefined) { + this.isExecuting = false; + } + if (this.stateConfVectorPosition === undefined) { + this.stateConfVectorPosition = 0; + } + if (this.pressCapsLock === undefined) { + this.pressCapsLock = false; + } + if (this.pressNumLock === undefined) { + this.pressNumLock = false; + } + for (let i = 0; i < 2; i++) { + { + this.stateVector[i] = Statemachine.State.$NULLSTATE$; + } + ; + } + this.clearInEvents(); + this.isExecuting = false; + } + getIsExecuting() { + return this.isExecuting; + } + setIsExecuting(value) { + this.isExecuting = value; + } + getStateConfVectorPosition() { + return this.stateConfVectorPosition; + } + setStateConfVectorPosition(value) { + this.stateConfVectorPosition = value; + } + enter() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_ENTER, this))); + this.enterSequence_CapsLock_default(); + this.enterSequence_NumLock_default(); + this.isExecuting = false; + } + exit() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_EXIT, this))); + this.exitSequence_CapsLock(); + this.exitSequence_NumLock(); + this.isExecuting = false; + } + /** + * @see IStatemachine#isActive() + * @return {boolean} + */ + isActive() { + return this.stateVector[0] !== Statemachine.State.$NULLSTATE$ || this.stateVector[1] !== Statemachine.State.$NULLSTATE$; + } + /** + * + * Always returns 'false' since this state machine can never become final. + * + * @see IStatemachine#isFinal() + * @return {boolean} + */ + isFinal() { + return false; + } + clearInEvents() { + this.pressCapsLock = false; + this.pressNumLock = false; + } + microStep() { + let transitioned = -1; + this.stateConfVectorPosition = 0; + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.CAPSLOCK_CAPSLOCK_OFF: + transitioned = this.capsLock_CapsLock_OFF_react(transitioned); + break; + case sct.yakindu.io.Statemachine.State.CAPSLOCK_CAPSLOCK_ON: + transitioned = this.capsLock_CapsLock_ON_react(transitioned); + break; + default: + break; + } + if (this.getStateConfVectorPosition() < 1) { + switch ((this.stateVector[1])) { + case sct.yakindu.io.Statemachine.State.NUMLOCK_NUMLOCK_OFF: + transitioned = this.numLock_NumLock_OFF_react(transitioned); + break; + case sct.yakindu.io.Statemachine.State.NUMLOCK_NUMLOCK_ON: + transitioned = this.numLock_NumLock_ON_react(transitioned); + break; + default: + break; + } + } + } + runCycle() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_START, this))); + this.nextEvent(); + do { + { + this.microStep(); + this.clearInEvents(); + this.nextEvent(); + } + } while (((this.pressCapsLock || this.pressNumLock))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_STOP, this))); + this.isExecuting = false; + } + nextEvent() { + if (!(this.inEventQueue.length == 0)) { + (target => (typeof target === 'function') ? target() : target.run())(/* poll */ (a => a.length == 0 ? null : a.shift())(this.inEventQueue)); + return; + } + } + /** + * Returns true if the given state is currently active otherwise false. + * @param {sct.yakindu.io.Statemachine.State} state + * @return {boolean} + */ + isStateActive(state) { + switch ((state)) { + case sct.yakindu.io.Statemachine.State.CAPSLOCK_CAPSLOCK_OFF: + return this.stateVector[0] === Statemachine.State.CAPSLOCK_CAPSLOCK_OFF; + case sct.yakindu.io.Statemachine.State.CAPSLOCK_CAPSLOCK_ON: + return this.stateVector[0] === Statemachine.State.CAPSLOCK_CAPSLOCK_ON; + case sct.yakindu.io.Statemachine.State.NUMLOCK_NUMLOCK_OFF: + return this.stateVector[1] === Statemachine.State.NUMLOCK_NUMLOCK_OFF; + case sct.yakindu.io.Statemachine.State.NUMLOCK_NUMLOCK_ON: + return this.stateVector[1] === Statemachine.State.NUMLOCK_NUMLOCK_ON; + default: + return false; + } + } + getTrace() { + return this.trace; + } + raisePressCapsLock() { + /* add */ (this.inEventQueue.push(() => { + this.pressCapsLock = true; + }) > 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this, null, Statemachine.Feature.PRESSCAPSLOCK, null))); + this.runCycle(); + } + raisePressNumLock() { + /* add */ (this.inEventQueue.push(() => { + this.pressNumLock = true; + }) > 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this, null, Statemachine.Feature.PRESSNUMLOCK, null))); + this.runCycle(); + } + enterSequence_CapsLock_CapsLock_OFF_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.CAPSLOCK_CAPSLOCK_OFF, null, null))); + this.stateVector[0] = Statemachine.State.CAPSLOCK_CAPSLOCK_OFF; + this.stateConfVectorPosition = 0; + } + enterSequence_CapsLock_CapsLock_ON_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.CAPSLOCK_CAPSLOCK_ON, null, null))); + this.stateVector[0] = Statemachine.State.CAPSLOCK_CAPSLOCK_ON; + this.stateConfVectorPosition = 0; + } + enterSequence_NumLock_NumLock_OFF_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.NUMLOCK_NUMLOCK_OFF, null, null))); + this.stateVector[1] = Statemachine.State.NUMLOCK_NUMLOCK_OFF; + this.stateConfVectorPosition = 1; + } + enterSequence_NumLock_NumLock_ON_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.NUMLOCK_NUMLOCK_ON, null, null))); + this.stateVector[1] = Statemachine.State.NUMLOCK_NUMLOCK_ON; + this.stateConfVectorPosition = 1; + } + enterSequence_CapsLock_default() { + this.react_CapsLock__entry_Default(); + } + enterSequence_NumLock_default() { + this.react_NumLock__entry_Default(); + } + exitSequence_CapsLock_CapsLock_OFF() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.stateConfVectorPosition = 0; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.CAPSLOCK_CAPSLOCK_OFF, null, null))); + } + exitSequence_CapsLock_CapsLock_ON() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.stateConfVectorPosition = 0; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.CAPSLOCK_CAPSLOCK_ON, null, null))); + } + exitSequence_NumLock_NumLock_OFF() { + this.stateVector[1] = Statemachine.State.$NULLSTATE$; + this.stateConfVectorPosition = 1; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.NUMLOCK_NUMLOCK_OFF, null, null))); + } + exitSequence_NumLock_NumLock_ON() { + this.stateVector[1] = Statemachine.State.$NULLSTATE$; + this.stateConfVectorPosition = 1; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.NUMLOCK_NUMLOCK_ON, null, null))); + } + exitSequence_CapsLock() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.CAPSLOCK_CAPSLOCK_OFF: + this.exitSequence_CapsLock_CapsLock_OFF(); + break; + case sct.yakindu.io.Statemachine.State.CAPSLOCK_CAPSLOCK_ON: + this.exitSequence_CapsLock_CapsLock_ON(); + break; + default: + break; + } + } + exitSequence_NumLock() { + switch ((this.stateVector[1])) { + case sct.yakindu.io.Statemachine.State.NUMLOCK_NUMLOCK_OFF: + this.exitSequence_NumLock_NumLock_OFF(); + break; + case sct.yakindu.io.Statemachine.State.NUMLOCK_NUMLOCK_ON: + this.exitSequence_NumLock_NumLock_ON(); + break; + default: + break; + } + } + react_CapsLock__entry_Default() { + this.enterSequence_CapsLock_CapsLock_OFF_default(); + } + react_NumLock__entry_Default() { + this.enterSequence_NumLock_NumLock_OFF_default(); + } + react(transitioned_before) { + return transitioned_before; + } + capsLock_CapsLock_OFF_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.pressCapsLock) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.CAPSLOCK_CAPSLOCK_OFF, null, 0))); + this.exitSequence_CapsLock_CapsLock_OFF(); + this.enterSequence_CapsLock_CapsLock_ON_default(); + transitioned_after = 0; + } + } + return transitioned_after; + } + capsLock_CapsLock_ON_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.pressCapsLock) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.CAPSLOCK_CAPSLOCK_ON, null, 0))); + this.exitSequence_CapsLock_CapsLock_ON(); + this.enterSequence_CapsLock_CapsLock_OFF_default(); + transitioned_after = 0; + } + } + return transitioned_after; + } + numLock_NumLock_OFF_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 1) { + if (this.pressNumLock) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.NUMLOCK_NUMLOCK_OFF, null, 0))); + this.exitSequence_NumLock_NumLock_OFF(); + this.enterSequence_NumLock_NumLock_ON_default(); + this.react(0); + transitioned_after = 1; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + numLock_NumLock_ON_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 1) { + if (this.pressNumLock) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.NUMLOCK_NUMLOCK_ON, null, 0))); + this.exitSequence_NumLock_NumLock_ON(); + this.enterSequence_NumLock_NumLock_OFF_default(); + this.react(0); + transitioned_after = 1; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + } + io.Statemachine = Statemachine; + Statemachine["__class"] = "sct.yakindu.io.Statemachine"; + Statemachine["__interfaces"] = ["com.yakindu.core.IStatemachine"]; + (function (Statemachine) { + let State; + (function (State) { + State[State["CAPSLOCK_CAPSLOCK_OFF"] = 0] = "CAPSLOCK_CAPSLOCK_OFF"; + State[State["CAPSLOCK_CAPSLOCK_ON"] = 1] = "CAPSLOCK_CAPSLOCK_ON"; + State[State["NUMLOCK_NUMLOCK_OFF"] = 2] = "NUMLOCK_NUMLOCK_OFF"; + State[State["NUMLOCK_NUMLOCK_ON"] = 3] = "NUMLOCK_NUMLOCK_ON"; + State[State["$NULLSTATE$"] = 4] = "$NULLSTATE$"; + })(State = Statemachine.State || (Statemachine.State = {})); + /** + * Enumeration of all features of the statechart + * @enum + * @property {sct.yakindu.io.Statemachine.Feature} NO_FEATURE + * @property {sct.yakindu.io.Statemachine.Feature} PRESSCAPSLOCK + * @property {sct.yakindu.io.Statemachine.Feature} PRESSNUMLOCK + * @class + */ + let Feature; + (function (Feature) { + Feature[Feature["NO_FEATURE"] = 0] = "NO_FEATURE"; + Feature[Feature["PRESSCAPSLOCK"] = 1] = "PRESSCAPSLOCK"; + Feature[Feature["PRESSNUMLOCK"] = 2] = "PRESSNUMLOCK"; + })(Feature = Statemachine.Feature || (Statemachine.Feature = {})); + })(Statemachine = io.Statemachine || (io.Statemachine = {})); + })(io = yakindu.io || (yakindu.io = {})); + })(yakindu = sct.yakindu || (sct.yakindu = {})); +})(sct || (sct = {})); diff --git a/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/assets/context.json.js b/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/assets/context.json.js new file mode 100644 index 00000000..dd81ca3e --- /dev/null +++ b/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/assets/context.json.js @@ -0,0 +1 @@ +const contextJson = {"elements":[{"elements":[{"kind":"event","name":"pressCapsLock","fqName":"pressCapsLock","featureId":"PRESSCAPSLOCK","writable":true},{"kind":"event","name":"pressNumLock","fqName":"pressNumLock","featureId":"PRESSNUMLOCK","writable":true}],"kind":"composite","name":"default","featureId":"","writable":true}]} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/assets/hashes.json.js b/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/assets/hashes.json.js new file mode 100644 index 00000000..df90dd4d --- /dev/null +++ b/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/assets/hashes.json.js @@ -0,0 +1 @@ +const hashesJson = {"CAPSLOCK_CAPSLOCK_OFF":"d653b839-e17d-42c2-bd9d-f68abc323a92","CAPSLOCK_CAPSLOCK_OFF_tr0":"e3b3686c-beeb-4a1b-8053-b7820c77300b","CAPSLOCK_CAPSLOCK_ON_tr0":"47ab051c-ac93-4b20-90d4-2ce765efda2a","CAPSLOCK_CAPSLOCK_ON":"9809ceb9-ec98-4d94-a4bf-ac28d6a707b8","NUMLOCK_NUMLOCK_ON":"f5ee293a-a675-4e15-8ea1-68ed4ba611c4","NUMLOCK_NUMLOCK_ON_tr0":"2429150a-158c-4893-be03-8ab6b88d62b4","NUMLOCK_NUMLOCK_OFF_tr0":"779432d0-1e28-45a8-8c3c-998cd1bc2d25","NUMLOCK_NUMLOCK_OFF":"f6d580f2-1ddb-4019-8cd7-3b485ce0c754"} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/assets/statemachine.svg.js b/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/assets/statemachine.svg.js new file mode 100644 index 00000000..f97ea26c --- /dev/null +++ b/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/assets/statemachine.svg.js @@ -0,0 +1 @@ +let svg = `CapsLock1-CapsLock_OFFCapsLock_ONNumLock2-NumLock_OFFNumLock_ON-1pressCapsLockpressCapsLock1pressCapsLockpressCapsLock1-1pressNumLockpressNumLock1pressNumLockpressNumLock1` \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/assets/ypi.css b/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/assets/ypi.css new file mode 100644 index 00000000..771aaa11 --- /dev/null +++ b/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/assets/ypi.css @@ -0,0 +1,113 @@ +/*! + * itemis CREATE Player Styles + * Copyright 2021 itemis AG + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ + + + /*! + * Style definitions follow BEM pattern using and additional 'y' namespace (for itemis CREATE). + */ +.y-declaration { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; + background-color: #eee; + font-family: 'Courier New', Courier, monospace; +} + + +.y-entry { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; +} + +.y-entry:after { + content: ' \25CF '; + font-size: larger; +} + +.y-state { + background-color: rgb(209, 223, 238); + padding: 3px; + border: 0.5pt;; + border: 0.5pt; + border-radius: 4px; + border-color: #bbb; + font-family: 'Courier New', Courier, monospace; +} + +.y-state--active { + background-color: rgb(244, 215, 66); +} + +.y-state--inactive { + background-color: rgb(209, 223, 238); +} + +.y-variable{ + background-color: #eee; + border-color: #aaa; + border: 0.5pt; + border: 0.5pt; + border-radius: 2px; + font-family: 'Courier New', Courier, monospace; +} + +.y-variable::after { + color: #aaa; + content: attr(value); + font-family: 'Courier New', Courier, monospace; +} + +.y-do-enter { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; +} + +.y-do-enter:before { + content: ' \2192 '; +} + +.y-do-exit { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer +} + +.y-do-exit:before { + content: ' \2192 '; +} + +.y-do-raise { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; + white-space: nowrap; +} + +.y-do-raise:before { + content: ' \2192 '; +} + +button.y-do-raise:before { + content: ''; +} + +button.y-do-raise { + cursor: pointer; +} + +.y-do--over { + color: blue; + background-color: #eee; + cursor: pointer; +} + +.y-player { + border-style: solid; + border-width: 1px; + border-color: ; +} diff --git a/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/index.html b/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/index.html new file mode 100644 index 00000000..a2607c4c --- /dev/null +++ b/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/index.html @@ -0,0 +1,251 @@ + + +sct-web-player demo + + + + + + + +
+

How to embed your statechart player

+

+ This document describes how to embed your statechart player into an arbitrary HTML document. + The statechart player itself is encapsulated in player.html file. This HTML file can + be embedded into another document as an HTML iframe. Furthermore, it is possible + to communicate with the embedded statechart by sending and receiving messages in a well-defined + format. +

+ +
+ +
+

The player toolbar

+

+ The embedded statechart can be controlled by the player's bottom toolbar. This toolbar allows to + start and stop the statechart with the play and stop buttons. The button to the right opens the + execution context which allows to raise events and set variables. +

+ + + + + + + + + + + + + + + + + + + + + +
ButtonsDescription
Start/stop the statechart execution.
Control the zoom level and open the statechart in fullscreen mode.
Open the execution context to watch/set variable values and to raise events.
+

Custom control elements

+

+ In addition to the functionality of the player toolbar, it is possible to create custom UI elements + to control the statechart. The chapters below show the various possibilities for the embedded statechart. + Play around with the statechart and see how these values and colors change. +

+
Enter / exit statechart
+

+

+ Click on enter to enter the statechart. This is equivalent to clicking the play button. +
+
+ Click on exit to exit the statechart. This is equivalent to clicking the stop button. +
+

+
Raise events
+

+ This is a list of all events defined in the statechart's interfaces (if none events are defined, this list is empty). You can click on the events to raise them on the statechart: +

+ pressCapsLock + pressNumLock +
+

+
Detect state changes
+

+ This is a list of all states with their corresponding activity status: +

+ CapsLock_OFF + CapsLock_ON + NumLock_OFF + NumLock_ON +
+

+
Setting variable values
+

+ This is a list of all variables defined in the statechart's interfaces (if none variables are defined, this list is empty). You can change the values and thereby directly set them on the statechart: +

+

Embedding the player

+

+ In order to embed the statechart player into a document use the HTML iframe tag like the following: +

+            
+            <iframe src="player.html?start=true" width="100%" height="500px" id="statechart"></iframe>
+            
+          
+ + + + + + + + + + + + + + + + + + + + + +
AttributeDescription
srcDefines the link to the player file. The parameter start allows to define whether the statechart should be entered when the page is loaded. The default value is false.
width / heightDefines the dimensions of the iframe. For a list of all available attributes, see also here.
idThis is required in order to access the embedded statechart for sending messages (see next chapter).
+

+ +

Sending messages to the statechart

+

+ In order to control the statechart with your custom UI elements you need to send corresponding messages to it. Messages are sent with the postMessage function on the iframe's content window. The example below demonstrates how to raise the artificial event myEvent: +

+              
+                var remoteframe = document.getElementById("statechart");
+                remoteframe.contentWindow.postMessage(
+                  {
+                    cmd: "raiseEvent",
+                    eventId: "myEvent",
+                  },
+                  "*"
+                );
+              
+            
+ The message transmitted via postMessage has a well-defined structure which is parsed by the statechart player. The cmd property defines the type of the message. It can be raiseEvent, enter, exit or changeValue. Depending on the command used, further properties are required. For example, in order to raise an event, we also need to specify the event's ID. +

+

Receiving messages from the statechart

+

+ Besides sending messages to the embedded statechart, the statechart itself sends messages back when its state or one of its values changes. These messages are transported by the message event one can subscribe to as the following code snippet shows: +

+              
+                window.addEventListener("message", (event) => {
+                  var data = event.data;
+                  switch (data.cmd) {
+                    case "stateEntered":
+                      console.log("State entered " + data.stateId);
+                      break;
+                    case "stateExited":
+                      console.log("State exited " + data.stateId);
+                      break;
+                    case "valueChanged":
+                      console.log("Value changed  " + data.varId + " " + data.value);
+                      break;
+                  }
+                });
+              
+            
+ Every message sent by the statechart contains a cmd property that defines the type of change that is reported. It can be stateEntered, stateExited or valueChanged. Depending on the cmd value, the message holds furter properties to track the affected state or variable. Please check the source code of this file for more information. +

+
+ + + + + diff --git a/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/model.scm b/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/model.scm new file mode 100644 index 00000000..50606c0f --- /dev/null +++ b/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/model.scm @@ -0,0 +1,592 @@ +{ + "cells": [ + { + "position": { + "x": 0, + "y": 0 + }, + "size": { + "height": 10, + "width": 10 + }, + "angle": 0, + "type": "Statechart", + "id": "2f231437-8283-45e3-8679-2a463f103676", + "linkable": false, + "z": 1, + "attrs": { + "name": { + "text": "keyboard" + }, + "specification": { + "text": "@CycleBased(200)\n\ninterface:\n\tin event pressCapsLock\n\tin event pressNumLock\n" + } + } + }, + { + "type": "Region", + "position": { + "x": 8, + "y": 0 + }, + "size": { + "width": 278, + "height": 221 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "5adcb244-fac9-4b05-bcbd-b513453db02e", + "z": 2, + "embeds": [ + "47ab051c-ac93-4b20-90d4-2ce765efda2a", + "e3b3686c-beeb-4a1b-8053-b7820c77300b", + "49fd8005-3b8e-48df-8a58-3a25c8624be3", + "8b558cc5-660f-4b4d-938a-6daa35360456", + "d653b839-e17d-42c2-bd9d-f68abc323a92", + "9809ceb9-ec98-4d94-a4bf-ac28d6a707b8" + ], + "attrs": { + "priority": { + "text": 1 + }, + "name": { + "fontSize": "9", + "text": "CapsLock" + } + } + }, + { + "type": "Entry", + "position": { + "x": 36, + "y": 51 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "8b558cc5-660f-4b4d-938a-6daa35360456", + "parent": "5adcb244-fac9-4b05-bcbd-b513453db02e", + "z": 3, + "embeds": [ + "ecfbf5e1-fc45-434f-9341-779533934870" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 36, + "y": 66 + }, + "id": "ecfbf5e1-fc45-434f-9341-779533934870", + "z": 4, + "parent": "8b558cc5-660f-4b4d-938a-6daa35360456", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 85, + "y": 35 + }, + "size": { + "width": 85, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "d653b839-e17d-42c2-bd9d-f68abc323a92", + "parent": "5adcb244-fac9-4b05-bcbd-b513453db02e", + "z": 5, + "attrs": { + "body": { + "fill": "#F5D82C", + "oldFill": "#CEDCEA", + "oldStroke": "#F2F2F2" + }, + "name": { + "text": "CapsLock_OFF" + } + } + }, + { + "type": "State", + "position": { + "x": 85, + "y": 142 + }, + "size": { + "width": 79, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "9809ceb9-ec98-4d94-a4bf-ac28d6a707b8", + "parent": "5adcb244-fac9-4b05-bcbd-b513453db02e", + "z": 6, + "attrs": { + "body": { + "oldFill": "#CEDCEA", + "oldStroke": "#F2F2F2" + }, + "name": { + "text": "CapsLock_ON" + } + } + }, + { + "type": "Region", + "position": { + "x": 280, + "y": 0 + }, + "size": { + "width": 261, + "height": 221 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "c7f43efe-ca1f-4986-a4b8-34583c5d46c2", + "z": 7, + "embeds": [ + "2429150a-158c-4893-be03-8ab6b88d62b4", + "779432d0-1e28-45a8-8c3c-998cd1bc2d25", + "2c6182bb-fbe2-4d8d-9b33-7cbad41cdef1", + "04218c71-4503-48b5-8b5d-547b313b93d1", + "f6d580f2-1ddb-4019-8cd7-3b485ce0c754", + "f5ee293a-a675-4e15-8ea1-68ed4ba611c4" + ], + "attrs": { + "priority": { + "text": 2 + }, + "name": { + "fontSize": "9", + "text": "NumLock" + } + } + }, + { + "type": "Entry", + "position": { + "x": 303, + "y": 52 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "04218c71-4503-48b5-8b5d-547b313b93d1", + "parent": "c7f43efe-ca1f-4986-a4b8-34583c5d46c2", + "z": 8, + "embeds": [ + "6d8cca5e-7281-4453-9d1a-e6886b7a015f" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 303, + "y": 67 + }, + "id": "6d8cca5e-7281-4453-9d1a-e6886b7a015f", + "z": 9, + "parent": "04218c71-4503-48b5-8b5d-547b313b93d1", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 361, + "y": 36 + }, + "size": { + "width": 79, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "f6d580f2-1ddb-4019-8cd7-3b485ce0c754", + "parent": "c7f43efe-ca1f-4986-a4b8-34583c5d46c2", + "z": 10, + "attrs": { + "body": { + "fill": "#F5D82C", + "oldFill": "#CEDCEA", + "oldStroke": "#F2F2F2" + }, + "name": { + "text": "NumLock_OFF" + } + } + }, + { + "type": "State", + "position": { + "x": 362, + "y": 139 + }, + "size": { + "width": 74, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "f5ee293a-a675-4e15-8ea1-68ed4ba611c4", + "parent": "c7f43efe-ca1f-4986-a4b8-34583c5d46c2", + "z": 11, + "attrs": { + "body": { + "oldFill": "#CEDCEA", + "oldStroke": "#F2F2F2" + }, + "name": { + "text": "NumLock_ON" + } + } + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "72.22222222222224%", + "dy": "50.00000000000004%", + "rotate": true + } + }, + "id": "8b558cc5-660f-4b4d-938a-6daa35360456" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "44.33962264150944%", + "rotate": true + } + }, + "id": "d653b839-e17d-42c2-bd9d-f68abc323a92" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "49fd8005-3b8e-48df-8a58-3a25c8624be3", + "z": 12, + "parent": "5adcb244-fac9-4b05-bcbd-b513453db02e", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "18.62745098039217%", + "dy": "95.28301886792453%", + "rotate": true + } + }, + "id": "d653b839-e17d-42c2-bd9d-f68abc323a92" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "20.042194092827017%", + "dy": "4.716981132075472%", + "rotate": true + } + }, + "id": "9809ceb9-ec98-4d94-a4bf-ac28d6a707b8" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "pressCapsLock", + "fontSize": "9" + } + }, + "position": { + "distance": 0.5370370370370371, + "offset": 51.82999999999999, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "e3b3686c-beeb-4a1b-8053-b7820c77300b", + "z": 13, + "parent": "5adcb244-fac9-4b05-bcbd-b513453db02e", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "81.28874303276554%", + "dy": "3.7735849056603774%", + "rotate": true + } + }, + "id": "9809ceb9-ec98-4d94-a4bf-ac28d6a707b8" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "75.55071411280561%", + "dy": "96.22641509433963%", + "rotate": true + } + }, + "id": "d653b839-e17d-42c2-bd9d-f68abc323a92" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "pressCapsLock", + "fontSize": "9" + } + }, + "position": { + "offset": 52.78, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "47ab051c-ac93-4b20-90d4-2ce765efda2a", + "z": 14, + "parent": "5adcb244-fac9-4b05-bcbd-b513453db02e", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "84.95314591700132%", + "dy": "48.88888888888891%", + "rotate": true + } + }, + "id": "04218c71-4503-48b5-8b5d-547b313b93d1" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "44.02515723270441%", + "rotate": true + } + }, + "id": "f6d580f2-1ddb-4019-8cd7-3b485ce0c754" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "2c6182bb-fbe2-4d8d-9b33-7cbad41cdef1", + "z": 15, + "parent": "c7f43efe-ca1f-4986-a4b8-34583c5d46c2", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "16.77240608001628%", + "dy": "92.45283018867924%", + "rotate": true + } + }, + "id": "f6d580f2-1ddb-4019-8cd7-3b485ce0c754" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "16.55432540974711%", + "dy": "9.433962264150944%", + "rotate": true + } + }, + "id": "f5ee293a-a675-4e15-8ea1-68ed4ba611c4" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "pressNumLock", + "fontSize": "9" + } + }, + "position": { + "distance": 0.52, + "offset": -76.75, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "779432d0-1e28-45a8-8c3c-998cd1bc2d25", + "z": 16, + "parent": "c7f43efe-ca1f-4986-a4b8-34583c5d46c2", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "60.80484098556384%", + "dy": "4.402515723270458%", + "rotate": true + } + }, + "id": "f5ee293a-a675-4e15-8ea1-68ed4ba611c4" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "58.2222561130598%", + "dy": "97.48427672955972%", + "rotate": true + } + }, + "id": "f6d580f2-1ddb-4019-8cd7-3b485ce0c754" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "pressNumLock", + "fontSize": "9" + } + }, + "position": { + "distance": 0.52, + "offset": -81, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "2429150a-158c-4893-be03-8ab6b88d62b4", + "z": 17, + "parent": "c7f43efe-ca1f-4986-a4b8-34583c5d46c2", + "attrs": {} + } + ] +} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/player.html b/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/player.html new file mode 100644 index 00000000..a40d8757 --- /dev/null +++ b/org.yakindu.sct.examples.basic.orthogonality/keyboard-player/player.html @@ -0,0 +1,52 @@ + +sct-web-player demo + + + + + + + + + + + + + + + +
+ +
+ + + + + \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/assets/bundle.js b/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/assets/bundle.js new file mode 100644 index 00000000..eb5bf99f --- /dev/null +++ b/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/assets/bundle.js @@ -0,0 +1,671 @@ +var com; +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Instances represent state machine trace events. + * @param {com.yakindu.core.TraceEventType} type + * @param {*} machine + * @param {*} state + * @param {*} feature + * @param {*} value + * @class + */ + class TraceEvent { + constructor(type, machine, state, feature, value) { + if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && ((state != null) || state === null) && ((feature != null) || feature === null) && ((value != null) || value === null)) { + let __args = arguments; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + else if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && state === undefined && feature === undefined && value === undefined) { + let __args = arguments; + { + let __args = arguments; + let state = null; + let feature = null; + let value = null; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + } + else + throw new Error('invalid overload'); + } + getType() { + return this.type; + } + getMachine() { + return this.machine; + } + getState() { + return this.state; + } + getFeature() { + return this.feature; + } + getValue() { + return this.value; + } + } + core.TraceEvent = TraceEvent; + TraceEvent["__class"] = "com.yakindu.core.TraceEvent"; + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Trace event type enumeration. + * @enum + * @property {com.yakindu.core.TraceEventType} MACHINE_ENTER + * @property {com.yakindu.core.TraceEventType} MACHINE_EXIT + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_START + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_STOP + * @property {com.yakindu.core.TraceEventType} STATE_ENTERED + * @property {com.yakindu.core.TraceEventType} STATE_EXITED + * @property {com.yakindu.core.TraceEventType} STATE_TRANSITION + * @property {com.yakindu.core.TraceEventType} EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} VARIABLE_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_UNSET + * @class + */ + let TraceEventType; + (function (TraceEventType) { + TraceEventType[TraceEventType["MACHINE_ENTER"] = 0] = "MACHINE_ENTER"; + TraceEventType[TraceEventType["MACHINE_EXIT"] = 1] = "MACHINE_EXIT"; + TraceEventType[TraceEventType["MACHINE_RTS_START"] = 2] = "MACHINE_RTS_START"; + TraceEventType[TraceEventType["MACHINE_RTS_STOP"] = 3] = "MACHINE_RTS_STOP"; + TraceEventType[TraceEventType["STATE_ENTERED"] = 4] = "STATE_ENTERED"; + TraceEventType[TraceEventType["STATE_EXITED"] = 5] = "STATE_EXITED"; + TraceEventType[TraceEventType["STATE_TRANSITION"] = 6] = "STATE_TRANSITION"; + TraceEventType[TraceEventType["EVENT_RAISED"] = 7] = "EVENT_RAISED"; + TraceEventType[TraceEventType["VARIABLE_SET"] = 8] = "VARIABLE_SET"; + TraceEventType[TraceEventType["TIME_EVENT_RAISED"] = 9] = "TIME_EVENT_RAISED"; + TraceEventType[TraceEventType["TIME_EVENT_SET"] = 10] = "TIME_EVENT_SET"; + TraceEventType[TraceEventType["TIME_EVENT_UNSET"] = 11] = "TIME_EVENT_UNSET"; + })(TraceEventType = core.TraceEventType || (core.TraceEventType = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + var rx; + (function (rx) { + class Observable { + constructor() { + this.observers = ([]); + } + next(value) { + for (let index = 0; index < this.observers.length; index++) { + let observer = this.observers[index]; + { + observer.next(value); + } + } + } + subscribe(observer) { + return observer != null ? /* add */ (this.observers.push(observer) > 0) : false; + } + unsubscribe(observer) { + return observer != null ? /* remove */ (a => { let index = a.indexOf(observer); if (index >= 0) { + a.splice(index, 1); + return true; + } + else { + return false; + } })(this.observers) : false; + } + } + rx.Observable = Observable; + Observable["__class"] = "com.yakindu.core.rx.Observable"; + })(rx = core.rx || (core.rx = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +var sct; +(function (sct) { + var yakindu; + (function (yakindu) { + var io; + (function (io) { + class Statemachine { + constructor() { + this.stateVector = [null, null]; + this.trace = (new com.yakindu.core.rx.Observable()); + this.inEventQueue = ([]); + if (this.isExecuting === undefined) { + this.isExecuting = false; + } + if (this.stateConfVectorPosition === undefined) { + this.stateConfVectorPosition = 0; + } + if (this.proceed === undefined) { + this.proceed = false; + } + if (this.pa === undefined) { + this.pa = false; + } + if (this.pb === undefined) { + this.pb = false; + } + for (let i = 0; i < 2; i++) { + { + this.stateVector[i] = Statemachine.State.$NULLSTATE$; + } + ; + } + this.clearInEvents(); + this.isExecuting = false; + } + getIsExecuting() { + return this.isExecuting; + } + setIsExecuting(value) { + this.isExecuting = value; + } + getStateConfVectorPosition() { + return this.stateConfVectorPosition; + } + setStateConfVectorPosition(value) { + this.stateConfVectorPosition = value; + } + enter() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_ENTER, this))); + this.enterSequence_main_region_default(); + this.isExecuting = false; + } + exit() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_EXIT, this))); + this.exitSequence_main_region(); + this.isExecuting = false; + } + /** + * @see IStatemachine#isActive() + * @return {boolean} + */ + isActive() { + return this.stateVector[0] !== Statemachine.State.$NULLSTATE$ || this.stateVector[1] !== Statemachine.State.$NULLSTATE$; + } + /** + * + * @see IStatemachine#isFinal() + * @return {boolean} + */ + isFinal() { + return (this.stateVector[0] === Statemachine.State.MAIN_REGION__FINAL_) && (this.stateVector[1] === Statemachine.State.$NULLSTATE$); + } + clearInEvents() { + this.proceed = false; + this.pa = false; + this.pb = false; + } + microStep() { + let transitioned = -1; + this.stateConfVectorPosition = 0; + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_PROCESS_R1_LINE_A_1: + transitioned = this.main_region_Process_r1_Line_A_1_react(transitioned); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_PROCESS_R1_LINE_A_2: + transitioned = this.main_region_Process_r1_Line_A_2_react(transitioned); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_INITIALIZE: + transitioned = this.main_region_Initialize_react(transitioned); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_CLEANUP: + transitioned = this.main_region_Cleanup_react(transitioned); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION__FINAL_: + transitioned = this.main_region__final__react(transitioned); + break; + default: + break; + } + if (this.getStateConfVectorPosition() < 1) { + switch ((this.stateVector[1])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_PROCESS_R2_LINE_B_1: + transitioned = this.main_region_Process_r2_Line_B_1_react(transitioned); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_PROCESS_R2_LINE_B_2: + transitioned = this.main_region_Process_r2_Line_B_2_react(transitioned); + break; + default: + break; + } + } + } + runCycle() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_START, this))); + this.nextEvent(); + do { + { + this.microStep(); + this.clearInEvents(); + this.nextEvent(); + } + } while ((((this.proceed || this.pa) || this.pb))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_STOP, this))); + this.isExecuting = false; + } + nextEvent() { + if (!(this.inEventQueue.length == 0)) { + (target => (typeof target === 'function') ? target() : target.run())(/* poll */ (a => a.length == 0 ? null : a.shift())(this.inEventQueue)); + return; + } + } + /** + * Returns true if the given state is currently active otherwise false. + * @param {sct.yakindu.io.Statemachine.State} state + * @return {boolean} + */ + isStateActive(state) { + switch ((state)) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_PROCESS: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_PROCESS]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_PROCESS_R2_LINE_B_2]]; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_PROCESS_R1_LINE_A_1: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_PROCESS_R1_LINE_A_1; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_PROCESS_R1_LINE_A_2: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_PROCESS_R1_LINE_A_2; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_PROCESS_R2_LINE_B_1: + return this.stateVector[1] === Statemachine.State.MAIN_REGION_PROCESS_R2_LINE_B_1; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_PROCESS_R2_LINE_B_2: + return this.stateVector[1] === Statemachine.State.MAIN_REGION_PROCESS_R2_LINE_B_2; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_INITIALIZE: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_INITIALIZE; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_CLEANUP: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_CLEANUP; + case sct.yakindu.io.Statemachine.State.MAIN_REGION__FINAL_: + return this.stateVector[0] === Statemachine.State.MAIN_REGION__FINAL_; + default: + return false; + } + } + getTrace() { + return this.trace; + } + raiseProceed() { + /* add */ (this.inEventQueue.push(() => { + this.proceed = true; + }) > 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this, null, Statemachine.Feature.PROCEED, null))); + this.runCycle(); + } + raisePa() { + /* add */ (this.inEventQueue.push(() => { + this.pa = true; + }) > 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this, null, Statemachine.Feature.PA, null))); + this.runCycle(); + } + raisePb() { + /* add */ (this.inEventQueue.push(() => { + this.pb = true; + }) > 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this, null, Statemachine.Feature.PB, null))); + this.runCycle(); + } + enterSequence_main_region_Process_r1_Line_A_1_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_PROCESS_R1_LINE_A_1, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_PROCESS_R1_LINE_A_1; + this.stateConfVectorPosition = 0; + } + enterSequence_main_region_Process_r1_Line_A_2_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_PROCESS_R1_LINE_A_2, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_PROCESS_R1_LINE_A_2; + this.stateConfVectorPosition = 0; + } + enterSequence_main_region_Process_r2_Line_B_1_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_PROCESS_R2_LINE_B_1, null, null))); + this.stateVector[1] = Statemachine.State.MAIN_REGION_PROCESS_R2_LINE_B_1; + this.stateConfVectorPosition = 1; + } + enterSequence_main_region_Process_r2_Line_B_2_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_PROCESS_R2_LINE_B_2, null, null))); + this.stateVector[1] = Statemachine.State.MAIN_REGION_PROCESS_R2_LINE_B_2; + this.stateConfVectorPosition = 1; + } + enterSequence_main_region_Initialize_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_INITIALIZE, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_INITIALIZE; + this.stateConfVectorPosition = 0; + } + enterSequence_main_region_Cleanup_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_CLEANUP, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_CLEANUP; + this.stateConfVectorPosition = 0; + } + enterSequence_main_region__final__default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION__FINAL_, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION__FINAL_; + this.stateConfVectorPosition = 0; + } + enterSequence_main_region_default() { + this.react_main_region__entry_Default(); + } + exitSequence_main_region_Process() { + this.exitSequence_main_region_Process_r1(); + this.exitSequence_main_region_Process_r2(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_PROCESS, null, null))); + } + exitSequence_main_region_Process_r1_Line_A_1() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.stateConfVectorPosition = 0; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_PROCESS_R1_LINE_A_1, null, null))); + } + exitSequence_main_region_Process_r1_Line_A_2() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.stateConfVectorPosition = 0; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_PROCESS_R1_LINE_A_2, null, null))); + } + exitSequence_main_region_Process_r2_Line_B_1() { + this.stateVector[1] = Statemachine.State.$NULLSTATE$; + this.stateConfVectorPosition = 1; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_PROCESS_R2_LINE_B_1, null, null))); + } + exitSequence_main_region_Process_r2_Line_B_2() { + this.stateVector[1] = Statemachine.State.$NULLSTATE$; + this.stateConfVectorPosition = 1; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_PROCESS_R2_LINE_B_2, null, null))); + } + exitSequence_main_region_Initialize() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.stateConfVectorPosition = 0; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_INITIALIZE, null, null))); + } + exitSequence_main_region_Cleanup() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.stateConfVectorPosition = 0; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_CLEANUP, null, null))); + } + exitSequence_main_region__final_() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.stateConfVectorPosition = 0; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION__FINAL_, null, null))); + } + exitSequence_main_region() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_PROCESS_R1_LINE_A_1: + this.exitSequence_main_region_Process_r1_Line_A_1(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_PROCESS_R1_LINE_A_2: + this.exitSequence_main_region_Process_r1_Line_A_2(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_INITIALIZE: + this.exitSequence_main_region_Initialize(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_CLEANUP: + this.exitSequence_main_region_Cleanup(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION__FINAL_: + this.exitSequence_main_region__final_(); + break; + default: + break; + } + switch ((this.stateVector[1])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_PROCESS_R2_LINE_B_1: + this.exitSequence_main_region_Process_r2_Line_B_1(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_PROCESS, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_PROCESS_R2_LINE_B_2: + this.exitSequence_main_region_Process_r2_Line_B_2(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_PROCESS, null, null))); + break; + default: + break; + } + } + exitSequence_main_region_Process_r1() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_PROCESS_R1_LINE_A_1: + this.exitSequence_main_region_Process_r1_Line_A_1(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_PROCESS_R1_LINE_A_2: + this.exitSequence_main_region_Process_r1_Line_A_2(); + break; + default: + break; + } + } + exitSequence_main_region_Process_r2() { + switch ((this.stateVector[1])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_PROCESS_R2_LINE_B_1: + this.exitSequence_main_region_Process_r2_Line_B_1(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_PROCESS_R2_LINE_B_2: + this.exitSequence_main_region_Process_r2_Line_B_2(); + break; + default: + break; + } + } + react_main_region__entry_Default() { + this.enterSequence_main_region_Initialize_default(); + } + react_main_region__sync0() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_PROCESS, null, null))); + this.enterSequence_main_region_Process_r1_Line_A_1_default(); + this.enterSequence_main_region_Process_r2_Line_B_1_default(); + } + react_main_region__sync1() { + this.enterSequence_main_region_Cleanup_default(); + } + react(transitioned_before) { + return transitioned_before; + } + main_region_Process_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_region_Process_r1_Line_A_1_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.pa) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_PROCESS_R1_LINE_A_1, null, 0))); + this.exitSequence_main_region_Process_r1_Line_A_1(); + this.enterSequence_main_region_Process_r1_Line_A_2_default(); + transitioned_after = 0; + } + } + return transitioned_after; + } + main_region_Process_r1_Line_A_2_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (((true && this.isStateActive(Statemachine.State.MAIN_REGION_PROCESS_R2_LINE_B_2)) && true)) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_PROCESS_R1_LINE_A_2, null, 0))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_PROCESS_R2_LINE_B_2, null, 0))); + this.exitSequence_main_region_Process(); + this.react_main_region__sync1(); + transitioned_after = 0; + } + } + return transitioned_after; + } + main_region_Process_r2_Line_B_1_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 1) { + if (this.pb) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_PROCESS_R2_LINE_B_1, null, 0))); + this.exitSequence_main_region_Process_r2_Line_B_1(); + this.enterSequence_main_region_Process_r2_Line_B_2_default(); + this.main_region_Process_react(0); + transitioned_after = 1; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_Process_react(transitioned_before); + } + return transitioned_after; + } + main_region_Process_r2_Line_B_2_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 1) { + if (((true && this.isStateActive(Statemachine.State.MAIN_REGION_PROCESS_R1_LINE_A_2)) && true)) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_PROCESS_R1_LINE_A_2, null, 0))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_PROCESS_R2_LINE_B_2, null, 0))); + this.exitSequence_main_region_Process(); + this.react_main_region__sync1(); + transitioned_after = 1; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_Process_react(transitioned_before); + } + return transitioned_after; + } + main_region_Initialize_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.proceed) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_INITIALIZE, null, 0))); + this.exitSequence_main_region_Initialize(); + this.react_main_region__sync0(); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_region_Cleanup_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.proceed) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_CLEANUP, null, 0))); + this.exitSequence_main_region_Cleanup(); + this.enterSequence_main_region__final__default(); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_region__final__react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + } + io.Statemachine = Statemachine; + Statemachine["__class"] = "sct.yakindu.io.Statemachine"; + Statemachine["__interfaces"] = ["com.yakindu.core.IStatemachine"]; + (function (Statemachine) { + let State; + (function (State) { + State[State["MAIN_REGION_PROCESS"] = 0] = "MAIN_REGION_PROCESS"; + State[State["MAIN_REGION_PROCESS_R1_LINE_A_1"] = 1] = "MAIN_REGION_PROCESS_R1_LINE_A_1"; + State[State["MAIN_REGION_PROCESS_R1_LINE_A_2"] = 2] = "MAIN_REGION_PROCESS_R1_LINE_A_2"; + State[State["MAIN_REGION_PROCESS_R2_LINE_B_1"] = 3] = "MAIN_REGION_PROCESS_R2_LINE_B_1"; + State[State["MAIN_REGION_PROCESS_R2_LINE_B_2"] = 4] = "MAIN_REGION_PROCESS_R2_LINE_B_2"; + State[State["MAIN_REGION_INITIALIZE"] = 5] = "MAIN_REGION_INITIALIZE"; + State[State["MAIN_REGION_CLEANUP"] = 6] = "MAIN_REGION_CLEANUP"; + State[State["MAIN_REGION__FINAL_"] = 7] = "MAIN_REGION__FINAL_"; + State[State["$NULLSTATE$"] = 8] = "$NULLSTATE$"; + })(State = Statemachine.State || (Statemachine.State = {})); + /** + * Enumeration of all features of the statechart + * @enum + * @property {sct.yakindu.io.Statemachine.Feature} NO_FEATURE + * @property {sct.yakindu.io.Statemachine.Feature} PROCEED + * @property {sct.yakindu.io.Statemachine.Feature} PA + * @property {sct.yakindu.io.Statemachine.Feature} PB + * @class + */ + let Feature; + (function (Feature) { + Feature[Feature["NO_FEATURE"] = 0] = "NO_FEATURE"; + Feature[Feature["PROCEED"] = 1] = "PROCEED"; + Feature[Feature["PA"] = 2] = "PA"; + Feature[Feature["PB"] = 3] = "PB"; + })(Feature = Statemachine.Feature || (Statemachine.Feature = {})); + })(Statemachine = io.Statemachine || (io.Statemachine = {})); + })(io = yakindu.io || (yakindu.io = {})); + })(yakindu = sct.yakindu || (sct.yakindu = {})); +})(sct || (sct = {})); diff --git a/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/assets/context.json.js b/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/assets/context.json.js new file mode 100644 index 00000000..8bd14db7 --- /dev/null +++ b/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/assets/context.json.js @@ -0,0 +1 @@ +const contextJson = {"elements":[{"elements":[{"kind":"event","name":"proceed","fqName":"proceed","featureId":"PROCEED","writable":true},{"kind":"event","name":"pa","fqName":"pa","featureId":"PA","writable":true},{"kind":"event","name":"pb","fqName":"pb","featureId":"PB","writable":true}],"kind":"composite","name":"default","featureId":"","writable":true}]} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/assets/hashes.json.js b/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/assets/hashes.json.js new file mode 100644 index 00000000..60aa6aec --- /dev/null +++ b/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/assets/hashes.json.js @@ -0,0 +1 @@ +const hashesJson = {"MAIN_REGION_CLEANUP":"8cce5025-d59a-4f66-b066-c663e67a9619","MAIN_REGION_INITIALIZE_tr0":"7fb872e6-be4b-42f9-a7e2-0962e848fcb9","MAIN_REGION_PROCESS_R2_LINE_B_2_tr0":"8bd0ae9f-a4d4-4667-9e26-508d11147703","MAIN_REGION_PROCESS_R1_LINE_A_1":"6972e023-04ee-4e68-a30e-84c90253cf8c","MAIN_REGION_PROCESS_R1_LINE_A_2":"60625f66-5293-45aa-a88f-957b029bb888","MAIN_REGION_INITIALIZE":"4ea50919-c6fc-4e28-b193-20b053a54048","MAIN_REGION_PROCESS_R1_LINE_A_2_tr0":"309cf5e7-69fb-4da7-a2c5-f71f07a9aab6","MAIN_REGION_PROCESS":"dbecd0ec-4779-4c1f-a6e6-685e89bdaa0b","MAIN_REGION_PROCESS_R2_LINE_B_1":"f1a1d37a-564b-4f89-9f25-c6b8250729fc","MAIN_REGION_CLEANUP_tr0":"dc0cb22d-b59e-42c0-b868-8c70285aa50c","MAIN_REGION_PROCESS_R2_LINE_B_2":"5d21453b-bd97-4ca5-8fcb-5ee6b1116dfe","MAIN_REGION_PROCESS_R2_LINE_B_1_tr0":"fe8ef8bd-6904-4c4e-a6db-987d8962ba44","MAIN_REGION_PROCESS_R1_LINE_A_1_tr0":"5e514f70-1c97-4e8f-a537-2e54823e6d5b"} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/assets/statemachine.svg.js b/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/assets/statemachine.svg.js new file mode 100644 index 00000000..a98109ff --- /dev/null +++ b/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/assets/statemachine.svg.js @@ -0,0 +1 @@ +let svg = `main region1Processr1-r2-Line A 1Line A 2papa1Line B 1Line B 2pbpb1-2-1Initializeproceedproceed1--1alwaysalways1alwaysalways1Cleanup-1proceedproceed1` \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/assets/ypi.css b/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/assets/ypi.css new file mode 100644 index 00000000..771aaa11 --- /dev/null +++ b/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/assets/ypi.css @@ -0,0 +1,113 @@ +/*! + * itemis CREATE Player Styles + * Copyright 2021 itemis AG + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ + + + /*! + * Style definitions follow BEM pattern using and additional 'y' namespace (for itemis CREATE). + */ +.y-declaration { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; + background-color: #eee; + font-family: 'Courier New', Courier, monospace; +} + + +.y-entry { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; +} + +.y-entry:after { + content: ' \25CF '; + font-size: larger; +} + +.y-state { + background-color: rgb(209, 223, 238); + padding: 3px; + border: 0.5pt;; + border: 0.5pt; + border-radius: 4px; + border-color: #bbb; + font-family: 'Courier New', Courier, monospace; +} + +.y-state--active { + background-color: rgb(244, 215, 66); +} + +.y-state--inactive { + background-color: rgb(209, 223, 238); +} + +.y-variable{ + background-color: #eee; + border-color: #aaa; + border: 0.5pt; + border: 0.5pt; + border-radius: 2px; + font-family: 'Courier New', Courier, monospace; +} + +.y-variable::after { + color: #aaa; + content: attr(value); + font-family: 'Courier New', Courier, monospace; +} + +.y-do-enter { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; +} + +.y-do-enter:before { + content: ' \2192 '; +} + +.y-do-exit { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer +} + +.y-do-exit:before { + content: ' \2192 '; +} + +.y-do-raise { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; + white-space: nowrap; +} + +.y-do-raise:before { + content: ' \2192 '; +} + +button.y-do-raise:before { + content: ''; +} + +button.y-do-raise { + cursor: pointer; +} + +.y-do--over { + color: blue; + background-color: #eee; + cursor: pointer; +} + +.y-player { + border-style: solid; + border-width: 1px; + border-color: ; +} diff --git a/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/index.html b/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/index.html new file mode 100644 index 00000000..15c4ecd6 --- /dev/null +++ b/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/index.html @@ -0,0 +1,256 @@ + + +sct-web-player demo + + + + + + + +
+

How to embed your statechart player

+

+ This document describes how to embed your statechart player into an arbitrary HTML document. + The statechart player itself is encapsulated in player.html file. This HTML file can + be embedded into another document as an HTML iframe. Furthermore, it is possible + to communicate with the embedded statechart by sending and receiving messages in a well-defined + format. +

+ +
+ +
+

The player toolbar

+

+ The embedded statechart can be controlled by the player's bottom toolbar. This toolbar allows to + start and stop the statechart with the play and stop buttons. The button to the right opens the + execution context which allows to raise events and set variables. +

+ + + + + + + + + + + + + + + + + + + + + +
ButtonsDescription
Start/stop the statechart execution.
Control the zoom level and open the statechart in fullscreen mode.
Open the execution context to watch/set variable values and to raise events.
+

Custom control elements

+

+ In addition to the functionality of the player toolbar, it is possible to create custom UI elements + to control the statechart. The chapters below show the various possibilities for the embedded statechart. + Play around with the statechart and see how these values and colors change. +

+
Enter / exit statechart
+

+

+ Click on enter to enter the statechart. This is equivalent to clicking the play button. +
+
+ Click on exit to exit the statechart. This is equivalent to clicking the stop button. +
+

+
Raise events
+

+ This is a list of all events defined in the statechart's interfaces (if none events are defined, this list is empty). You can click on the events to raise them on the statechart: +

+ proceed + pa + pb +
+

+
Detect state changes
+

+ This is a list of all states with their corresponding activity status: +

+ Process + Line A 1 + Line A 2 + Line B 1 + Line B 2 + Initialize + Cleanup + +
+

+
Setting variable values
+

+ This is a list of all variables defined in the statechart's interfaces (if none variables are defined, this list is empty). You can change the values and thereby directly set them on the statechart: +

+

Embedding the player

+

+ In order to embed the statechart player into a document use the HTML iframe tag like the following: +

+            
+            <iframe src="player.html?start=true" width="100%" height="500px" id="statechart"></iframe>
+            
+          
+ + + + + + + + + + + + + + + + + + + + + +
AttributeDescription
srcDefines the link to the player file. The parameter start allows to define whether the statechart should be entered when the page is loaded. The default value is false.
width / heightDefines the dimensions of the iframe. For a list of all available attributes, see also here.
idThis is required in order to access the embedded statechart for sending messages (see next chapter).
+

+ +

Sending messages to the statechart

+

+ In order to control the statechart with your custom UI elements you need to send corresponding messages to it. Messages are sent with the postMessage function on the iframe's content window. The example below demonstrates how to raise the artificial event myEvent: +

+              
+                var remoteframe = document.getElementById("statechart");
+                remoteframe.contentWindow.postMessage(
+                  {
+                    cmd: "raiseEvent",
+                    eventId: "myEvent",
+                  },
+                  "*"
+                );
+              
+            
+ The message transmitted via postMessage has a well-defined structure which is parsed by the statechart player. The cmd property defines the type of the message. It can be raiseEvent, enter, exit or changeValue. Depending on the command used, further properties are required. For example, in order to raise an event, we also need to specify the event's ID. +

+

Receiving messages from the statechart

+

+ Besides sending messages to the embedded statechart, the statechart itself sends messages back when its state or one of its values changes. These messages are transported by the message event one can subscribe to as the following code snippet shows: +

+              
+                window.addEventListener("message", (event) => {
+                  var data = event.data;
+                  switch (data.cmd) {
+                    case "stateEntered":
+                      console.log("State entered " + data.stateId);
+                      break;
+                    case "stateExited":
+                      console.log("State exited " + data.stateId);
+                      break;
+                    case "valueChanged":
+                      console.log("Value changed  " + data.varId + " " + data.value);
+                      break;
+                  }
+                });
+              
+            
+ Every message sent by the statechart contains a cmd property that defines the type of change that is reported. It can be stateEntered, stateExited or valueChanged. Depending on the cmd value, the message holds furter properties to track the affected state or variable. Please check the source code of this file for more information. +

+
+ + + + + diff --git a/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/model.scm b/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/model.scm new file mode 100644 index 00000000..73354fb6 --- /dev/null +++ b/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/model.scm @@ -0,0 +1,921 @@ +{ + "cells": [ + { + "position": { + "x": 0, + "y": 0 + }, + "size": { + "height": 10, + "width": 10 + }, + "angle": 0, + "type": "Statechart", + "id": "077d5dce-b015-472d-bd9e-a2ec84218edb", + "linkable": false, + "z": 1, + "attrs": { + "name": { + "text": "Orthogonality" + }, + "specification": { + "text": "@CycleBased(200)\n\ninterface:\n\tin event proceed\n\tin event pa\n\tin event pb" + } + } + }, + { + "type": "Region", + "position": { + "x": 26, + "y": 0 + }, + "size": { + "width": 779, + "height": 399 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "506092c3-a7ab-404a-9cef-c36045692229", + "z": 2, + "embeds": [ + "dc0cb22d-b59e-42c0-b868-8c70285aa50c", + "07be1acc-7057-47c3-800c-d8f1bca5a7fb", + "309cf5e7-69fb-4da7-a2c5-f71f07a9aab6", + "8bd0ae9f-a4d4-4667-9e26-508d11147703", + "79ecbdce-0c1d-4f45-87e6-69c8834e1195", + "7fb872e6-be4b-42f9-a7e2-0962e848fcb9", + "1de89ab5-9f30-4b41-8d79-7e1cfe7e96a0", + "f59338fa-537c-4f4d-8425-58588a9c77b1", + "dbecd0ec-4779-4c1f-a6e6-685e89bdaa0b", + "3c641471-981b-4194-a329-e83dd46dd9d6", + "4ea50919-c6fc-4e28-b193-20b053a54048", + "5aadbaad-0964-4c58-a1dc-684dd7636654", + "2aed92ec-30f6-4972-8fc3-f4a267cef1b7", + "8cce5025-d59a-4f66-b066-c663e67a9619", + "fefa31b7-72bf-4ea0-924e-9506ddbb1ad1" + ], + "attrs": { + "priority": { + "text": 1 + }, + "name": { + "fontSize": 9, + "text": "main region" + } + } + }, + { + "type": "State", + "position": { + "x": 228.31005999509676, + "y": 26 + }, + "size": { + "width": 424, + "height": 257 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "dbecd0ec-4779-4c1f-a6e6-685e89bdaa0b", + "z": 99, + "embeds": [ + "4e0afd31-5f82-4681-9af6-521de78a8a36", + "857e6d13-2334-4b3f-9f11-db862f34a40f" + ], + "parent": "506092c3-a7ab-404a-9cef-c36045692229", + "attrs": { + "body": { + "oldFill": "#CEDCEA", + "oldStroke": "#F2F2F2" + }, + "name": { + "text": "Process" + } + } + }, + { + "type": "Region", + "position": { + "x": 229.31005999509676, + "y": 66 + }, + "size": { + "width": 210.61263030293762, + "height": 216 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "4e0afd31-5f82-4681-9af6-521de78a8a36", + "z": 100, + "embeds": [ + "5e514f70-1c97-4e8f-a537-2e54823e6d5b", + "6972e023-04ee-4e68-a30e-84c90253cf8c", + "60625f66-5293-45aa-a88f-957b029bb888" + ], + "parent": "dbecd0ec-4779-4c1f-a6e6-685e89bdaa0b", + "attrs": { + "name": { + "fontSize": 9, + "text": "r1" + } + } + }, + { + "type": "Region", + "position": { + "x": 439.92269029803435, + "y": 66 + }, + "size": { + "width": 211.3873696970624, + "height": 216 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "857e6d13-2334-4b3f-9f11-db862f34a40f", + "z": 101, + "embeds": [ + "fe8ef8bd-6904-4c4e-a6db-987d8962ba44", + "f1a1d37a-564b-4f89-9f25-c6b8250729fc", + "5d21453b-bd97-4ca5-8fcb-5ee6b1116dfe" + ], + "parent": "dbecd0ec-4779-4c1f-a6e6-685e89bdaa0b", + "attrs": { + "name": { + "fontSize": 9, + "text": "r2" + } + } + }, + { + "type": "State", + "position": { + "x": 256.31005999509676, + "y": 87 + }, + "size": { + "width": 63, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "6972e023-04ee-4e68-a30e-84c90253cf8c", + "parent": "4e0afd31-5f82-4681-9af6-521de78a8a36", + "z": 103, + "attrs": { + "body": { + "oldFill": "#CEDCEA", + "oldStroke": "#F2F2F2" + }, + "name": { + "text": "Line A 1" + } + } + }, + { + "type": "State", + "position": { + "x": 366.31005999509676, + "y": 87 + }, + "size": { + "width": 63, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "60625f66-5293-45aa-a88f-957b029bb888", + "parent": "4e0afd31-5f82-4681-9af6-521de78a8a36", + "z": 104, + "attrs": { + "body": { + "oldFill": "#CEDCEA", + "oldStroke": "#F2F2F2" + }, + "name": { + "text": "Line A 2" + } + } + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "92.80338397985462%", + "dy": "54.08805031446544%", + "rotate": true + } + }, + "id": "6972e023-04ee-4e68-a30e-84c90253cf8c" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "7.396089749030875%", + "dy": "54.08805031446544%", + "rotate": true + } + }, + "id": "60625f66-5293-45aa-a88f-957b029bb888" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "pa", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "5e514f70-1c97-4e8f-a537-2e54823e6d5b", + "z": 108, + "parent": "4e0afd31-5f82-4681-9af6-521de78a8a36", + "attrs": {} + }, + { + "type": "State", + "position": { + "x": 461.267660300486, + "y": 180 + }, + "size": { + "width": 63, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "f1a1d37a-564b-4f89-9f25-c6b8250729fc", + "z": 117, + "parent": "857e6d13-2334-4b3f-9f11-db862f34a40f", + "attrs": { + "body": { + "oldFill": "#CEDCEA", + "oldStroke": "#F2F2F2" + }, + "name": { + "text": "Line B 1" + } + } + }, + { + "type": "State", + "position": { + "x": 564.7025331370806, + "y": 180 + }, + "size": { + "width": 63, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "5d21453b-bd97-4ca5-8fcb-5ee6b1116dfe", + "z": 119, + "parent": "857e6d13-2334-4b3f-9f11-db862f34a40f", + "attrs": { + "body": { + "oldFill": "#CEDCEA", + "oldStroke": "#F2F2F2" + }, + "name": { + "text": "Line B 2" + } + } + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "99.7354497354498%", + "dy": "40.56603773584906%", + "rotate": true + } + }, + "id": "f1a1d37a-564b-4f89-9f25-c6b8250729fc" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "40.56603773584906%", + "rotate": true + } + }, + "id": "5d21453b-bd97-4ca5-8fcb-5ee6b1116dfe" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "pb", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "fe8ef8bd-6904-4c4e-a6db-987d8962ba44", + "z": 120, + "parent": "857e6d13-2334-4b3f-9f11-db862f34a40f", + "attrs": {} + }, + { + "type": "Synchronization", + "position": { + "x": 176, + "y": 97 + }, + "size": { + "width": 8, + "height": 47 + }, + "angle": 0, + "fillOpacity": 1, + "embedable": false, + "linkable": true, + "id": "3c641471-981b-4194-a329-e83dd46dd9d6", + "z": 121, + "parent": "506092c3-a7ab-404a-9cef-c36045692229", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "id": "3c641471-981b-4194-a329-e83dd46dd9d6", + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "20%", + "rotate": true + } + } + }, + "target": { + "id": "6972e023-04ee-4e68-a30e-84c90253cf8c", + "anchor": { + "name": "topLeft", + "args": { + "dx": "44%", + "dy": "37%", + "rotate": true + } + } + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "1de89ab5-9f30-4b41-8d79-7e1cfe7e96a0", + "z": 122, + "parent": "506092c3-a7ab-404a-9cef-c36045692229", + "vertices": [], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "id": "3c641471-981b-4194-a329-e83dd46dd9d6", + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "79%", + "rotate": true + } + } + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "50%", + "rotate": true + } + }, + "id": "f1a1d37a-564b-4f89-9f25-c6b8250729fc" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "2" + } + } + } + ], + "id": "f59338fa-537c-4f4d-8425-58588a9c77b1", + "z": 122, + "vertices": [ + { + "x": 212, + "y": 134.13 + }, + { + "x": 212, + "y": 206.5 + } + ], + "parent": "506092c3-a7ab-404a-9cef-c36045692229", + "attrs": {} + }, + { + "type": "State", + "position": { + "x": 47, + "y": 91 + }, + "size": { + "width": 72, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "4ea50919-c6fc-4e28-b193-20b053a54048", + "z": 123, + "parent": "506092c3-a7ab-404a-9cef-c36045692229", + "attrs": { + "body": { + "oldFill": "#CEDCEA", + "oldStroke": "#F2F2F2" + }, + "name": { + "text": "Initialize" + } + } + }, + { + "type": "Transition", + "source": { + "id": "4ea50919-c6fc-4e28-b193-20b053a54048", + "anchor": { + "name": "topLeft", + "args": { + "dx": "64%", + "dy": "46%", + "rotate": true + } + } + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "39.007092198581574%", + "rotate": true + } + }, + "id": "3c641471-981b-4194-a329-e83dd46dd9d6" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "proceed", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "7fb872e6-be4b-42f9-a7e2-0962e848fcb9", + "z": 124, + "parent": "506092c3-a7ab-404a-9cef-c36045692229", + "attrs": {} + }, + { + "type": "Entry", + "position": { + "x": 75.5, + "y": 39 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "5aadbaad-0964-4c58-a1dc-684dd7636654", + "z": 125, + "embeds": [ + "a9ea2df1-e931-4a8b-a668-1e30bf7c1e5d" + ], + "parent": "506092c3-a7ab-404a-9cef-c36045692229", + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 75.5, + "y": 54 + }, + "id": "a9ea2df1-e931-4a8b-a668-1e30bf7c1e5d", + "z": 126, + "parent": "5aadbaad-0964-4c58-a1dc-684dd7636654", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "56.666666666666664%", + "rotate": true + } + }, + "id": "5aadbaad-0964-4c58-a1dc-684dd7636654" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "46.22641509433962%", + "rotate": true + } + }, + "id": "4ea50919-c6fc-4e28-b193-20b053a54048" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "79ecbdce-0c1d-4f45-87e6-69c8834e1195", + "z": 127, + "parent": "506092c3-a7ab-404a-9cef-c36045692229", + "attrs": {} + }, + { + "type": "Synchronization", + "position": { + "x": 683, + "y": 225 + }, + "size": { + "width": 81, + "height": 8 + }, + "angle": 0, + "fillOpacity": 1, + "embedable": false, + "linkable": true, + "id": "2aed92ec-30f6-4972-8fc3-f4a267cef1b7", + "z": 136, + "parent": "506092c3-a7ab-404a-9cef-c36045692229", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "id": "60625f66-5293-45aa-a88f-957b029bb888", + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "55.42452830188679%", + "rotate": true + } + } + }, + "target": { + "id": "2aed92ec-30f6-4972-8fc3-f4a267cef1b7", + "anchor": { + "name": "topLeft", + "args": { + "dx": "79%", + "dy": "50%", + "rotate": true + } + } + }, + "labels": [ + { + "attrs": { + "text": { + "text": "always", + "fontSize": "9" + } + }, + "position": { + "distance": 0.582426387126928, + "offset": -9.379999999999995, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "309cf5e7-69fb-4da7-a2c5-f71f07a9aab6", + "z": 137, + "vertices": [ + { + "x": 747, + "y": 116.38 + } + ], + "parent": "506092c3-a7ab-404a-9cef-c36045692229", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "id": "5d21453b-bd97-4ca5-8fcb-5ee6b1116dfe", + "anchor": { + "name": "topLeft", + "args": { + "dx": "48.603623839472846%", + "dy": "50%", + "rotate": true + } + } + }, + "target": { + "id": "2aed92ec-30f6-4972-8fc3-f4a267cef1b7", + "anchor": { + "name": "topLeft", + "args": { + "dx": "17%", + "dy": "50%", + "rotate": true + } + } + }, + "labels": [ + { + "attrs": { + "text": { + "text": "always", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "8bd0ae9f-a4d4-4667-9e26-508d11147703", + "z": 137, + "vertices": [ + { + "x": 697, + "y": 206.5 + } + ], + "parent": "506092c3-a7ab-404a-9cef-c36045692229", + "attrs": {} + }, + { + "type": "State", + "position": { + "x": 685.5, + "y": 259 + }, + "size": { + "width": 76, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "8cce5025-d59a-4f66-b066-c663e67a9619", + "z": 138, + "parent": "506092c3-a7ab-404a-9cef-c36045692229", + "attrs": { + "body": { + "oldFill": "#CEDCEA", + "oldStroke": "#F2F2F2" + }, + "name": { + "text": "Cleanup" + } + } + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "53.49794238683132%", + "dy": "50%", + "rotate": true + } + }, + "id": "2aed92ec-30f6-4972-8fc3-f4a267cef1b7" + }, + "target": { + "id": "8cce5025-d59a-4f66-b066-c663e67a9619", + "anchor": { + "name": "topLeft", + "args": { + "dx": "54%", + "dy": "10%", + "rotate": true + } + } + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "07be1acc-7057-47c3-800c-d8f1bca5a7fb", + "z": 139, + "parent": "506092c3-a7ab-404a-9cef-c36045692229", + "attrs": {} + }, + { + "type": "Final", + "position": { + "x": 716, + "y": 370 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "fefa31b7-72bf-4ea0-924e-9506ddbb1ad1", + "z": 140, + "parent": "506092c3-a7ab-404a-9cef-c36045692229", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "id": "8cce5025-d59a-4f66-b066-c663e67a9619", + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "47%", + "rotate": true + } + } + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "47.77777777777828%", + "dy": "3.3333333333333335%", + "rotate": true + } + }, + "id": "fefa31b7-72bf-4ea0-924e-9506ddbb1ad1" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "proceed", + "fontSize": "9" + } + }, + "position": { + "distance": 0.4480474731506966, + "offset": -24.659566396809534, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "dc0cb22d-b59e-42c0-b868-8c70285aa50c", + "z": 141, + "parent": "506092c3-a7ab-404a-9cef-c36045692229", + "attrs": {} + } + ] +} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/player.html b/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/player.html new file mode 100644 index 00000000..a40d8757 --- /dev/null +++ b/org.yakindu.sct.examples.basic.orthogonality/orthogonality-player/player.html @@ -0,0 +1,52 @@ + +sct-web-player demo + + + + + + + + + + + + + + + +
+ +
+ + + + + \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/.project b/org.yakindu.sct.examples.basic.tutorial/.project index 2bbaf558..dc003b74 100644 --- a/org.yakindu.sct.examples.basic.tutorial/.project +++ b/org.yakindu.sct.examples.basic.tutorial/.project @@ -26,4 +26,15 @@ org.eclipse.xtext.ui.shared.xtextNature com.yakindu.sct.builder.SCTNature + + + 1675684448555 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + diff --git a/org.yakindu.sct.examples.basic.tutorial/_01_lightswitch-player/assets/bundle.js b/org.yakindu.sct.examples.basic.tutorial/_01_lightswitch-player/assets/bundle.js new file mode 100644 index 00000000..d246a2eb --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_01_lightswitch-player/assets/bundle.js @@ -0,0 +1,412 @@ +var com; +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Instances represent state machine trace events. + * @param {com.yakindu.core.TraceEventType} type + * @param {*} machine + * @param {*} state + * @param {*} feature + * @param {*} value + * @class + */ + class TraceEvent { + constructor(type, machine, state, feature, value) { + if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && ((state != null) || state === null) && ((feature != null) || feature === null) && ((value != null) || value === null)) { + let __args = arguments; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + else if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && state === undefined && feature === undefined && value === undefined) { + let __args = arguments; + { + let __args = arguments; + let state = null; + let feature = null; + let value = null; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + } + else + throw new Error('invalid overload'); + } + getType() { + return this.type; + } + getMachine() { + return this.machine; + } + getState() { + return this.state; + } + getFeature() { + return this.feature; + } + getValue() { + return this.value; + } + } + core.TraceEvent = TraceEvent; + TraceEvent["__class"] = "com.yakindu.core.TraceEvent"; + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Trace event type enumeration. + * @enum + * @property {com.yakindu.core.TraceEventType} MACHINE_ENTER + * @property {com.yakindu.core.TraceEventType} MACHINE_EXIT + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_START + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_STOP + * @property {com.yakindu.core.TraceEventType} STATE_ENTERED + * @property {com.yakindu.core.TraceEventType} STATE_EXITED + * @property {com.yakindu.core.TraceEventType} STATE_TRANSITION + * @property {com.yakindu.core.TraceEventType} EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} VARIABLE_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_UNSET + * @class + */ + let TraceEventType; + (function (TraceEventType) { + TraceEventType[TraceEventType["MACHINE_ENTER"] = 0] = "MACHINE_ENTER"; + TraceEventType[TraceEventType["MACHINE_EXIT"] = 1] = "MACHINE_EXIT"; + TraceEventType[TraceEventType["MACHINE_RTS_START"] = 2] = "MACHINE_RTS_START"; + TraceEventType[TraceEventType["MACHINE_RTS_STOP"] = 3] = "MACHINE_RTS_STOP"; + TraceEventType[TraceEventType["STATE_ENTERED"] = 4] = "STATE_ENTERED"; + TraceEventType[TraceEventType["STATE_EXITED"] = 5] = "STATE_EXITED"; + TraceEventType[TraceEventType["STATE_TRANSITION"] = 6] = "STATE_TRANSITION"; + TraceEventType[TraceEventType["EVENT_RAISED"] = 7] = "EVENT_RAISED"; + TraceEventType[TraceEventType["VARIABLE_SET"] = 8] = "VARIABLE_SET"; + TraceEventType[TraceEventType["TIME_EVENT_RAISED"] = 9] = "TIME_EVENT_RAISED"; + TraceEventType[TraceEventType["TIME_EVENT_SET"] = 10] = "TIME_EVENT_SET"; + TraceEventType[TraceEventType["TIME_EVENT_UNSET"] = 11] = "TIME_EVENT_UNSET"; + })(TraceEventType = core.TraceEventType || (core.TraceEventType = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + var rx; + (function (rx) { + class Observable { + constructor() { + this.observers = ([]); + } + next(value) { + for (let index = 0; index < this.observers.length; index++) { + let observer = this.observers[index]; + { + observer.next(value); + } + } + } + subscribe(observer) { + return observer != null ? /* add */ (this.observers.push(observer) > 0) : false; + } + unsubscribe(observer) { + return observer != null ? /* remove */ (a => { let index = a.indexOf(observer); if (index >= 0) { + a.splice(index, 1); + return true; + } + else { + return false; + } })(this.observers) : false; + } + } + rx.Observable = Observable; + Observable["__class"] = "com.yakindu.core.rx.Observable"; + })(rx = core.rx || (core.rx = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +var sct; +(function (sct) { + var yakindu; + (function (yakindu) { + var io; + (function (io) { + class Statemachine { + constructor() { + this.stateVector = [null]; + this.trace = (new com.yakindu.core.rx.Observable()); + this.inEventQueue = ([]); + if (this.isExecuting === undefined) { + this.isExecuting = false; + } + if (this.switchEvent === undefined) { + this.switchEvent = false; + } + for (let i = 0; i < 1; i++) { + { + this.stateVector[i] = Statemachine.State.$NULLSTATE$; + } + ; + } + this.clearInEvents(); + this.isExecuting = false; + } + getIsExecuting() { + return this.isExecuting; + } + setIsExecuting(value) { + this.isExecuting = value; + } + enter() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_ENTER, this))); + this.enterSequence_main_default(); + this.isExecuting = false; + } + exit() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_EXIT, this))); + this.exitSequence_main(); + this.isExecuting = false; + } + /** + * @see IStatemachine#isActive() + * @return {boolean} + */ + isActive() { + return this.stateVector[0] !== Statemachine.State.$NULLSTATE$; + } + /** + * + * Always returns 'false' since this state machine can never become final. + * + * @see IStatemachine#isFinal() + * @return {boolean} + */ + isFinal() { + return false; + } + clearInEvents() { + this.switchEvent = false; + } + microStep() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_OFF: + this.main_Off_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_ON: + this.main_On_react(-1); + break; + default: + break; + } + } + runCycle() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_START, this))); + this.nextEvent(); + do { + { + this.microStep(); + this.clearInEvents(); + this.nextEvent(); + } + } while ((this.switchEvent)); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_STOP, this))); + this.isExecuting = false; + } + nextEvent() { + if (!(this.inEventQueue.length == 0)) { + (target => (typeof target === 'function') ? target() : target.run())(/* poll */ (a => a.length == 0 ? null : a.shift())(this.inEventQueue)); + return; + } + } + /** + * Returns true if the given state is currently active otherwise false. + * @param {sct.yakindu.io.Statemachine.State} state + * @return {boolean} + */ + isStateActive(state) { + switch ((state)) { + case sct.yakindu.io.Statemachine.State.MAIN_OFF: + return this.stateVector[0] === Statemachine.State.MAIN_OFF; + case sct.yakindu.io.Statemachine.State.MAIN_ON: + return this.stateVector[0] === Statemachine.State.MAIN_ON; + default: + return false; + } + } + getTrace() { + return this.trace; + } + raiseSwitch() { + /* add */ (this.inEventQueue.push(() => { + this.switchEvent = true; + }) > 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this, null, Statemachine.Feature.SWITCH, null))); + this.runCycle(); + } + enterSequence_main_Off_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_OFF, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_OFF; + } + enterSequence_main_On_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_ON, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_ON; + } + enterSequence_main_default() { + this.react_main__entry_Default(); + } + exitSequence_main_Off() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_OFF, null, null))); + } + exitSequence_main_On() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_ON, null, null))); + } + exitSequence_main() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_OFF: + this.exitSequence_main_Off(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_ON: + this.exitSequence_main_On(); + break; + default: + break; + } + } + react_main__entry_Default() { + this.enterSequence_main_Off_default(); + } + react(transitioned_before) { + return transitioned_before; + } + main_Off_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.switchEvent) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_OFF, null, 0))); + this.exitSequence_main_Off(); + this.enterSequence_main_On_default(); + this.react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_On_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.switchEvent) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_ON, null, 0))); + this.exitSequence_main_On(); + this.enterSequence_main_Off_default(); + this.react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + } + io.Statemachine = Statemachine; + Statemachine["__class"] = "sct.yakindu.io.Statemachine"; + Statemachine["__interfaces"] = ["com.yakindu.core.IStatemachine"]; + (function (Statemachine) { + let State; + (function (State) { + State[State["MAIN_OFF"] = 0] = "MAIN_OFF"; + State[State["MAIN_ON"] = 1] = "MAIN_ON"; + State[State["$NULLSTATE$"] = 2] = "$NULLSTATE$"; + })(State = Statemachine.State || (Statemachine.State = {})); + /** + * Enumeration of all features of the statechart + * @enum + * @property {sct.yakindu.io.Statemachine.Feature} NO_FEATURE + * @property {sct.yakindu.io.Statemachine.Feature} SWITCH + * @class + */ + let Feature; + (function (Feature) { + Feature[Feature["NO_FEATURE"] = 0] = "NO_FEATURE"; + Feature[Feature["SWITCH"] = 1] = "SWITCH"; + })(Feature = Statemachine.Feature || (Statemachine.Feature = {})); + })(Statemachine = io.Statemachine || (io.Statemachine = {})); + })(io = yakindu.io || (yakindu.io = {})); + })(yakindu = sct.yakindu || (sct.yakindu = {})); +})(sct || (sct = {})); diff --git a/org.yakindu.sct.examples.basic.tutorial/_01_lightswitch-player/assets/context.json.js b/org.yakindu.sct.examples.basic.tutorial/_01_lightswitch-player/assets/context.json.js new file mode 100644 index 00000000..9b77cd1a --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_01_lightswitch-player/assets/context.json.js @@ -0,0 +1 @@ +const contextJson = {"elements":[{"elements":[{"kind":"event","name":"switch","fqName":"switch","featureId":"SWITCH","writable":true}],"kind":"composite","name":"default","featureId":"","writable":true}]} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_01_lightswitch-player/assets/hashes.json.js b/org.yakindu.sct.examples.basic.tutorial/_01_lightswitch-player/assets/hashes.json.js new file mode 100644 index 00000000..4687cfb2 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_01_lightswitch-player/assets/hashes.json.js @@ -0,0 +1 @@ +const hashesJson = {"MAIN_ON":"2ad91e83-e1fe-4487-b9d4-8716da4b4fa5","MAIN_OFF":"4e674d9c-6ca5-4e0a-87d7-f66267594232","MAIN_ON_tr0":"b1bb7086-fc46-42f4-a6c9-ea27940d431a","MAIN_OFF_tr0":"3867482f-5f79-4406-b9d0-fb2236618d12"} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_01_lightswitch-player/assets/statemachine.svg.js b/org.yakindu.sct.examples.basic.tutorial/_01_lightswitch-player/assets/statemachine.svg.js new file mode 100644 index 00000000..0f0bde71 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_01_lightswitch-player/assets/statemachine.svg.js @@ -0,0 +1 @@ +let svg = `main1-OffOn-1switchswitch1switchswitch1` \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_01_lightswitch-player/assets/ypi.css b/org.yakindu.sct.examples.basic.tutorial/_01_lightswitch-player/assets/ypi.css new file mode 100644 index 00000000..771aaa11 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_01_lightswitch-player/assets/ypi.css @@ -0,0 +1,113 @@ +/*! + * itemis CREATE Player Styles + * Copyright 2021 itemis AG + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ + + + /*! + * Style definitions follow BEM pattern using and additional 'y' namespace (for itemis CREATE). + */ +.y-declaration { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; + background-color: #eee; + font-family: 'Courier New', Courier, monospace; +} + + +.y-entry { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; +} + +.y-entry:after { + content: ' \25CF '; + font-size: larger; +} + +.y-state { + background-color: rgb(209, 223, 238); + padding: 3px; + border: 0.5pt;; + border: 0.5pt; + border-radius: 4px; + border-color: #bbb; + font-family: 'Courier New', Courier, monospace; +} + +.y-state--active { + background-color: rgb(244, 215, 66); +} + +.y-state--inactive { + background-color: rgb(209, 223, 238); +} + +.y-variable{ + background-color: #eee; + border-color: #aaa; + border: 0.5pt; + border: 0.5pt; + border-radius: 2px; + font-family: 'Courier New', Courier, monospace; +} + +.y-variable::after { + color: #aaa; + content: attr(value); + font-family: 'Courier New', Courier, monospace; +} + +.y-do-enter { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; +} + +.y-do-enter:before { + content: ' \2192 '; +} + +.y-do-exit { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer +} + +.y-do-exit:before { + content: ' \2192 '; +} + +.y-do-raise { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; + white-space: nowrap; +} + +.y-do-raise:before { + content: ' \2192 '; +} + +button.y-do-raise:before { + content: ''; +} + +button.y-do-raise { + cursor: pointer; +} + +.y-do--over { + color: blue; + background-color: #eee; + cursor: pointer; +} + +.y-player { + border-style: solid; + border-width: 1px; + border-color: ; +} diff --git a/org.yakindu.sct.examples.basic.tutorial/_01_lightswitch-player/model.scm b/org.yakindu.sct.examples.basic.tutorial/_01_lightswitch-player/model.scm new file mode 100644 index 00000000..bd1a54e8 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_01_lightswitch-player/model.scm @@ -0,0 +1,313 @@ +{ + "cells": [ + { + "position": { + "x": 0, + "y": 0 + }, + "size": { + "height": 10, + "width": 10 + }, + "angle": 0, + "type": "Statechart", + "id": "7d956db8-e436-46cb-9846-fcf5528572bd", + "linkable": false, + "z": 1, + "attrs": { + "name": { + "text": "_01_LightSwitch" + }, + "specification": { + "text": "@EventDriven\n\ninterface:\n\tin event switch" + } + } + }, + { + "type": "Region", + "position": { + "x": 9, + "y": 9 + }, + "size": { + "width": 255, + "height": 227 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "b87be53c-caad-4e0b-b62d-f92a0b9b71c2", + "z": 2, + "embeds": [ + "b1bb7086-fc46-42f4-a6c9-ea27940d431a", + "3867482f-5f79-4406-b9d0-fb2236618d12", + "db722577-d435-4a2f-a4ac-36a9b5f8f72b", + "66ce1f09-050a-4104-bf29-c829dc5b4b87", + "4e674d9c-6ca5-4e0a-87d7-f66267594232", + "2ad91e83-e1fe-4487-b9d4-8716da4b4fa5" + ], + "attrs": { + "priority": { + "text": 1 + }, + "name": { + "fontSize": "9", + "text": "main" + } + } + }, + { + "type": "Entry", + "position": { + "x": 43, + "y": 51 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "66ce1f09-050a-4104-bf29-c829dc5b4b87", + "parent": "b87be53c-caad-4e0b-b62d-f92a0b9b71c2", + "z": 3, + "embeds": [ + "97b906e1-f51b-474a-993e-37e29a4be534" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 43, + "y": 66 + }, + "id": "97b906e1-f51b-474a-993e-37e29a4be534", + "z": 4, + "parent": "66ce1f09-050a-4104-bf29-c829dc5b4b87", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 113, + "y": 45 + }, + "size": { + "width": 40, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "4e674d9c-6ca5-4e0a-87d7-f66267594232", + "parent": "b87be53c-caad-4e0b-b62d-f92a0b9b71c2", + "z": 5, + "attrs": { + "name": { + "text": "Off" + } + } + }, + { + "type": "State", + "position": { + "x": 113, + "y": 155 + }, + "size": { + "width": 40, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "2ad91e83-e1fe-4487-b9d4-8716da4b4fa5", + "parent": "b87be53c-caad-4e0b-b62d-f92a0b9b71c2", + "z": 6, + "attrs": { + "name": { + "text": "On" + } + } + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "88.8888888888889%", + "dy": "36.666666666666664%", + "rotate": true + } + }, + "id": "66ce1f09-050a-4104-bf29-c829dc5b4b87" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.416666666666643%", + "dy": "21.69811320754717%", + "rotate": true + } + }, + "id": "4e674d9c-6ca5-4e0a-87d7-f66267594232" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "db722577-d435-4a2f-a4ac-36a9b5f8f72b", + "z": 7, + "parent": "b87be53c-caad-4e0b-b62d-f92a0b9b71c2", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "63.20754716981132%", + "rotate": true + } + }, + "id": "4e674d9c-6ca5-4e0a-87d7-f66267594232" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "50%", + "rotate": true + } + }, + "id": "2ad91e83-e1fe-4487-b9d4-8716da4b4fa5" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "switch", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "3867482f-5f79-4406-b9d0-fb2236618d12", + "z": 8, + "parent": "b87be53c-caad-4e0b-b62d-f92a0b9b71c2", + "vertices": [ + { + "x": 86, + "y": 78.5 + }, + { + "x": 86, + "y": 181.5 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "54.90566037735854%", + "rotate": true + } + }, + "id": "2ad91e83-e1fe-4487-b9d4-8716da4b4fa5" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "60.94339622641509%", + "rotate": true + } + }, + "id": "4e674d9c-6ca5-4e0a-87d7-f66267594232" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "switch", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "b1bb7086-fc46-42f4-a6c9-ea27940d431a", + "z": 9, + "parent": "b87be53c-caad-4e0b-b62d-f92a0b9b71c2", + "vertices": [ + { + "x": 179, + "y": 184.10000000000002 + }, + { + "x": 179, + "y": 77.3 + } + ], + "attrs": {} + } + ] +} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_01_lightswitch-player/player.html b/org.yakindu.sct.examples.basic.tutorial/_01_lightswitch-player/player.html new file mode 100644 index 00000000..a40d8757 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_01_lightswitch-player/player.html @@ -0,0 +1,52 @@ + +sct-web-player demo + + + + + + + + + + + + + + + +
+ +
+ + + + + \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_02_dimmablelightswitch-player/assets/bundle.js b/org.yakindu.sct.examples.basic.tutorial/_02_dimmablelightswitch-player/assets/bundle.js new file mode 100644 index 00000000..2d19a444 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_02_dimmablelightswitch-player/assets/bundle.js @@ -0,0 +1,468 @@ +var com; +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Instances represent state machine trace events. + * @param {com.yakindu.core.TraceEventType} type + * @param {*} machine + * @param {*} state + * @param {*} feature + * @param {*} value + * @class + */ + class TraceEvent { + constructor(type, machine, state, feature, value) { + if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && ((state != null) || state === null) && ((feature != null) || feature === null) && ((value != null) || value === null)) { + let __args = arguments; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + else if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && state === undefined && feature === undefined && value === undefined) { + let __args = arguments; + { + let __args = arguments; + let state = null; + let feature = null; + let value = null; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + } + else + throw new Error('invalid overload'); + } + getType() { + return this.type; + } + getMachine() { + return this.machine; + } + getState() { + return this.state; + } + getFeature() { + return this.feature; + } + getValue() { + return this.value; + } + } + core.TraceEvent = TraceEvent; + TraceEvent["__class"] = "com.yakindu.core.TraceEvent"; + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Trace event type enumeration. + * @enum + * @property {com.yakindu.core.TraceEventType} MACHINE_ENTER + * @property {com.yakindu.core.TraceEventType} MACHINE_EXIT + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_START + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_STOP + * @property {com.yakindu.core.TraceEventType} STATE_ENTERED + * @property {com.yakindu.core.TraceEventType} STATE_EXITED + * @property {com.yakindu.core.TraceEventType} STATE_TRANSITION + * @property {com.yakindu.core.TraceEventType} EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} VARIABLE_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_UNSET + * @class + */ + let TraceEventType; + (function (TraceEventType) { + TraceEventType[TraceEventType["MACHINE_ENTER"] = 0] = "MACHINE_ENTER"; + TraceEventType[TraceEventType["MACHINE_EXIT"] = 1] = "MACHINE_EXIT"; + TraceEventType[TraceEventType["MACHINE_RTS_START"] = 2] = "MACHINE_RTS_START"; + TraceEventType[TraceEventType["MACHINE_RTS_STOP"] = 3] = "MACHINE_RTS_STOP"; + TraceEventType[TraceEventType["STATE_ENTERED"] = 4] = "STATE_ENTERED"; + TraceEventType[TraceEventType["STATE_EXITED"] = 5] = "STATE_EXITED"; + TraceEventType[TraceEventType["STATE_TRANSITION"] = 6] = "STATE_TRANSITION"; + TraceEventType[TraceEventType["EVENT_RAISED"] = 7] = "EVENT_RAISED"; + TraceEventType[TraceEventType["VARIABLE_SET"] = 8] = "VARIABLE_SET"; + TraceEventType[TraceEventType["TIME_EVENT_RAISED"] = 9] = "TIME_EVENT_RAISED"; + TraceEventType[TraceEventType["TIME_EVENT_SET"] = 10] = "TIME_EVENT_SET"; + TraceEventType[TraceEventType["TIME_EVENT_UNSET"] = 11] = "TIME_EVENT_UNSET"; + })(TraceEventType = core.TraceEventType || (core.TraceEventType = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + var rx; + (function (rx) { + class Observable { + constructor() { + this.observers = ([]); + } + next(value) { + for (let index = 0; index < this.observers.length; index++) { + let observer = this.observers[index]; + { + observer.next(value); + } + } + } + subscribe(observer) { + return observer != null ? /* add */ (this.observers.push(observer) > 0) : false; + } + unsubscribe(observer) { + return observer != null ? /* remove */ (a => { let index = a.indexOf(observer); if (index >= 0) { + a.splice(index, 1); + return true; + } + else { + return false; + } })(this.observers) : false; + } + } + rx.Observable = Observable; + Observable["__class"] = "com.yakindu.core.rx.Observable"; + })(rx = core.rx || (core.rx = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +var sct; +(function (sct) { + var yakindu; + (function (yakindu) { + var io; + (function (io) { + class Statemachine { + constructor() { + this.stateVector = [null]; + this.trace = (new com.yakindu.core.rx.Observable()); + this.inEventQueue = ([]); + if (this.isExecuting === undefined) { + this.isExecuting = false; + } + if (this.switchEvent === undefined) { + this.switchEvent = false; + } + if (this.changeBrightness === undefined) { + this.changeBrightness = false; + } + if (this.brightness === undefined) { + this.brightness = 0; + } + for (let i = 0; i < 1; i++) { + { + this.stateVector[i] = Statemachine.State.$NULLSTATE$; + } + ; + } + this.clearInEvents(); + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + this.isExecuting = false; + } + getIsExecuting() { + return this.isExecuting; + } + setIsExecuting(value) { + this.isExecuting = value; + } + enter() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_ENTER, this))); + this.enterSequence_main_default(); + this.isExecuting = false; + } + exit() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_EXIT, this))); + this.exitSequence_main(); + this.isExecuting = false; + } + /** + * @see IStatemachine#isActive() + * @return {boolean} + */ + isActive() { + return this.stateVector[0] !== Statemachine.State.$NULLSTATE$; + } + /** + * + * Always returns 'false' since this state machine can never become final. + * + * @see IStatemachine#isFinal() + * @return {boolean} + */ + isFinal() { + return false; + } + clearInEvents() { + this.switchEvent = false; + this.changeBrightness = false; + } + microStep() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_OFF: + this.main_Off_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_ON: + this.main_On_react(-1); + break; + default: + break; + } + } + runCycle() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_START, this))); + this.nextEvent(); + do { + { + this.microStep(); + this.clearInEvents(); + this.nextEvent(); + } + } while (((this.switchEvent || this.changeBrightness))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_STOP, this))); + this.isExecuting = false; + } + nextEvent() { + if (!(this.inEventQueue.length == 0)) { + (target => (typeof target === 'function') ? target() : target.run())(/* poll */ (a => a.length == 0 ? null : a.shift())(this.inEventQueue)); + return; + } + } + /** + * Returns true if the given state is currently active otherwise false. + * @param {sct.yakindu.io.Statemachine.State} state + * @return {boolean} + */ + isStateActive(state) { + switch ((state)) { + case sct.yakindu.io.Statemachine.State.MAIN_OFF: + return this.stateVector[0] === Statemachine.State.MAIN_OFF; + case sct.yakindu.io.Statemachine.State.MAIN_ON: + return this.stateVector[0] === Statemachine.State.MAIN_ON; + default: + return false; + } + } + getTrace() { + return this.trace; + } + raiseSwitch() { + /* add */ (this.inEventQueue.push(() => { + this.switchEvent = true; + }) > 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this, null, Statemachine.Feature.SWITCH, null))); + this.runCycle(); + } + raiseChangeBrightness() { + /* add */ (this.inEventQueue.push(() => { + this.changeBrightness = true; + }) > 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this, null, Statemachine.Feature.CHANGEBRIGHTNESS, null))); + this.runCycle(); + } + getBrightness() { + return this.brightness; + } + setBrightness(value) { + this.brightness = value; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + } + entryAction_main_Off() { + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + } + enterSequence_main_Off_default() { + this.entryAction_main_Off(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_OFF, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_OFF; + } + enterSequence_main_On_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_ON, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_ON; + } + enterSequence_main_default() { + this.react_main__entry_Default(); + } + exitSequence_main_Off() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_OFF, null, null))); + } + exitSequence_main_On() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_ON, null, null))); + } + exitSequence_main() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_OFF: + this.exitSequence_main_Off(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_ON: + this.exitSequence_main_On(); + break; + default: + break; + } + } + react_main__entry_Default() { + this.enterSequence_main_Off_default(); + } + react(transitioned_before) { + return transitioned_before; + } + main_Off_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.switchEvent) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_OFF, null, 0))); + this.exitSequence_main_Off(); + this.setBrightness(10); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + this.enterSequence_main_On_default(); + this.react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_On_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.switchEvent) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_ON, null, 0))); + this.exitSequence_main_On(); + this.enterSequence_main_Off_default(); + this.react(0); + transitioned_after = 0; + } + else { + if (((this.changeBrightness) && (this.getBrightness() > 1))) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_ON, null, 1))); + this.exitSequence_main_On(); + this.setBrightness(this.getBrightness() - 1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + this.enterSequence_main_On_default(); + this.react(0); + transitioned_after = 0; + } + else { + if (((this.changeBrightness) && (this.getBrightness() <= 1))) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_ON, null, 2))); + this.exitSequence_main_On(); + this.setBrightness(10); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + this.enterSequence_main_On_default(); + this.react(0); + transitioned_after = 0; + } + } + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + } + io.Statemachine = Statemachine; + Statemachine["__class"] = "sct.yakindu.io.Statemachine"; + Statemachine["__interfaces"] = ["com.yakindu.core.IStatemachine"]; + (function (Statemachine) { + let State; + (function (State) { + State[State["MAIN_OFF"] = 0] = "MAIN_OFF"; + State[State["MAIN_ON"] = 1] = "MAIN_ON"; + State[State["$NULLSTATE$"] = 2] = "$NULLSTATE$"; + })(State = Statemachine.State || (Statemachine.State = {})); + /** + * Enumeration of all features of the statechart + * @enum + * @property {sct.yakindu.io.Statemachine.Feature} NO_FEATURE + * @property {sct.yakindu.io.Statemachine.Feature} SWITCH + * @property {sct.yakindu.io.Statemachine.Feature} CHANGEBRIGHTNESS + * @property {sct.yakindu.io.Statemachine.Feature} BRIGHTNESS + * @class + */ + let Feature; + (function (Feature) { + Feature[Feature["NO_FEATURE"] = 0] = "NO_FEATURE"; + Feature[Feature["SWITCH"] = 1] = "SWITCH"; + Feature[Feature["CHANGEBRIGHTNESS"] = 2] = "CHANGEBRIGHTNESS"; + Feature[Feature["BRIGHTNESS"] = 3] = "BRIGHTNESS"; + })(Feature = Statemachine.Feature || (Statemachine.Feature = {})); + })(Statemachine = io.Statemachine || (io.Statemachine = {})); + })(io = yakindu.io || (yakindu.io = {})); + })(yakindu = sct.yakindu || (sct.yakindu = {})); +})(sct || (sct = {})); diff --git a/org.yakindu.sct.examples.basic.tutorial/_02_dimmablelightswitch-player/assets/context.json.js b/org.yakindu.sct.examples.basic.tutorial/_02_dimmablelightswitch-player/assets/context.json.js new file mode 100644 index 00000000..96c1f802 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_02_dimmablelightswitch-player/assets/context.json.js @@ -0,0 +1 @@ +const contextJson = {"elements":[{"elements":[{"kind":"event","name":"switch","fqName":"switch","featureId":"SWITCH","writable":true},{"kind":"event","name":"changeBrightness","fqName":"changeBrightness","featureId":"CHANGEBRIGHTNESS","writable":true},{"kind":"variable","type":"integer","name":"brightness","fqName":"brightness","featureId":"BRIGHTNESS","writable":true,"value":0}],"kind":"composite","name":"default","featureId":"","writable":true}]} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_02_dimmablelightswitch-player/assets/hashes.json.js b/org.yakindu.sct.examples.basic.tutorial/_02_dimmablelightswitch-player/assets/hashes.json.js new file mode 100644 index 00000000..4dbc0f01 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_02_dimmablelightswitch-player/assets/hashes.json.js @@ -0,0 +1 @@ +const hashesJson = {"MAIN_OFF":"97961d62-266a-416d-8c6f-ec072e9d5c94","MAIN_ON":"82242200-41cf-419f-890c-c1d2c046f1e5","MAIN_ON_tr1":"92843b77-6eaa-4a02-9cd2-00ca32524b40","MAIN_OFF_tr0":"c56d8c53-be8c-49ad-a243-44591015ae59","MAIN_ON_tr0":"bd48324d-87bd-4534-a534-590cc73d9685","MAIN_ON_tr2":"1914b3f4-6026-45c9-9b30-598f0b954bbf"} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_02_dimmablelightswitch-player/assets/statemachine.svg.js b/org.yakindu.sct.examples.basic.tutorial/_02_dimmablelightswitch-player/assets/statemachine.svg.js new file mode 100644 index 00000000..9753fa18 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_02_dimmablelightswitch-player/assets/statemachine.svg.js @@ -0,0 +1 @@ +let svg = `main1-Offentry / brightness = 0On-1switch / brightness = 10switch / brightness = 101switch switch 1changeBrightness     [brightness > 1] /     brightness -= 1    changeBrightness [brightness > 1] / brightness -= 1 2changeBrightness     [brightness <= 1] /     brightness = 10    changeBrightness [brightness <= 1] / brightness = 10 3` \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_02_dimmablelightswitch-player/assets/ypi.css b/org.yakindu.sct.examples.basic.tutorial/_02_dimmablelightswitch-player/assets/ypi.css new file mode 100644 index 00000000..771aaa11 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_02_dimmablelightswitch-player/assets/ypi.css @@ -0,0 +1,113 @@ +/*! + * itemis CREATE Player Styles + * Copyright 2021 itemis AG + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ + + + /*! + * Style definitions follow BEM pattern using and additional 'y' namespace (for itemis CREATE). + */ +.y-declaration { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; + background-color: #eee; + font-family: 'Courier New', Courier, monospace; +} + + +.y-entry { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; +} + +.y-entry:after { + content: ' \25CF '; + font-size: larger; +} + +.y-state { + background-color: rgb(209, 223, 238); + padding: 3px; + border: 0.5pt;; + border: 0.5pt; + border-radius: 4px; + border-color: #bbb; + font-family: 'Courier New', Courier, monospace; +} + +.y-state--active { + background-color: rgb(244, 215, 66); +} + +.y-state--inactive { + background-color: rgb(209, 223, 238); +} + +.y-variable{ + background-color: #eee; + border-color: #aaa; + border: 0.5pt; + border: 0.5pt; + border-radius: 2px; + font-family: 'Courier New', Courier, monospace; +} + +.y-variable::after { + color: #aaa; + content: attr(value); + font-family: 'Courier New', Courier, monospace; +} + +.y-do-enter { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; +} + +.y-do-enter:before { + content: ' \2192 '; +} + +.y-do-exit { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer +} + +.y-do-exit:before { + content: ' \2192 '; +} + +.y-do-raise { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; + white-space: nowrap; +} + +.y-do-raise:before { + content: ' \2192 '; +} + +button.y-do-raise:before { + content: ''; +} + +button.y-do-raise { + cursor: pointer; +} + +.y-do--over { + color: blue; + background-color: #eee; + cursor: pointer; +} + +.y-player { + border-style: solid; + border-width: 1px; + border-color: ; +} diff --git a/org.yakindu.sct.examples.basic.tutorial/_02_dimmablelightswitch-player/model.scm b/org.yakindu.sct.examples.basic.tutorial/_02_dimmablelightswitch-player/model.scm new file mode 100644 index 00000000..d89639da --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_02_dimmablelightswitch-player/model.scm @@ -0,0 +1,436 @@ +{ + "cells": [ + { + "position": { + "x": 0, + "y": 0 + }, + "size": { + "height": 10, + "width": 10 + }, + "angle": 0, + "type": "Statechart", + "id": "b0456e8e-3f72-4243-851d-97d26b4c38fe", + "linkable": false, + "z": 1, + "attrs": { + "name": { + "text": "_02_DimmableLightSwitch" + }, + "specification": { + "text": "@EventDriven\n\ninterface:\n\tin event switch\n\tin event changeBrightness\n\tvar brightness: integer" + } + } + }, + { + "type": "Region", + "position": { + "x": 0, + "y": 7 + }, + "size": { + "width": 540, + "height": 288 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "10fa37b1-4b9b-40ff-8056-624d8d4e4260", + "z": 2, + "embeds": [ + "1914b3f4-6026-45c9-9b30-598f0b954bbf", + "92843b77-6eaa-4a02-9cd2-00ca32524b40", + "bd48324d-87bd-4534-a534-590cc73d9685", + "c56d8c53-be8c-49ad-a243-44591015ae59", + "372465ad-5728-4305-ae67-2dcff3666e4d", + "0539bd4a-d1ff-4da5-8495-06f092cd2312", + "97961d62-266a-416d-8c6f-ec072e9d5c94", + "82242200-41cf-419f-890c-c1d2c046f1e5" + ], + "attrs": { + "priority": { + "text": 1 + }, + "name": { + "fontSize": "9", + "text": "main" + } + } + }, + { + "type": "Entry", + "position": { + "x": 104, + "y": 64 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "0539bd4a-d1ff-4da5-8495-06f092cd2312", + "parent": "10fa37b1-4b9b-40ff-8056-624d8d4e4260", + "z": 3, + "embeds": [ + "5f0670fd-93c2-4e63-831e-26153c9aa72c" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 104, + "y": 79 + }, + "id": "5f0670fd-93c2-4e63-831e-26153c9aa72c", + "z": 4, + "parent": "0539bd4a-d1ff-4da5-8495-06f092cd2312", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 180, + "y": 45 + }, + "size": { + "width": 176, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "97961d62-266a-416d-8c6f-ec072e9d5c94", + "parent": "10fa37b1-4b9b-40ff-8056-624d8d4e4260", + "z": 5, + "attrs": { + "name": { + "text": "Off" + }, + "specification": { + "text": "entry / brightness = 0", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 180, + "y": 146 + }, + "size": { + "width": 181, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "82242200-41cf-419f-890c-c1d2c046f1e5", + "parent": "10fa37b1-4b9b-40ff-8056-624d8d4e4260", + "z": 6, + "attrs": { + "name": { + "text": "On" + } + } + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "95.55555555555561%", + "dy": "50%", + "rotate": true + } + }, + "id": "0539bd4a-d1ff-4da5-8495-06f092cd2312" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.09469696969698047%", + "dy": "50%", + "rotate": true + } + }, + "id": "97961d62-266a-416d-8c6f-ec072e9d5c94" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "372465ad-5728-4305-ae67-2dcff3666e4d", + "z": 7, + "parent": "10fa37b1-4b9b-40ff-8056-624d8d4e4260", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "25.09469696969698%", + "dy": "50%", + "rotate": true + } + }, + "id": "97961d62-266a-416d-8c6f-ec072e9d5c94" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "24.40147329650093%", + "dy": "0.9433962264150944%", + "rotate": true + } + }, + "id": "82242200-41cf-419f-890c-c1d2c046f1e5" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "switch /\n brightness = 10", + "fontSize": "9" + } + }, + "position": { + "distance": 0.4375, + "offset": 48.16999999999999, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "c56d8c53-be8c-49ad-a243-44591015ae59", + "z": 8, + "parent": "10fa37b1-4b9b-40ff-8056-624d8d4e4260", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "52.48618784530387%", + "dy": "0.3144654088050672%", + "rotate": true + } + }, + "id": "82242200-41cf-419f-890c-c1d2c046f1e5" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "53.97727272727273%", + "dy": "50%", + "rotate": true + } + }, + "id": "97961d62-266a-416d-8c6f-ec072e9d5c94" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "switch ", + "fontSize": "9" + } + }, + "position": { + "offset": 32, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "bd48324d-87bd-4534-a534-590cc73d9685", + "z": 9, + "parent": "10fa37b1-4b9b-40ff-8056-624d8d4e4260", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "50%", + "rotate": true + } + }, + "id": "82242200-41cf-419f-890c-c1d2c046f1e5" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "63.812154696132595%", + "dy": "50%", + "rotate": true + } + }, + "id": "82242200-41cf-419f-890c-c1d2c046f1e5" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "changeBrightness \n [brightness > 1] / \n brightness -= 1\n ", + "fontSize": "9" + } + }, + "position": { + "distance": 0.3520408163265306, + "offset": -72.5, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "2" + } + } + } + ], + "id": "92843b77-6eaa-4a02-9cd2-00ca32524b40", + "z": 10, + "parent": "10fa37b1-4b9b-40ff-8056-624d8d4e4260", + "vertices": [ + { + "x": 383.5, + "y": 172.5 + }, + { + "x": 383.5, + "y": 228.5 + }, + { + "x": 295.5, + "y": 228.5 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "3.6710371800606385%", + "dy": "49.056603773584904%", + "rotate": true + } + }, + "id": "82242200-41cf-419f-890c-c1d2c046f1e5" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "29.02891600034112%", + "dy": "50%", + "rotate": true + } + }, + "id": "82242200-41cf-419f-890c-c1d2c046f1e5" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "changeBrightness \n [brightness <= 1] / \n brightness = 10\n ", + "fontSize": "9" + } + }, + "position": { + "distance": 0.3398529355959671, + "offset": 70.94383085081233, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "3" + } + } + } + ], + "id": "1914b3f4-6026-45c9-9b30-598f0b954bbf", + "z": 11, + "parent": "10fa37b1-4b9b-40ff-8056-624d8d4e4260", + "vertices": [ + { + "x": 161.94383085081233, + "y": 172 + }, + { + "x": 161.94383085081233, + "y": 231 + }, + { + "x": 232.54233796061743, + "y": 231 + } + ], + "attrs": {} + } + ] +} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_02_dimmablelightswitch-player/player.html b/org.yakindu.sct.examples.basic.tutorial/_02_dimmablelightswitch-player/player.html new file mode 100644 index 00000000..a40d8757 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_02_dimmablelightswitch-player/player.html @@ -0,0 +1,52 @@ + +sct-web-player demo + + + + + + + + + + + + + + + +
+ +
+ + + + + \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_03_motionlightswitch-player/assets/bundle.js b/org.yakindu.sct.examples.basic.tutorial/_03_motionlightswitch-player/assets/bundle.js new file mode 100644 index 00000000..8e399da5 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_03_motionlightswitch-player/assets/bundle.js @@ -0,0 +1,691 @@ +var com; +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Instances represent state machine trace events. + * @param {com.yakindu.core.TraceEventType} type + * @param {*} machine + * @param {*} state + * @param {*} feature + * @param {*} value + * @class + */ + class TraceEvent { + constructor(type, machine, state, feature, value) { + if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && ((state != null) || state === null) && ((feature != null) || feature === null) && ((value != null) || value === null)) { + let __args = arguments; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + else if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && state === undefined && feature === undefined && value === undefined) { + let __args = arguments; + { + let __args = arguments; + let state = null; + let feature = null; + let value = null; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + } + else + throw new Error('invalid overload'); + } + getType() { + return this.type; + } + getMachine() { + return this.machine; + } + getState() { + return this.state; + } + getFeature() { + return this.feature; + } + getValue() { + return this.value; + } + } + core.TraceEvent = TraceEvent; + TraceEvent["__class"] = "com.yakindu.core.TraceEvent"; + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Trace event type enumeration. + * @enum + * @property {com.yakindu.core.TraceEventType} MACHINE_ENTER + * @property {com.yakindu.core.TraceEventType} MACHINE_EXIT + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_START + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_STOP + * @property {com.yakindu.core.TraceEventType} STATE_ENTERED + * @property {com.yakindu.core.TraceEventType} STATE_EXITED + * @property {com.yakindu.core.TraceEventType} STATE_TRANSITION + * @property {com.yakindu.core.TraceEventType} EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} VARIABLE_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_UNSET + * @class + */ + let TraceEventType; + (function (TraceEventType) { + TraceEventType[TraceEventType["MACHINE_ENTER"] = 0] = "MACHINE_ENTER"; + TraceEventType[TraceEventType["MACHINE_EXIT"] = 1] = "MACHINE_EXIT"; + TraceEventType[TraceEventType["MACHINE_RTS_START"] = 2] = "MACHINE_RTS_START"; + TraceEventType[TraceEventType["MACHINE_RTS_STOP"] = 3] = "MACHINE_RTS_STOP"; + TraceEventType[TraceEventType["STATE_ENTERED"] = 4] = "STATE_ENTERED"; + TraceEventType[TraceEventType["STATE_EXITED"] = 5] = "STATE_EXITED"; + TraceEventType[TraceEventType["STATE_TRANSITION"] = 6] = "STATE_TRANSITION"; + TraceEventType[TraceEventType["EVENT_RAISED"] = 7] = "EVENT_RAISED"; + TraceEventType[TraceEventType["VARIABLE_SET"] = 8] = "VARIABLE_SET"; + TraceEventType[TraceEventType["TIME_EVENT_RAISED"] = 9] = "TIME_EVENT_RAISED"; + TraceEventType[TraceEventType["TIME_EVENT_SET"] = 10] = "TIME_EVENT_SET"; + TraceEventType[TraceEventType["TIME_EVENT_UNSET"] = 11] = "TIME_EVENT_UNSET"; + })(TraceEventType = core.TraceEventType || (core.TraceEventType = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + var rx; + (function (rx) { + class Observable { + constructor() { + this.observers = ([]); + } + next(value) { + for (let index = 0; index < this.observers.length; index++) { + let observer = this.observers[index]; + { + observer.next(value); + } + } + } + subscribe(observer) { + return observer != null ? /* add */ (this.observers.push(observer) > 0) : false; + } + unsubscribe(observer) { + return observer != null ? /* remove */ (a => { let index = a.indexOf(observer); if (index >= 0) { + a.splice(index, 1); + return true; + } + else { + return false; + } })(this.observers) : false; + } + } + rx.Observable = Observable; + Observable["__class"] = "com.yakindu.core.rx.Observable"; + })(rx = core.rx || (core.rx = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +var sct; +(function (sct) { + var yakindu; + (function (yakindu) { + var io; + (function (io) { + class Statemachine { + constructor() { + this.stateVector = [null]; + this.trace = (new com.yakindu.core.rx.Observable()); + if (this.timerService === undefined) { + this.timerService = null; + } + this.timeEvents = [false]; + this.inEventQueue = ([]); + if (this.isExecuting === undefined) { + this.isExecuting = false; + } + if (this.switchEvent === undefined) { + this.switchEvent = false; + } + if (this.changeBrightness === undefined) { + this.changeBrightness = false; + } + if (this.toggleMode === undefined) { + this.toggleMode = false; + } + if (this.motionDetected === undefined) { + this.motionDetected = false; + } + if (this.brightness === undefined) { + this.brightness = 0; + } + for (let i = 0; i < 1; i++) { + { + this.stateVector[i] = Statemachine.State.$NULLSTATE$; + } + ; + } + this.clearInEvents(); + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + this.isExecuting = false; + } + getIsExecuting() { + return this.isExecuting; + } + setIsExecuting(value) { + this.isExecuting = value; + } + enter() { + if (this.timerService == null) { + throw Object.defineProperty(new Error("Timer service must be set."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.IllegalStateException', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.Exception'] }); + } + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_ENTER, this))); + this.enterSequence_main_default(); + this.isExecuting = false; + } + exit() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_EXIT, this))); + this.exitSequence_main(); + this.isExecuting = false; + } + /** + * @see IStatemachine#isActive() + * @return {boolean} + */ + isActive() { + return this.stateVector[0] !== Statemachine.State.$NULLSTATE$; + } + /** + * + * Always returns 'false' since this state machine can never become final. + * + * @see IStatemachine#isFinal() + * @return {boolean} + */ + isFinal() { + return false; + } + clearInEvents() { + this.switchEvent = false; + this.changeBrightness = false; + this.toggleMode = false; + this.motionDetected = false; + this.timeEvents[0] = false; + } + microStep() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_MOTIONSENSING_R1_OFF: + this.main_MotionSensing_r1_Off_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_MOTIONSENSING_R1_ON: + this.main_MotionSensing_r1_On_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_MANUAL_R1_OFF: + this.main_Manual_r1_Off_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_MANUAL_R1_ON: + this.main_Manual_r1_On_react(-1); + break; + default: + break; + } + } + runCycle() { + if (this.timerService == null) { + throw Object.defineProperty(new Error("Timer service must be set."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.IllegalStateException', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.Exception'] }); + } + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_START, this))); + this.nextEvent(); + do { + { + this.microStep(); + this.clearInEvents(); + this.nextEvent(); + } + } while ((((((this.switchEvent || this.changeBrightness) || this.toggleMode) || this.motionDetected) || this.timeEvents[0]))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_STOP, this))); + this.isExecuting = false; + } + nextEvent() { + if (!(this.inEventQueue.length == 0)) { + (target => (typeof target === 'function') ? target() : target.run())(/* poll */ (a => a.length == 0 ? null : a.shift())(this.inEventQueue)); + return; + } + } + /** + * Returns true if the given state is currently active otherwise false. + * @param {sct.yakindu.io.Statemachine.State} state + * @return {boolean} + */ + isStateActive(state) { + switch ((state)) { + case sct.yakindu.io.Statemachine.State.MAIN_MOTIONSENSING: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_MOTIONSENSING]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_MOTIONSENSING_R1_ON]]; + case sct.yakindu.io.Statemachine.State.MAIN_MOTIONSENSING_R1_OFF: + return this.stateVector[0] === Statemachine.State.MAIN_MOTIONSENSING_R1_OFF; + case sct.yakindu.io.Statemachine.State.MAIN_MOTIONSENSING_R1_ON: + return this.stateVector[0] === Statemachine.State.MAIN_MOTIONSENSING_R1_ON; + case sct.yakindu.io.Statemachine.State.MAIN_MANUAL: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_MANUAL]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_MANUAL_R1_ON]]; + case sct.yakindu.io.Statemachine.State.MAIN_MANUAL_R1_OFF: + return this.stateVector[0] === Statemachine.State.MAIN_MANUAL_R1_OFF; + case sct.yakindu.io.Statemachine.State.MAIN_MANUAL_R1_ON: + return this.stateVector[0] === Statemachine.State.MAIN_MANUAL_R1_ON; + default: + return false; + } + } + setTimerService(timerService) { + this.timerService = timerService; + } + getTimerService() { + return this.timerService; + } + raiseTimeEvent(eventID) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_RAISED, this, null, null, eventID))); + /* add */ (this.inEventQueue.push(() => { + this.timeEvents[eventID] = true; + }) > 0); + this.runCycle(); + } + getTrace() { + return this.trace; + } + raiseSwitch() { + /* add */ (this.inEventQueue.push(() => { + this.switchEvent = true; + }) > 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this, null, Statemachine.Feature.SWITCH, null))); + this.runCycle(); + } + raiseChangeBrightness() { + /* add */ (this.inEventQueue.push(() => { + this.changeBrightness = true; + }) > 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this, null, Statemachine.Feature.CHANGEBRIGHTNESS, null))); + this.runCycle(); + } + raiseToggleMode() { + /* add */ (this.inEventQueue.push(() => { + this.toggleMode = true; + }) > 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this, null, Statemachine.Feature.TOGGLEMODE, null))); + this.runCycle(); + } + raiseMotionDetected() { + /* add */ (this.inEventQueue.push(() => { + this.motionDetected = true; + }) > 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this, null, Statemachine.Feature.MOTIONDETECTED, null))); + this.runCycle(); + } + getBrightness() { + return this.brightness; + } + setBrightness(value) { + this.brightness = value; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + } + entryAction_main_MotionSensing_r1_Off() { + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + } + entryAction_main_MotionSensing_r1_On() { + this.timerService.setTimer(this, 0, (30 * 1000), false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_SET, this, null, null, 0))); + this.setBrightness(1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + } + entryAction_main_Manual_r1_Off() { + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + } + exitAction_main_MotionSensing_r1_On() { + this.timerService.unsetTimer(this, 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_UNSET, this, null, null, 0))); + } + enterSequence_main_MotionSensing_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_MOTIONSENSING, null, null))); + this.enterSequence_main_MotionSensing_r1_default(); + } + enterSequence_main_MotionSensing_r1_Off_default() { + this.entryAction_main_MotionSensing_r1_Off(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_MOTIONSENSING_R1_OFF, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_MOTIONSENSING_R1_OFF; + } + enterSequence_main_MotionSensing_r1_On_default() { + this.entryAction_main_MotionSensing_r1_On(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_MOTIONSENSING_R1_ON, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_MOTIONSENSING_R1_ON; + } + enterSequence_main_Manual_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_MANUAL, null, null))); + this.enterSequence_main_Manual_r1_default(); + } + enterSequence_main_Manual_r1_Off_default() { + this.entryAction_main_Manual_r1_Off(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_MANUAL_R1_OFF, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_MANUAL_R1_OFF; + } + enterSequence_main_Manual_r1_On_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_MANUAL_R1_ON, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_MANUAL_R1_ON; + } + enterSequence_main_default() { + this.react_main__entry_Default(); + } + enterSequence_main_MotionSensing_r1_default() { + this.react_main_MotionSensing_r1__entry_Default(); + } + enterSequence_main_Manual_r1_default() { + this.react_main_Manual_r1__entry_Default(); + } + exitSequence_main_MotionSensing() { + this.exitSequence_main_MotionSensing_r1(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_MOTIONSENSING, null, null))); + } + exitSequence_main_MotionSensing_r1_Off() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_MOTIONSENSING_R1_OFF, null, null))); + } + exitSequence_main_MotionSensing_r1_On() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.exitAction_main_MotionSensing_r1_On(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_MOTIONSENSING_R1_ON, null, null))); + } + exitSequence_main_Manual() { + this.exitSequence_main_Manual_r1(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_MANUAL, null, null))); + } + exitSequence_main_Manual_r1_Off() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_MANUAL_R1_OFF, null, null))); + } + exitSequence_main_Manual_r1_On() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_MANUAL_R1_ON, null, null))); + } + exitSequence_main() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_MOTIONSENSING_R1_OFF: + this.exitSequence_main_MotionSensing_r1_Off(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_MOTIONSENSING, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_MOTIONSENSING_R1_ON: + this.exitSequence_main_MotionSensing_r1_On(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_MOTIONSENSING, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_MANUAL_R1_OFF: + this.exitSequence_main_Manual_r1_Off(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_MANUAL, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_MANUAL_R1_ON: + this.exitSequence_main_Manual_r1_On(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_MANUAL, null, null))); + break; + default: + break; + } + } + exitSequence_main_MotionSensing_r1() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_MOTIONSENSING_R1_OFF: + this.exitSequence_main_MotionSensing_r1_Off(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_MOTIONSENSING_R1_ON: + this.exitSequence_main_MotionSensing_r1_On(); + break; + default: + break; + } + } + exitSequence_main_Manual_r1() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_MANUAL_R1_OFF: + this.exitSequence_main_Manual_r1_Off(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_MANUAL_R1_ON: + this.exitSequence_main_Manual_r1_On(); + break; + default: + break; + } + } + react_main_MotionSensing_r1__entry_Default() { + this.enterSequence_main_MotionSensing_r1_Off_default(); + } + react_main_Manual_r1__entry_Default() { + this.enterSequence_main_Manual_r1_Off_default(); + } + react_main__entry_Default() { + this.enterSequence_main_MotionSensing_default(); + } + react(transitioned_before) { + return transitioned_before; + } + main_MotionSensing_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.toggleMode) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_MOTIONSENSING, null, 0))); + this.exitSequence_main_MotionSensing(); + this.enterSequence_main_Manual_default(); + this.react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_MotionSensing_r1_Off_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.motionDetected) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_MOTIONSENSING_R1_OFF, null, 0))); + this.exitSequence_main_MotionSensing_r1_Off(); + this.enterSequence_main_MotionSensing_r1_On_default(); + this.main_MotionSensing_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_MotionSensing_react(transitioned_before); + } + return transitioned_after; + } + main_MotionSensing_r1_On_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.timeEvents[0]) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_MOTIONSENSING_R1_ON, null, 0))); + this.exitSequence_main_MotionSensing_r1_On(); + this.timeEvents[0] = false; + this.enterSequence_main_MotionSensing_r1_Off_default(); + this.main_MotionSensing_react(0); + transitioned_after = 0; + } + else { + if (this.motionDetected) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_MOTIONSENSING_R1_ON, null, 1))); + this.exitSequence_main_MotionSensing_r1_On(); + this.enterSequence_main_MotionSensing_r1_On_default(); + this.main_MotionSensing_react(0); + transitioned_after = 0; + } + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_MotionSensing_react(transitioned_before); + } + return transitioned_after; + } + main_Manual_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.toggleMode) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_MANUAL, null, 0))); + this.exitSequence_main_Manual(); + this.enterSequence_main_MotionSensing_default(); + this.react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_Manual_r1_Off_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.switchEvent) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_MANUAL_R1_OFF, null, 0))); + this.exitSequence_main_Manual_r1_Off(); + this.setBrightness(10); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + this.enterSequence_main_Manual_r1_On_default(); + this.main_Manual_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_Manual_react(transitioned_before); + } + return transitioned_after; + } + main_Manual_r1_On_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.switchEvent) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_MANUAL_R1_ON, null, 0))); + this.exitSequence_main_Manual_r1_On(); + this.enterSequence_main_Manual_r1_Off_default(); + this.main_Manual_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + if (((this.changeBrightness) && (this.getBrightness() > 1))) { + this.setBrightness(this.getBrightness() - 1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + } + if (((this.changeBrightness) && (this.getBrightness() <= 1))) { + this.setBrightness(10); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + } + transitioned_after = this.main_Manual_react(transitioned_before); + } + return transitioned_after; + } + } + io.Statemachine = Statemachine; + Statemachine["__class"] = "sct.yakindu.io.Statemachine"; + Statemachine["__interfaces"] = ["com.yakindu.core.IStatemachine", "com.yakindu.core.ITimed"]; + (function (Statemachine) { + let State; + (function (State) { + State[State["MAIN_MOTIONSENSING"] = 0] = "MAIN_MOTIONSENSING"; + State[State["MAIN_MOTIONSENSING_R1_OFF"] = 1] = "MAIN_MOTIONSENSING_R1_OFF"; + State[State["MAIN_MOTIONSENSING_R1_ON"] = 2] = "MAIN_MOTIONSENSING_R1_ON"; + State[State["MAIN_MANUAL"] = 3] = "MAIN_MANUAL"; + State[State["MAIN_MANUAL_R1_OFF"] = 4] = "MAIN_MANUAL_R1_OFF"; + State[State["MAIN_MANUAL_R1_ON"] = 5] = "MAIN_MANUAL_R1_ON"; + State[State["$NULLSTATE$"] = 6] = "$NULLSTATE$"; + })(State = Statemachine.State || (Statemachine.State = {})); + /** + * Enumeration of all features of the statechart + * @enum + * @property {sct.yakindu.io.Statemachine.Feature} NO_FEATURE + * @property {sct.yakindu.io.Statemachine.Feature} SWITCH + * @property {sct.yakindu.io.Statemachine.Feature} CHANGEBRIGHTNESS + * @property {sct.yakindu.io.Statemachine.Feature} TOGGLEMODE + * @property {sct.yakindu.io.Statemachine.Feature} MOTIONDETECTED + * @property {sct.yakindu.io.Statemachine.Feature} BRIGHTNESS + * @class + */ + let Feature; + (function (Feature) { + Feature[Feature["NO_FEATURE"] = 0] = "NO_FEATURE"; + Feature[Feature["SWITCH"] = 1] = "SWITCH"; + Feature[Feature["CHANGEBRIGHTNESS"] = 2] = "CHANGEBRIGHTNESS"; + Feature[Feature["TOGGLEMODE"] = 3] = "TOGGLEMODE"; + Feature[Feature["MOTIONDETECTED"] = 4] = "MOTIONDETECTED"; + Feature[Feature["BRIGHTNESS"] = 5] = "BRIGHTNESS"; + })(Feature = Statemachine.Feature || (Statemachine.Feature = {})); + })(Statemachine = io.Statemachine || (io.Statemachine = {})); + })(io = yakindu.io || (yakindu.io = {})); + })(yakindu = sct.yakindu || (sct.yakindu = {})); +})(sct || (sct = {})); diff --git a/org.yakindu.sct.examples.basic.tutorial/_03_motionlightswitch-player/assets/context.json.js b/org.yakindu.sct.examples.basic.tutorial/_03_motionlightswitch-player/assets/context.json.js new file mode 100644 index 00000000..e7c2f457 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_03_motionlightswitch-player/assets/context.json.js @@ -0,0 +1 @@ +const contextJson = {"elements":[{"elements":[{"kind":"event","name":"switch","fqName":"switch","featureId":"SWITCH","writable":true},{"kind":"event","name":"changeBrightness","fqName":"changeBrightness","featureId":"CHANGEBRIGHTNESS","writable":true},{"kind":"event","name":"toggleMode","fqName":"toggleMode","featureId":"TOGGLEMODE","writable":true},{"kind":"event","name":"motionDetected","fqName":"motionDetected","featureId":"MOTIONDETECTED","writable":true},{"kind":"variable","type":"integer","name":"brightness","fqName":"brightness","featureId":"BRIGHTNESS","writable":true,"value":0}],"kind":"composite","name":"default","featureId":"","writable":true},{"elements":[{"kind":"event","type":"integer","name":"On_time_event_0","fqName":"_03_MotionLightSwitch.main.MotionSensing.r1.On_time_event_0","featureId":"ON_TIME_EVENT_0","writable":true,"value":0}],"kind":"composite","name":"time events","featureId":"","writable":true}]} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_03_motionlightswitch-player/assets/hashes.json.js b/org.yakindu.sct.examples.basic.tutorial/_03_motionlightswitch-player/assets/hashes.json.js new file mode 100644 index 00000000..b3aa74bc --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_03_motionlightswitch-player/assets/hashes.json.js @@ -0,0 +1 @@ +const hashesJson = {"MAIN_MANUAL_R1_OFF_tr0":"f19d0376-7c3a-475b-ad13-ab7c6b69a438","MAIN_MOTIONSENSING_R1_OFF":"99b282df-76d2-4488-be81-e91d83b4d135","MAIN_MOTIONSENSING_R1_ON":"8031cb6e-4c16-407b-a825-71e3c650f4a4","MAIN_MOTIONSENSING":"bdddf684-7f08-451c-806c-3d9772b5187a","MAIN_MANUAL_tr0":"7f1d21aa-0834-4fb9-926d-51fe0362efca","MAIN_MANUAL_R1_ON_tr0":"3f364057-d9a2-4e29-8442-c0ad9c9106c8","MAIN_MANUAL_R1_OFF":"d75e6a9e-fcee-44b9-b17c-bc58a9056dae","MAIN_MOTIONSENSING_tr0":"9eff113c-7784-4c53-8173-878e3bda2b5b","MAIN_MANUAL_R1_ON":"b6b48ac5-abca-4b12-8afa-8a385190a5e4","MAIN_MANUAL":"ec72d50b-2905-4996-bcca-9817044151bb","MAIN_MOTIONSENSING_R1_ON_tr0":"9263c09d-98eb-4ebe-a256-0cb42b504fd3","MAIN_MOTIONSENSING_R1_ON_tr1":"c45c1000-84ee-415c-97d0-484bd341ef0c","MAIN_MOTIONSENSING_R1_OFF_tr0":"57b70201-3c73-4e3b-ae94-769365641a5e"} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_03_motionlightswitch-player/assets/statemachine.svg.js b/org.yakindu.sct.examples.basic.tutorial/_03_motionlightswitch-player/assets/statemachine.svg.js new file mode 100644 index 00000000..f5e8f1d6 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_03_motionlightswitch-player/assets/statemachine.svg.js @@ -0,0 +1 @@ +let svg = `main1-MotionSensingr1-Offentry / brightness = 0-Onentry /brightness = 1Manualr1--Offentry / brightness = 0OnchangeBrightness [brightness > 1] / brightness -= 1changeBrightness [brightness <= 1] / brightness = 10-1motionDetectedmotionDetected1after 30safter 30s1toggleModetoggleMode1toggleModetoggleMode1motionDetectedmotionDetected2-1-1switch / brightness = 10switch / brightness = 101switch switch 1` \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_03_motionlightswitch-player/assets/ypi.css b/org.yakindu.sct.examples.basic.tutorial/_03_motionlightswitch-player/assets/ypi.css new file mode 100644 index 00000000..771aaa11 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_03_motionlightswitch-player/assets/ypi.css @@ -0,0 +1,113 @@ +/*! + * itemis CREATE Player Styles + * Copyright 2021 itemis AG + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ + + + /*! + * Style definitions follow BEM pattern using and additional 'y' namespace (for itemis CREATE). + */ +.y-declaration { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; + background-color: #eee; + font-family: 'Courier New', Courier, monospace; +} + + +.y-entry { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; +} + +.y-entry:after { + content: ' \25CF '; + font-size: larger; +} + +.y-state { + background-color: rgb(209, 223, 238); + padding: 3px; + border: 0.5pt;; + border: 0.5pt; + border-radius: 4px; + border-color: #bbb; + font-family: 'Courier New', Courier, monospace; +} + +.y-state--active { + background-color: rgb(244, 215, 66); +} + +.y-state--inactive { + background-color: rgb(209, 223, 238); +} + +.y-variable{ + background-color: #eee; + border-color: #aaa; + border: 0.5pt; + border: 0.5pt; + border-radius: 2px; + font-family: 'Courier New', Courier, monospace; +} + +.y-variable::after { + color: #aaa; + content: attr(value); + font-family: 'Courier New', Courier, monospace; +} + +.y-do-enter { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; +} + +.y-do-enter:before { + content: ' \2192 '; +} + +.y-do-exit { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer +} + +.y-do-exit:before { + content: ' \2192 '; +} + +.y-do-raise { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; + white-space: nowrap; +} + +.y-do-raise:before { + content: ' \2192 '; +} + +button.y-do-raise:before { + content: ''; +} + +button.y-do-raise { + cursor: pointer; +} + +.y-do--over { + color: blue; + background-color: #eee; + cursor: pointer; +} + +.y-player { + border-style: solid; + border-width: 1px; + border-color: ; +} diff --git a/org.yakindu.sct.examples.basic.tutorial/_03_motionlightswitch-player/model.scm b/org.yakindu.sct.examples.basic.tutorial/_03_motionlightswitch-player/model.scm new file mode 100644 index 00000000..909c8115 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_03_motionlightswitch-player/model.scm @@ -0,0 +1,909 @@ +{ + "cells": [ + { + "position": { + "x": 0, + "y": 0 + }, + "size": { + "height": 10, + "width": 10 + }, + "angle": 0, + "type": "Statechart", + "id": "22c4d9bb-d6ad-4dec-9f59-fea69ecf8097", + "linkable": false, + "z": 1, + "attrs": { + "name": { + "text": "_03_MotionLightSwitch" + }, + "specification": { + "text": "@EventDriven\n\ninterface:\n\tin event switch\n\tin event changeBrightness\n\tin event toggleMode\n\tin event motionDetected\n\t\n\tvar brightness: integer" + } + } + }, + { + "type": "Region", + "position": { + "x": 9, + "y": 0 + }, + "size": { + "width": 1164, + "height": 330 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "baca18da-7ab9-4c2f-b97a-185d4775fa30", + "z": 2, + "embeds": [ + "102dcd23-67e6-415d-bdaa-128ab333c7b6", + "9eff113c-7784-4c53-8173-878e3bda2b5b", + "7f1d21aa-0834-4fb9-926d-51fe0362efca", + "eb20886d-7334-410c-ad6c-5df2b8dc0516", + "bdddf684-7f08-451c-806c-3d9772b5187a", + "ec72d50b-2905-4996-bcca-9817044151bb" + ], + "attrs": { + "priority": { + "text": 1 + }, + "name": { + "fontSize": "9", + "text": "main" + } + } + }, + { + "type": "Entry", + "position": { + "x": 235, + "y": 28 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "eb20886d-7334-410c-ad6c-5df2b8dc0516", + "parent": "baca18da-7ab9-4c2f-b97a-185d4775fa30", + "z": 3, + "embeds": [ + "40578349-3556-4906-b8a9-15350704225f" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 235, + "y": 43 + }, + "id": "40578349-3556-4906-b8a9-15350704225f", + "z": 4, + "parent": "eb20886d-7334-410c-ad6c-5df2b8dc0516", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 34, + "y": 77 + }, + "size": { + "width": 418, + "height": 225 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "bdddf684-7f08-451c-806c-3d9772b5187a", + "parent": "baca18da-7ab9-4c2f-b97a-185d4775fa30", + "z": 5, + "embeds": [ + "e29a9f23-6255-4f6e-a2f2-d18010ce811c" + ], + "attrs": { + "name": { + "text": "MotionSensing" + } + } + }, + { + "type": "Region", + "position": { + "x": 35, + "y": 117 + }, + "size": { + "width": 416, + "height": 184 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "e29a9f23-6255-4f6e-a2f2-d18010ce811c", + "z": 6, + "parent": "bdddf684-7f08-451c-806c-3d9772b5187a", + "embeds": [ + "c45c1000-84ee-415c-97d0-484bd341ef0c", + "9263c09d-98eb-4ebe-a256-0cb42b504fd3", + "57b70201-3c73-4e3b-ae94-769365641a5e", + "f75eeecb-407c-424f-b052-25b0ebf8dd5b", + "99b282df-76d2-4488-be81-e91d83b4d135", + "9c68627e-182e-472e-bb4f-4eadd738026d", + "8031cb6e-4c16-407b-a825-71e3c650f4a4" + ], + "attrs": { + "name": { + "fontSize": "9", + "text": "r1" + } + } + }, + { + "type": "State", + "position": { + "x": 49, + "y": 145 + }, + "size": { + "width": 123, + "height": 62 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "99b282df-76d2-4488-be81-e91d83b4d135", + "parent": "e29a9f23-6255-4f6e-a2f2-d18010ce811c", + "z": 7, + "attrs": { + "name": { + "text": "Off" + }, + "specification": { + "text": "entry / \r\nbrightness = 0", + "fontSize": "9" + } + } + }, + { + "type": "Entry", + "position": { + "x": 108, + "y": 250 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "9c68627e-182e-472e-bb4f-4eadd738026d", + "parent": "e29a9f23-6255-4f6e-a2f2-d18010ce811c", + "z": 8, + "embeds": [ + "0fccd18e-6e92-4c52-a3bc-ebb05a0f9450" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 108, + "y": 265 + }, + "id": "0fccd18e-6e92-4c52-a3bc-ebb05a0f9450", + "z": 9, + "parent": "9c68627e-182e-472e-bb4f-4eadd738026d", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 271, + "y": 145 + }, + "size": { + "width": 132, + "height": 62 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "8031cb6e-4c16-407b-a825-71e3c650f4a4", + "parent": "e29a9f23-6255-4f6e-a2f2-d18010ce811c", + "z": 10, + "attrs": { + "name": { + "text": "On" + }, + "specification": { + "text": "entry /\nbrightness = 1", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 572, + "y": 77 + }, + "size": { + "width": 551, + "height": 225 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "ec72d50b-2905-4996-bcca-9817044151bb", + "parent": "baca18da-7ab9-4c2f-b97a-185d4775fa30", + "z": 11, + "embeds": [ + "256f22c3-eeda-4bfd-8040-a2633d82bcd9" + ], + "attrs": { + "name": { + "text": "Manual" + } + } + }, + { + "type": "Region", + "position": { + "x": 573, + "y": 117 + }, + "size": { + "width": 549, + "height": 184 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "256f22c3-eeda-4bfd-8040-a2633d82bcd9", + "z": 12, + "parent": "ec72d50b-2905-4996-bcca-9817044151bb", + "embeds": [ + "3f364057-d9a2-4e29-8442-c0ad9c9106c8", + "f19d0376-7c3a-475b-ad13-ab7c6b69a438", + "756e86de-3650-41fd-98b8-b6134a4d9c4f", + "0ed07006-c1d4-4b33-9b21-378d10ea921b", + "d75e6a9e-fcee-44b9-b17c-bc58a9056dae", + "b6b48ac5-abca-4b12-8afa-8a385190a5e4" + ], + "attrs": { + "name": { + "fontSize": "9", + "text": "r1" + } + } + }, + { + "type": "Entry", + "position": { + "x": 656, + "y": 247 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "0ed07006-c1d4-4b33-9b21-378d10ea921b", + "parent": "256f22c3-eeda-4bfd-8040-a2633d82bcd9", + "z": 13, + "embeds": [ + "80ae9fff-723b-4416-ae5c-1e9df5ccb3c4" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 656, + "y": 262 + }, + "id": "80ae9fff-723b-4416-ae5c-1e9df5ccb3c4", + "z": 14, + "parent": "0ed07006-c1d4-4b33-9b21-378d10ea921b", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 585, + "y": 145 + }, + "size": { + "width": 144, + "height": 68 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "d75e6a9e-fcee-44b9-b17c-bc58a9056dae", + "parent": "256f22c3-eeda-4bfd-8040-a2633d82bcd9", + "z": 15, + "attrs": { + "name": { + "text": "Off" + }, + "specification": { + "text": "entry \n / brightness = 0", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 875, + "y": 145 + }, + "size": { + "width": 232, + "height": 135 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "b6b48ac5-abca-4b12-8afa-8a385190a5e4", + "parent": "256f22c3-eeda-4bfd-8040-a2633d82bcd9", + "z": 16, + "attrs": { + "name": { + "text": "On" + }, + "specification": { + "text": "changeBrightness \n [brightness > 1] / brightness -= 1\nchangeBrightness \n [brightness <= 1] / brightness = 10", + "fontSize": "9" + } + } + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50.69444444444458%", + "dy": "3.0188679245285734%", + "rotate": true + } + }, + "id": "9c68627e-182e-472e-bb4f-4eadd738026d" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "54.14972899728999%", + "dy": "50%", + "rotate": true + } + }, + "id": "99b282df-76d2-4488-be81-e91d83b4d135" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "f75eeecb-407c-424f-b052-25b0ebf8dd5b", + "z": 17, + "parent": "e29a9f23-6255-4f6e-a2f2-d18010ce811c", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "24.32542097788601%", + "rotate": true + } + }, + "id": "99b282df-76d2-4488-be81-e91d83b4d135" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.3029935987784728%", + "dy": "24.32542097788601%", + "rotate": true + } + }, + "id": "8031cb6e-4c16-407b-a825-71e3c650f4a4" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "motionDetected", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "57b70201-3c73-4e3b-ae94-769365641a5e", + "z": 18, + "parent": "e29a9f23-6255-4f6e-a2f2-d18010ce811c", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.36150411292872126%", + "dy": "79.45119396732304%", + "rotate": true + } + }, + "id": "8031cb6e-4c16-407b-a825-71e3c650f4a4" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "79.45119396732304%", + "rotate": true + } + }, + "id": "99b282df-76d2-4488-be81-e91d83b4d135" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "after 30s", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "9263c09d-98eb-4ebe-a256-0cb42b504fd3", + "z": 19, + "parent": "e29a9f23-6255-4f6e-a2f2-d18010ce811c", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.13486658979703062%", + "dy": "34.122079421505205%", + "rotate": true + } + }, + "id": "ec72d50b-2905-4996-bcca-9817044151bb" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "34.122079421505205%", + "rotate": true + } + }, + "id": "bdddf684-7f08-451c-806c-3d9772b5187a" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "toggleMode", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "7f1d21aa-0834-4fb9-926d-51fe0362efca", + "z": 20, + "parent": "baca18da-7ab9-4c2f-b97a-185d4775fa30", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "55.661835748792264%", + "rotate": true + } + }, + "id": "bdddf684-7f08-451c-806c-3d9772b5187a" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.09834927867935579%", + "dy": "55.661835748792264%", + "rotate": true + } + }, + "id": "ec72d50b-2905-4996-bcca-9817044151bb" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "toggleMode", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "9eff113c-7784-4c53-8173-878e3bda2b5b", + "z": 21, + "parent": "baca18da-7ab9-4c2f-b97a-185d4775fa30", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "98.32900669652105%", + "dy": "34.67392822231531%", + "rotate": true + } + }, + "id": "8031cb6e-4c16-407b-a825-71e3c650f4a4" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "72.41837098276804%", + "dy": "50%", + "rotate": true + } + }, + "id": "8031cb6e-4c16-407b-a825-71e3c650f4a4" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "motionDetected", + "fontSize": "9" + } + }, + "position": { + "distance": 0.6388253317287163, + "offset": -14.493506493506516, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "2" + } + } + } + ], + "id": "c45c1000-84ee-415c-97d0-484bd341ef0c", + "z": 22, + "parent": "e29a9f23-6255-4f6e-a2f2-d18010ce811c", + "vertices": [ + { + "x": 421.06027579202316, + "y": 166.4978354978355 + }, + { + "x": 421.06027579202316, + "y": 226.50649350649348 + }, + { + "x": 366.5922496972538, + "y": 226.50649350649348 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "48.88888888888896%", + "dy": "97.11583924349885%", + "rotate": true + } + }, + "id": "eb20886d-7334-410c-ad6c-5df2b8dc0516" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "49.84051036682616%", + "dy": "0.2821118991331812%", + "rotate": true + } + }, + "id": "bdddf684-7f08-451c-806c-3d9772b5187a" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "102dcd23-67e6-415d-bdaa-128ab333c7b6", + "z": 23, + "parent": "baca18da-7ab9-4c2f-b97a-185d4775fa30", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "35.555555555555806%", + "dy": "2.222222222222475%", + "rotate": true + } + }, + "id": "0ed07006-c1d4-4b33-9b21-378d10ea921b" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "53.00925925925929%", + "dy": "50%", + "rotate": true + } + }, + "id": "d75e6a9e-fcee-44b9-b17c-bc58a9056dae" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "756e86de-3650-41fd-98b8-b6134a4d9c4f", + "z": 24, + "parent": "256f22c3-eeda-4bfd-8040-a2633d82bcd9", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "17.892156862745125%", + "rotate": true + } + }, + "id": "d75e6a9e-fcee-44b9-b17c-bc58a9056dae" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "9.012345679012359%", + "rotate": true + } + }, + "id": "b6b48ac5-abca-4b12-8afa-8a385190a5e4" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "switch /\n brightness = 10", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "f19d0376-7c3a-475b-ad13-ab7c6b69a438", + "z": 25, + "parent": "256f22c3-eeda-4bfd-8040-a2633d82bcd9", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "33.53831819240626%", + "rotate": true + } + }, + "id": "b6b48ac5-abca-4b12-8afa-8a385190a5e4" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "66.58342582315949%", + "rotate": true + } + }, + "id": "d75e6a9e-fcee-44b9-b17c-bc58a9056dae" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "switch ", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "3f364057-d9a2-4e29-8442-c0ad9c9106c8", + "z": 26, + "parent": "256f22c3-eeda-4bfd-8040-a2633d82bcd9", + "attrs": {} + } + ] +} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_03_motionlightswitch-player/player.html b/org.yakindu.sct.examples.basic.tutorial/_03_motionlightswitch-player/player.html new file mode 100644 index 00000000..a40d8757 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_03_motionlightswitch-player/player.html @@ -0,0 +1,52 @@ + +sct-web-player demo + + + + + + + + + + + + + + + +
+ +
+ + + + + \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_04_lightandmotionsensinglightswitch-player/assets/bundle.js b/org.yakindu.sct.examples.basic.tutorial/_04_lightandmotionsensinglightswitch-player/assets/bundle.js new file mode 100644 index 00000000..7652f6b6 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_04_lightandmotionsensinglightswitch-player/assets/bundle.js @@ -0,0 +1,1191 @@ +var com; +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Instances represent state machine trace events. + * @param {com.yakindu.core.TraceEventType} type + * @param {*} machine + * @param {*} state + * @param {*} feature + * @param {*} value + * @class + */ + class TraceEvent { + constructor(type, machine, state, feature, value) { + if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && ((state != null) || state === null) && ((feature != null) || feature === null) && ((value != null) || value === null)) { + let __args = arguments; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + else if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && state === undefined && feature === undefined && value === undefined) { + let __args = arguments; + { + let __args = arguments; + let state = null; + let feature = null; + let value = null; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + } + else + throw new Error('invalid overload'); + } + getType() { + return this.type; + } + getMachine() { + return this.machine; + } + getState() { + return this.state; + } + getFeature() { + return this.feature; + } + getValue() { + return this.value; + } + } + core.TraceEvent = TraceEvent; + TraceEvent["__class"] = "com.yakindu.core.TraceEvent"; + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Trace event type enumeration. + * @enum + * @property {com.yakindu.core.TraceEventType} MACHINE_ENTER + * @property {com.yakindu.core.TraceEventType} MACHINE_EXIT + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_START + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_STOP + * @property {com.yakindu.core.TraceEventType} STATE_ENTERED + * @property {com.yakindu.core.TraceEventType} STATE_EXITED + * @property {com.yakindu.core.TraceEventType} STATE_TRANSITION + * @property {com.yakindu.core.TraceEventType} EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} VARIABLE_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_UNSET + * @class + */ + let TraceEventType; + (function (TraceEventType) { + TraceEventType[TraceEventType["MACHINE_ENTER"] = 0] = "MACHINE_ENTER"; + TraceEventType[TraceEventType["MACHINE_EXIT"] = 1] = "MACHINE_EXIT"; + TraceEventType[TraceEventType["MACHINE_RTS_START"] = 2] = "MACHINE_RTS_START"; + TraceEventType[TraceEventType["MACHINE_RTS_STOP"] = 3] = "MACHINE_RTS_STOP"; + TraceEventType[TraceEventType["STATE_ENTERED"] = 4] = "STATE_ENTERED"; + TraceEventType[TraceEventType["STATE_EXITED"] = 5] = "STATE_EXITED"; + TraceEventType[TraceEventType["STATE_TRANSITION"] = 6] = "STATE_TRANSITION"; + TraceEventType[TraceEventType["EVENT_RAISED"] = 7] = "EVENT_RAISED"; + TraceEventType[TraceEventType["VARIABLE_SET"] = 8] = "VARIABLE_SET"; + TraceEventType[TraceEventType["TIME_EVENT_RAISED"] = 9] = "TIME_EVENT_RAISED"; + TraceEventType[TraceEventType["TIME_EVENT_SET"] = 10] = "TIME_EVENT_SET"; + TraceEventType[TraceEventType["TIME_EVENT_UNSET"] = 11] = "TIME_EVENT_UNSET"; + })(TraceEventType = core.TraceEventType || (core.TraceEventType = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + var rx; + (function (rx) { + class Observable { + constructor() { + this.observers = ([]); + } + next(value) { + for (let index = 0; index < this.observers.length; index++) { + let observer = this.observers[index]; + { + observer.next(value); + } + } + } + subscribe(observer) { + return observer != null ? /* add */ (this.observers.push(observer) > 0) : false; + } + unsubscribe(observer) { + return observer != null ? /* remove */ (a => { let index = a.indexOf(observer); if (index >= 0) { + a.splice(index, 1); + return true; + } + else { + return false; + } })(this.observers) : false; + } + } + rx.Observable = Observable; + Observable["__class"] = "com.yakindu.core.rx.Observable"; + })(rx = core.rx || (core.rx = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +var sct; +(function (sct) { + var yakindu; + (function (yakindu) { + var io; + (function (io) { + class Statemachine { + constructor() { + if (this.__hmi === undefined) { + this.__hmi = null; + } + if (this.__motion === undefined) { + this.__motion = null; + } + if (this.__luminosity === undefined) { + this.__luminosity = null; + } + this.historyVector = [null, null, null, null]; + this.stateVector = [null]; + this.trace = (new com.yakindu.core.rx.Observable()); + if (this.timerService === undefined) { + this.timerService = null; + } + this.timeEvents = [false, false, false]; + this.inEventQueue = ([]); + if (this.isExecuting === undefined) { + this.isExecuting = false; + } + if (this.brightness === undefined) { + this.brightness = 0; + } + this.__hmi = new Statemachine.Hmi(this); + this.__motion = new Statemachine.Motion(this); + this.__luminosity = new Statemachine.Luminosity(this); + for (let i = 0; i < 1; i++) { + { + this.stateVector[i] = Statemachine.State.$NULLSTATE$; + } + ; + } + for (let i = 0; i < 4; i++) { + { + this.historyVector[i] = Statemachine.State.$NULLSTATE$; + } + ; + } + this.clearInEvents(); + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + this.isExecuting = false; + } + getIsExecuting() { + return this.isExecuting; + } + setIsExecuting(value) { + this.isExecuting = value; + } + enter() { + if (this.timerService == null) { + throw Object.defineProperty(new Error("Timer service must be set."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.IllegalStateException', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.Exception'] }); + } + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_ENTER, this))); + this.enterSequence_modes_default(); + this.isExecuting = false; + } + exit() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_EXIT, this))); + this.exitSequence_modes(); + this.isExecuting = false; + } + /** + * @see IStatemachine#isActive() + * @return {boolean} + */ + isActive() { + return this.stateVector[0] !== Statemachine.State.$NULLSTATE$; + } + /** + * + * Always returns 'false' since this state machine can never become final. + * + * @see IStatemachine#isFinal() + * @return {boolean} + */ + isFinal() { + return false; + } + clearInEvents() { + this.__hmi.switchEvent = false; + this.__hmi.toggleMode = false; + this.__hmi.changeBrightness = false; + this.__motion.detected = false; + this.__luminosity.bright = false; + this.__luminosity.dark = false; + this.timeEvents[0] = false; + this.timeEvents[1] = false; + this.timeEvents[2] = false; + } + microStep() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_STILL: + this.modes_Automatic_modes_Motion_Sensing_r1_Still_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_MOTION: + this.modes_Automatic_modes_Motion_Sensing_r1_Motion_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_BRIGHT: + this.modes_Automatic_modes_Light_Sensing_r1_Bright_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_DARK: + this.modes_Automatic_modes_Light_Sensing_r1_Dark_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_DARK: + this.modes_Automatic_modes_Light_Sensing_r1_Getting_Dark_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_BRIGHT: + this.modes_Automatic_modes_Light_Sensing_r1_Getting_Bright_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MODES_MANUAL_R1_OFF: + this.modes_Manual_r1_Off_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MODES_MANUAL_R1_ON: + this.modes_Manual_r1_On_react(-1); + break; + default: + break; + } + } + runCycle() { + if (this.timerService == null) { + throw Object.defineProperty(new Error("Timer service must be set."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.IllegalStateException', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.Exception'] }); + } + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_START, this))); + this.nextEvent(); + do { + { + this.microStep(); + this.clearInEvents(); + this.nextEvent(); + } + } while ((((((((((this.__hmi.switchEvent || this.__hmi.toggleMode) || this.__hmi.changeBrightness) || this.__motion.detected) || this.__luminosity.bright) || this.__luminosity.dark) || this.timeEvents[0]) || this.timeEvents[1]) || this.timeEvents[2]))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_STOP, this))); + this.isExecuting = false; + } + nextEvent() { + if (!(this.inEventQueue.length == 0)) { + (target => (typeof target === 'function') ? target() : target.run())(/* poll */ (a => a.length == 0 ? null : a.shift())(this.inEventQueue)); + return; + } + } + /** + * Returns true if the given state is currently active otherwise false. + * @param {sct.yakindu.io.Statemachine.State} state + * @return {boolean} + */ + isStateActive(state) { + switch ((state)) { + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MODES_AUTOMATIC]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_BRIGHT]]; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_MOTION]]; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_STILL: + return this.stateVector[0] === Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_STILL; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_MOTION: + return this.stateVector[0] === Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_MOTION; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_BRIGHT]]; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_BRIGHT: + return this.stateVector[0] === Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_BRIGHT; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_DARK: + return this.stateVector[0] === Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_DARK; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_DARK: + return this.stateVector[0] === Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_DARK; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_BRIGHT: + return this.stateVector[0] === Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_BRIGHT; + case sct.yakindu.io.Statemachine.State.MODES_MANUAL: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MODES_MANUAL]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MODES_MANUAL_R1_ON]]; + case sct.yakindu.io.Statemachine.State.MODES_MANUAL_R1_OFF: + return this.stateVector[0] === Statemachine.State.MODES_MANUAL_R1_OFF; + case sct.yakindu.io.Statemachine.State.MODES_MANUAL_R1_ON: + return this.stateVector[0] === Statemachine.State.MODES_MANUAL_R1_ON; + default: + return false; + } + } + setTimerService(timerService) { + this.timerService = timerService; + } + getTimerService() { + return this.timerService; + } + raiseTimeEvent(eventID) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_RAISED, this, null, null, eventID))); + /* add */ (this.inEventQueue.push(() => { + this.timeEvents[eventID] = true; + }) > 0); + this.runCycle(); + } + hmi() { + return this.__hmi; + } + motion() { + return this.__motion; + } + luminosity() { + return this.__luminosity; + } + getTrace() { + return this.trace; + } + getBrightness() { + return this.brightness; + } + setBrightness(value) { + this.brightness = value; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + } + entryAction_modes_Automatic_modes_Motion_Sensing_r1_Still() { + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + } + entryAction_modes_Automatic_modes_Motion_Sensing_r1_Motion() { + this.timerService.setTimer(this, 0, (this.__motion.getTimeout() * 1000), false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_SET, this, null, null, 0))); + this.setBrightness(10); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + } + entryAction_modes_Automatic_modes_Light_Sensing_r1_Bright() { + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + } + entryAction_modes_Automatic_modes_Light_Sensing_r1_Dark() { + this.setBrightness(10); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + } + entryAction_modes_Automatic_modes_Light_Sensing_r1_Getting_Dark() { + this.timerService.setTimer(this, 1, (this.__luminosity.getDelay() * 1000), false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_SET, this, null, null, 1))); + } + entryAction_modes_Automatic_modes_Light_Sensing_r1_Getting_Bright() { + this.timerService.setTimer(this, 2, (this.__luminosity.getDelay() * 1000), false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_SET, this, null, null, 2))); + } + entryAction_modes_Manual_r1_Off() { + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + } + exitAction_modes_Automatic_modes_Motion_Sensing_r1_Motion() { + this.timerService.unsetTimer(this, 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_UNSET, this, null, null, 0))); + } + exitAction_modes_Automatic_modes_Light_Sensing_r1_Getting_Dark() { + this.timerService.unsetTimer(this, 1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_UNSET, this, null, null, 1))); + } + exitAction_modes_Automatic_modes_Light_Sensing_r1_Getting_Bright() { + this.timerService.unsetTimer(this, 2); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_UNSET, this, null, null, 2))); + } + enterSequence_modes_Automatic_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MODES_AUTOMATIC, null, null))); + this.enterSequence_modes_Automatic_modes_default(); + } + enterSequence_modes_Automatic_modes_Motion_Sensing_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING, null, null))); + this.enterSequence_modes_Automatic_modes_Motion_Sensing_r1_default(); + this.historyVector[0] = this.stateVector[0]; + } + enterSequence_modes_Automatic_modes_Motion_Sensing_r1_Still_default() { + this.entryAction_modes_Automatic_modes_Motion_Sensing_r1_Still(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_STILL, null, null))); + this.stateVector[0] = Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_STILL; + this.historyVector[1] = this.stateVector[0]; + } + enterSequence_modes_Automatic_modes_Motion_Sensing_r1_Motion_default() { + this.entryAction_modes_Automatic_modes_Motion_Sensing_r1_Motion(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_MOTION, null, null))); + this.stateVector[0] = Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_MOTION; + this.historyVector[1] = this.stateVector[0]; + } + enterSequence_modes_Automatic_modes_Light_Sensing_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING, null, null))); + this.enterSequence_modes_Automatic_modes_Light_Sensing_r1_default(); + this.historyVector[0] = this.stateVector[0]; + } + enterSequence_modes_Automatic_modes_Light_Sensing_r1_Bright_default() { + this.entryAction_modes_Automatic_modes_Light_Sensing_r1_Bright(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_BRIGHT, null, null))); + this.stateVector[0] = Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_BRIGHT; + this.historyVector[2] = this.stateVector[0]; + } + enterSequence_modes_Automatic_modes_Light_Sensing_r1_Dark_default() { + this.entryAction_modes_Automatic_modes_Light_Sensing_r1_Dark(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_DARK, null, null))); + this.stateVector[0] = Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_DARK; + this.historyVector[2] = this.stateVector[0]; + } + enterSequence_modes_Automatic_modes_Light_Sensing_r1_Getting_Dark_default() { + this.entryAction_modes_Automatic_modes_Light_Sensing_r1_Getting_Dark(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_DARK, null, null))); + this.stateVector[0] = Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_DARK; + this.historyVector[2] = this.stateVector[0]; + } + enterSequence_modes_Automatic_modes_Light_Sensing_r1_Getting_Bright_default() { + this.entryAction_modes_Automatic_modes_Light_Sensing_r1_Getting_Bright(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_BRIGHT, null, null))); + this.stateVector[0] = Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_BRIGHT; + this.historyVector[2] = this.stateVector[0]; + } + enterSequence_modes_Manual_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MODES_MANUAL, null, null))); + this.enterSequence_modes_Manual_r1_default(); + } + enterSequence_modes_Manual_r1_Off_default() { + this.entryAction_modes_Manual_r1_Off(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MODES_MANUAL_R1_OFF, null, null))); + this.stateVector[0] = Statemachine.State.MODES_MANUAL_R1_OFF; + this.historyVector[3] = this.stateVector[0]; + } + enterSequence_modes_Manual_r1_On_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MODES_MANUAL_R1_ON, null, null))); + this.stateVector[0] = Statemachine.State.MODES_MANUAL_R1_ON; + this.historyVector[3] = this.stateVector[0]; + } + enterSequence_modes_default() { + this.react_modes__entry_Default(); + } + enterSequence_modes_Automatic_modes_default() { + this.react_modes_Automatic_modes__entry_Default(); + } + shallowEnterSequence_modes_Automatic_modes() { + switch ((this.historyVector[0])) { + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_STILL: + this.enterSequence_modes_Automatic_modes_Motion_Sensing_default(); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_MOTION: + this.enterSequence_modes_Automatic_modes_Motion_Sensing_default(); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_BRIGHT: + this.enterSequence_modes_Automatic_modes_Light_Sensing_default(); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_DARK: + this.enterSequence_modes_Automatic_modes_Light_Sensing_default(); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_DARK: + this.enterSequence_modes_Automatic_modes_Light_Sensing_default(); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_BRIGHT: + this.enterSequence_modes_Automatic_modes_Light_Sensing_default(); + break; + default: + break; + } + } + enterSequence_modes_Automatic_modes_Motion_Sensing_r1_default() { + this.react_modes_Automatic_modes_Motion_Sensing_r1__entry_Default(); + } + shallowEnterSequence_modes_Automatic_modes_Motion_Sensing_r1() { + switch ((this.historyVector[1])) { + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_STILL: + this.enterSequence_modes_Automatic_modes_Motion_Sensing_r1_Still_default(); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_MOTION: + this.enterSequence_modes_Automatic_modes_Motion_Sensing_r1_Motion_default(); + break; + default: + break; + } + } + enterSequence_modes_Automatic_modes_Light_Sensing_r1_default() { + this.react_modes_Automatic_modes_Light_Sensing_r1__entry_Default(); + } + shallowEnterSequence_modes_Automatic_modes_Light_Sensing_r1() { + switch ((this.historyVector[2])) { + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_BRIGHT: + this.enterSequence_modes_Automatic_modes_Light_Sensing_r1_Bright_default(); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_DARK: + this.enterSequence_modes_Automatic_modes_Light_Sensing_r1_Dark_default(); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_DARK: + this.enterSequence_modes_Automatic_modes_Light_Sensing_r1_Getting_Dark_default(); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_BRIGHT: + this.enterSequence_modes_Automatic_modes_Light_Sensing_r1_Getting_Bright_default(); + break; + default: + break; + } + } + enterSequence_modes_Manual_r1_default() { + this.react_modes_Manual_r1__entry_Default(); + } + shallowEnterSequence_modes_Manual_r1() { + switch ((this.historyVector[3])) { + case sct.yakindu.io.Statemachine.State.MODES_MANUAL_R1_OFF: + this.enterSequence_modes_Manual_r1_Off_default(); + break; + case sct.yakindu.io.Statemachine.State.MODES_MANUAL_R1_ON: + this.enterSequence_modes_Manual_r1_On_default(); + break; + default: + break; + } + } + exitSequence_modes_Automatic() { + this.exitSequence_modes_Automatic_modes(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC, null, null))); + } + exitSequence_modes_Automatic_modes_Motion_Sensing() { + this.exitSequence_modes_Automatic_modes_Motion_Sensing_r1(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING, null, null))); + } + exitSequence_modes_Automatic_modes_Motion_Sensing_r1_Still() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_STILL, null, null))); + } + exitSequence_modes_Automatic_modes_Motion_Sensing_r1_Motion() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.exitAction_modes_Automatic_modes_Motion_Sensing_r1_Motion(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_MOTION, null, null))); + } + exitSequence_modes_Automatic_modes_Light_Sensing() { + this.exitSequence_modes_Automatic_modes_Light_Sensing_r1(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING, null, null))); + } + exitSequence_modes_Automatic_modes_Light_Sensing_r1_Bright() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_BRIGHT, null, null))); + } + exitSequence_modes_Automatic_modes_Light_Sensing_r1_Dark() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_DARK, null, null))); + } + exitSequence_modes_Automatic_modes_Light_Sensing_r1_Getting_Dark() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.exitAction_modes_Automatic_modes_Light_Sensing_r1_Getting_Dark(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_DARK, null, null))); + } + exitSequence_modes_Automatic_modes_Light_Sensing_r1_Getting_Bright() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.exitAction_modes_Automatic_modes_Light_Sensing_r1_Getting_Bright(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_BRIGHT, null, null))); + } + exitSequence_modes_Manual() { + this.exitSequence_modes_Manual_r1(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_MANUAL, null, null))); + } + exitSequence_modes_Manual_r1_Off() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_MANUAL_R1_OFF, null, null))); + } + exitSequence_modes_Manual_r1_On() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_MANUAL_R1_ON, null, null))); + } + exitSequence_modes() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_STILL: + this.exitSequence_modes_Automatic_modes_Motion_Sensing_r1_Still(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING, null, null))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_MOTION: + this.exitSequence_modes_Automatic_modes_Motion_Sensing_r1_Motion(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING, null, null))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_BRIGHT: + this.exitSequence_modes_Automatic_modes_Light_Sensing_r1_Bright(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING, null, null))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_DARK: + this.exitSequence_modes_Automatic_modes_Light_Sensing_r1_Dark(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING, null, null))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_DARK: + this.exitSequence_modes_Automatic_modes_Light_Sensing_r1_Getting_Dark(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING, null, null))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_BRIGHT: + this.exitSequence_modes_Automatic_modes_Light_Sensing_r1_Getting_Bright(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING, null, null))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MODES_MANUAL_R1_OFF: + this.exitSequence_modes_Manual_r1_Off(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_MANUAL, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MODES_MANUAL_R1_ON: + this.exitSequence_modes_Manual_r1_On(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_MANUAL, null, null))); + break; + default: + break; + } + } + exitSequence_modes_Automatic_modes() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_STILL: + this.exitSequence_modes_Automatic_modes_Motion_Sensing_r1_Still(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_MOTION: + this.exitSequence_modes_Automatic_modes_Motion_Sensing_r1_Motion(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_BRIGHT: + this.exitSequence_modes_Automatic_modes_Light_Sensing_r1_Bright(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_DARK: + this.exitSequence_modes_Automatic_modes_Light_Sensing_r1_Dark(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_DARK: + this.exitSequence_modes_Automatic_modes_Light_Sensing_r1_Getting_Dark(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_BRIGHT: + this.exitSequence_modes_Automatic_modes_Light_Sensing_r1_Getting_Bright(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING, null, null))); + break; + default: + break; + } + } + exitSequence_modes_Automatic_modes_Motion_Sensing_r1() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_STILL: + this.exitSequence_modes_Automatic_modes_Motion_Sensing_r1_Still(); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_MOTION: + this.exitSequence_modes_Automatic_modes_Motion_Sensing_r1_Motion(); + break; + default: + break; + } + } + exitSequence_modes_Automatic_modes_Light_Sensing_r1() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_BRIGHT: + this.exitSequence_modes_Automatic_modes_Light_Sensing_r1_Bright(); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_DARK: + this.exitSequence_modes_Automatic_modes_Light_Sensing_r1_Dark(); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_DARK: + this.exitSequence_modes_Automatic_modes_Light_Sensing_r1_Getting_Dark(); + break; + case sct.yakindu.io.Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_BRIGHT: + this.exitSequence_modes_Automatic_modes_Light_Sensing_r1_Getting_Bright(); + break; + default: + break; + } + } + exitSequence_modes_Manual_r1() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MODES_MANUAL_R1_OFF: + this.exitSequence_modes_Manual_r1_Off(); + break; + case sct.yakindu.io.Statemachine.State.MODES_MANUAL_R1_ON: + this.exitSequence_modes_Manual_r1_On(); + break; + default: + break; + } + } + react_modes_Automatic_modes_Motion_Sensing_r1__entry_Default() { + if (this.historyVector[1] !== Statemachine.State.$NULLSTATE$) { + this.shallowEnterSequence_modes_Automatic_modes_Motion_Sensing_r1(); + } + else { + this.enterSequence_modes_Automatic_modes_Motion_Sensing_r1_Still_default(); + } + } + react_modes_Automatic_modes_Light_Sensing_r1__entry_Default() { + if (this.historyVector[2] !== Statemachine.State.$NULLSTATE$) { + this.shallowEnterSequence_modes_Automatic_modes_Light_Sensing_r1(); + } + else { + this.enterSequence_modes_Automatic_modes_Light_Sensing_r1_Bright_default(); + } + } + react_modes_Automatic_modes__entry_Default() { + if (this.historyVector[0] !== Statemachine.State.$NULLSTATE$) { + this.shallowEnterSequence_modes_Automatic_modes(); + } + else { + this.enterSequence_modes_Automatic_modes_Motion_Sensing_default(); + } + } + react_modes_Manual_r1__entry_Default() { + if (this.historyVector[3] !== Statemachine.State.$NULLSTATE$) { + this.shallowEnterSequence_modes_Manual_r1(); + } + else { + this.enterSequence_modes_Manual_r1_Off_default(); + } + } + react_modes__entry_Default() { + this.enterSequence_modes_Manual_default(); + } + react(transitioned_before) { + return transitioned_before; + } + modes_Automatic_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__hmi.switchEvent) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MODES_AUTOMATIC, null, 0))); + this.exitSequence_modes_Automatic(); + this.enterSequence_modes_Manual_default(); + this.react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + modes_Automatic_modes_Motion_Sensing_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__hmi.toggleMode) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING, null, 0))); + this.exitSequence_modes_Automatic_modes_Motion_Sensing(); + this.enterSequence_modes_Automatic_modes_Light_Sensing_default(); + this.modes_Automatic_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.modes_Automatic_react(transitioned_before); + } + return transitioned_after; + } + modes_Automatic_modes_Motion_Sensing_r1_Still_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__motion.detected) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_STILL, null, 0))); + this.exitSequence_modes_Automatic_modes_Motion_Sensing_r1_Still(); + this.enterSequence_modes_Automatic_modes_Motion_Sensing_r1_Motion_default(); + this.modes_Automatic_modes_Motion_Sensing_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.modes_Automatic_modes_Motion_Sensing_react(transitioned_before); + } + return transitioned_after; + } + modes_Automatic_modes_Motion_Sensing_r1_Motion_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.timeEvents[0]) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_MOTION, null, 0))); + this.exitSequence_modes_Automatic_modes_Motion_Sensing_r1_Motion(); + this.timeEvents[0] = false; + this.enterSequence_modes_Automatic_modes_Motion_Sensing_r1_Still_default(); + this.modes_Automatic_modes_Motion_Sensing_react(0); + transitioned_after = 0; + } + else { + if (this.__motion.detected) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_MOTION, null, 1))); + this.exitSequence_modes_Automatic_modes_Motion_Sensing_r1_Motion(); + this.enterSequence_modes_Automatic_modes_Motion_Sensing_r1_Motion_default(); + this.modes_Automatic_modes_Motion_Sensing_react(0); + transitioned_after = 0; + } + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.modes_Automatic_modes_Motion_Sensing_react(transitioned_before); + } + return transitioned_after; + } + modes_Automatic_modes_Light_Sensing_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__hmi.toggleMode) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING, null, 0))); + this.exitSequence_modes_Automatic_modes_Light_Sensing(); + this.enterSequence_modes_Automatic_modes_Motion_Sensing_default(); + this.modes_Automatic_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.modes_Automatic_react(transitioned_before); + } + return transitioned_after; + } + modes_Automatic_modes_Light_Sensing_r1_Bright_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__luminosity.dark) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_BRIGHT, null, 0))); + this.exitSequence_modes_Automatic_modes_Light_Sensing_r1_Bright(); + this.enterSequence_modes_Automatic_modes_Light_Sensing_r1_Getting_Dark_default(); + this.modes_Automatic_modes_Light_Sensing_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.modes_Automatic_modes_Light_Sensing_react(transitioned_before); + } + return transitioned_after; + } + modes_Automatic_modes_Light_Sensing_r1_Dark_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__luminosity.bright) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_DARK, null, 0))); + this.exitSequence_modes_Automatic_modes_Light_Sensing_r1_Dark(); + this.enterSequence_modes_Automatic_modes_Light_Sensing_r1_Getting_Bright_default(); + this.modes_Automatic_modes_Light_Sensing_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.modes_Automatic_modes_Light_Sensing_react(transitioned_before); + } + return transitioned_after; + } + modes_Automatic_modes_Light_Sensing_r1_Getting_Dark_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__luminosity.bright) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_DARK, null, 0))); + this.exitSequence_modes_Automatic_modes_Light_Sensing_r1_Getting_Dark(); + this.enterSequence_modes_Automatic_modes_Light_Sensing_r1_Bright_default(); + this.modes_Automatic_modes_Light_Sensing_react(0); + transitioned_after = 0; + } + else { + if (this.timeEvents[1]) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_DARK, null, 1))); + this.exitSequence_modes_Automatic_modes_Light_Sensing_r1_Getting_Dark(); + this.timeEvents[1] = false; + this.enterSequence_modes_Automatic_modes_Light_Sensing_r1_Dark_default(); + this.modes_Automatic_modes_Light_Sensing_react(0); + transitioned_after = 0; + } + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.modes_Automatic_modes_Light_Sensing_react(transitioned_before); + } + return transitioned_after; + } + modes_Automatic_modes_Light_Sensing_r1_Getting_Bright_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__luminosity.dark) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_BRIGHT, null, 0))); + this.exitSequence_modes_Automatic_modes_Light_Sensing_r1_Getting_Bright(); + this.enterSequence_modes_Automatic_modes_Light_Sensing_r1_Dark_default(); + this.modes_Automatic_modes_Light_Sensing_react(0); + transitioned_after = 0; + } + else { + if (this.timeEvents[2]) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_BRIGHT, null, 1))); + this.exitSequence_modes_Automatic_modes_Light_Sensing_r1_Getting_Bright(); + this.timeEvents[2] = false; + this.enterSequence_modes_Automatic_modes_Light_Sensing_r1_Bright_default(); + this.modes_Automatic_modes_Light_Sensing_react(0); + transitioned_after = 0; + } + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.modes_Automatic_modes_Light_Sensing_react(transitioned_before); + } + return transitioned_after; + } + modes_Manual_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__hmi.toggleMode) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MODES_MANUAL, null, 0))); + this.exitSequence_modes_Manual(); + this.enterSequence_modes_Automatic_default(); + this.react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + modes_Manual_r1_Off_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__hmi.switchEvent) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MODES_MANUAL_R1_OFF, null, 0))); + this.exitSequence_modes_Manual_r1_Off(); + this.setBrightness(5); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + this.enterSequence_modes_Manual_r1_On_default(); + this.modes_Manual_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.modes_Manual_react(transitioned_before); + } + return transitioned_after; + } + modes_Manual_r1_On_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__hmi.switchEvent) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MODES_MANUAL_R1_ON, null, 0))); + this.exitSequence_modes_Manual_r1_On(); + this.enterSequence_modes_Manual_r1_Off_default(); + this.modes_Manual_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + if (((this.__hmi.changeBrightness) && (this.getBrightness() > 1))) { + this.setBrightness(this.getBrightness() - 1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + } + if (((this.__hmi.changeBrightness) && (this.getBrightness() <= 1))) { + this.setBrightness(10); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + } + transitioned_after = this.modes_Manual_react(transitioned_before); + } + return transitioned_after; + } + } + io.Statemachine = Statemachine; + Statemachine["__class"] = "sct.yakindu.io.Statemachine"; + Statemachine["__interfaces"] = ["com.yakindu.core.IStatemachine", "com.yakindu.core.ITimed"]; + (function (Statemachine) { + class Hmi { + constructor(parent) { + if (this.parent === undefined) { + this.parent = null; + } + if (this.switchEvent === undefined) { + this.switchEvent = false; + } + if (this.toggleMode === undefined) { + this.toggleMode = false; + } + if (this.changeBrightness === undefined) { + this.changeBrightness = false; + } + this.parent = parent; + } + raiseSwitch() { + /* add */ (this.parent.inEventQueue.push(() => { + this.switchEvent = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.HMI_SWITCH, null))); + this.parent.runCycle(); + } + raiseToggleMode() { + /* add */ (this.parent.inEventQueue.push(() => { + this.toggleMode = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.HMI_TOGGLEMODE, null))); + this.parent.runCycle(); + } + raiseChangeBrightness() { + /* add */ (this.parent.inEventQueue.push(() => { + this.changeBrightness = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.HMI_CHANGEBRIGHTNESS, null))); + this.parent.runCycle(); + } + } + Statemachine.Hmi = Hmi; + Hmi["__class"] = "sct.yakindu.io.Statemachine.Hmi"; + class Motion { + constructor(parent) { + if (this.parent === undefined) { + this.parent = null; + } + if (this.detected === undefined) { + this.detected = false; + } + this.parent = parent; + } + raiseDetected() { + /* add */ (this.parent.inEventQueue.push(() => { + this.detected = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.MOTION_DETECTED, null))); + this.parent.runCycle(); + } + getTimeout() { + return Motion.timeout; + } + } + Motion.timeout = 30; + Statemachine.Motion = Motion; + Motion["__class"] = "sct.yakindu.io.Statemachine.Motion"; + class Luminosity { + constructor(parent) { + if (this.parent === undefined) { + this.parent = null; + } + if (this.bright === undefined) { + this.bright = false; + } + if (this.dark === undefined) { + this.dark = false; + } + this.parent = parent; + } + raiseBright() { + /* add */ (this.parent.inEventQueue.push(() => { + this.bright = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.LUMINOSITY_BRIGHT, null))); + this.parent.runCycle(); + } + raiseDark() { + /* add */ (this.parent.inEventQueue.push(() => { + this.dark = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.LUMINOSITY_DARK, null))); + this.parent.runCycle(); + } + getDelay() { + return Luminosity.delay; + } + } + Luminosity.delay = 10; + Statemachine.Luminosity = Luminosity; + Luminosity["__class"] = "sct.yakindu.io.Statemachine.Luminosity"; + let State; + (function (State) { + State[State["MODES_AUTOMATIC"] = 0] = "MODES_AUTOMATIC"; + State[State["MODES_AUTOMATIC_MODES_MOTION_SENSING"] = 1] = "MODES_AUTOMATIC_MODES_MOTION_SENSING"; + State[State["MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_STILL"] = 2] = "MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_STILL"; + State[State["MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_MOTION"] = 3] = "MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_MOTION"; + State[State["MODES_AUTOMATIC_MODES_LIGHT_SENSING"] = 4] = "MODES_AUTOMATIC_MODES_LIGHT_SENSING"; + State[State["MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_BRIGHT"] = 5] = "MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_BRIGHT"; + State[State["MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_DARK"] = 6] = "MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_DARK"; + State[State["MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_DARK"] = 7] = "MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_DARK"; + State[State["MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_BRIGHT"] = 8] = "MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_BRIGHT"; + State[State["MODES_MANUAL"] = 9] = "MODES_MANUAL"; + State[State["MODES_MANUAL_R1_OFF"] = 10] = "MODES_MANUAL_R1_OFF"; + State[State["MODES_MANUAL_R1_ON"] = 11] = "MODES_MANUAL_R1_ON"; + State[State["$NULLSTATE$"] = 12] = "$NULLSTATE$"; + })(State = Statemachine.State || (Statemachine.State = {})); + /** + * Enumeration of all features of the statechart + * @enum + * @property {sct.yakindu.io.Statemachine.Feature} NO_FEATURE + * @property {sct.yakindu.io.Statemachine.Feature} BRIGHTNESS + * @property {sct.yakindu.io.Statemachine.Feature} HMI_SWITCH + * @property {sct.yakindu.io.Statemachine.Feature} HMI_TOGGLEMODE + * @property {sct.yakindu.io.Statemachine.Feature} HMI_CHANGEBRIGHTNESS + * @property {sct.yakindu.io.Statemachine.Feature} MOTION_TIMEOUT + * @property {sct.yakindu.io.Statemachine.Feature} MOTION_DETECTED + * @property {sct.yakindu.io.Statemachine.Feature} LUMINOSITY_DELAY + * @property {sct.yakindu.io.Statemachine.Feature} LUMINOSITY_BRIGHT + * @property {sct.yakindu.io.Statemachine.Feature} LUMINOSITY_DARK + * @class + */ + let Feature; + (function (Feature) { + Feature[Feature["NO_FEATURE"] = 0] = "NO_FEATURE"; + Feature[Feature["BRIGHTNESS"] = 1] = "BRIGHTNESS"; + Feature[Feature["HMI_SWITCH"] = 2] = "HMI_SWITCH"; + Feature[Feature["HMI_TOGGLEMODE"] = 3] = "HMI_TOGGLEMODE"; + Feature[Feature["HMI_CHANGEBRIGHTNESS"] = 4] = "HMI_CHANGEBRIGHTNESS"; + Feature[Feature["MOTION_TIMEOUT"] = 5] = "MOTION_TIMEOUT"; + Feature[Feature["MOTION_DETECTED"] = 6] = "MOTION_DETECTED"; + Feature[Feature["LUMINOSITY_DELAY"] = 7] = "LUMINOSITY_DELAY"; + Feature[Feature["LUMINOSITY_BRIGHT"] = 8] = "LUMINOSITY_BRIGHT"; + Feature[Feature["LUMINOSITY_DARK"] = 9] = "LUMINOSITY_DARK"; + })(Feature = Statemachine.Feature || (Statemachine.Feature = {})); + })(Statemachine = io.Statemachine || (io.Statemachine = {})); + })(io = yakindu.io || (yakindu.io = {})); + })(yakindu = sct.yakindu || (sct.yakindu = {})); +})(sct || (sct = {})); diff --git a/org.yakindu.sct.examples.basic.tutorial/_04_lightandmotionsensinglightswitch-player/assets/context.json.js b/org.yakindu.sct.examples.basic.tutorial/_04_lightandmotionsensinglightswitch-player/assets/context.json.js new file mode 100644 index 00000000..39ee9c60 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_04_lightandmotionsensinglightswitch-player/assets/context.json.js @@ -0,0 +1 @@ +const contextJson = {"elements":[{"elements":[{"kind":"variable","type":"integer","name":"brightness","fqName":"brightness","featureId":"BRIGHTNESS","writable":true,"value":0}],"kind":"composite","name":"default","featureId":"","writable":true},{"elements":[{"kind":"event","name":"switch","fqName":"hmi.switch","featureId":"HMI_SWITCH","writable":true},{"kind":"event","name":"toggleMode","fqName":"hmi.toggleMode","featureId":"HMI_TOGGLEMODE","writable":true},{"kind":"event","name":"changeBrightness","fqName":"hmi.changeBrightness","featureId":"HMI_CHANGEBRIGHTNESS","writable":true}],"kind":"composite","name":"hmi","fqName":"hmi","featureId":"","writable":true},{"elements":[{"kind":"variable","type":"integer","name":"timeout","fqName":"motion.timeout","featureId":"MOTION_TIMEOUT","writable":false,"value":30},{"kind":"event","name":"detected","fqName":"motion.detected","featureId":"MOTION_DETECTED","writable":true}],"kind":"composite","name":"motion","fqName":"motion","featureId":"","writable":true},{"elements":[{"kind":"variable","type":"integer","name":"delay","fqName":"luminosity.delay","featureId":"LUMINOSITY_DELAY","writable":false,"value":10},{"kind":"event","name":"bright","fqName":"luminosity.bright","featureId":"LUMINOSITY_BRIGHT","writable":true},{"kind":"event","name":"dark","fqName":"luminosity.dark","featureId":"LUMINOSITY_DARK","writable":true}],"kind":"composite","name":"luminosity","fqName":"luminosity","featureId":"","writable":true},{"elements":[{"kind":"event","type":"integer","name":"Motion_time_event_0","fqName":"_04_LightAndMotionSensingLightSwitch.modes.Automatic.modes.Motion_Sensing.r1.Motion_time_event_0","featureId":"MOTION_TIME_EVENT_0","writable":true,"value":0},{"kind":"event","type":"integer","name":"Getting_Dark_time_event_0","fqName":"_04_LightAndMotionSensingLightSwitch.modes.Automatic.modes.Light_Sensing.r1.Getting_Dark_time_event_0","featureId":"GETTING_DARK_TIME_EVENT_0","writable":true,"value":0},{"kind":"event","type":"integer","name":"Getting_Bright_time_event_0","fqName":"_04_LightAndMotionSensingLightSwitch.modes.Automatic.modes.Light_Sensing.r1.Getting_Bright_time_event_0","featureId":"GETTING_BRIGHT_TIME_EVENT_0","writable":true,"value":0}],"kind":"composite","name":"time events","featureId":"","writable":true}]} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_04_lightandmotionsensinglightswitch-player/assets/hashes.json.js b/org.yakindu.sct.examples.basic.tutorial/_04_lightandmotionsensinglightswitch-player/assets/hashes.json.js new file mode 100644 index 00000000..97d7cfaf --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_04_lightandmotionsensinglightswitch-player/assets/hashes.json.js @@ -0,0 +1 @@ +const hashesJson = {"MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_BRIGHT":"da6d330d-9a52-4b1c-87ea-9566e25de3ec","MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_DARK":"ac780f67-f150-47ea-b520-5a033878658d","MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_DARK_tr0":"036562ad-a456-413b-ba90-035f3d65d120","MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_DARK_tr1":"f17a37b2-f83c-4320-acdf-ef4e01cfa926","MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_DARK_tr0":"b0682eb5-ff90-4ea8-8b37-be97a182d53a","MODES_MANUAL_R1_OFF_tr0":"475ff1f0-3054-437d-9ac9-da17e3c5cb3b","MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_MOTION_tr0":"d8098cd2-521f-4223-8eb2-f17178677397","MODES_AUTOMATIC_MODES_MOTION_SENSING":"44ad37b1-8174-44db-9af3-ee5d5f378ce8","MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_MOTION_tr1":"36f02087-8958-4cf9-8e55-117060dead31","MODES_MANUAL":"bd02f6d2-2770-462d-8023-5f4683fcb85b","MODES_AUTOMATIC_MODES_LIGHT_SENSING_tr0":"aa232eb9-0b18-413c-a579-3b62fe180bc1","MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_STILL_tr0":"2e3025b5-9ed8-431e-821d-56b2c7c9f82e","MODES_MANUAL_R1_ON":"ea064364-8a4b-433c-8610-7fb0515ea792","MODES_AUTOMATIC_tr0":"6d2e0252-baab-430a-9d1d-03b79369e04f","MODES_MANUAL_tr0":"4c43c205-cb4f-46f8-b139-f9282d1d4060","MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_STILL":"27cb303e-d67f-4f21-96b8-f1816d79bfa1","MODES_MANUAL_R1_ON_tr0":"1f426c73-cd8e-4c41-8f4c-f186e24189ad","MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_BRIGHT":"bcdbf5c2-d641-4052-b3c8-2c1e575c596b","MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_BRIGHT_tr0":"89411791-00de-48df-b9c6-f98db3467d33","MODES_AUTOMATIC_MODES_MOTION_SENSING_tr0":"8b31cf25-ece0-4d3e-b0b3-5def3fd7b83d","MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_BRIGHT_tr0":"cf1f4883-292d-46f9-a24f-0e338b9e2c7f","MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_GETTING_BRIGHT_tr1":"9a36dfb3-d4ca-4cfa-9ab6-0ac319449bfe","MODES_AUTOMATIC_MODES_LIGHT_SENSING_R1_DARK":"dd2455fd-4984-418c-954a-5436c187d4ac","MODES_AUTOMATIC_MODES_LIGHT_SENSING":"278ae822-3bb5-4b3b-b9b1-79f7fe46209b","MODES_MANUAL_R1_OFF":"d2b5b9c0-4488-47c5-aeb9-96fbfc1f2a15","MODES_AUTOMATIC_MODES_MOTION_SENSING_R1_MOTION":"ff734c35-d03a-47d2-87ed-f39a3e33d278","MODES_AUTOMATIC":"09ff90e6-25bc-41ce-a4b7-9b020a63096a"} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_04_lightandmotionsensinglightswitch-player/assets/statemachine.svg.js b/org.yakindu.sct.examples.basic.tutorial/_04_lightandmotionsensinglightswitch-player/assets/statemachine.svg.js new file mode 100644 index 00000000..2eac5c08 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_04_lightandmotionsensinglightswitch-player/assets/statemachine.svg.js @@ -0,0 +1 @@ +let svg = `modes1-Automaticmodes-Motion Sensingr1-Stillentry / brightness = 0-Motionentry /brightness = 10Light Sensing-Manualr1--Offentry / brightness = 0Onhmi.changeBrightness [brightness > 1] / brightness -= 1hmi.changeBrightness [brightness <= 1] / brightness = 10-1motion.detectedmotion.detected1after motion.timeout safter motion.timeout s1-1hmi.toggleModehmi.toggleMode1hmi.switchhmi.switch1-1hmi.toggleModehmi.toggleMode1hmi.toggleModehmi.toggleMode1-1hmi.switch / brightness = 5hmi.switch / brightness = 51hmi.switchhmi.switch1motion.detectedmotion.detected2r1-Brightentry /brightness = 0Darkentry / brightness = 10Getting DarkGetting Bright-luminosity.darkluminosity.dark1luminosity.brightluminosity.bright1luminosity.brightluminosity.bright1-1after luminosity.delay safter luminosity.delay s2after luminosity.delay safter luminosity.delay s2luminosity.darkluminosity.dark1` \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_04_lightandmotionsensinglightswitch-player/assets/ypi.css b/org.yakindu.sct.examples.basic.tutorial/_04_lightandmotionsensinglightswitch-player/assets/ypi.css new file mode 100644 index 00000000..771aaa11 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_04_lightandmotionsensinglightswitch-player/assets/ypi.css @@ -0,0 +1,113 @@ +/*! + * itemis CREATE Player Styles + * Copyright 2021 itemis AG + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ + + + /*! + * Style definitions follow BEM pattern using and additional 'y' namespace (for itemis CREATE). + */ +.y-declaration { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; + background-color: #eee; + font-family: 'Courier New', Courier, monospace; +} + + +.y-entry { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; +} + +.y-entry:after { + content: ' \25CF '; + font-size: larger; +} + +.y-state { + background-color: rgb(209, 223, 238); + padding: 3px; + border: 0.5pt;; + border: 0.5pt; + border-radius: 4px; + border-color: #bbb; + font-family: 'Courier New', Courier, monospace; +} + +.y-state--active { + background-color: rgb(244, 215, 66); +} + +.y-state--inactive { + background-color: rgb(209, 223, 238); +} + +.y-variable{ + background-color: #eee; + border-color: #aaa; + border: 0.5pt; + border: 0.5pt; + border-radius: 2px; + font-family: 'Courier New', Courier, monospace; +} + +.y-variable::after { + color: #aaa; + content: attr(value); + font-family: 'Courier New', Courier, monospace; +} + +.y-do-enter { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; +} + +.y-do-enter:before { + content: ' \2192 '; +} + +.y-do-exit { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer +} + +.y-do-exit:before { + content: ' \2192 '; +} + +.y-do-raise { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; + white-space: nowrap; +} + +.y-do-raise:before { + content: ' \2192 '; +} + +button.y-do-raise:before { + content: ''; +} + +button.y-do-raise { + cursor: pointer; +} + +.y-do--over { + color: blue; + background-color: #eee; + cursor: pointer; +} + +.y-player { + border-style: solid; + border-width: 1px; + border-color: ; +} diff --git a/org.yakindu.sct.examples.basic.tutorial/_04_lightandmotionsensinglightswitch-player/model.scm b/org.yakindu.sct.examples.basic.tutorial/_04_lightandmotionsensinglightswitch-player/model.scm new file mode 100644 index 00000000..aa3e74fe --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_04_lightandmotionsensinglightswitch-player/model.scm @@ -0,0 +1,1761 @@ +{ + "cells": [ + { + "position": { + "x": 0, + "y": 0 + }, + "size": { + "height": 10, + "width": 10 + }, + "angle": 0, + "type": "Statechart", + "id": "28eb1d70-39e4-4253-b8ec-92e8fcfa1022", + "linkable": false, + "z": 1, + "attrs": { + "name": { + "text": "_04_LightAndMotionSensingLightSwitch" + }, + "specification": { + "text": "@EventDriven\n\ninterface:\n\tvar brightness: integer\n\ninterface hmi:\n\tin event switch\n\tin event toggleMode\n\tin event changeBrightness\n\t\t\ninterface motion:\n\tconst timeout: integer = 30\n\tin event detected\n\t\ninterface luminosity:\n\tconst delay: integer = 10\n \tin event bright\n \tin event dark" + } + } + }, + { + "type": "Region", + "position": { + "x": 0, + "y": 0 + }, + "size": { + "width": 1379, + "height": 622 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "b9e4ae18-b543-482f-8464-646a9e68136d", + "z": 2, + "embeds": [ + "231c4a4b-3c3d-42f9-869b-bf57e95dba5c", + "6d2e0252-baab-430a-9d1d-03b79369e04f", + "4c43c205-cb4f-46f8-b139-f9282d1d4060", + "2a9a1697-9390-4309-b28f-19339e7a037e", + "09ff90e6-25bc-41ce-a4b7-9b020a63096a", + "bd02f6d2-2770-462d-8023-5f4683fcb85b" + ], + "attrs": { + "priority": { + "text": 1 + }, + "name": { + "fontSize": "9", + "text": "modes" + } + } + }, + { + "type": "Entry", + "position": { + "x": 602, + "y": 47 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "2a9a1697-9390-4309-b28f-19339e7a037e", + "parent": "b9e4ae18-b543-482f-8464-646a9e68136d", + "z": 3, + "embeds": [ + "414bbca3-3560-4319-b25d-3da8a0b619c7" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 602, + "y": 62 + }, + "id": "414bbca3-3560-4319-b25d-3da8a0b619c7", + "z": 4, + "parent": "2a9a1697-9390-4309-b28f-19339e7a037e", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 18, + "y": 294 + }, + "size": { + "width": 1311, + "height": 300 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "09ff90e6-25bc-41ce-a4b7-9b020a63096a", + "parent": "b9e4ae18-b543-482f-8464-646a9e68136d", + "z": 5, + "embeds": [ + "da19678f-222e-45bf-a8a2-ef7a6ecce6f0" + ], + "attrs": { + "name": { + "text": "Automatic" + } + } + }, + { + "type": "Region", + "position": { + "x": 19, + "y": 334 + }, + "size": { + "width": 1309, + "height": 259 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "da19678f-222e-45bf-a8a2-ef7a6ecce6f0", + "z": 6, + "parent": "09ff90e6-25bc-41ce-a4b7-9b020a63096a", + "embeds": [ + "aa232eb9-0b18-413c-a579-3b62fe180bc1", + "8b31cf25-ece0-4d3e-b0b3-5def3fd7b83d", + "d2a87959-719a-4ffc-8057-3687760c97d6", + "44ad37b1-8174-44db-9af3-ee5d5f378ce8", + "278ae822-3bb5-4b3b-b9b1-79f7fe46209b", + "0dc6563b-8e04-4736-a3c9-3af0c523e057" + ], + "attrs": { + "name": { + "fontSize": "9", + "text": "modes" + } + } + }, + { + "type": "State", + "position": { + "x": 861, + "y": 362 + }, + "size": { + "width": 428, + "height": 209 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "44ad37b1-8174-44db-9af3-ee5d5f378ce8", + "parent": "da19678f-222e-45bf-a8a2-ef7a6ecce6f0", + "z": 7, + "embeds": [ + "c657162c-aaf7-4760-869e-6731fcbca2ab" + ], + "attrs": { + "name": { + "text": "Motion Sensing" + } + } + }, + { + "type": "Region", + "position": { + "x": 862, + "y": 402 + }, + "size": { + "width": 426, + "height": 168 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "c657162c-aaf7-4760-869e-6731fcbca2ab", + "z": 8, + "parent": "44ad37b1-8174-44db-9af3-ee5d5f378ce8", + "embeds": [ + "36f02087-8958-4cf9-8e55-117060dead31", + "d8098cd2-521f-4223-8eb2-f17178677397", + "2e3025b5-9ed8-431e-821d-56b2c7c9f82e", + "2bde34fc-18e2-43e5-9963-289e47b2536d", + "27cb303e-d67f-4f21-96b8-f1816d79bfa1", + "29220651-4eed-46c0-bec4-0d4624858ddc", + "ff734c35-d03a-47d2-87ed-f39a3e33d278" + ], + "attrs": { + "name": { + "fontSize": "9", + "text": "r1" + } + } + }, + { + "type": "State", + "position": { + "x": 887, + "y": 430 + }, + "size": { + "width": 117, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "27cb303e-d67f-4f21-96b8-f1816d79bfa1", + "parent": "c657162c-aaf7-4760-869e-6731fcbca2ab", + "z": 9, + "attrs": { + "name": { + "text": "Still" + }, + "specification": { + "text": "entry / \r\nbrightness = 0", + "fontSize": "9" + } + } + }, + { + "type": "ShallowHistory", + "position": { + "x": 907, + "y": 520 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "29220651-4eed-46c0-bec4-0d4624858ddc", + "parent": "c657162c-aaf7-4760-869e-6731fcbca2ab", + "z": 10, + "embeds": [ + "b5bdac9d-8e57-4a86-889f-388a5b94eebc" + ], + "attrs": { + "name": { + "fill": "#555555" + } + } + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 907, + "y": 535 + }, + "id": "b5bdac9d-8e57-4a86-889f-388a5b94eebc", + "z": 11, + "parent": "29220651-4eed-46c0-bec4-0d4624858ddc", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 1132, + "y": 430 + }, + "size": { + "width": 117, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "ff734c35-d03a-47d2-87ed-f39a3e33d278", + "parent": "c657162c-aaf7-4760-869e-6731fcbca2ab", + "z": 12, + "attrs": { + "name": { + "text": "Motion" + }, + "specification": { + "text": "entry /\nbrightness = 10", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 31, + "y": 362 + }, + "size": { + "width": 674, + "height": 210 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "278ae822-3bb5-4b3b-b9b1-79f7fe46209b", + "parent": "da19678f-222e-45bf-a8a2-ef7a6ecce6f0", + "z": 13, + "embeds": [ + "f786f67b-f82a-44f2-b9ac-c54fbb407874" + ], + "attrs": { + "name": { + "text": "Light Sensing" + } + } + }, + { + "type": "ShallowHistory", + "position": { + "x": 762, + "y": 385 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "0dc6563b-8e04-4736-a3c9-3af0c523e057", + "parent": "da19678f-222e-45bf-a8a2-ef7a6ecce6f0", + "z": 21, + "embeds": [ + "783a632d-b8fb-4329-8b82-e317f8929ed2" + ], + "attrs": { + "name": { + "fill": "#555555" + } + } + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 762, + "y": 400 + }, + "id": "783a632d-b8fb-4329-8b82-e317f8929ed2", + "z": 22, + "parent": "0dc6563b-8e04-4736-a3c9-3af0c523e057", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 18, + "y": 28 + }, + "size": { + "width": 530, + "height": 216 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "bd02f6d2-2770-462d-8023-5f4683fcb85b", + "parent": "b9e4ae18-b543-482f-8464-646a9e68136d", + "z": 23, + "embeds": [ + "d0e022eb-a366-47d2-8de7-341d16439357" + ], + "attrs": { + "name": { + "text": "Manual" + } + } + }, + { + "type": "Region", + "position": { + "x": 19, + "y": 68 + }, + "size": { + "width": 528, + "height": 175 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "d0e022eb-a366-47d2-8de7-341d16439357", + "z": 24, + "parent": "bd02f6d2-2770-462d-8023-5f4683fcb85b", + "embeds": [ + "1f426c73-cd8e-4c41-8f4c-f186e24189ad", + "475ff1f0-3054-437d-9ac9-da17e3c5cb3b", + "f1526dbc-acb5-4bf2-897e-67afebb6245c", + "9712ac76-6397-4d7e-984f-572bcfdf78a5", + "d2b5b9c0-4488-47c5-aeb9-96fbfc1f2a15", + "ea064364-8a4b-433c-8610-7fb0515ea792" + ], + "attrs": { + "name": { + "fontSize": "9", + "text": "r1" + } + } + }, + { + "type": "ShallowHistory", + "position": { + "x": 97, + "y": 198 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "9712ac76-6397-4d7e-984f-572bcfdf78a5", + "parent": "d0e022eb-a366-47d2-8de7-341d16439357", + "z": 25, + "embeds": [ + "06a940c3-9c22-4f5b-800c-4d1f07528571" + ], + "attrs": { + "name": { + "fill": "#555555" + } + } + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 97, + "y": 213 + }, + "id": "06a940c3-9c22-4f5b-800c-4d1f07528571", + "z": 26, + "parent": "9712ac76-6397-4d7e-984f-572bcfdf78a5", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 48, + "y": 96 + }, + "size": { + "width": 126, + "height": 68 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "d2b5b9c0-4488-47c5-aeb9-96fbfc1f2a15", + "parent": "d0e022eb-a366-47d2-8de7-341d16439357", + "z": 27, + "attrs": { + "name": { + "text": "Off" + }, + "specification": { + "text": "entry \n / brightness = 0", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 295, + "y": 96 + }, + "size": { + "width": 213, + "height": 126 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "ea064364-8a4b-433c-8610-7fb0515ea792", + "parent": "d0e022eb-a366-47d2-8de7-341d16439357", + "z": 28, + "attrs": { + "name": { + "text": "On" + }, + "specification": { + "text": "hmi.changeBrightness \n [brightness > 1] / brightness -= 1\nhmi.changeBrightness \n [brightness <= 1] / brightness = 10", + "fontSize": "9" + } + } + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "69.30555555555581%", + "dy": "2.222222222222475%", + "rotate": true + } + }, + "id": "29220651-4eed-46c0-bec4-0d4624858ddc" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "25.97934472934476%", + "dy": "50%", + "rotate": true + } + }, + "id": "27cb303e-d67f-4f21-96b8-f1816d79bfa1" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "2bde34fc-18e2-43e5-9963-289e47b2536d", + "z": 29, + "parent": "c657162c-aaf7-4760-869e-6731fcbca2ab", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "57.763620027771026%", + "rotate": true + } + }, + "id": "27cb303e-d67f-4f21-96b8-f1816d79bfa1" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.5075534487299297%", + "dy": "57.763620027771026%", + "rotate": true + } + }, + "id": "ff734c35-d03a-47d2-87ed-f39a3e33d278" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "motion.detected", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "2e3025b5-9ed8-431e-821d-56b2c7c9f82e", + "z": 30, + "parent": "c657162c-aaf7-4760-869e-6731fcbca2ab", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "8.548445019033336%", + "dy": "50%", + "rotate": true + } + }, + "id": "ff734c35-d03a-47d2-87ed-f39a3e33d278" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "53.85046326222792%", + "dy": "50%", + "rotate": true + } + }, + "id": "27cb303e-d67f-4f21-96b8-f1816d79bfa1" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "after motion.timeout s", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "d8098cd2-521f-4223-8eb2-f17178677397", + "z": 31, + "parent": "c657162c-aaf7-4760-869e-6731fcbca2ab", + "vertices": [ + { + "x": 1142.001680672269, + "y": 512.8103896103896 + }, + { + "x": 950.0050420168067, + "y": 512.8103896103896 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "90.89743589743648%", + "dy": "36.030595813204705%", + "rotate": true + } + }, + "id": "0dc6563b-8e04-4736-a3c9-3af0c523e057" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.17972681524082168%", + "dy": "13.590712618172587%", + "rotate": true + } + }, + "id": "44ad37b1-8174-44db-9af3-ee5d5f378ce8" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "d2a87959-719a-4ffc-8057-3687760c97d6", + "z": 32, + "parent": "da19678f-222e-45bf-a8a2-ef7a6ecce6f0", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "65.99964401987621%", + "dy": "50%", + "rotate": true + } + }, + "id": "bd02f6d2-2770-462d-8023-5f4683fcb85b" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "26.681778284160483%", + "dy": "0.2673672203953477%", + "rotate": true + } + }, + "id": "09ff90e6-25bc-41ce-a4b7-9b020a63096a" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "hmi.toggleMode", + "fontSize": "9" + } + }, + "position": { + "distance": 0.44, + "offset": -47.19999999999999, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "4c43c205-cb4f-46f8-b139-f9282d1d4060", + "z": 33, + "parent": "b9e4ae18-b543-482f-8464-646a9e68136d", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "10.458475214784666%", + "dy": "0.11090347971346166%", + "rotate": true + } + }, + "id": "09ff90e6-25bc-41ce-a4b7-9b020a63096a" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "25.869926427514528%", + "dy": "50%", + "rotate": true + } + }, + "id": "bd02f6d2-2770-462d-8023-5f4683fcb85b" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "hmi.switch", + "fontSize": "9" + } + }, + "position": { + "distance": 0.54, + "offset": -39.110000000000014, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "6d2e0252-baab-430a-9d1d-03b79369e04f", + "z": 34, + "parent": "b9e4ae18-b543-482f-8464-646a9e68136d", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "3.1481481481478113%", + "dy": "37.38562091503274%", + "rotate": true + } + }, + "id": "2a9a1697-9390-4309-b28f-19339e7a037e" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "11.392519970951348%", + "rotate": true + } + }, + "id": "bd02f6d2-2770-462d-8023-5f4683fcb85b" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "231c4a4b-3c3d-42f9-869b-bf57e95dba5c", + "z": 35, + "parent": "b9e4ae18-b543-482f-8464-646a9e68136d", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.16703480837721943%", + "dy": "58.62515313316228%", + "rotate": true + } + }, + "id": "44ad37b1-8174-44db-9af3-ee5d5f378ce8" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "58.345985737290086%", + "rotate": true + } + }, + "id": "278ae822-3bb5-4b3b-b9b1-79f7fe46209b" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "hmi.toggleMode", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "8b31cf25-ece0-4d3e-b0b3-5def3fd7b83d", + "z": 43, + "parent": "da19678f-222e-45bf-a8a2-ef7a6ecce6f0", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "78.03830227743273%", + "rotate": true + } + }, + "id": "278ae822-3bb5-4b3b-b9b1-79f7fe46209b" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.13530571256240442%", + "dy": "78.41169128354485%", + "rotate": true + } + }, + "id": "44ad37b1-8174-44db-9af3-ee5d5f378ce8" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "hmi.toggleMode", + "fontSize": "9" + } + }, + "position": { + "distance": 0.4807692307692308, + "offset": 10.120000000000005, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "aa232eb9-0b18-413c-a579-3b62fe180bc1", + "z": 44, + "parent": "da19678f-222e-45bf-a8a2-ef7a6ecce6f0", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "35.55555555555562%", + "dy": "11.111111111111237%", + "rotate": true + } + }, + "id": "9712ac76-6397-4d7e-984f-572bcfdf78a5" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "43.12169312169313%", + "dy": "98.28431372549021%", + "rotate": true + } + }, + "id": "d2b5b9c0-4488-47c5-aeb9-96fbfc1f2a15" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "f1526dbc-acb5-4bf2-897e-67afebb6245c", + "z": 45, + "parent": "d0e022eb-a366-47d2-8de7-341d16439357", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "17.64705882352943%", + "rotate": true + } + }, + "id": "d2b5b9c0-4488-47c5-aeb9-96fbfc1f2a15" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.15649452269172356%", + "dy": "9.523809523809536%", + "rotate": true + } + }, + "id": "ea064364-8a4b-433c-8610-7fb0515ea792" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "hmi.switch /\n brightness = 5", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "475ff1f0-3054-437d-9ac9-da17e3c5cb3b", + "z": 46, + "parent": "d0e022eb-a366-47d2-8de7-341d16439357", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "43.820505141259865%", + "rotate": true + } + }, + "id": "ea064364-8a4b-433c-8610-7fb0515ea792" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "81.19681834998151%", + "rotate": true + } + }, + "id": "d2b5b9c0-4488-47c5-aeb9-96fbfc1f2a15" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "hmi.switch", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "1f426c73-cd8e-4c41-8f4c-f186e24189ad", + "z": 47, + "parent": "d0e022eb-a366-47d2-8de7-341d16439357", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "86.79245283018868%", + "rotate": true + } + }, + "id": "ff734c35-d03a-47d2-87ed-f39a3e33d278" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "55.55555555555556%", + "dy": "50%", + "rotate": true + } + }, + "id": "ff734c35-d03a-47d2-87ed-f39a3e33d278" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "motion.detected", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "2" + } + } + } + ], + "id": "36f02087-8958-4cf9-8e55-117060dead31", + "z": 48, + "parent": "c657162c-aaf7-4760-869e-6731fcbca2ab", + "vertices": [ + { + "x": 1274, + "y": 476 + }, + { + "x": 1274, + "y": 510 + }, + { + "x": 1197, + "y": 510 + } + ], + "attrs": {} + }, + { + "type": "Region", + "position": { + "x": 32, + "y": 402 + }, + "size": { + "width": 672, + "height": 169 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "f786f67b-f82a-44f2-b9ac-c54fbb407874", + "z": 49, + "embeds": [ + "9a36dfb3-d4ca-4cfa-9ab6-0ac319449bfe", + "cf1f4883-292d-46f9-a24f-0e338b9e2c7f", + "b0682eb5-ff90-4ea8-8b37-be97a182d53a", + "f17a37b2-f83c-4320-acdf-ef4e01cfa926", + "036562ad-a456-413b-ba90-035f3d65d120", + "89411791-00de-48df-b9c6-f98db3467d33", + "a2eb38c9-4c56-40f6-91ae-a976acfa0a33", + "bcdbf5c2-d641-4052-b3c8-2c1e575c596b", + "dd2455fd-4984-418c-954a-5436c187d4ac", + "ac780f67-f150-47ea-b520-5a033878658d", + "da6d330d-9a52-4b1c-87ea-9566e25de3ec", + "32feccbc-a22c-45b0-8b19-685e874fb9f4" + ], + "parent": "278ae822-3bb5-4b3b-b9b1-79f7fe46209b", + "attrs": { + "name": { + "fontSize": "9", + "text": "r1" + } + } + }, + { + "type": "State", + "position": { + "x": 51, + "y": 494 + }, + "size": { + "width": 117, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "bcdbf5c2-d641-4052-b3c8-2c1e575c596b", + "parent": "f786f67b-f82a-44f2-b9ac-c54fbb407874", + "z": 57, + "attrs": { + "name": { + "text": "Bright" + }, + "specification": { + "text": "entry /\r\nbrightness = 0", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 548, + "y": 430 + }, + "size": { + "width": 117, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "dd2455fd-4984-418c-954a-5436c187d4ac", + "parent": "f786f67b-f82a-44f2-b9ac-c54fbb407874", + "z": 58, + "attrs": { + "name": { + "text": "Dark" + }, + "specification": { + "text": "entry / \r\nbrightness = 10", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 238, + "y": 430 + }, + "size": { + "width": 104, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "ac780f67-f150-47ea-b520-5a033878658d", + "parent": "f786f67b-f82a-44f2-b9ac-c54fbb407874", + "z": 59, + "attrs": { + "name": { + "text": "Getting Dark" + } + } + }, + { + "type": "State", + "position": { + "x": 346, + "y": 494 + }, + "size": { + "width": 122, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "da6d330d-9a52-4b1c-87ea-9566e25de3ec", + "parent": "f786f67b-f82a-44f2-b9ac-c54fbb407874", + "z": 60, + "attrs": { + "name": { + "text": "Getting Bright" + } + } + }, + { + "type": "ShallowHistory", + "position": { + "x": 61, + "y": 436 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "32feccbc-a22c-45b0-8b19-685e874fb9f4", + "parent": "f786f67b-f82a-44f2-b9ac-c54fbb407874", + "z": 61, + "embeds": [ + "8bb89c86-dd62-4d3e-9ae5-ef15c6435598" + ], + "attrs": { + "name": { + "fill": "#555555" + } + } + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 61, + "y": 451 + }, + "id": "8bb89c86-dd62-4d3e-9ae5-ef15c6435598", + "z": 62, + "parent": "32feccbc-a22c-45b0-8b19-685e874fb9f4", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "30.43974437005477%", + "rotate": true + } + }, + "id": "da6d330d-9a52-4b1c-87ea-9566e25de3ec" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "8.684371184371129%", + "dy": "50%", + "rotate": true + } + }, + "id": "dd2455fd-4984-418c-954a-5436c187d4ac" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "luminosity.dark", + "fontSize": "9" + } + }, + "position": { + "distance": 0.3069158153123002, + "offset": -20.13122360978476, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "cf1f4883-292d-46f9-a24f-0e338b9e2c7f", + "z": 63, + "parent": "f786f67b-f82a-44f2-b9ac-c54fbb407874", + "vertices": [ + { + "x": 558.1607142857142, + "y": 510.133064516129 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "43.65997159667284%", + "rotate": true + } + }, + "id": "ac780f67-f150-47ea-b520-5a033878658d" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.2572400630653576%", + "dy": "43.65997159667284%", + "rotate": true + } + }, + "id": "dd2455fd-4984-418c-954a-5436c187d4ac" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "after luminosity.delay s", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "2" + } + } + } + ], + "id": "f17a37b2-f83c-4320-acdf-ef4e01cfa926", + "z": 63, + "parent": "f786f67b-f82a-44f2-b9ac-c54fbb407874", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "31.134004884004916%", + "dy": "50%", + "rotate": true + } + }, + "id": "dd2455fd-4984-418c-954a-5436c187d4ac" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "77.35849056603774%", + "rotate": true + } + }, + "id": "da6d330d-9a52-4b1c-87ea-9566e25de3ec" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "luminosity.bright", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "b0682eb5-ff90-4ea8-8b37-be97a182d53a", + "z": 63, + "parent": "f786f67b-f82a-44f2-b9ac-c54fbb407874", + "vertices": [ + { + "x": 584.4267857142858, + "y": 535 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.3903200624512144%", + "dy": "58.76445526475976%", + "rotate": true + } + }, + "id": "da6d330d-9a52-4b1c-87ea-9566e25de3ec" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "58.76445526475976%", + "rotate": true + } + }, + "id": "bcdbf5c2-d641-4052-b3c8-2c1e575c596b" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "after luminosity.delay s", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "2" + } + } + } + ], + "id": "9a36dfb3-d4ca-4cfa-9ab6-0ac319449bfe", + "z": 63, + "parent": "f786f67b-f82a-44f2-b9ac-c54fbb407874", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.14278045983141613%", + "dy": "26.41509433962264%", + "rotate": true + } + }, + "id": "ac780f67-f150-47ea-b520-5a033878658d" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "43.82697938523181%", + "dy": "50%", + "rotate": true + } + }, + "id": "bcdbf5c2-d641-4052-b3c8-2c1e575c596b" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "luminosity.bright", + "fontSize": "9" + } + }, + "position": { + "distance": 0.41683216491738817, + "offset": 14, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "036562ad-a456-413b-ba90-035f3d65d120", + "z": 63, + "parent": "f786f67b-f82a-44f2-b9ac-c54fbb407874", + "vertices": [ + { + "x": 103.27756588072121, + "y": 444 + } + ], + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "70.47619047619045%", + "dy": "88.88888888888914%", + "rotate": true + } + }, + "id": "32feccbc-a22c-45b0-8b19-685e874fb9f4" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "17.58241758241758%", + "dy": "0.31446540880495993%", + "rotate": true + } + }, + "id": "bcdbf5c2-d641-4052-b3c8-2c1e575c596b" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "a2eb38c9-4c56-40f6-91ae-a976acfa0a33", + "z": 63, + "parent": "f786f67b-f82a-44f2-b9ac-c54fbb407874", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "72.64957264957265%", + "dy": "0.5249543517954476%", + "rotate": true + } + }, + "id": "bcdbf5c2-d641-4052-b3c8-2c1e575c596b" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "49.40657334144857%", + "rotate": true + } + }, + "id": "ac780f67-f150-47ea-b520-5a033878658d" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "luminosity.dark", + "fontSize": "9" + } + }, + "position": { + "distance": 0.6137615335097633, + "offset": 11.810000000000004, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "89411791-00de-48df-b9c6-f98db3467d33", + "z": 63, + "vertices": [ + { + "x": 136, + "y": 456.19 + } + ], + "parent": "f786f67b-f82a-44f2-b9ac-c54fbb407874", + "attrs": {} + } + ] +} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_04_lightandmotionsensinglightswitch-player/player.html b/org.yakindu.sct.examples.basic.tutorial/_04_lightandmotionsensinglightswitch-player/player.html new file mode 100644 index 00000000..a40d8757 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_04_lightandmotionsensinglightswitch-player/player.html @@ -0,0 +1,52 @@ + +sct-web-player demo + + + + + + + + + + + + + + + +
+ +
+ + + + + \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_05_presencesimulationlightswitch-player/assets/bundle.js b/org.yakindu.sct.examples.basic.tutorial/_05_presencesimulationlightswitch-player/assets/bundle.js new file mode 100644 index 00000000..5ea7dffa --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_05_presencesimulationlightswitch-player/assets/bundle.js @@ -0,0 +1,1063 @@ +var com; +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Instances represent state machine trace events. + * @param {com.yakindu.core.TraceEventType} type + * @param {*} machine + * @param {*} state + * @param {*} feature + * @param {*} value + * @class + */ + class TraceEvent { + constructor(type, machine, state, feature, value) { + if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && ((state != null) || state === null) && ((feature != null) || feature === null) && ((value != null) || value === null)) { + let __args = arguments; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + else if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && state === undefined && feature === undefined && value === undefined) { + let __args = arguments; + { + let __args = arguments; + let state = null; + let feature = null; + let value = null; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + } + else + throw new Error('invalid overload'); + } + getType() { + return this.type; + } + getMachine() { + return this.machine; + } + getState() { + return this.state; + } + getFeature() { + return this.feature; + } + getValue() { + return this.value; + } + } + core.TraceEvent = TraceEvent; + TraceEvent["__class"] = "com.yakindu.core.TraceEvent"; + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Trace event type enumeration. + * @enum + * @property {com.yakindu.core.TraceEventType} MACHINE_ENTER + * @property {com.yakindu.core.TraceEventType} MACHINE_EXIT + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_START + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_STOP + * @property {com.yakindu.core.TraceEventType} STATE_ENTERED + * @property {com.yakindu.core.TraceEventType} STATE_EXITED + * @property {com.yakindu.core.TraceEventType} STATE_TRANSITION + * @property {com.yakindu.core.TraceEventType} EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} VARIABLE_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_UNSET + * @class + */ + let TraceEventType; + (function (TraceEventType) { + TraceEventType[TraceEventType["MACHINE_ENTER"] = 0] = "MACHINE_ENTER"; + TraceEventType[TraceEventType["MACHINE_EXIT"] = 1] = "MACHINE_EXIT"; + TraceEventType[TraceEventType["MACHINE_RTS_START"] = 2] = "MACHINE_RTS_START"; + TraceEventType[TraceEventType["MACHINE_RTS_STOP"] = 3] = "MACHINE_RTS_STOP"; + TraceEventType[TraceEventType["STATE_ENTERED"] = 4] = "STATE_ENTERED"; + TraceEventType[TraceEventType["STATE_EXITED"] = 5] = "STATE_EXITED"; + TraceEventType[TraceEventType["STATE_TRANSITION"] = 6] = "STATE_TRANSITION"; + TraceEventType[TraceEventType["EVENT_RAISED"] = 7] = "EVENT_RAISED"; + TraceEventType[TraceEventType["VARIABLE_SET"] = 8] = "VARIABLE_SET"; + TraceEventType[TraceEventType["TIME_EVENT_RAISED"] = 9] = "TIME_EVENT_RAISED"; + TraceEventType[TraceEventType["TIME_EVENT_SET"] = 10] = "TIME_EVENT_SET"; + TraceEventType[TraceEventType["TIME_EVENT_UNSET"] = 11] = "TIME_EVENT_UNSET"; + })(TraceEventType = core.TraceEventType || (core.TraceEventType = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + var rx; + (function (rx) { + class Observable { + constructor() { + this.observers = ([]); + } + next(value) { + for (let index = 0; index < this.observers.length; index++) { + let observer = this.observers[index]; + { + observer.next(value); + } + } + } + subscribe(observer) { + return observer != null ? /* add */ (this.observers.push(observer) > 0) : false; + } + unsubscribe(observer) { + return observer != null ? /* remove */ (a => { let index = a.indexOf(observer); if (index >= 0) { + a.splice(index, 1); + return true; + } + else { + return false; + } })(this.observers) : false; + } + } + rx.Observable = Observable; + Observable["__class"] = "com.yakindu.core.rx.Observable"; + })(rx = core.rx || (core.rx = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +var sct; +(function (sct) { + var yakindu; + (function (yakindu) { + var io; + (function (io) { + class Statemachine { + constructor() { + if (this.__hmi === undefined) { + this.__hmi = null; + } + if (this.__simulation === undefined) { + this.__simulation = null; + } + this.historyVector = [null]; + this.stateVector = [null, null]; + this.trace = (new com.yakindu.core.rx.Observable()); + if (this.timerService === undefined) { + this.timerService = null; + } + this.timeEvents = [false, false]; + this.internalEventQueue = ([]); + this.inEventQueue = ([]); + if (this.changePresence === undefined) { + this.changePresence = false; + } + if (this.startSimulation === undefined) { + this.startSimulation = false; + } + if (this.stopSimulation === undefined) { + this.stopSimulation = false; + } + if (this.wait_time === undefined) { + this.wait_time = 0; + } + if (this.hour === undefined) { + this.hour = 0; + } + if (this.isExecuting === undefined) { + this.isExecuting = false; + } + if (this.stateConfVectorPosition === undefined) { + this.stateConfVectorPosition = 0; + } + if (this.internalOperationCallback === undefined) { + this.internalOperationCallback = null; + } + if (this.brightness === undefined) { + this.brightness = 0; + } + this.__hmi = new Statemachine.Hmi(this); + this.__simulation = new Statemachine.Simulation(this); + for (let i = 0; i < 2; i++) { + { + this.stateVector[i] = Statemachine.State.$NULLSTATE$; + } + ; + } + for (let i = 0; i < 1; i++) { + { + this.historyVector[i] = Statemachine.State.$NULLSTATE$; + } + ; + } + this.clearInEvents(); + this.clearInternalEvents(); + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + this.__simulation.setWAIT_MIN(5); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.SIMULATION_WAIT_MIN, this.__simulation.wAIT_MIN))); + this.__simulation.setWAIT_MAX(1200); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.SIMULATION_WAIT_MAX, this.__simulation.wAIT_MAX))); + this.__simulation.setUPDATE_PERIOD(2); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.SIMULATION_UPDATE_PERIOD, this.__simulation.uPDATE_PERIOD))); + this.setWait_time(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_WAIT_TIME, this.wait_time))); + this.setHour(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_HOUR, this.hour))); + this.isExecuting = false; + } + getWait_time() { + return this.wait_time; + } + setWait_time(value) { + this.wait_time = value; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_WAIT_TIME, this.wait_time))); + } + getHour() { + return this.hour; + } + setHour(value) { + this.hour = value; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_HOUR, this.hour))); + } + getIsExecuting() { + return this.isExecuting; + } + setIsExecuting(value) { + this.isExecuting = value; + } + getStateConfVectorPosition() { + return this.stateConfVectorPosition; + } + setStateConfVectorPosition(value) { + this.stateConfVectorPosition = value; + } + enter() { + if (this.timerService == null) { + throw Object.defineProperty(new Error("Timer service must be set."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.IllegalStateException', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.Exception'] }); + } + if (this.internalOperationCallback == null) { + throw Object.defineProperty(new Error("Internal operation callback must be set."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.IllegalStateException', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.Exception'] }); + } + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_ENTER, this))); + this.enterSequence_main_default(); + this.isExecuting = false; + } + exit() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_EXIT, this))); + this.exitSequence_main(); + this.isExecuting = false; + } + /** + * @see IStatemachine#isActive() + * @return {boolean} + */ + isActive() { + return this.stateVector[0] !== Statemachine.State.$NULLSTATE$ || this.stateVector[1] !== Statemachine.State.$NULLSTATE$; + } + /** + * + * Always returns 'false' since this state machine can never become final. + * + * @see IStatemachine#isFinal() + * @return {boolean} + */ + isFinal() { + return false; + } + clearInEvents() { + this.__hmi.switchEvent = false; + this.__hmi.toggleMode = false; + this.__hmi.changeBrightness = false; + this.timeEvents[0] = false; + this.timeEvents[1] = false; + } + clearInternalEvents() { + this.changePresence = false; + this.startSimulation = false; + this.stopSimulation = false; + } + microStep() { + let transitioned = -1; + this.stateConfVectorPosition = 0; + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_IDLE: + transitioned = this.main_Presence_Simulation_mode_Idle_react(transitioned); + break; + case sct.yakindu.io.Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_SCHEDULE_WAITING: + transitioned = this.main_Presence_Simulation_mode_Active_schedule_Waiting_react(transitioned); + break; + case sct.yakindu.io.Statemachine.State.MAIN_MANUAL_MODE_OFF: + transitioned = this.main_Manual_mode_Off_react(transitioned); + break; + case sct.yakindu.io.Statemachine.State.MAIN_MANUAL_MODE_ON: + transitioned = this.main_Manual_mode_On_react(transitioned); + break; + default: + break; + } + if (this.getStateConfVectorPosition() < 1) { + switch ((this.stateVector[1])) { + case sct.yakindu.io.Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_PRESENT: + transitioned = this.main_Presence_Simulation_mode_Active_presence_Present_react(transitioned); + break; + case sct.yakindu.io.Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_ABSENT: + transitioned = this.main_Presence_Simulation_mode_Active_presence_Absent_react(transitioned); + break; + default: + break; + } + } + } + runCycle() { + if (this.timerService == null) { + throw Object.defineProperty(new Error("Timer service must be set."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.IllegalStateException', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.Exception'] }); + } + if (this.internalOperationCallback == null) { + throw Object.defineProperty(new Error("Internal operation callback must be set."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.IllegalStateException', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.Exception'] }); + } + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_START, this))); + this.nextEvent(); + do { + { + this.microStep(); + this.clearInEvents(); + this.clearInternalEvents(); + this.nextEvent(); + } + } while (((((((((this.__hmi.switchEvent || this.__hmi.toggleMode) || this.__hmi.changeBrightness) || this.changePresence) || this.startSimulation) || this.stopSimulation) || this.timeEvents[0]) || this.timeEvents[1]))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_STOP, this))); + this.isExecuting = false; + } + nextEvent() { + if (!(this.internalEventQueue.length == 0)) { + (target => (typeof target === 'function') ? target() : target.run())(/* poll */ (a => a.length == 0 ? null : a.shift())(this.internalEventQueue)); + return; + } + if (!(this.inEventQueue.length == 0)) { + (target => (typeof target === 'function') ? target() : target.run())(/* poll */ (a => a.length == 0 ? null : a.shift())(this.inEventQueue)); + return; + } + } + /** + * Returns true if the given state is currently active otherwise false. + * @param {sct.yakindu.io.Statemachine.State} state + * @return {boolean} + */ + isStateActive(state) { + switch ((state)) { + case sct.yakindu.io.Statemachine.State.MAIN_PRESENCE_SIMULATION: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_PRESENCE_SIMULATION]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_ABSENT]]; + case sct.yakindu.io.Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_IDLE: + return this.stateVector[0] === Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_IDLE; + case sct.yakindu.io.Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_ABSENT]]; + case sct.yakindu.io.Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_SCHEDULE_WAITING: + return this.stateVector[0] === Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_SCHEDULE_WAITING; + case sct.yakindu.io.Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_PRESENT: + return this.stateVector[1] === Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_PRESENT; + case sct.yakindu.io.Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_ABSENT: + return this.stateVector[1] === Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_ABSENT; + case sct.yakindu.io.Statemachine.State.MAIN_MANUAL: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_MANUAL]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_MANUAL_MODE_ON]]; + case sct.yakindu.io.Statemachine.State.MAIN_MANUAL_MODE_OFF: + return this.stateVector[0] === Statemachine.State.MAIN_MANUAL_MODE_OFF; + case sct.yakindu.io.Statemachine.State.MAIN_MANUAL_MODE_ON: + return this.stateVector[0] === Statemachine.State.MAIN_MANUAL_MODE_ON; + default: + return false; + } + } + setTimerService(timerService) { + this.timerService = timerService; + } + getTimerService() { + return this.timerService; + } + raiseTimeEvent(eventID) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_RAISED, this, null, null, eventID))); + /* add */ (this.inEventQueue.push(() => { + this.timeEvents[eventID] = true; + }) > 0); + this.runCycle(); + } + hmi() { + return this.__hmi; + } + simulation() { + return this.__simulation; + } + getTrace() { + return this.trace; + } + raiseChangePresence() { + /* add */ (this.internalEventQueue.push(() => { + this.changePresence = true; + }) > 0); + } + raiseStartSimulation() { + /* add */ (this.internalEventQueue.push(() => { + this.startSimulation = true; + }) > 0); + } + raiseStopSimulation() { + /* add */ (this.internalEventQueue.push(() => { + this.stopSimulation = true; + }) > 0); + } + setInternalOperationCallback(internalOperationCallback) { + this.internalOperationCallback = internalOperationCallback; + } + getBrightness() { + return this.brightness; + } + setBrightness(value) { + this.brightness = value; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + } + entryAction_main_Presence_Simulation() { + this.timerService.setTimer(this, 0, (this.__simulation.getUPDATE_PERIOD() * 1000), true); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_SET, this, null, null, 0))); + } + entryAction_main_Presence_Simulation_mode_Idle() { + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + } + entryAction_main_Presence_Simulation_mode_Active_schedule_Waiting() { + this.timerService.setTimer(this, 1, (this.getWait_time() * 1000), false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_SET, this, null, null, 1))); + this.setWait_time(((n => n < 0 ? Math.ceil(n) : Math.floor(n))(((this.__simulation.wAIT_MIN + (this.internalOperationCallback.get_rand() * ((this.__simulation.wAIT_MAX - this.__simulation.wAIT_MIN)))))))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_WAIT_TIME, this.wait_time))); + } + entryAction_main_Presence_Simulation_mode_Active_presence_Present() { + this.setBrightness(10); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + } + entryAction_main_Presence_Simulation_mode_Active_presence_Absent() { + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + } + entryAction_main_Manual_mode_Off() { + this.setBrightness(0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + } + exitAction_main_Presence_Simulation() { + this.timerService.unsetTimer(this, 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_UNSET, this, null, null, 0))); + } + exitAction_main_Presence_Simulation_mode_Active_schedule_Waiting() { + this.timerService.unsetTimer(this, 1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_UNSET, this, null, null, 1))); + } + enterSequence_main_Presence_Simulation_default() { + this.entryAction_main_Presence_Simulation(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_PRESENCE_SIMULATION, null, null))); + this.enterSequence_main_Presence_Simulation_mode_default(); + } + enterSequence_main_Presence_Simulation_mode_Idle_default() { + this.entryAction_main_Presence_Simulation_mode_Idle(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_IDLE, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_IDLE; + this.stateConfVectorPosition = 0; + } + enterSequence_main_Presence_Simulation_mode_Active_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE, null, null))); + this.enterSequence_main_Presence_Simulation_mode_Active_schedule_default(); + this.enterSequence_main_Presence_Simulation_mode_Active_presence_default(); + } + enterSequence_main_Presence_Simulation_mode_Active_schedule_Waiting_default() { + this.entryAction_main_Presence_Simulation_mode_Active_schedule_Waiting(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_SCHEDULE_WAITING, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_SCHEDULE_WAITING; + this.stateConfVectorPosition = 0; + } + enterSequence_main_Presence_Simulation_mode_Active_presence_Present_default() { + this.entryAction_main_Presence_Simulation_mode_Active_presence_Present(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_PRESENT, null, null))); + this.stateVector[1] = Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_PRESENT; + this.stateConfVectorPosition = 1; + this.historyVector[0] = this.stateVector[1]; + } + enterSequence_main_Presence_Simulation_mode_Active_presence_Absent_default() { + this.entryAction_main_Presence_Simulation_mode_Active_presence_Absent(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_ABSENT, null, null))); + this.stateVector[1] = Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_ABSENT; + this.stateConfVectorPosition = 1; + this.historyVector[0] = this.stateVector[1]; + } + enterSequence_main_Manual_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_MANUAL, null, null))); + this.enterSequence_main_Manual_mode_default(); + } + enterSequence_main_Manual_mode_Off_default() { + this.entryAction_main_Manual_mode_Off(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_MANUAL_MODE_OFF, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_MANUAL_MODE_OFF; + this.stateConfVectorPosition = 0; + } + enterSequence_main_Manual_mode_On_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_MANUAL_MODE_ON, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_MANUAL_MODE_ON; + this.stateConfVectorPosition = 0; + } + enterSequence_main_default() { + this.react_main__entry_Default(); + } + enterSequence_main_Presence_Simulation_mode_default() { + this.react_main_Presence_Simulation_mode__entry_Default(); + } + enterSequence_main_Presence_Simulation_mode_Active_schedule_default() { + this.react_main_Presence_Simulation_mode_Active_schedule__entry_Default(); + } + enterSequence_main_Presence_Simulation_mode_Active_presence_default() { + this.react_main_Presence_Simulation_mode_Active_presence__entry_Default(); + } + shallowEnterSequence_main_Presence_Simulation_mode_Active_presence() { + switch ((this.historyVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_PRESENT: + this.enterSequence_main_Presence_Simulation_mode_Active_presence_Present_default(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_ABSENT: + this.enterSequence_main_Presence_Simulation_mode_Active_presence_Absent_default(); + break; + default: + break; + } + } + enterSequence_main_Manual_mode_default() { + this.react_main_Manual_mode__entry_Default(); + } + exitSequence_main_Presence_Simulation() { + this.exitSequence_main_Presence_Simulation_mode(); + this.exitAction_main_Presence_Simulation(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_PRESENCE_SIMULATION, null, null))); + } + exitSequence_main_Presence_Simulation_mode_Idle() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.stateConfVectorPosition = 0; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_IDLE, null, null))); + } + exitSequence_main_Presence_Simulation_mode_Active() { + this.exitSequence_main_Presence_Simulation_mode_Active_schedule(); + this.exitSequence_main_Presence_Simulation_mode_Active_presence(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE, null, null))); + } + exitSequence_main_Presence_Simulation_mode_Active_schedule_Waiting() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.stateConfVectorPosition = 0; + this.exitAction_main_Presence_Simulation_mode_Active_schedule_Waiting(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_SCHEDULE_WAITING, null, null))); + } + exitSequence_main_Presence_Simulation_mode_Active_presence_Present() { + this.stateVector[1] = Statemachine.State.$NULLSTATE$; + this.stateConfVectorPosition = 1; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_PRESENT, null, null))); + } + exitSequence_main_Presence_Simulation_mode_Active_presence_Absent() { + this.stateVector[1] = Statemachine.State.$NULLSTATE$; + this.stateConfVectorPosition = 1; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_ABSENT, null, null))); + } + exitSequence_main_Manual() { + this.exitSequence_main_Manual_mode(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_MANUAL, null, null))); + } + exitSequence_main_Manual_mode_Off() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.stateConfVectorPosition = 0; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_MANUAL_MODE_OFF, null, null))); + } + exitSequence_main_Manual_mode_On() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.stateConfVectorPosition = 0; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_MANUAL_MODE_ON, null, null))); + } + exitSequence_main() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_IDLE: + this.exitSequence_main_Presence_Simulation_mode_Idle(); + this.exitAction_main_Presence_Simulation(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_PRESENCE_SIMULATION, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_SCHEDULE_WAITING: + this.exitSequence_main_Presence_Simulation_mode_Active_schedule_Waiting(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_MANUAL_MODE_OFF: + this.exitSequence_main_Manual_mode_Off(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_MANUAL, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_MANUAL_MODE_ON: + this.exitSequence_main_Manual_mode_On(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_MANUAL, null, null))); + break; + default: + break; + } + switch ((this.stateVector[1])) { + case sct.yakindu.io.Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_PRESENT: + this.exitSequence_main_Presence_Simulation_mode_Active_presence_Present(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE, null, null))); + this.exitAction_main_Presence_Simulation(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_PRESENCE_SIMULATION, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_ABSENT: + this.exitSequence_main_Presence_Simulation_mode_Active_presence_Absent(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE, null, null))); + this.exitAction_main_Presence_Simulation(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_PRESENCE_SIMULATION, null, null))); + break; + default: + break; + } + } + exitSequence_main_Presence_Simulation_mode() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_IDLE: + this.exitSequence_main_Presence_Simulation_mode_Idle(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_SCHEDULE_WAITING: + this.exitSequence_main_Presence_Simulation_mode_Active_schedule_Waiting(); + break; + default: + break; + } + switch ((this.stateVector[1])) { + case sct.yakindu.io.Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_PRESENT: + this.exitSequence_main_Presence_Simulation_mode_Active_presence_Present(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_ABSENT: + this.exitSequence_main_Presence_Simulation_mode_Active_presence_Absent(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE, null, null))); + break; + default: + break; + } + } + exitSequence_main_Presence_Simulation_mode_Active_schedule() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_SCHEDULE_WAITING: + this.exitSequence_main_Presence_Simulation_mode_Active_schedule_Waiting(); + break; + default: + break; + } + } + exitSequence_main_Presence_Simulation_mode_Active_presence() { + switch ((this.stateVector[1])) { + case sct.yakindu.io.Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_PRESENT: + this.exitSequence_main_Presence_Simulation_mode_Active_presence_Present(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_ABSENT: + this.exitSequence_main_Presence_Simulation_mode_Active_presence_Absent(); + break; + default: + break; + } + } + exitSequence_main_Manual_mode() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_MANUAL_MODE_OFF: + this.exitSequence_main_Manual_mode_Off(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_MANUAL_MODE_ON: + this.exitSequence_main_Manual_mode_On(); + break; + default: + break; + } + } + react_main_Presence_Simulation_mode_Active_schedule__entry_Default() { + this.enterSequence_main_Presence_Simulation_mode_Active_schedule_Waiting_default(); + } + react_main_Presence_Simulation_mode_Active_presence__entry_Default() { + if (this.historyVector[0] !== Statemachine.State.$NULLSTATE$) { + this.shallowEnterSequence_main_Presence_Simulation_mode_Active_presence(); + } + else { + this.enterSequence_main_Presence_Simulation_mode_Active_presence_Absent_default(); + } + } + react_main_Presence_Simulation_mode__entry_Default() { + this.enterSequence_main_Presence_Simulation_mode_Idle_default(); + } + react_main_Manual_mode__entry_Default() { + this.enterSequence_main_Manual_mode_Off_default(); + } + react_main__entry_Default() { + this.enterSequence_main_Manual_default(); + } + react(transitioned_before) { + return transitioned_before; + } + main_Presence_Simulation_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__hmi.toggleMode) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_PRESENCE_SIMULATION, null, 0))); + this.exitSequence_main_Presence_Simulation(); + this.enterSequence_main_Manual_default(); + this.react(0); + transitioned_after = 1; + } + } + if (transitioned_after === transitioned_before) { + if (this.timeEvents[0]) { + this.setHour(this.internalOperationCallback.get_hour()); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.INTERNAL_HOUR, this.hour))); + } + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_Presence_Simulation_mode_Idle_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.startSimulation) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_IDLE, null, 0))); + this.exitSequence_main_Presence_Simulation_mode_Idle(); + this.enterSequence_main_Presence_Simulation_mode_Active_default(); + this.main_Presence_Simulation_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + if ((this.getHour() > 17 || ((this.getHour() > 7 && this.getHour() < 10)))) { + this.raiseStartSimulation(); + } + transitioned_after = this.main_Presence_Simulation_react(transitioned_before); + } + return transitioned_after; + } + main_Presence_Simulation_mode_Active_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.stopSimulation) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE, null, 0))); + this.exitSequence_main_Presence_Simulation_mode_Active(); + this.enterSequence_main_Presence_Simulation_mode_Idle_default(); + this.main_Presence_Simulation_react(0); + transitioned_after = 1; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_Presence_Simulation_react(transitioned_before); + } + return transitioned_after; + } + main_Presence_Simulation_mode_Active_schedule_Waiting_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.changePresence) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_SCHEDULE_WAITING, null, 0))); + this.exitSequence_main_Presence_Simulation_mode_Active_schedule_Waiting(); + this.enterSequence_main_Presence_Simulation_mode_Active_schedule_Waiting_default(); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + if (!((this.getHour() > 17 || ((this.getHour() > 7 && this.getHour() < 10))))) { + this.raiseStopSimulation(); + } + if (this.timeEvents[1]) { + this.raiseChangePresence(); + } + } + return transitioned_after; + } + main_Presence_Simulation_mode_Active_presence_Present_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 1) { + if (this.changePresence) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_PRESENT, null, 0))); + this.exitSequence_main_Presence_Simulation_mode_Active_presence_Present(); + this.enterSequence_main_Presence_Simulation_mode_Active_presence_Absent_default(); + this.main_Presence_Simulation_mode_Active_react(0); + transitioned_after = 1; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_Presence_Simulation_mode_Active_react(transitioned_before); + } + return transitioned_after; + } + main_Presence_Simulation_mode_Active_presence_Absent_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 1) { + if (this.changePresence) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_ABSENT, null, 0))); + this.exitSequence_main_Presence_Simulation_mode_Active_presence_Absent(); + this.enterSequence_main_Presence_Simulation_mode_Active_presence_Present_default(); + this.main_Presence_Simulation_mode_Active_react(0); + transitioned_after = 1; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_Presence_Simulation_mode_Active_react(transitioned_before); + } + return transitioned_after; + } + main_Manual_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__hmi.toggleMode) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_MANUAL, null, 0))); + this.exitSequence_main_Manual(); + this.enterSequence_main_Presence_Simulation_default(); + this.react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_Manual_mode_Off_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__hmi.switchEvent) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_MANUAL_MODE_OFF, null, 0))); + this.exitSequence_main_Manual_mode_Off(); + this.setBrightness(10); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + this.enterSequence_main_Manual_mode_On_default(); + this.main_Manual_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_Manual_react(transitioned_before); + } + return transitioned_after; + } + main_Manual_mode_On_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.__hmi.switchEvent) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_MANUAL_MODE_ON, null, 0))); + this.exitSequence_main_Manual_mode_On(); + this.enterSequence_main_Manual_mode_Off_default(); + this.main_Manual_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + if (((this.__hmi.changeBrightness) && (this.getBrightness() > 1))) { + this.setBrightness(this.getBrightness() - 1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + } + if (((this.__hmi.changeBrightness) && (this.getBrightness() <= 1))) { + this.setBrightness(10); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.BRIGHTNESS, this.brightness))); + } + transitioned_after = this.main_Manual_react(transitioned_before); + } + return transitioned_after; + } + } + io.Statemachine = Statemachine; + Statemachine["__class"] = "sct.yakindu.io.Statemachine"; + Statemachine["__interfaces"] = ["com.yakindu.core.IStatemachine", "com.yakindu.core.ITimed"]; + (function (Statemachine) { + class Hmi { + constructor(parent) { + if (this.parent === undefined) { + this.parent = null; + } + if (this.switchEvent === undefined) { + this.switchEvent = false; + } + if (this.toggleMode === undefined) { + this.toggleMode = false; + } + if (this.changeBrightness === undefined) { + this.changeBrightness = false; + } + this.parent = parent; + } + raiseSwitch() { + /* add */ (this.parent.inEventQueue.push(() => { + this.switchEvent = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.HMI_SWITCH, null))); + this.parent.runCycle(); + } + raiseToggleMode() { + /* add */ (this.parent.inEventQueue.push(() => { + this.toggleMode = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.HMI_TOGGLEMODE, null))); + this.parent.runCycle(); + } + raiseChangeBrightness() { + /* add */ (this.parent.inEventQueue.push(() => { + this.changeBrightness = true; + }) > 0); + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this.parent, null, Statemachine.Feature.HMI_CHANGEBRIGHTNESS, null))); + this.parent.runCycle(); + } + } + Statemachine.Hmi = Hmi; + Hmi["__class"] = "sct.yakindu.io.Statemachine.Hmi"; + class Simulation { + constructor(parent) { + if (this.parent === undefined) { + this.parent = null; + } + if (this.wAIT_MIN === undefined) { + this.wAIT_MIN = 0; + } + if (this.wAIT_MAX === undefined) { + this.wAIT_MAX = 0; + } + if (this.uPDATE_PERIOD === undefined) { + this.uPDATE_PERIOD = 0; + } + this.parent = parent; + } + getWAIT_MIN() { + return this.wAIT_MIN; + } + setWAIT_MIN(value) { + this.wAIT_MIN = value; + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this.parent, null, Statemachine.Feature.SIMULATION_WAIT_MIN, this.wAIT_MIN))); + } + getWAIT_MAX() { + return this.wAIT_MAX; + } + setWAIT_MAX(value) { + this.wAIT_MAX = value; + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this.parent, null, Statemachine.Feature.SIMULATION_WAIT_MAX, this.wAIT_MAX))); + } + getUPDATE_PERIOD() { + return this.uPDATE_PERIOD; + } + setUPDATE_PERIOD(value) { + this.uPDATE_PERIOD = value; + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this.parent, null, Statemachine.Feature.SIMULATION_UPDATE_PERIOD, this.uPDATE_PERIOD))); + } + } + Statemachine.Simulation = Simulation; + Simulation["__class"] = "sct.yakindu.io.Statemachine.Simulation"; + let State; + (function (State) { + State[State["MAIN_PRESENCE_SIMULATION"] = 0] = "MAIN_PRESENCE_SIMULATION"; + State[State["MAIN_PRESENCE_SIMULATION_MODE_IDLE"] = 1] = "MAIN_PRESENCE_SIMULATION_MODE_IDLE"; + State[State["MAIN_PRESENCE_SIMULATION_MODE_ACTIVE"] = 2] = "MAIN_PRESENCE_SIMULATION_MODE_ACTIVE"; + State[State["MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_SCHEDULE_WAITING"] = 3] = "MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_SCHEDULE_WAITING"; + State[State["MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_PRESENT"] = 4] = "MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_PRESENT"; + State[State["MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_ABSENT"] = 5] = "MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_ABSENT"; + State[State["MAIN_MANUAL"] = 6] = "MAIN_MANUAL"; + State[State["MAIN_MANUAL_MODE_OFF"] = 7] = "MAIN_MANUAL_MODE_OFF"; + State[State["MAIN_MANUAL_MODE_ON"] = 8] = "MAIN_MANUAL_MODE_ON"; + State[State["$NULLSTATE$"] = 9] = "$NULLSTATE$"; + })(State = Statemachine.State || (Statemachine.State = {})); + /** + * Enumeration of all features of the statechart + * @enum + * @property {sct.yakindu.io.Statemachine.Feature} NO_FEATURE + * @property {sct.yakindu.io.Statemachine.Feature} BRIGHTNESS + * @property {sct.yakindu.io.Statemachine.Feature} HMI_SWITCH + * @property {sct.yakindu.io.Statemachine.Feature} HMI_TOGGLEMODE + * @property {sct.yakindu.io.Statemachine.Feature} HMI_CHANGEBRIGHTNESS + * @property {sct.yakindu.io.Statemachine.Feature} SIMULATION_WAIT_MIN + * @property {sct.yakindu.io.Statemachine.Feature} SIMULATION_WAIT_MAX + * @property {sct.yakindu.io.Statemachine.Feature} SIMULATION_UPDATE_PERIOD + * @property {sct.yakindu.io.Statemachine.Feature} INTERNAL_WAIT_TIME + * @property {sct.yakindu.io.Statemachine.Feature} INTERNAL_HOUR + * @property {sct.yakindu.io.Statemachine.Feature} INTERNAL_CHANGEPRESENCE + * @property {sct.yakindu.io.Statemachine.Feature} INTERNAL_STARTSIMULATION + * @property {sct.yakindu.io.Statemachine.Feature} INTERNAL_STOPSIMULATION + * @class + */ + let Feature; + (function (Feature) { + Feature[Feature["NO_FEATURE"] = 0] = "NO_FEATURE"; + Feature[Feature["BRIGHTNESS"] = 1] = "BRIGHTNESS"; + Feature[Feature["HMI_SWITCH"] = 2] = "HMI_SWITCH"; + Feature[Feature["HMI_TOGGLEMODE"] = 3] = "HMI_TOGGLEMODE"; + Feature[Feature["HMI_CHANGEBRIGHTNESS"] = 4] = "HMI_CHANGEBRIGHTNESS"; + Feature[Feature["SIMULATION_WAIT_MIN"] = 5] = "SIMULATION_WAIT_MIN"; + Feature[Feature["SIMULATION_WAIT_MAX"] = 6] = "SIMULATION_WAIT_MAX"; + Feature[Feature["SIMULATION_UPDATE_PERIOD"] = 7] = "SIMULATION_UPDATE_PERIOD"; + Feature[Feature["INTERNAL_WAIT_TIME"] = 8] = "INTERNAL_WAIT_TIME"; + Feature[Feature["INTERNAL_HOUR"] = 9] = "INTERNAL_HOUR"; + Feature[Feature["INTERNAL_CHANGEPRESENCE"] = 10] = "INTERNAL_CHANGEPRESENCE"; + Feature[Feature["INTERNAL_STARTSIMULATION"] = 11] = "INTERNAL_STARTSIMULATION"; + Feature[Feature["INTERNAL_STOPSIMULATION"] = 12] = "INTERNAL_STOPSIMULATION"; + })(Feature = Statemachine.Feature || (Statemachine.Feature = {})); + })(Statemachine = io.Statemachine || (io.Statemachine = {})); + })(io = yakindu.io || (yakindu.io = {})); + })(yakindu = sct.yakindu || (sct.yakindu = {})); +})(sct || (sct = {})); diff --git a/org.yakindu.sct.examples.basic.tutorial/_05_presencesimulationlightswitch-player/assets/context.json.js b/org.yakindu.sct.examples.basic.tutorial/_05_presencesimulationlightswitch-player/assets/context.json.js new file mode 100644 index 00000000..5230f8a9 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_05_presencesimulationlightswitch-player/assets/context.json.js @@ -0,0 +1 @@ +const contextJson = {"elements":[{"elements":[{"kind":"variable","type":"integer","name":"brightness","fqName":"brightness","featureId":"BRIGHTNESS","writable":true,"value":0}],"kind":"composite","name":"default","featureId":"","writable":true},{"elements":[{"kind":"event","name":"switch","fqName":"hmi.switch","featureId":"HMI_SWITCH","writable":true},{"kind":"event","name":"toggleMode","fqName":"hmi.toggleMode","featureId":"HMI_TOGGLEMODE","writable":true},{"kind":"event","name":"changeBrightness","fqName":"hmi.changeBrightness","featureId":"HMI_CHANGEBRIGHTNESS","writable":true}],"kind":"composite","name":"hmi","fqName":"hmi","featureId":"","writable":true},{"elements":[{"kind":"variable","type":"integer","name":"WAIT_MIN","fqName":"simulation.WAIT_MIN","featureId":"SIMULATION_WAIT_MIN","writable":true,"value":5},{"kind":"variable","type":"integer","name":"WAIT_MAX","fqName":"simulation.WAIT_MAX","featureId":"SIMULATION_WAIT_MAX","writable":true,"value":1200},{"kind":"variable","type":"integer","name":"UPDATE_PERIOD","fqName":"simulation.UPDATE_PERIOD","featureId":"SIMULATION_UPDATE_PERIOD","writable":true,"value":2}],"kind":"composite","name":"simulation","fqName":"simulation","featureId":"","writable":true},{"elements":[{"kind":"variable","type":"integer","name":"wait_time","fqName":"wait_time","featureId":"INTERNAL_WAIT_TIME","writable":true,"value":0},{"kind":"variable","type":"integer","name":"hour","fqName":"hour","featureId":"INTERNAL_HOUR","writable":true,"value":0},{"kind":"operation","type":"real","name":"get_rand","fqName":"get_rand","featureId":"INTERNAL_GET_RAND","writable":true,"value":0.0},{"kind":"operation","type":"integer","name":"get_hour","fqName":"get_hour","featureId":"INTERNAL_GET_HOUR","writable":true,"value":0}],"kind":"composite","name":"internal","featureId":"","writable":true},{"elements":[{"kind":"event","type":"integer","name":"Presence_Simulation_time_event_0","fqName":"_05_PresenceSimulationLightSwitch.main.Presence_Simulation_time_event_0","featureId":"PRESENCE_SIMULATION_TIME_EVENT_0","writable":true,"value":0},{"kind":"event","type":"integer","name":"Waiting_time_event_0","fqName":"_05_PresenceSimulationLightSwitch.main.Presence_Simulation.mode.Active.schedule.Waiting_time_event_0","featureId":"WAITING_TIME_EVENT_0","writable":true,"value":0}],"kind":"composite","name":"time events","featureId":"","writable":true}]} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_05_presencesimulationlightswitch-player/assets/hashes.json.js b/org.yakindu.sct.examples.basic.tutorial/_05_presencesimulationlightswitch-player/assets/hashes.json.js new file mode 100644 index 00000000..90154b14 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_05_presencesimulationlightswitch-player/assets/hashes.json.js @@ -0,0 +1 @@ +const hashesJson = {"MAIN_PRESENCE_SIMULATION_MODE_ACTIVE":"6c1679c4-7121-4ff3-a63b-55a0d872812c","MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_SCHEDULE_WAITING_tr0":"a5a3c4c5-4d03-4997-856d-3b9e71d54d44","MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_SCHEDULE_WAITING":"d3692ff5-f72e-44cb-a4e1-121c214d76a0","MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_PRESENT_tr0":"f2a4acb9-65c9-4695-a29c-f49956dbfe41","MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_PRESENT":"0ec80181-baad-43be-856d-d9b213a775e9","MAIN_MANUAL_tr0":"638bb0bb-3dec-4c9b-8b24-ca6ea5db1db0","MAIN_PRESENCE_SIMULATION_tr0":"b2d1772a-2f6e-4a24-a853-5fbeabcc594b","MAIN_MANUAL":"0a9d0361-bd0b-484c-9258-dd9c7f77e4ba","MAIN_PRESENCE_SIMULATION":"07946cb1-5a22-4700-900b-d1063d931909","MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_ABSENT":"024687c4-9673-49af-9435-75d7aca4cbc9","MAIN_PRESENCE_SIMULATION_MODE_IDLE_tr0":"75488694-b5a8-4aa5-9487-60565f341956","MAIN_MANUAL_MODE_OFF":"0667d8ef-3fc1-4297-b64a-b718ebd16170","MAIN_MANUAL_MODE_OFF_tr0":"f9895c16-e41d-44d5-8514-d12880368cdc","MAIN_PRESENCE_SIMULATION_MODE_IDLE":"268d569e-a9ef-4e40-95f1-392806cdf02d","MAIN_MANUAL_MODE_ON_tr0":"ba5b58dc-01e3-4bdc-b95e-d3807e983340","MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_PRESENCE_ABSENT_tr0":"f86606a0-d804-4ee3-a57d-48a49491e564","MAIN_PRESENCE_SIMULATION_MODE_ACTIVE_tr0":"cc22fd67-4d1e-46c9-b31d-03a588d760bc","MAIN_MANUAL_MODE_ON":"ed689cd7-556f-4d90-a640-c821abd4d860"} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_05_presencesimulationlightswitch-player/assets/statemachine.svg.js b/org.yakindu.sct.examples.basic.tutorial/_05_presencesimulationlightswitch-player/assets/statemachine.svg.js new file mode 100644 index 00000000..59806d7a --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_05_presencesimulationlightswitch-player/assets/statemachine.svg.js @@ -0,0 +1 @@ +let svg = `main1-Presence Simulation every simulation.UPDATE_PERIOD s / hour = get_hour mode--Idleentry / brightness = 0[ hour > 17 || (hour > 7 && hour < 10) ] / raise startSimulationActiveschedule-Waitingentry / wait_time = (simulation.WAIT_MIN + get_rand() * (simulation.WAIT_MAX - simulation.WAIT_MIN) ) as integeralways [ !(hour > 17 || (hour > 7 && hour < 10)) ] / raise stopSimulationafter wait_time s / raise changePresence-presence-Presententry / brightness = 10Absententry / brightness = 0-Manualmode--Offentry / brightness = 0Onhmi.changeBrightness [brightness > 1] / brightness -= 1 hmi.changeBrightness [brightness <= 1] / brightness = 10-1-1hmi.toggleModehmi.toggleMode1hmi.toggleModehmi.toggleMode1startSimulationstartSimulation1stopSimulationstopSimulation1-1changePresencechangePresence1changePresencechangePresence1-1-1hmi.switch / brightness = 10hmi.switch / brightness = 101hmi.switch hmi.switch 1changePresencechangePresence1` \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_05_presencesimulationlightswitch-player/assets/ypi.css b/org.yakindu.sct.examples.basic.tutorial/_05_presencesimulationlightswitch-player/assets/ypi.css new file mode 100644 index 00000000..771aaa11 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_05_presencesimulationlightswitch-player/assets/ypi.css @@ -0,0 +1,113 @@ +/*! + * itemis CREATE Player Styles + * Copyright 2021 itemis AG + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ + + + /*! + * Style definitions follow BEM pattern using and additional 'y' namespace (for itemis CREATE). + */ +.y-declaration { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; + background-color: #eee; + font-family: 'Courier New', Courier, monospace; +} + + +.y-entry { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; +} + +.y-entry:after { + content: ' \25CF '; + font-size: larger; +} + +.y-state { + background-color: rgb(209, 223, 238); + padding: 3px; + border: 0.5pt;; + border: 0.5pt; + border-radius: 4px; + border-color: #bbb; + font-family: 'Courier New', Courier, monospace; +} + +.y-state--active { + background-color: rgb(244, 215, 66); +} + +.y-state--inactive { + background-color: rgb(209, 223, 238); +} + +.y-variable{ + background-color: #eee; + border-color: #aaa; + border: 0.5pt; + border: 0.5pt; + border-radius: 2px; + font-family: 'Courier New', Courier, monospace; +} + +.y-variable::after { + color: #aaa; + content: attr(value); + font-family: 'Courier New', Courier, monospace; +} + +.y-do-enter { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; +} + +.y-do-enter:before { + content: ' \2192 '; +} + +.y-do-exit { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer +} + +.y-do-exit:before { + content: ' \2192 '; +} + +.y-do-raise { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; + white-space: nowrap; +} + +.y-do-raise:before { + content: ' \2192 '; +} + +button.y-do-raise:before { + content: ''; +} + +button.y-do-raise { + cursor: pointer; +} + +.y-do--over { + color: blue; + background-color: #eee; + cursor: pointer; +} + +.y-player { + border-style: solid; + border-width: 1px; + border-color: ; +} diff --git a/org.yakindu.sct.examples.basic.tutorial/_05_presencesimulationlightswitch-player/model.scm b/org.yakindu.sct.examples.basic.tutorial/_05_presencesimulationlightswitch-player/model.scm new file mode 100644 index 00000000..7a19d962 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_05_presencesimulationlightswitch-player/model.scm @@ -0,0 +1,1349 @@ +{ + "cells": [ + { + "position": { + "x": 0, + "y": 0 + }, + "size": { + "height": 10, + "width": 10 + }, + "angle": 0, + "type": "Statechart", + "id": "7f85a5d8-4f8b-4021-89ed-2c96ab106e07", + "linkable": false, + "z": 1, + "attrs": { + "name": { + "text": "_05_PresenceSimulationLightSwitch" + }, + "specification": { + "text": "@EventDriven\n\t\ninterface:\n\tvar brightness: integer\n\ninterface hmi:\n\tin event switch\n\tin event toggleMode\n\tin event changeBrightness\n\ninterface simulation:\n\tvar WAIT_MIN: integer = 5\n\tvar WAIT_MAX: integer = 1200\n\tvar UPDATE_PERIOD : integer = 2\n\n\ninternal:\n\tvar wait_time: integer\n\tvar hour: integer\n\t\n\tevent changePresence\n\tevent startSimulation\n\tevent stopSimulation\n\t\n\toperation get_rand(): real\n\toperation get_hour(): integer\n\t\t\n\t\n\t" + } + } + }, + { + "type": "Region", + "position": { + "x": 0, + "y": 0 + }, + "size": { + "width": 1362, + "height": 703 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "d6eff3b9-ca8d-4163-b996-a6c587f11158", + "z": 2, + "embeds": [ + "638bb0bb-3dec-4c9b-8b24-ca6ea5db1db0", + "b2d1772a-2f6e-4a24-a853-5fbeabcc594b", + "e410273c-308a-490c-8def-97fe976e2772", + "4f052e01-2238-403d-b1b9-313465e9899f", + "07946cb1-5a22-4700-900b-d1063d931909", + "0a9d0361-bd0b-484c-9258-dd9c7f77e4ba" + ], + "attrs": { + "priority": { + "text": 1 + }, + "name": { + "fontSize": "10", + "text": "main" + } + } + }, + { + "type": "Entry", + "position": { + "x": 737, + "y": 46 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "4f052e01-2238-403d-b1b9-313465e9899f", + "parent": "d6eff3b9-ca8d-4163-b996-a6c587f11158", + "z": 3, + "embeds": [ + "fe373c20-adba-4235-8444-8b042d0ab7a7" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 737, + "y": 61 + }, + "id": "fe373c20-adba-4235-8444-8b042d0ab7a7", + "z": 4, + "parent": "4f052e01-2238-403d-b1b9-313465e9899f", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 16, + "y": 283 + }, + "size": { + "width": 1272, + "height": 408 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "07946cb1-5a22-4700-900b-d1063d931909", + "parent": "d6eff3b9-ca8d-4163-b996-a6c587f11158", + "z": 5, + "embeds": [ + "6c66075d-4e32-4391-ab8e-d695a156888c" + ], + "attrs": { + "name": { + "text": "Presence Simulation" + }, + "specification": { + "text": "\tevery simulation.UPDATE_PERIOD s / hour = get_hour ", + "fontSize": "9" + } + } + }, + { + "type": "Region", + "position": { + "x": 17, + "y": 319 + }, + "size": { + "width": 1270, + "height": 371 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "6c66075d-4e32-4391-ab8e-d695a156888c", + "z": 6, + "parent": "07946cb1-5a22-4700-900b-d1063d931909", + "embeds": [ + "cc22fd67-4d1e-46c9-b31d-03a588d760bc", + "75488694-b5a8-4aa5-9487-60565f341956", + "ad2377aa-6dc0-47f0-9ff8-3e3289a833a3", + "e59c2540-2777-4a41-ac4b-5d7ec1c25369", + "268d569e-a9ef-4e40-95f1-392806cdf02d", + "6c1679c4-7121-4ff3-a63b-55a0d872812c" + ], + "attrs": { + "name": { + "fontSize": "9", + "text": "mode" + } + } + }, + { + "type": "Entry", + "position": { + "x": 90, + "y": 494 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "e59c2540-2777-4a41-ac4b-5d7ec1c25369", + "parent": "6c66075d-4e32-4391-ab8e-d695a156888c", + "z": 7, + "embeds": [ + "6676ba5d-41b4-4f00-8f97-8ceb4069cb2c" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 90, + "y": 509 + }, + "id": "6676ba5d-41b4-4f00-8f97-8ceb4069cb2c", + "z": 8, + "parent": "e59c2540-2777-4a41-ac4b-5d7ec1c25369", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 38, + "y": 347 + }, + "size": { + "width": 220, + "height": 111 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "268d569e-a9ef-4e40-95f1-392806cdf02d", + "parent": "6c66075d-4e32-4391-ab8e-d695a156888c", + "z": 9, + "attrs": { + "name": { + "text": "Idle" + }, + "specification": { + "text": "entry / brightness = 0\n\n[ hour > 17 \n || (hour > 7 && hour < 10) \n] / raise startSimulation", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 391, + "y": 347 + }, + "size": { + "width": 842, + "height": 334 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "6c1679c4-7121-4ff3-a63b-55a0d872812c", + "parent": "6c66075d-4e32-4391-ab8e-d695a156888c", + "z": 10, + "embeds": [ + "88a8c04d-8e20-4c78-a672-a079ff68a21c", + "56c1f544-1d81-43fc-a4f1-e8395e163f0c" + ], + "attrs": { + "name": { + "text": "Active" + } + } + }, + { + "type": "Region", + "position": { + "x": 392, + "y": 385 + }, + "size": { + "width": 543, + "height": 293 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "88a8c04d-8e20-4c78-a672-a079ff68a21c", + "z": 11, + "parent": "6c1679c4-7121-4ff3-a63b-55a0d872812c", + "embeds": [ + "a5a3c4c5-4d03-4997-856d-3b9e71d54d44", + "3133b1a6-9e84-463e-a167-068f5a1d8c1f", + "d3692ff5-f72e-44cb-a4e1-121c214d76a0", + "fdf95d30-e875-4951-a053-725ac435b2f3" + ], + "attrs": { + "name": { + "fontSize": "9", + "text": "schedule" + } + } + }, + { + "type": "State", + "position": { + "x": 466, + "y": 414 + }, + "size": { + "width": 403, + "height": 205 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "d3692ff5-f72e-44cb-a4e1-121c214d76a0", + "parent": "88a8c04d-8e20-4c78-a672-a079ff68a21c", + "z": 12, + "attrs": { + "name": { + "text": "Waiting" + }, + "specification": { + "text": "entry /\n wait_time =\n (simulation.WAIT_MIN \n + get_rand() \n * (simulation.WAIT_MAX - simulation.WAIT_MIN)\n ) as integer\n\nalways [ !(hour > 17 || (hour > 7 && hour < 10)) ] \n\t/ raise stopSimulation\n\nafter wait_time s / raise changePresence", + "fontSize": "9" + } + } + }, + { + "type": "Entry", + "position": { + "x": 422, + "y": 426 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "fdf95d30-e875-4951-a053-725ac435b2f3", + "parent": "88a8c04d-8e20-4c78-a672-a079ff68a21c", + "z": 13, + "embeds": [ + "2dc8a8f3-0d0b-45c3-b548-d4ecc7fd9792" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 422, + "y": 441 + }, + "id": "2dc8a8f3-0d0b-45c3-b548-d4ecc7fd9792", + "z": 14, + "parent": "fdf95d30-e875-4951-a053-725ac435b2f3", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "Region", + "position": { + "x": 935, + "y": 385 + }, + "size": { + "width": 297, + "height": 293 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "56c1f544-1d81-43fc-a4f1-e8395e163f0c", + "z": 15, + "parent": "6c1679c4-7121-4ff3-a63b-55a0d872812c", + "embeds": [ + "f86606a0-d804-4ee3-a57d-48a49491e564", + "f2a4acb9-65c9-4695-a29c-f49956dbfe41", + "3a8d50e4-18df-4a23-bf91-447b91b19dfc", + "0ec80181-baad-43be-856d-d9b213a775e9", + "024687c4-9673-49af-9435-75d7aca4cbc9", + "4fe93143-4f52-4ee3-9ab1-26d0a993434c" + ], + "attrs": { + "name": { + "fontSize": "9", + "text": "presence" + } + } + }, + { + "type": "State", + "position": { + "x": 1015, + "y": 496 + }, + "size": { + "width": 176, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "0ec80181-baad-43be-856d-d9b213a775e9", + "parent": "56c1f544-1d81-43fc-a4f1-e8395e163f0c", + "z": 16, + "attrs": { + "name": { + "text": "Present" + }, + "specification": { + "text": "entry / brightness = 10", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 1012, + "y": 413 + }, + "size": { + "width": 179, + "height": 53 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "024687c4-9673-49af-9435-75d7aca4cbc9", + "parent": "56c1f544-1d81-43fc-a4f1-e8395e163f0c", + "z": 17, + "attrs": { + "name": { + "text": "Absent" + }, + "specification": { + "text": "entry / brightness = 0", + "fontSize": "9" + } + } + }, + { + "type": "ShallowHistory", + "position": { + "x": 964, + "y": 428 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "4fe93143-4f52-4ee3-9ab1-26d0a993434c", + "parent": "56c1f544-1d81-43fc-a4f1-e8395e163f0c", + "z": 18, + "embeds": [ + "e4c2c1a4-25e6-4c29-8d6e-9e7c960725f2" + ], + "attrs": { + "name": { + "fill": "#555555" + } + } + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 964, + "y": 443 + }, + "id": "e4c2c1a4-25e6-4c29-8d6e-9e7c960725f2", + "z": 19, + "parent": "4fe93143-4f52-4ee3-9ab1-26d0a993434c", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 16, + "y": 36 + }, + "size": { + "width": 665, + "height": 185 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "0a9d0361-bd0b-484c-9258-dd9c7f77e4ba", + "parent": "d6eff3b9-ca8d-4163-b996-a6c587f11158", + "z": 20, + "embeds": [ + "c130c1b9-0cc7-471c-bc25-41e10fa734d8" + ], + "attrs": { + "name": { + "text": "Manual" + } + } + }, + { + "type": "Region", + "position": { + "x": 17, + "y": 76 + }, + "size": { + "width": 663, + "height": 144 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": false, + "id": "c130c1b9-0cc7-471c-bc25-41e10fa734d8", + "z": 21, + "parent": "0a9d0361-bd0b-484c-9258-dd9c7f77e4ba", + "embeds": [ + "ba5b58dc-01e3-4bdc-b95e-d3807e983340", + "f9895c16-e41d-44d5-8514-d12880368cdc", + "96c9bcf8-061d-43b0-9347-c144af91998d", + "8bc70fba-1ad7-45e5-90f4-b32eeddced18", + "0667d8ef-3fc1-4297-b64a-b718ebd16170", + "ed689cd7-556f-4d90-a640-c821abd4d860" + ], + "attrs": { + "name": { + "fontSize": "9", + "text": "mode" + } + } + }, + { + "type": "Entry", + "position": { + "x": 134, + "y": 201 + }, + "size": { + "width": 15, + "height": 15 + }, + "angle": 0, + "fixedRatio": true, + "embedable": false, + "linkable": true, + "id": "8bc70fba-1ad7-45e5-90f4-b32eeddced18", + "parent": "c130c1b9-0cc7-471c-bc25-41e10fa734d8", + "z": 22, + "embeds": [ + "62f6416c-96aa-4595-b843-f41ee86a670a" + ], + "attrs": {} + }, + { + "type": "NodeLabel", + "label": true, + "size": { + "width": 15, + "height": 15 + }, + "position": { + "x": 134, + "y": 216 + }, + "id": "62f6416c-96aa-4595-b843-f41ee86a670a", + "z": 23, + "parent": "8bc70fba-1ad7-45e5-90f4-b32eeddced18", + "attrs": { + "label": { + "fontSize": "9", + "refX": "50%", + "textAnchor": "middle", + "refY": "50%", + "textVerticalAnchor": "middle" + } + } + }, + { + "type": "State", + "position": { + "x": 36, + "y": 104 + }, + "size": { + "width": 159, + "height": 68 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "0667d8ef-3fc1-4297-b64a-b718ebd16170", + "parent": "c130c1b9-0cc7-471c-bc25-41e10fa734d8", + "z": 24, + "attrs": { + "name": { + "text": "Off" + }, + "specification": { + "text": "entry \n / brightness = 0", + "fontSize": "9" + } + } + }, + { + "type": "State", + "position": { + "x": 338, + "y": 104 + }, + "size": { + "width": 303, + "height": 98 + }, + "angle": 0, + "fixedRatio": false, + "embedable": true, + "linkable": true, + "id": "ed689cd7-556f-4d90-a640-c821abd4d860", + "parent": "c130c1b9-0cc7-471c-bc25-41e10fa734d8", + "z": 25, + "attrs": { + "name": { + "text": "On" + }, + "specification": { + "text": "hmi.changeBrightness \n [brightness > 1] / brightness -= 1 \nhmi.changeBrightness \n [brightness <= 1] / brightness = 10", + "fontSize": "9" + } + } + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "3.283902858371069%", + "dy": "37.4020397208803%", + "rotate": true + } + }, + "id": "4f052e01-2238-403d-b1b9-313465e9899f" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "8.438003220611916%", + "rotate": true + } + }, + "id": "0a9d0361-bd0b-484c-9258-dd9c7f77e4ba" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "e410273c-308a-490c-8def-97fe976e2772", + "z": 26, + "parent": "d6eff3b9-ca8d-4163-b996-a6c587f11158", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "37.736240913811045%", + "dy": "3.1452991452992287%", + "rotate": true + } + }, + "id": "e59c2540-2777-4a41-ac4b-5d7ec1c25369" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "26.20928915321439%", + "dy": "50%", + "rotate": true + } + }, + "id": "268d569e-a9ef-4e40-95f1-392806cdf02d" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "ad2377aa-6dc0-47f0-9ff8-3e3289a833a3", + "z": 27, + "parent": "6c66075d-4e32-4391-ab8e-d695a156888c", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "15.336454271338493%", + "dy": "0.015614221904530323%", + "rotate": true + } + }, + "id": "07946cb1-5a22-4700-900b-d1063d931909" + }, + "target": { + "id": "0a9d0361-bd0b-484c-9258-dd9c7f77e4ba", + "anchor": { + "name": "topLeft", + "args": { + "dx": "29%", + "dy": "51%", + "rotate": true + } + } + }, + "labels": [ + { + "attrs": { + "text": { + "text": "hmi.toggleMode", + "fontSize": "9" + } + }, + "position": { + "distance": 0.5451798482226036, + "offset": -54.58976543309253, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "b2d1772a-2f6e-4a24-a853-5fbeabcc594b", + "z": 28, + "parent": "d6eff3b9-ca8d-4163-b996-a6c587f11158", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "id": "0a9d0361-bd0b-484c-9258-dd9c7f77e4ba", + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "50%", + "rotate": true + } + } + }, + "target": { + "id": "07946cb1-5a22-4700-900b-d1063d931909", + "anchor": { + "name": "topLeft", + "args": { + "dx": "26%", + "dy": "1%", + "rotate": true + } + } + }, + "labels": [ + { + "attrs": { + "text": { + "text": "hmi.toggleMode", + "fontSize": "9" + } + }, + "position": { + "distance": 0.47563760378169606, + "offset": -45.871030369228, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "638bb0bb-3dec-4c9b-8b24-ca6ea5db1db0", + "z": 29, + "parent": "d6eff3b9-ca8d-4163-b996-a6c587f11158", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "58.252534968952915%", + "rotate": true + } + }, + "id": "268d569e-a9ef-4e40-95f1-392806cdf02d" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.04259412144254548%", + "dy": "19.359375393873574%", + "rotate": true + } + }, + "id": "6c1679c4-7121-4ff3-a63b-55a0d872812c" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "startSimulation", + "fontSize": "9" + } + }, + "position": { + "distance": 0.47368421052631576, + "offset": 17.339999999999918, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "75488694-b5a8-4aa5-9487-60565f341956", + "z": 30, + "parent": "6c66075d-4e32-4391-ab8e-d695a156888c", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.05689644653007485%", + "dy": "3.4639251063545413%", + "rotate": true + } + }, + "id": "6c1679c4-7121-4ff3-a63b-55a0d872812c" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "10.422981851553304%", + "rotate": true + } + }, + "id": "268d569e-a9ef-4e40-95f1-392806cdf02d" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "stopSimulation", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "cc22fd67-4d1e-46c9-b31d-03a588d760bc", + "z": 31, + "parent": "6c66075d-4e32-4391-ab8e-d695a156888c", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "89.6106362773033%", + "dy": "28.88888888888914%", + "rotate": true + } + }, + "id": "4fe93143-4f52-4ee3-9ab1-26d0a993434c" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.21407311910111249%", + "dy": "36.477987421383716%", + "rotate": true + } + }, + "id": "024687c4-9673-49af-9435-75d7aca4cbc9" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "3a8d50e4-18df-4a23-bf91-447b91b19dfc", + "z": 32, + "parent": "56c1f544-1d81-43fc-a4f1-e8395e163f0c", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "14.554011114413806%", + "dy": "1.6302077739191887%", + "rotate": true + } + }, + "id": "0ec80181-baad-43be-856d-d9b213a775e9" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "15.986066794060502%", + "dy": "50%", + "rotate": true + } + }, + "id": "024687c4-9673-49af-9435-75d7aca4cbc9" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "changePresence", + "fontSize": "9" + } + }, + "position": { + "distance": 0.4666666666666667, + "offset": -59.61999999999989, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "f2a4acb9-65c9-4695-a29c-f49956dbfe41", + "z": 33, + "parent": "56c1f544-1d81-43fc-a4f1-e8395e163f0c", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "56.69143340541619%", + "dy": "50%", + "rotate": true + } + }, + "id": "024687c4-9673-49af-9435-75d7aca4cbc9" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "55.95321920209941%", + "dy": "1.242138364779817%", + "rotate": true + } + }, + "id": "0ec80181-baad-43be-856d-d9b213a775e9" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "changePresence", + "fontSize": "9" + } + }, + "position": { + "distance": 0.43333333333333335, + "offset": -43.51999999999998, + "angle": 0 + } + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "f86606a0-d804-4ee3-a57d-48a49491e564", + "z": 34, + "parent": "56c1f544-1d81-43fc-a4f1-e8395e163f0c", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "97.00305810397595%", + "dy": "48.88888888888914%", + "rotate": true + } + }, + "id": "fdf95d30-e875-4951-a053-725ac435b2f3" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.14911102510984367%", + "dy": "9.430894308943108%", + "rotate": true + } + }, + "id": "d3692ff5-f72e-44cb-a4e1-121c214d76a0" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "3133b1a6-9e84-463e-a167-068f5a1d8c1f", + "z": 35, + "parent": "88a8c04d-8e20-4c78-a672-a079ff68a21c", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "2.2222222222222854%", + "rotate": true + } + }, + "id": "8bc70fba-1ad7-45e5-90f4-b32eeddced18" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "66.35220125786164%", + "dy": "50%", + "rotate": true + } + }, + "id": "0667d8ef-3fc1-4297-b64a-b718ebd16170" + }, + "labels": [ + { + "attrs": { + "text": { + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "96c9bcf8-061d-43b0-9347-c144af91998d", + "z": 36, + "parent": "c130c1b9-0cc7-471c-bc25-41e10fa734d8", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "16.176470588235293%", + "rotate": true + } + }, + "id": "0667d8ef-3fc1-4297-b64a-b718ebd16170" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.16501650165016502%", + "dy": "11.224489795918368%", + "rotate": true + } + }, + "id": "ed689cd7-556f-4d90-a640-c821abd4d860" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "hmi.switch /\n brightness = 10", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "f9895c16-e41d-44d5-8514-d12880368cdc", + "z": 37, + "parent": "c130c1b9-0cc7-471c-bc25-41e10fa734d8", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "0.05500550055006126%", + "dy": "59.504556539596976%", + "rotate": true + } + }, + "id": "ed689cd7-556f-4d90-a640-c821abd4d860" + }, + "target": { + "anchor": { + "name": "topLeft", + "args": { + "dx": "50%", + "dy": "85.75656677765447%", + "rotate": true + } + }, + "id": "0667d8ef-3fc1-4297-b64a-b718ebd16170" + }, + "labels": [ + { + "attrs": { + "text": { + "text": "hmi.switch ", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "ba5b58dc-01e3-4bdc-b95e-d3807e983340", + "z": 38, + "parent": "c130c1b9-0cc7-471c-bc25-41e10fa734d8", + "attrs": {} + }, + { + "type": "Transition", + "source": { + "id": "d3692ff5-f72e-44cb-a4e1-121c214d76a0", + "anchor": { + "name": "topLeft", + "args": { + "dx": "77.91563275434244%", + "dy": "50%", + "rotate": true + } + } + }, + "target": { + "id": "d3692ff5-f72e-44cb-a4e1-121c214d76a0", + "anchor": { + "name": "topLeft", + "args": { + "dx": "63.27543424317618%", + "dy": "50%", + "rotate": true + } + } + }, + "labels": [ + { + "attrs": { + "text": { + "text": "changePresence", + "fontSize": "9" + } + }, + "position": {} + }, + { + "attrs": { + "label": { + "text": "1" + } + } + } + ], + "id": "a5a3c4c5-4d03-4997-856d-3b9e71d54d44", + "z": 39, + "parent": "88a8c04d-8e20-4c78-a672-a079ff68a21c", + "vertices": [ + { + "x": 780, + "y": 644 + }, + { + "x": 721, + "y": 644 + } + ], + "attrs": {} + } + ] +} \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/_05_presencesimulationlightswitch-player/player.html b/org.yakindu.sct.examples.basic.tutorial/_05_presencesimulationlightswitch-player/player.html new file mode 100644 index 00000000..a40d8757 --- /dev/null +++ b/org.yakindu.sct.examples.basic.tutorial/_05_presencesimulationlightswitch-player/player.html @@ -0,0 +1,52 @@ + +sct-web-player demo + + + + + + + + + + + + + + + +
+ +
+ + + + + \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/css/ypi.css b/org.yakindu.sct.examples.basic.tutorial/css/ypi.css index 39d56ca8..771aaa11 100644 --- a/org.yakindu.sct.examples.basic.tutorial/css/ypi.css +++ b/org.yakindu.sct.examples.basic.tutorial/css/ypi.css @@ -1,12 +1,12 @@ /*! - * YAKINDU Player Styles + * itemis CREATE Player Styles * Copyright 2021 itemis AG * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) */ /*! - * Style definitions follow BEM pattern using and additional 'y' namespace (for YAKINDU). + * Style definitions follow BEM pattern using and additional 'y' namespace (for itemis CREATE). */ .y-declaration { padding: 3px; diff --git a/org.yakindu.sct.examples.basic.tutorial/index.html b/org.yakindu.sct.examples.basic.tutorial/index.html index 6237e560..d5b84842 100644 --- a/org.yakindu.sct.examples.basic.tutorial/index.html +++ b/org.yakindu.sct.examples.basic.tutorial/index.html @@ -1,289 +1,458 @@ + - -Light Switch Series - - + + Light Switch Series + + +

Basic Tutorial - Light Switch Example Series

- In this example series we will develop a lamp control from scratch. Starting from a simple On/Off switch, we will add further features like brightness adjustment and motion detection step-by-step while introducing new statechart elements with each iteration. In that way you will learn how to use: + In this example series we will develop a lamp control from scratch. Starting from a simple On/Off switch, we will + add further features like brightness adjustment and motion detection step-by-step while introducing new statechart + elements with each iteration. In that way you will learn how to use:

    -
  • States and transitions
  • -
  • Transition triggers, guards, and actions
  • -
  • Statechart interfaces, and where to declare events, variables and operations
  • -
  • Composite states, and how they help structuring your statechart
  • -
  • History states, and the difference between shallow and deep history
  • +
  • States and transitions
  • +
  • Transition triggers, guards, and actions
  • +
  • Statechart interfaces, and where to declare events, variables and operations
  • +
  • Composite states, and how they help structuring your statechart
  • +
  • History states, and the difference between shallow and deep history
- - This example is a good starting point to dive into YAKINDU Statechart Tools headfirst.

-

- -

+ This example is a good starting point to dive into itemis CREATE headfirst.

+ +

+ +

The First Iteration: States, Transitions and Events

-

A statechart is a graphical model which describes the behavior of some thing or entity. It describes how such an entity reacts to changes and events in its environment. Due to it’s graphical nature, lucid concepts, and well defined semantics it provides a comprehensive and executable basis for system specification and implementation which can be shared between stakeholders without demanding too many technical skills.

-

The most basic element of a statechart are states, transitions, and events. To introduce these basic concepts we take a look at the simple light switch example below. States represent the modes of a system or entity and in the case of this very simple light switch two states - Off and - On exist. States have a name, are visualized as rounded rectangles. At any point of time states are either active or inactive. Active state are highlighted using a - yellow background color while inactive states have a - blue background color. -

-

If something happens then the statechart may change its state. Each state can have outgoing transitions. These transitions connect two states and have a direction which is indicated by the arrow head. Our light switch states are mutually connected by transitions. These transitions are directed and define how state changes (state transitions) can occur under which conditions. Here, the light switch simply defines that - Off and - On are toggled whenever a - switch event occurs. As the state machine only reacts in response to events, it is called - event driven. -

-

-

Events typically occur in the environment of the statechart’s entity. To simulate this environment and to play with the light switch you can interactively trigger events e.g. by clicking on interactive elements like - switch. -

-

- The First Iteration: States, Transitions and Events +

A statechart is a graphical model which describes the behavior of some thing or entity. It describes how such + an entity reacts to changes and events in its environment. Due to it’s graphical nature, lucid concepts, and + well defined semantics it provides a comprehensive and executable basis for system specification and + implementation which can be shared between stakeholders without demanding too many technical skills.

+

The most basic element of a statechart are states, transitions, and events. To introduce these basic concepts + we take a look at the simple light switch example below. States represent the modes of a system or entity and in + the case of this very simple light switch two states + Off and + On exist. States have a name, are visualized as rounded rectangles. At + any point of time states are either active or inactive. Active state are highlighted using a + yellow background color while inactive states have a + blue background color.

-

State machines as a whole can be active or inactive. If a state machine is inactive then no state is active and it won’t react on any event. If a state machine is active then is has at least one active state and it is ready to react on events. - Entering a state machine activates it - exiting deactivates it. If you - enter the light switch state machine then - Off is the first active state. The first active state is called - initial state and is defined by the - entry node whose single outgoing transition points to - Off. -

-

- The statechart can be simulated in YAKINDU Statechart Tools via right-click -> Run As -> Statechart Simulation. +

If something happens then the statechart may change its state. Each state can have outgoing transitions. These + transitions connect two states and have a direction which is indicated by the arrow head. Our light switch + states are mutually connected by transitions. These transitions are directed and define how state changes (state + transitions) can occur under which conditions. Here, the light switch simply defines that + Off and + On are toggled whenever a + switch event occurs. As the state machine only reacts in response to + events, it is called + event driven.

-
+

+
+

+

Events typically occur in the environment of the statechart’s entity. To simulate this environment and to + play with the light switch you can interactively trigger events e.g. by clicking on interactive elements like + switch. +

+

+

+

+

State machines as a whole can be active or inactive. If a state machine is inactive then no state is active + and it won’t react on any event. If a state machine is active then is has at least one active state and it is + ready to react on events. + Entering a state machine activates it + exiting deactivates it. If you + enter the light switch state machine then + Off is the first active state. The first active state is called + initial state and is defined by the + entry node whose single outgoing transition points to + Off. +

+

+ The statechart can be simulated in itemis CREATE via right-click -> Run As -> Statechart + Simulation. +

+
-
-

The Second Iteration: Variables

- -

While the classic theory of input/output automata is only aware of events, Harel statecharts and as such YAKINDU statecharts have many more features, including variables. Variables allow to use quantitative values in statecharts and are very comparable to variables in programming languages.

-

-

To explain the use of variables we extend the light switch by adding - dimming functionality. The light switch supports ten different dimming levels. It still defines the states - Off and - On with mutual transitions which are triggered by - switch events. -

-

To handle the dimming functionality the light switch statechart defines two additional elements:

-
    -
  • The variable - brightness holds the dimming level of the light. Changing this variable’s value corresponds to changing the lamp’s brightness. -
  • -
  • The additional event - changeBrightness increases changes the dimming level incrementally. -
  • -
-

To handle the - brightness level correctly the statechart must maintain its value depending on the active state and the occurring events. As such it defines the following rules: -

-
    -
  • Whenever - Off is active - brightness must be 0. This is enforced by the - Off state’s - entry action which is defined as entry / brightness = 0. This action assigns 0 and is executed whenever state - Off is entered. -
  • -
  • When the light - switches from - Off to - On then the - brightness must be set to the maximum value of 10. -
  • -
  • If - On is active and - changeBrightness is requested and - brightness is larger 1 then the brightness value is decremented. This rule is specified by an additional transition which reacts on the - changeBrightness event and uses a - guard condition which must become true for taking the transition. The proper variable assignment is specified as a transition action. The target of the transition is the state itself as the switch should remain in the - On state. Such transitions are called - self transition. -
  • -
  • If - On is active and - changeBrightness is requested and - brightness equals 1 then the value is reset to 10. Here again an additional transition with guard and action is defined to cover the desired condition and effect. -
  • -
-

This example shows how variables can be used in conjunction with more complex conditions. Variables can be assigned and can also be used in conditions and calculation expressions. Actions can be specified as part of a transition as well as part of states.

- - -

- The Second Iteration: Variables -

-
+
+

The Second Iteration: Variables

-
-

The Third Iteration: Composite States

- -

Normally, a statechart does not only consist of two states. The specification of even simple systems require tens and more complex systems hundreds of states and transitions. To cope with large number of states the base concept of - composite states can be used. -

-

Let’s enhance our light switch to explain this in more detail. The light switch now provides an additional motion sensing mode which automatically switches the light on and off depending on the input of a motion sensor. Initially, the light is off, but whenever the motion sensor senses a motion, it turns the light on. After 30 seconds without any motion the light is turned off again. As manually switching and dimming the light should still be supported the existing statechart must be extended.

-

First, an additional event - toggleMode is defined. This is used to toggle between the already existing manual and the automated motion sensing mode. To model these modes two additional states are introduced. -

-
    -
  1. The composite state - Manual contains the existing behavior. These are the - On and - Off states of previous statechart. Here only the dimming transitions were replaced by - local state reactions. -
  2. -
  3. The composite state - MotionSensing is completely new and contains the states - MotionSensing.On and - MotionSensing.Off. These handle the - motionDetected event. The required timeout is specified using the time trigger after 30s. If the state does not change for 30 seconds then a time event is raised which will cause to switch the light off. -
  4. -
-

A - composite state is a state that contains one or more other states (sub states). One of the advantages is the possibility to group states into logical compounds and thus make the statechart more comprehensible. Another advantage is the option to exit a composite state by transitions that have the composite state as their source states, not any substate. If such a transition is executed, the composite state is left regardless of which of its sub states are active at the moment. You could achieve the same without composite states, but it would be cumbersome since you would need a transition from each of the plain states in the group to the „outside”. -

-

The transitions which toggles between - MotionSensing and - Manual state are defined for the composite states. This implies that the transitions will be taken independent of the concrete active sub state. So all sub states share the behavior of their parent states. -

-

If you want to learn more about composite states, you can check out our Hierarchical tatecharts example or the chapter Composite states in our documentation.

- -

- The Third Iteration: Composite States -

+

While the classic theory of input/output + automata is only aware of events, Harel statecharts and as such + itemis CREATE statecharts have many more features, including variables. Variables allow to use quantitative values + in statecharts and are very comparable to variables in programming languages.

+

+
+

+

To explain the use of variables we extend the light switch by adding + dimming functionality. The light switch supports ten different dimming levels. It still + defines the states + Off and + On with mutual transitions which are triggered by + switch events. +

+

To handle the dimming functionality the light switch statechart defines two additional elements:

+
    +
  • The variable + brightness holds the dimming level of the light. Changing + this variable’s value corresponds to changing the lamp’s brightness. +
  • +
  • The additional event + changeBrightness increases changes the dimming level + incrementally. +
  • +
+

To handle the + brightness level correctly the statechart must maintain its + value depending on the active state and the occurring events. As such it defines the following rules: +

+
    +
  • Whenever + Off is active + brightness must be 0. This is enforced by the + Off state’s + entry action which is defined as entry / brightness = 0. This action assigns 0 and + is executed whenever state + Off is entered. +
  • +
  • When the light + switches from + Off to + On then the + brightness must be set to the maximum value of 10. +
  • +
  • If + On is active and + changeBrightness is requested and + brightness is larger 1 then the brightness value is + decremented. This rule is specified by an additional transition which reacts on the + changeBrightness event and uses a + guard condition which must become true for taking the transition. The proper variable assignment + is specified as a transition action. The target of the transition is the state itself as the switch should + remain in the + On state. Such transitions are called + self transition. +
  • +
  • If + On is active and + changeBrightness is requested and + brightness equals 1 then the value is reset to 10. Here + again an additional transition with guard and action is defined to cover the desired condition and effect. +
  • +
+

This example shows how variables can be used in conjunction with more complex conditions. Variables can be + assigned and can also be used in conditions and calculation expressions. Actions can be specified as part of + a transition as well as part of states.

-
-

The Fourth Iteration: History Entries and Named Interfaces

-

We already discussed the default entry behavior for regions and how sub states are activated. Histories provide an extension to this mechanism and this section clarifies how history entries work, what they do, and especially what they don’t do. To illustrate this, we introduce another mode to our light switch: light sensing. When operating in light sensing mode, the light control automatically turns on the light when it is dark and turns it off when it is bright. For this purpose a luminosity sensor is used. It permanently senses the ambient brightness and fires - luminosity.bright or - luminosity.dark events all the time. It is out of scope how „dark” and „bright” are defined and how they are configured in the luminosity sensor. Suffice to say that the sensor is always raising events – say, multiple times per second. -

-

As before the light switch is either operated manually or operates automatically. When in automatic mode, the light switch functions either as a twilight switch as explained above or as the already introduced motion sense switch (see the previous iteration). The user interface gets another button to toggle between the two modes via the user.mode_button event. The light switch is starting to change into a full light control module.

+

+

+

+
+
+

The Third Iteration: Composite States

-

- The Fourth Iteration: History Entries and Named Interfaces -

+

Normally, a statechart does not only consist of two states. The specification of even simple systems + require tens and more complex systems hundreds of states and transitions. To cope with large number of + states the base concept of + composite states can be used. +

+

Let’s enhance our light switch to explain this in more detail. The light switch now provides an additional + motion sensing mode which automatically switches the light on and off depending on the + input of a motion sensor. Initially, the light is off, but whenever the motion sensor senses a motion, it + turns the light on. After 30 seconds without any motion the light is turned off again. As manually switching + and dimming the light should still be supported the existing statechart must be extended. +

+

First, an additional event + toggleMode is defined. This is used to toggle between the + already existing manual and the automated motion sensing mode. To model these modes two additional states + are introduced. +

+
    +
  1. The composite state + Manual contains the existing behavior. These are the + On and + Off states of previous statechart. Here only the + dimming transitions were replaced by + local state reactions. +
  2. +
  3. The composite state + MotionSensing is completely new and contains the + states + MotionSensing.On and + MotionSensing.Off. These handle the + motionDetected event. The required timeout is + specified using the time trigger after 30s. If the state does not change for 30 seconds then + a time event is raised which will cause to switch the light off. +
  4. +
+

A + composite state is a state that contains one or more other states (sub states). One of the + advantages is the possibility to group states into logical compounds and thus make the statechart more + comprehensible. Another advantage is the option to exit a composite state by transitions that have the + composite state as their source states, not any substate. If such a transition is executed, the composite + state is left regardless of which of its sub states are active at the moment. You could achieve the same + without composite states, but it would be cumbersome since you would need a transition from each of the + plain states in the group to the „outside”. +

+

The transitions which toggles between + MotionSensing and + Manual state are defined for the composite states. This + implies that the transitions will be taken independent of the concrete active sub state. So all sub states + share the behavior of their parent states. +

+

If you want to learn more about composite states, you can check out our Hierarchical + tatecharts example or the chapter Composite + states in our documentation.

-

As we added a couple of additional declarations we now use named interfaces to group the different events and variables. This grouping makes the design more clear and provides a better overview. The usage is not different except for the fact that the interface name must be used when referencing its declarations.

- -

The automatic modes are grouped into the - Automatic composite state. That state is subdivided into a composite state for the twilight functionality and another one for motion sensing. We have discussed motion sensing before, but the - Light Sensing composite state deserves some explanation. When the ambient brightness is changing from day to night or from night to day, the luminosity sensor doesn’t deliver consistent values. Rather small fluctuations are causing a succession of quickly alternating - luminosity.dark and - luminosity.bright events. Having each of these events turn the light on or off, respectively, would result in a flickering lamp for some time during twilight. To avoid this, the state machine requires a certain permanence in the luminosity sensor’s results before actually toggling the light’s state. -

-

This is done like this: During the day the - Light Sensing composite state’s - Bright sub state is active. In this state the state machine listens for - luminosity.dark events. These events are starting to be raised when it is about to get dark. First they come in spuriously, later there are more - luminosity.dark than - luminosity.bright events within a given period of time, until only - luminosity.dark events are raised. The first - luminosity.dark changes the state from - Bright to - Getting Dark. In this state we are waiting until a certain time has passed, e. g. 10 seconds, to be configured as constant luminosity.wait_time. However, each - luminosity.bright event brings the state machine back to the Off. Only if the waiting time has passed without any - lum_sensor.bright interfering, the - Dark state is reached and the light is turned on. The analogous happens in the morning when the first light of the day is close. The twilight switch is also robust against short disruptions like overshadowing the sensor during the day or illuminating it briefly by a car’s headlamps during the night. -

-

An important requirement is that any of the automatic modes can be interrupted at any time by manually operating the light switch via . When the user later raises a event, the state machine should return to that particular sub state somewhere down in the - Automatic composite state that was active before the manual intervention. Similarly, when toggling between - Light Sensing and - Motion Sensing the state machine should remember the respective active sub state and return there when control is turned back. -

-

That’s what history entries are good for. The statechart contains a couple of shallow history entries. A shallow history state, contained in a composite state with a set of sub states, remembers which of these sub states was active when that composite state was left.

-

The shallow history state in - Automatic remembers whether - Light Sensing or - Motion_Sensing was active when - Automatic was left, but it doesn’t remember which state was active within the active one of these two. On re-entry, the history state would activate either - Twilight or - MotionSensing, but these would use their respective entries. This is why there is a history state in each of them as well. -

-

If you have worked with history states before, you might be inclined now to say: "A deep history state would have been the correct thing here." However, you would only be partially right. A deep history state remembers the active state in its own region and everything that was active inside of this state, recursively down to the lowest level. We might spare the two shallow history states in - Light Sensing and - Motion Sensing. But it would not behave in the same way – a history state is activated only when its containing region is actually left. Using one deep history state would not allow to remember the active state in - MotionSensing when switching to - Light Sensing, and vice versa. The deep history state would be activated only if we left the whole - Automatic composite state – and when switching between automatic modes this won’t happen. -

-

More information on history states can also be found in the History States example or the corresponding chapter in our documentation.

- - - -
+

+

+

-
-

The Fifth Iteration: Orthogonal States, Internal Events and Operations

- -

The different versions of light switches which we discussed so far define a couple of states but are quite simple in that respect that at any time at most one single state is active. You may object that hierarchy made up of composite states features a set of active states. This is not really true. Composite states just group a set of states but are not independent of their sub states. - Leaf states are the - real active states and the activation of a leaf state implies that also all its parent states are active. The leaf states also - inherit the parent states behavior. There are scenarios which require - orthogonal states (sometimes also called - parallel states or - and states). -

-

Additionally, there are also scenarios where calculation become so complex that you don’t want to maintain them within a statechart. In these cases - operations can be applied. -

-

To illustrate these concepts we define a variant of the light switch which includes a - presence simulation. It behaves as if a person operated the light at sensible and irregular intervals although nobody is present. The presence simulation is active on certain hours of the day only, namely from 17:00 to midnight and from 06:00 to 10:00. Here the motion detection and the twilight detection are left out for clarity. -

-

To define the presence simulation the - orthogonal state - Active is defined. It contains two sub regions which are independent of each other and are executed virtually in parallel (their order is relevant, though). Each region can contain one active state. Each region is caring about different aspects. The region - schedule includes a single state which cares about scheduling the next - changePresence event. This event in turn is consumed by the - presence region which switches the light on and off. -

-

The events - changePresence, - startSimulation, and - stopSimulation are - internal events (also called - local events) which are raised by the statechart itself when a certain condition is fulfilled. They can’t be raised by the environment and are not visible externally. These internal events will be processed directly after the current event. So - interbnal events can be used to chain multiple processing steps. The states - Idle and - Waiting raise these internal events. -

-

The definition of - Presence Simulation get quite complex. There are especially a couple of textual rules and expressions which include calculations. Additionally, a modeler may require functions which are not directly available within the statechart. However, YAKINDU SCT allows you to implement your own operations to overcome these limitations. An operation is called from the state machine itself, so you don’t have to care about when and how they will be called. Operations can receive arguments from the state machine and return a value, exactly like a normal function or method call. Operations are declared by the statechart but are not defined within the statechart and must be implemented externally. The presence simulation uses two operations: -

-
    -
  1. get_hour to ask for the current time of day to decide if the presence simulation must be activated.
  2. -
  3. get_rand to ask for a random float to calculate a random waiting interval in minutes between WAIT_MIN and WAIT_MAX.
  4. -
- -

- The Fifth Iteration: Orthogonal States, Internal Events and Operations -

+
+

The Fourth Iteration: History Entries and Named Interfaces

+ +

We already discussed the default entry behavior for regions and how sub states are activated. Histories + provide an extension to this mechanism and this section clarifies how history entries work, what they do, + and especially what they don’t do. To illustrate this, we introduce another mode to our light switch: + light sensing. When operating in light sensing mode, the light control automatically + turns on the light when it is dark and turns it off when it is bright. For this purpose a luminosity + sensor is used. It permanently senses the ambient brightness and fires + luminosity.bright or + luminosity.dark events all the time. It is out of + scope how „dark” and „bright” are defined and how they are configured in the luminosity sensor. Suffice to + say that the sensor is always raising events – say, multiple times per second. +

+

As before the light switch is either operated manually or operates automatically. When in automatic mode, + the light switch functions either as a twilight switch as explained above or as the already introduced + motion sense switch (see the previous iteration). The user interface gets another button to toggle between + the two modes via the user.mode_button event. The light switch is starting to change into a full + light control module.

+ + +

+

+

+ +

As we added a couple of additional declarations we now use named interfaces to group the different events + and variables. This grouping makes the design more clear and provides a better overview. The usage is not + different except for the fact that the interface name must be used when referencing its declarations.

- -
+

The automatic modes are grouped into the + Automatic composite state. That state is subdivided into + a composite state for the twilight functionality and another one for motion sensing. We have discussed + motion sensing before, but the + Light Sensing composite state + deserves some explanation. When the ambient brightness is changing from day to night or from night to day, + the luminosity sensor doesn’t deliver consistent values. Rather small fluctuations are causing a + succession of quickly alternating + luminosity.dark and + luminosity.bright events. Having each of these + events turn the light on or off, respectively, would result in a flickering lamp for some time during + twilight. To avoid this, the state machine requires a certain permanence in the luminosity sensor’s + results before actually toggling the light’s state. +

+

This is done like this: During the day the + Light Sensing composite state’s + Bright sub state is + active. In this state the state machine listens for + luminosity.dark events. These events are starting to + be raised when it is about to get dark. First they come in spuriously, later there are more + luminosity.dark than + luminosity.bright events within a given period of + time, until only + luminosity.dark events are raised. The first + luminosity.dark changes the state from + Bright to + Getting Dark. In + this state we are waiting until a certain time has passed, e. g. 10 seconds, to be configured as + constant luminosity.wait_time. However, each + luminosity.bright event brings the state machine + back to the Off. Only if the waiting time has passed without any + lum_sensor.bright interfering, the + Dark state is reached and + the light is turned on. The analogous happens in the morning when the first light of the day is close. The + twilight switch is also robust against short disruptions like overshadowing the sensor during the day or + illuminating it briefly by a car’s headlamps during the night. +

+

An important requirement is that any of the automatic modes can be interrupted at any time by manually + operating the light switch via . + When the user later raises a + event, the state machine should return to that particular sub state somewhere down in the + Automatic composite state that was active before the + manual intervention. Similarly, when toggling between + Light Sensing and + Motion Sensing the state machine + should remember the respective active sub state and return there when control is turned back. +

+

That’s what history entries are good for. The statechart contains a couple of + shallow history entries. A shallow history state, contained in a composite state with a set of + sub states, remembers which of these sub states was active when that composite state was left. +

+

The shallow history state in + Automatic remembers whether + Light Sensing or + Motion_Sensing was active when + Automatic was left, but it doesn’t remember which state + was active within the active one of these two. On re-entry, the history state would activate either + Twilight or + MotionSensing, but these would use + their respective entries. This is why there is a history state in each of them as well. +

+

If you have worked with history states before, you might be inclined now to say: "A deep history + state would have been the correct thing here." However, you would only be partially right. A deep history + state remembers the active state in its own region and everything that was active inside of this state, + recursively down to the lowest level. We might spare the two shallow history states in + Light Sensing and + Motion Sensing. But it would not + behave in the same way – a history state is activated only when its containing region is actually left. + Using one deep history state would not allow to remember the active state in + MotionSensing when switching to + Light Sensing, and vice versa. The + deep history state would be activated only if we left the whole + Automatic composite state – and when switching between + automatic modes this won’t happen. +

+

More information on history states can also be found in the History + States example or the corresponding chapter + in our documentation.

-
+ +
+ +
+

The Fifth Iteration: Orthogonal States, Internal Events and Operations

+ +

The different versions of light switches which we discussed so far define a couple of states but are + quite simple in that respect that at any time at most one single state is active. You may object that + hierarchy made up of composite states features a set of active states. This is not really true. Composite + states just group a set of states but are not independent of their sub states. + Leaf states are the + real active states and the activation of a leaf state implies that also all its parent states are + active. The leaf states also + inherit the parent states behavior. There are scenarios which require + orthogonal states (sometimes also called + parallel states or + and states). +

+

Additionally, there are also scenarios where calculation become so complex that you don’t want to + maintain them within a statechart. In these cases + operations can be applied. +

+

To illustrate these concepts we define a variant of the light switch which includes a + presence simulation. It behaves as if a person operated the light at sensible and + irregular intervals although nobody is present. The presence simulation is active on certain hours of the + day only, namely from 17:00 to midnight and from 06:00 to 10:00. Here the motion detection and the + twilight detection are left out for clarity. +

+

To define the presence simulation the + orthogonal state + Active is defined. It contains two + sub regions which are independent of each other and are executed virtually in parallel (their order is + relevant, though). Each region can contain one active state. Each region is caring about different + aspects. The region + schedule includes a single state which cares about scheduling the next + changePresence event. This event in turn is consumed + by the + presence region which switches the light on and off. +

+

The events + changePresence, + startSimulation, and + stopSimulation are + internal events (also called + local events) which are raised by the statechart itself when a certain condition is fulfilled. + They can’t be raised by the environment and are not visible externally. These internal events will be + processed directly after the current event. So + interbnal events can be used to chain multiple processing steps. The states + Idle and + Waiting raise + these internal events. +

+

The definition of + Presence Simulation get quite complex. There + are especially a couple of textual rules and expressions which include calculations. Additionally, a + modeler may require functions which are not directly available within the statechart. However, itemis CREATE + allows you to implement your own operations to overcome these limitations. An operation is called + from the state machine itself, so you don’t have to care about when and how they will be called. + Operations can receive arguments from the state machine and return a value, exactly like a normal function + or method call. Operations are declared by the statechart but are not defined within the statechart and + must be implemented externally. The presence simulation uses two operations: +

+
    +
  1. get_hour to ask for the current time of day to decide if the presence simulation must be + activated.
  2. +
  3. get_rand to ask for a random float to calculate a random waiting interval in minutes + between WAIT_MIN and WAIT_MAX.
  4. +
+ +

+

+

+ + +
+ + +
+ - + + \ No newline at end of file diff --git a/org.yakindu.sct.examples.basic.tutorial/metadata.json b/org.yakindu.sct.examples.basic.tutorial/metadata.json index 5bc5fbb6..e3a967cc 100644 --- a/org.yakindu.sct.examples.basic.tutorial/metadata.json +++ b/org.yakindu.sct.examples.basic.tutorial/metadata.json @@ -2,7 +2,7 @@ "id": "org.yakindu.sct.examples.basic.tutorial", "title": "Basic Tutorial", "author": "itemis AG", - "description": "This is a series of examples demonstrating multiple features of YAKINDU SCT. With each iteration, more features are shown. This example is a good starting point to dive into SCT headfirst.", + "description": "This is a series of examples demonstrating multiple features of itemis CREATE . With each iteration, more features are shown. This example is a good starting point to dive into headfirst.", "previewImage": "lights_thumb.jpg", "category": [ "open source", diff --git a/org.yakindu.sct.examples.digitalwatch/index.html b/org.yakindu.sct.examples.digitalwatch/index.html index 80561201..2c1abc91 100644 --- a/org.yakindu.sct.examples.digitalwatch/index.html +++ b/org.yakindu.sct.examples.digitalwatch/index.html @@ -30,7 +30,7 @@

The Digital Watch in all its Details

Gaining a Better Understanding Using Subdiagrams

-

We can use a YAKINDU SCT feature to extract composite states into +

We can use a itemis CREATE feature to extract composite states into subdiagrams. This makes the statechart much easier to comprehend:

Debug and remote control state machines using YET

- The YAKINDU Execution Trace (YET) infrastructure supports interoperability between - state machines running in a target application and the YAKINDU tooling. + The itemis CREATE Execution Trace (YET) infrastructure supports interoperability between + state machines running in a target application and the itemis CREATE tooling. It supports model-level debugging and testing of the state machines based on execution traces. This example shows how to remote debug a compiled state machine step by step. Please refer to the YET documentation for more information. @@ -33,7 +33,7 @@

ESP32 blinky LED example

This state machine is executed within an interactive application. This application can be used from the command line. It reads user input from the standard input and writes to the standard output. - It is build to run on a Raspberry PI. The SCT Simulation can be executed on any other machine. + It is build to run on a Raspberry PI. The Simulation can be executed on any other machine. For this setup both are located the same local network.

@@ -42,7 +42,7 @@

Building, flashing and running the application

using our example wizard, you can start skip the first part and start with Installing ESP-IDF Tools.

The instructions contain detailed explanations of how to set up the environment, compile the program and flash the binary on the ESP32. It also shows how a terminal can be added. Your WiFi SSID and password must be set in the sdkconfig file. WiFi settings

-

If you're running the application via UDP you must set the IP of the machine, which runs the debug SCT YET session:#define SCT_IP "Add your IP here". The simplest way finding your ip address using ifconfing on linux or mac and ipconfing on windows. It should be something like 192.168.0.42

+

If you're running the application via UDP you must set the IP of the machine, which runs the debug YET session:#define _IP "Add your IP here". The simplest way finding your ip address using ifconfing on linux or mac and ipconfing on windows. It should be something like 192.168.0.42

Debugging the statemachine trace

diff --git a/org.yakindu.sct.examples.esp32.tracing/main/main.c b/org.yakindu.sct.examples.esp32.tracing/main/main.c index c3c22b23..07f38f64 100644 --- a/org.yakindu.sct.examples.esp32.tracing/main/main.c +++ b/org.yakindu.sct.examples.esp32.tracing/main/main.c @@ -206,7 +206,7 @@ void app_main(int argc, char **argv) ESP_ERROR_CHECK(example_connect()); - printf("Hello YAKINDU Statechart Tools!\n"); + printf("Hello itemis CREATE!\n"); timestamp_offset = get_ms(); diff --git a/org.yakindu.sct.examples.esp32.tracing/metadata.json b/org.yakindu.sct.examples.esp32.tracing/metadata.json index a5a8b75f..7c0d3290 100644 --- a/org.yakindu.sct.examples.esp32.tracing/metadata.json +++ b/org.yakindu.sct.examples.esp32.tracing/metadata.json @@ -1,7 +1,7 @@ { "id": "org.yakindu.sct.examples.esp32.tracing", "title": "ESP32 - Tracing & Remote Control (C)", - "description": "YAKINDU provides infrastructure for debugging and remote controlling the state machines using execution traces (YET).", + "description": "itemis CREATE provides infrastructure for debugging and remote controlling the state machines using execution traces (YET).", "previewImage": "yet_target_trace_debugging.png", "author": "itemis AG", "license": "GNU Free Documentation License version 1.3", diff --git a/org.yakindu.sct.examples.fmu.bouncingball/index.html b/org.yakindu.sct.examples.fmu.bouncingball/index.html index 7aada980..adc8d0ed 100644 --- a/org.yakindu.sct.examples.fmu.bouncingball/index.html +++ b/org.yakindu.sct.examples.fmu.bouncingball/index.html @@ -15,8 +15,8 @@

FMU Code Generation

The Functional Mock-up Interface (FMI) standard addresses the exchange and joint execution of models for co-simulation. It mainly is applied for system level simulation of complex systems. - YAKINDU statecharts can be exported as *Functional Mock-up Units (FMUs)* and as such can participate in FMI based simulations. As FMUs provide binary executables and only bundle source code or models as an option FMUs can be - provided to other parties without exposing intellectual property. Concretely, YAKINDU Statechart Tools supports FMI 2.0 for Co-Simulation FMU export. By the support of the FMI standard YAKINDU statecharts are interoperable with + itemis CREATE statecharts can be exported as *Functional Mock-up Units (FMUs)* and as such can participate in FMI based simulations. As FMUs provide binary executables and only bundle source code or models as an option FMUs can be + provided to other parties without exposing intellectual property. Concretely, itemis CREATE supports FMI 2.0 for Co-Simulation FMU export. By the support of the FMI standard itemis CREATE statecharts are interoperable with a wide range of simulation tools.

diff --git a/org.yakindu.sct.examples.lightctrl.c.arduino/index.html b/org.yakindu.sct.examples.lightctrl.c.arduino/index.html index 42826732..a215e3bd 100644 --- a/org.yakindu.sct.examples.lightctrl.c.arduino/index.html +++ b/org.yakindu.sct.examples.lightctrl.c.arduino/index.html @@ -19,7 +19,7 @@

Basic Finite State Machine for Arduino

href="http://www.instructables.com/">instructables.com. You can read the article here. - It demonstrates how to get started with YAKINDU Statechart Tools and the + It demonstrates how to get started with itemis CREATE and the Arduino platform and contains a timer service for the Arduino. You need to have an Arduino plugin, as described in the example "Arduino traffic light" and in the linked article. diff --git a/org.yakindu.sct.examples.lightctrl.c.arduino/metadata.json b/org.yakindu.sct.examples.lightctrl.c.arduino/metadata.json index 634f3a9f..edeecc6e 100644 --- a/org.yakindu.sct.examples.lightctrl.c.arduino/metadata.json +++ b/org.yakindu.sct.examples.lightctrl.c.arduino/metadata.json @@ -2,8 +2,8 @@ "id": "org.yakindu.sct.examples.lightctrl.c.arduino", "title": "Arduino - Basic Finite State Machine (C)", "author": "itemis AG", - "description": "A very basic state machine example for the Arduino platform that switches an LED on and off. It demonstrates how to get started with YAKINDU Statechart Tools and the Arduino platform and contains a timer service for the Arduino. You need to have an Arduino plugin, as described in the \"Traffic Light Ported to Arduino\" example.", - "previewImage": "YAKINDU-Statecharts-Arduino_thumb.jpg", + "description": "A very basic state machine example for the Arduino platform that switches an LED on and off. It demonstrates how to get started with itemis CREATE and the Arduino platform and contains a timer service for the Arduino. You need to have an Arduino plugin, as described in the \"Traffic Light Ported to Arduino\" example.", + "previewImage": "itemis CREATE-Statecharts-Arduino_thumb.jpg", "category": [ "open source", "arduino", diff --git a/org.yakindu.sct.examples.msp430.blinky/index.html b/org.yakindu.sct.examples.msp430.blinky/index.html index 0721e3e5..03fe428f 100644 --- a/org.yakindu.sct.examples.msp430.blinky/index.html +++ b/org.yakindu.sct.examples.msp430.blinky/index.html @@ -15,14 +15,14 @@

Overview

This tutorial contains three parts: -

1. Installing the YAKINDU Statechart Tool as a Plugin into Texas +

1. Installing the itemis CREATE Statechart Tool as a Plugin into Texas Instruments Code Composer Studio

2. Adding state machines to the project

3. Creating the Blinky example with the Standard Edition

The whole tutorial gives you step-by-step instructions to enable you to upload the project.

-

Installing the YAKINDU Statechart Tool as a Plugin into Texas +

Installing the itemis CREATE Statechart Tool as a Plugin into Texas Instruments Code Composer Studio

First, you need to install TIs Code Composer Studio, which you can find here: @@ -49,7 +49,7 @@

Installing the YAKINDU Statechart Tool as a Plugin into Texas

- After this, you need to get the download site of YAKINDU Statechart Tools. + After this, you need to get the download site of itemis CREATE. Go to our download site and complete the free registration, in case you have not done this already. Then you will get a number of different @@ -60,7 +60,7 @@

Installing the YAKINDU Statechart Tool as a Plugin into Texas

Once again, go over to install new software. There you add the URL - you copied from our site. Choose YAKINDU Statechart Tools Standard Edition. You also can install + you copied from our site. Choose itemis CREATE Standard Edition. You also can install a Professional Edition, which includes a trial version for 30 days. You can still use the Standard Edition features after the trial version has expired. @@ -71,7 +71,7 @@

Installing the YAKINDU Statechart Tool as a Plugin into Texas instructions. After a successful installation CCS needs to be restarted. Afterwards the installation is finished.

-

Working with YAKINDU Statecharts Tool in CCS

+

Working with itemis CREATE Statecharts Tool in CCS

To use state machines proceed as normal and create a new CCS Project. Open the File tab, open New, click on Other and search for @@ -82,7 +82,7 @@

Working with YAKINDU Statecharts Tool in CCS

.

Now you can start working with state machines!

-

Working with YAKINDU Statecharts Tool Standard Edition

+

Working with itemis CREATE Statecharts Tool Standard Edition

Right click the project, open New and choose a Statechart Model. A Wizard will be opened in which you can select your project and name your @@ -122,7 +122,7 @@

Generate the C-Code

and click on Code Generator Model. Choose a name for the sgen file. It is good practice to stay with the state machine name. Call it "blinkyStateMachine.sgen" for example and click on Next. Choose the desired state machine by - clicking on the checkbox. Ensure that you have chosen the YAKINDU + clicking on the checkbox. Ensure that you have chosen the itemis CREATE SCT C Code Generator and click on Finish.

@@ -177,24 +177,24 @@

That’s it - Now you can build and upload the program to your

System and Version Information

The following tools were used in the creation of this tutorial:

System: Windows 10 -

YAKINDU Statechart Tool Version: 2.9.3 +

itemis CREATE Statechart Tool Version: 2.9.3

Code Composer Version: 7.0.0.00043

Note: The MSP430G2 Launchpad does not support Linux.

Support for Code Composer Studio Version 6

Code Composer Studio V6 is based Eclipse Mars (4.5.) and Java 7. - Installing and running YAKINDU Statechart Tools within CCSV6 requires two steps:

+ Installing and running itemis CREATE within CCSV6 requires two steps:

1st: Use the Mars update site instead of the Neon update site, which you can find here. As I mentioned before, you do not need to install anything of the Mars update site. Just add the update site. - After this you are able to install YAKINDU Statechart Tools within CCS V6 as described before. - You need to get the download site of YAKINDU Statechart Tools. + After this you are able to install itemis CREATE within CCS V6 as described before. + You need to get the download site of itemis CREATE. Go to our download site and complete the free registration, in case you have not done this already. Then you will get a number of different installation options. Choose the black button with install from update site.

-

2nd: YAKINDU Statechart Tools has been added, but it won't be executed, +

2nd: itemis CREATE has been added, but it won't be executed, because Java 8 is missing. Therefore, if you don't already have, install a 32 bit version of Java 8. Afterwards, right click your CCS V6 shortcut and add the path of the 32 bit Java 8. For my machine it looks like this:

diff --git a/org.yakindu.sct.examples.raspberry.helloworld/scutil/sc_cycle_runner.c b/org.yakindu.sct.examples.raspberry.helloworld/scutil/sc_cycle_runner.c index 04be88a8..4a6d8cc8 100644 --- a/org.yakindu.sct.examples.raspberry.helloworld/scutil/sc_cycle_runner.c +++ b/org.yakindu.sct.examples.raspberry.helloworld/scutil/sc_cycle_runner.c @@ -12,7 +12,7 @@ /*! - * POSIX thread that periodically runs the SCT's internal 'run to completion'. + * POSIX thread that periodically runs the 's internal 'run to completion'. * (State machine evaluates rising events and computes possible state changes) */ static void *sc_cycle_runner_thread(void *arg) { diff --git a/org.yakindu.sct.examples.raspberry.helloworld/scutil/sc_cycle_runner.h b/org.yakindu.sct.examples.raspberry.helloworld/scutil/sc_cycle_runner.h index e696f4ee..65c81e12 100644 --- a/org.yakindu.sct.examples.raspberry.helloworld/scutil/sc_cycle_runner.h +++ b/org.yakindu.sct.examples.raspberry.helloworld/scutil/sc_cycle_runner.h @@ -14,7 +14,7 @@ extern "C" { #endif -/*! \file Defines the cycle runner interface for YAKINDU state machines. +/*! \file Defines the cycle runner interface for itemis CREATE state machines. * A cycle runner performs a cyclic execution of the state machines runCycle function * with a fixed time interval. The implementation is based on POSIX threads and makes * use of a mutex for thread synchronization. diff --git a/org.yakindu.sct.examples.sctunit.java/src-gen/com/yakindu/core/IStatemachine.java b/org.yakindu.sct.examples.sctunit.java/src-gen/com/yakindu/core/IStatemachine.java index 01a10450..1dfbdba2 100644 --- a/org.yakindu.sct.examples.sctunit.java/src-gen/com/yakindu/core/IStatemachine.java +++ b/org.yakindu.sct.examples.sctunit.java/src-gen/com/yakindu/core/IStatemachine.java @@ -1,4 +1,4 @@ -/** Generated by YAKINDU Statechart Tools code generator. */ +/** Generated by itemis CREATE code generator. */ package com.yakindu.core; /** diff --git a/org.yakindu.sct.examples.sctunit.java/src-gen/com/yakindu/core/ITimed.java b/org.yakindu.sct.examples.sctunit.java/src-gen/com/yakindu/core/ITimed.java index c64e8f7f..2ac855d0 100644 --- a/org.yakindu.sct.examples.sctunit.java/src-gen/com/yakindu/core/ITimed.java +++ b/org.yakindu.sct.examples.sctunit.java/src-gen/com/yakindu/core/ITimed.java @@ -1,4 +1,4 @@ -/** Generated by YAKINDU Statechart Tools code generator. */ +/** Generated by itemis CREATE code generator. */ package com.yakindu.core; /** diff --git a/org.yakindu.sct.examples.sctunit.java/src-gen/com/yakindu/core/ITimerService.java b/org.yakindu.sct.examples.sctunit.java/src-gen/com/yakindu/core/ITimerService.java index acfd55ab..df9480dc 100644 --- a/org.yakindu.sct.examples.sctunit.java/src-gen/com/yakindu/core/ITimerService.java +++ b/org.yakindu.sct.examples.sctunit.java/src-gen/com/yakindu/core/ITimerService.java @@ -1,4 +1,4 @@ -/** Generated by YAKINDU Statechart Tools code generator. */ +/** Generated by itemis CREATE code generator. */ package com.yakindu.core; /** diff --git a/org.yakindu.sct.examples.sctunit.java/src-gen/com/yakindu/core/VirtualTimer.java b/org.yakindu.sct.examples.sctunit.java/src-gen/com/yakindu/core/VirtualTimer.java index 9e6a4821..05240e4c 100644 --- a/org.yakindu.sct.examples.sctunit.java/src-gen/com/yakindu/core/VirtualTimer.java +++ b/org.yakindu.sct.examples.sctunit.java/src-gen/com/yakindu/core/VirtualTimer.java @@ -1,4 +1,4 @@ -/** Generated by YAKINDU Statechart Tools code generator. */ +/** Generated by itemis CREATE code generator. */ package com.yakindu.core; import java.util.PriorityQueue; diff --git a/org.yakindu.sct.examples.sctunit.java/src-gen/light/tests/LightSwitchTest.java b/org.yakindu.sct.examples.sctunit.java/src-gen/light/tests/LightSwitchTest.java index 02d1f25e..2605a044 100644 --- a/org.yakindu.sct.examples.sctunit.java/src-gen/light/tests/LightSwitchTest.java +++ b/org.yakindu.sct.examples.sctunit.java/src-gen/light/tests/LightSwitchTest.java @@ -1,4 +1,4 @@ -/** Generated by YAKINDU Statechart Tools code generator. */ +/** Generated by itemis CREATE code generator. */ package light.tests; diff --git a/org.yakindu.sct.examples.sctunit/index.html b/org.yakindu.sct.examples.sctunit/index.html index 846cd30a..46c49d51 100644 --- a/org.yakindu.sct.examples.sctunit/index.html +++ b/org.yakindu.sct.examples.sctunit/index.html @@ -65,7 +65,7 @@

Test implementation

Coverage

- YAKINDU Statechart Tools supports another feature to improve the testing quality: Coverage. Each time a test is executed, a coverage analysis is started. The coverage score indicates how many of the state machine paths have been tested. + itemis CREATE supports another feature to improve the testing quality: Coverage. Each time a test is executed, a coverage analysis is started. The coverage score indicates how many of the state machine paths have been tested.

Let's take the LightSwitchTest and remove every test except for the very first one - testInitiallyTurnedOff. Executing the test will also run a coverage analysis, as mentioned before. The result of the coverage analysis is displayed in the coverage view: diff --git a/org.yakindu.sct.examples.tictoc.tracing/index.html b/org.yakindu.sct.examples.tictoc.tracing/index.html index 525d4d86..6bec02f5 100644 --- a/org.yakindu.sct.examples.tictoc.tracing/index.html +++ b/org.yakindu.sct.examples.tictoc.tracing/index.html @@ -11,8 +11,8 @@

Debug and remote control state machines using YET

- The YAKINDU Execution Trace (YET) infrastructure supports interoperability between - state machines running in a target application and the YAKINDU tooling. + The itemis CREATE Execution Trace (YET) infrastructure supports interoperability between + state machines running in a target application and the itemis CREATE tooling. It supports model-level debugging and testing of the state machines based on execution traces. This example shows how to remote debug a compiled state machine step by step. Please refer to the YET documentation for more information. diff --git a/org.yakindu.sct.examples.tictoc.tracing/metadata.json b/org.yakindu.sct.examples.tictoc.tracing/metadata.json index 3bbd374c..cb52d826 100644 --- a/org.yakindu.sct.examples.tictoc.tracing/metadata.json +++ b/org.yakindu.sct.examples.tictoc.tracing/metadata.json @@ -1,7 +1,7 @@ { "id": "org.yakindu.sct.examples.tictoc.tracing", "title": "TicToc - Tracing & Remote Control (C)", - "description": "YAKINDU provides infrastructure for debugging and remote controlling the state machines using execution traces (YET).", + "description": "itemis CREATE provides infrastructure for debugging and remote controlling the state machines using execution traces (YET).", "previewImage": "yet_target_trace_debugging.png", "author": "itemis AG", "license": "GNU Free Documentation License version 1.3", diff --git a/org.yakindu.sct.examples.trafficlight.c.arduino/metadata.json b/org.yakindu.sct.examples.trafficlight.c.arduino/metadata.json index 2ec873d0..f955d523 100644 --- a/org.yakindu.sct.examples.trafficlight.c.arduino/metadata.json +++ b/org.yakindu.sct.examples.trafficlight.c.arduino/metadata.json @@ -3,7 +3,7 @@ "title": "Arduino - Traffic Light (C)", "author": "itemis AG", "description": "Wondering how to execute your state machine on the Arduino platform? This example demonstrates the necessary steps, like installing the Arduino plugin, building the hardware, turning your statechart into code and uploading it to the Arduino. It does so by means of the standard traffic light example.", - "previewImage": "YAKINDU-Statecharts-Arduino_thumb.jpg", + "previewImage": "itemis CREATE-Statecharts-Arduino_thumb.jpg", "category": [ "open source", "embedded" diff --git a/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/TrafficLightStateMachine.cpp b/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/TrafficLightStateMachine.cpp index 46a7b25c..4fcbcd44 100644 --- a/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/TrafficLightStateMachine.cpp +++ b/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/TrafficLightStateMachine.cpp @@ -1,4 +1,4 @@ -/** Generated by YAKINDU Statechart Tools code generator. */ +/** Generated by itemis CREATE code generator. */ #include "TrafficLightStateMachine.h" diff --git a/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/TrafficLightStateMachine.h b/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/TrafficLightStateMachine.h index 22ef2c79..00748151 100644 --- a/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/TrafficLightStateMachine.h +++ b/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/TrafficLightStateMachine.h @@ -1,4 +1,4 @@ -/** Generated by YAKINDU Statechart Tools code generator. */ +/** Generated by itemis CREATE code generator. */ #ifndef TRAFFICLIGHTSTATEMACHINE_H_ #define TRAFFICLIGHTSTATEMACHINE_H_ diff --git a/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_qt_timerservice.cpp b/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_qt_timerservice.cpp index 327b30bf..a1d34fea 100644 --- a/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_qt_timerservice.cpp +++ b/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_qt_timerservice.cpp @@ -1,4 +1,4 @@ -/** Generated by YAKINDU Statechart Tools code generator. */ +/** Generated by itemis CREATE code generator. */ #include "sc_qt_timerservice.h" diff --git a/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_qt_timerservice.h b/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_qt_timerservice.h index 5e628a35..07686ee1 100644 --- a/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_qt_timerservice.h +++ b/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_qt_timerservice.h @@ -1,4 +1,4 @@ -/** Generated by YAKINDU Statechart Tools code generator. */ +/** Generated by itemis CREATE code generator. */ #ifndef SC_QT_TIMERSERVICE_H_ #define SC_QT_TIMERSERVICE_H_ diff --git a/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_rxcpp.h b/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_rxcpp.h index 4eda6b49..cb9e5017 100644 --- a/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_rxcpp.h +++ b/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_rxcpp.h @@ -1,4 +1,4 @@ -/** Generated by YAKINDU Statechart Tools code generator. */ +/** Generated by itemis CREATE code generator. */ #ifndef SC_RXCPP_H_ #define SC_RXCPP_H_ diff --git a/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_statemachine.h b/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_statemachine.h index a53e7d3c..181d8888 100644 --- a/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_statemachine.h +++ b/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_statemachine.h @@ -1,4 +1,4 @@ -/** Generated by YAKINDU Statechart Tools code generator. */ +/** Generated by itemis CREATE code generator. */ #ifndef SC_STATEMACHINE_H_ #define SC_STATEMACHINE_H_ diff --git a/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_timer.h b/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_timer.h index 4ec3efa2..2424f54f 100644 --- a/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_timer.h +++ b/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_timer.h @@ -1,4 +1,4 @@ -/** Generated by YAKINDU Statechart Tools code generator. */ +/** Generated by itemis CREATE code generator. */ #ifndef SC_TIMER_H_ #define SC_TIMER_H_ diff --git a/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_types.h b/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_types.h index 1129f917..0d4fd5af 100644 --- a/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_types.h +++ b/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/machine/sc_types.h @@ -1,4 +1,4 @@ -/** Generated by YAKINDU Statechart Tools code generator. */ +/** Generated by itemis CREATE code generator. */ #ifndef SC_TYPES_H_ #define SC_TYPES_H_ diff --git a/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/main.qml b/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/main.qml index 9c8aa615..2df3b4ea 100644 --- a/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/main.qml +++ b/org.yakindu.sct.examples.trafficlight.cpp.qt/implementation/main.qml @@ -5,7 +5,7 @@ Window { visible: true width: 400 height: 400 - title: qsTr("YAKINDU Qt/C++ Traffic Light State Machine") + title: qsTr("itemis CREATE Qt/C++ Traffic Light State Machine") Image { id: trafficLight diff --git a/org.yakindu.sct.examples.trafficlight.cpp.qt/index.html b/org.yakindu.sct.examples.trafficlight.cpp.qt/index.html index 8da038a6..d06b6bd5 100644 --- a/org.yakindu.sct.examples.trafficlight.cpp.qt/index.html +++ b/org.yakindu.sct.examples.trafficlight.cpp.qt/index.html @@ -10,8 +10,8 @@

Qt/C++ State Machine of a Traffic Light

- YAKINDU provides a Qt specific C++ code generator for statecharts. - This example project shows how easy YAKINDU Qt/C++ state machines can be integrated + itemis CREATE provides a Qt specific C++ code generator for statecharts. + This example project shows how easy itemis CREATE Qt/C++ state machines can be integrated into Qt applications.

@@ -81,16 +81,16 @@

Generating state machine code

Feel free to play around with the the traffic light and its statechart. When you modify the statechart the code generator will automatically run and regenerate the sources that you can find in the implementation/machine folder. - Also the synchronization between YAKINDU and Qt-Creator works painless. + Also the synchronization between itemis CREATE and Qt-Creator works painless. After generating the code, Qt-Creator may ask you to synchronize the new versions of the implementation files. Simply confirm and rebuild the project - that's it.

Installing the Qt/C++ code generator

- If code generation does not work and YAKINDU shows error markers on the + If code generation does not work and itemis CREATE shows error markers on the model/TrafficLightStateMachine.sgen file then you likely have to install the - YAKINDU Qt/C++ code generator. + itemis CREATE Qt/C++ code generator.

  1. Open Help > Install New Software ... from the menu.
  2. diff --git a/org.yakindu.sct.examples.trafficlight.cpp.qt/metadata.json b/org.yakindu.sct.examples.trafficlight.cpp.qt/metadata.json index 8f4eb81f..03c41f54 100644 --- a/org.yakindu.sct.examples.trafficlight.cpp.qt/metadata.json +++ b/org.yakindu.sct.examples.trafficlight.cpp.qt/metadata.json @@ -1,7 +1,7 @@ { "id": "org.yakindu.sct.examples.trafficlight.cpp.qt", "title": "Traffic Light (Qt/C++)", - "description": "YAKINDU provides a Qt specific C++ code generator for statecharts. This example project shows how easy YAKINDU Qt/C++ state machines can be integrated into Qt applications.", + "description": "itemis CREATE provides a Qt specific C++ code generator for statecharts. This example project shows how easy itemis CREATE Qt/C++ state machines can be integrated into Qt applications.", "previewImage": "traffic_light.jpg", "author": "itemis AG", "license": "GNU Free Documentation License version 1.3", diff --git a/org.yakindu.sct.examples.trafficlight.java/metadata.json b/org.yakindu.sct.examples.trafficlight.java/metadata.json index c9422ab6..be2473e4 100644 --- a/org.yakindu.sct.examples.trafficlight.java/metadata.json +++ b/org.yakindu.sct.examples.trafficlight.java/metadata.json @@ -2,7 +2,7 @@ "id": "org.yakindu.sct.examples.trafficlight.java", "title": "Traffic Light (Java)", "author": "itemis AG", - "description": "Demonstrates how to to generate Java source code from a statechart. The procedure is actually explained in the YAKINDU Statechart Tools documentation, section \"Java code generator\".", + "description": "Demonstrates how to to generate Java source code from a statechart. The procedure is actually explained in the itemis CREATE documentation, section \"Java code generator\".", "previewImage": "traffic_light_thumb.jpg", "category": [ "open source", diff --git a/org.yakindu.sct.examples.trafficlight.java/src/traffic/light/ui/ButtonPanel.java b/org.yakindu.sct.examples.trafficlight.java/src/traffic/light/ui/ButtonPanel.java index 494f655a..3954ba00 100644 --- a/org.yakindu.sct.examples.trafficlight.java/src/traffic/light/ui/ButtonPanel.java +++ b/org.yakindu.sct.examples.trafficlight.java/src/traffic/light/ui/ButtonPanel.java @@ -1,11 +1,11 @@ /** - * Copyright (c) 2016 committers of YAKINDU and others. + * Copyright (c) 2016 committers of itemis CREATE and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * Contributors: - * committers of YAKINDU - initial API and implementation + * committers of itemis CREATE - initial API and implementation * */ package traffic.light.ui; diff --git a/org.yakindu.sct.examples.trafficlight.java/src/traffic/light/ui/Counter.java b/org.yakindu.sct.examples.trafficlight.java/src/traffic/light/ui/Counter.java index 8c1bedd7..0ec9c34e 100644 --- a/org.yakindu.sct.examples.trafficlight.java/src/traffic/light/ui/Counter.java +++ b/org.yakindu.sct.examples.trafficlight.java/src/traffic/light/ui/Counter.java @@ -1,11 +1,11 @@ /** - * Copyright (c) 2016 committers of YAKINDU and others. + * Copyright (c) 2016 committers of itemis CREATE and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * Contributors: - * committers of YAKINDU - initial API and implementation + * committers of itemis CREATE - initial API and implementation * */ package traffic.light.ui; diff --git a/org.yakindu.sct.examples.trafficlight.java/src/traffic/light/ui/TrafficLight.java b/org.yakindu.sct.examples.trafficlight.java/src/traffic/light/ui/TrafficLight.java index 305b85cd..7573df76 100644 --- a/org.yakindu.sct.examples.trafficlight.java/src/traffic/light/ui/TrafficLight.java +++ b/org.yakindu.sct.examples.trafficlight.java/src/traffic/light/ui/TrafficLight.java @@ -1,11 +1,11 @@ /** - * Copyright (c) 2016 committers of YAKINDU and others. + * Copyright (c) 2016 committers of itemis CREATE and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * Contributors: - * committers of YAKINDU - initial API and implementation + * committers of itemis CREATE - initial API and implementation * */ package traffic.light.ui; diff --git a/org.yakindu.sct.examples.trafficlight.python/.vscode/settings.json b/org.yakindu.sct.examples.trafficlight.python/.vscode/settings.json new file mode 100644 index 00000000..155422b0 --- /dev/null +++ b/org.yakindu.sct.examples.trafficlight.python/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5503 +} \ No newline at end of file diff --git a/org.yakindu.sct.examples.trafficlight.python/assets/bundle.js b/org.yakindu.sct.examples.trafficlight.python/assets/bundle.js new file mode 100644 index 00000000..c14f8a67 --- /dev/null +++ b/org.yakindu.sct.examples.trafficlight.python/assets/bundle.js @@ -0,0 +1,1271 @@ +var com; +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Instances represent state machine trace events. + * @param {com.yakindu.core.TraceEventType} type + * @param {*} machine + * @param {*} state + * @param {*} feature + * @param {*} value + * @class + */ + class TraceEvent { + constructor(type, machine, state, feature, value) { + if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && ((state != null) || state === null) && ((feature != null) || feature === null) && ((value != null) || value === null)) { + let __args = arguments; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + else if (((typeof type === 'number') || type === null) && ((machine != null) || machine === null) && state === undefined && feature === undefined && value === undefined) { + let __args = arguments; + { + let __args = arguments; + let state = null; + let feature = null; + let value = null; + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + this.type = type; + this.machine = machine; + this.state = state; + this.feature = feature; + this.value = value; + } + if (this.type === undefined) { + this.type = null; + } + if (this.machine === undefined) { + this.machine = null; + } + if (this.state === undefined) { + this.state = null; + } + if (this.feature === undefined) { + this.feature = null; + } + if (this.value === undefined) { + this.value = null; + } + } + else + throw new Error('invalid overload'); + } + getType() { + return this.type; + } + getMachine() { + return this.machine; + } + getState() { + return this.state; + } + getFeature() { + return this.feature; + } + getValue() { + return this.value; + } + } + core.TraceEvent = TraceEvent; + TraceEvent["__class"] = "com.yakindu.core.TraceEvent"; + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + /** + * Trace event type enumeration. + * @enum + * @property {com.yakindu.core.TraceEventType} MACHINE_ENTER + * @property {com.yakindu.core.TraceEventType} MACHINE_EXIT + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_START + * @property {com.yakindu.core.TraceEventType} MACHINE_RTS_STOP + * @property {com.yakindu.core.TraceEventType} STATE_ENTERED + * @property {com.yakindu.core.TraceEventType} STATE_EXITED + * @property {com.yakindu.core.TraceEventType} STATE_TRANSITION + * @property {com.yakindu.core.TraceEventType} EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} VARIABLE_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_RAISED + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_SET + * @property {com.yakindu.core.TraceEventType} TIME_EVENT_UNSET + * @class + */ + let TraceEventType; + (function (TraceEventType) { + TraceEventType[TraceEventType["MACHINE_ENTER"] = 0] = "MACHINE_ENTER"; + TraceEventType[TraceEventType["MACHINE_EXIT"] = 1] = "MACHINE_EXIT"; + TraceEventType[TraceEventType["MACHINE_RTS_START"] = 2] = "MACHINE_RTS_START"; + TraceEventType[TraceEventType["MACHINE_RTS_STOP"] = 3] = "MACHINE_RTS_STOP"; + TraceEventType[TraceEventType["STATE_ENTERED"] = 4] = "STATE_ENTERED"; + TraceEventType[TraceEventType["STATE_EXITED"] = 5] = "STATE_EXITED"; + TraceEventType[TraceEventType["STATE_TRANSITION"] = 6] = "STATE_TRANSITION"; + TraceEventType[TraceEventType["EVENT_RAISED"] = 7] = "EVENT_RAISED"; + TraceEventType[TraceEventType["VARIABLE_SET"] = 8] = "VARIABLE_SET"; + TraceEventType[TraceEventType["TIME_EVENT_RAISED"] = 9] = "TIME_EVENT_RAISED"; + TraceEventType[TraceEventType["TIME_EVENT_SET"] = 10] = "TIME_EVENT_SET"; + TraceEventType[TraceEventType["TIME_EVENT_UNSET"] = 11] = "TIME_EVENT_UNSET"; + })(TraceEventType = core.TraceEventType || (core.TraceEventType = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +(function (com) { + var yakindu; + (function (yakindu) { + var core; + (function (core) { + var rx; + (function (rx) { + class Observable { + constructor() { + this.observers = ([]); + } + next(value) { + for (let index = 0; index < this.observers.length; index++) { + let observer = this.observers[index]; + { + observer.next(value); + } + } + } + subscribe(observer) { + return observer != null ? /* add */ (this.observers.push(observer) > 0) : false; + } + unsubscribe(observer) { + return observer != null ? /* remove */ (a => { let index = a.indexOf(observer); if (index >= 0) { + a.splice(index, 1); + return true; + } + else { + return false; + } })(this.observers) : false; + } + } + rx.Observable = Observable; + Observable["__class"] = "com.yakindu.core.rx.Observable"; + })(rx = core.rx || (core.rx = {})); + })(core = yakindu.core || (yakindu.core = {})); + })(yakindu = com.yakindu || (com.yakindu = {})); +})(com || (com = {})); +var sct; +(function (sct) { + var yakindu; + (function (yakindu) { + var io; + (function (io) { + class Statemachine { + constructor() { + if (this.__trafficLight === undefined) { + this.__trafficLight = null; + } + if (this.__pedestrian === undefined) { + this.__pedestrian = null; + } + this.stateVector = [null]; + this.trace = (new com.yakindu.core.rx.Observable()); + if (this.timerService === undefined) { + this.timerService = null; + } + this.timeEvents = (s => { let a = []; while (s-- > 0) + a.push(false); return a; })(12); + this.inEventQueue = ([]); + if (this.isExecuting === undefined) { + this.isExecuting = false; + } + if (this.operationCallback === undefined) { + this.operationCallback = null; + } + if (this.pedestrianRequest === undefined) { + this.pedestrianRequest = false; + } + if (this.onOff === undefined) { + this.onOff = false; + } + this.__trafficLight = new Statemachine.TrafficLight(this); + this.__pedestrian = new Statemachine.Pedestrian(this); + for (let i = 0; i < 1; i++) { + { + this.stateVector[i] = Statemachine.State.$NULLSTATE$; + } + ; + } + this.clearInEvents(); + this.__trafficLight.setRed(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.TRAFFICLIGHT_RED, this.__trafficLight.red))); + this.__trafficLight.setYellow(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.TRAFFICLIGHT_YELLOW, this.__trafficLight.yellow))); + this.__trafficLight.setGreen(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.TRAFFICLIGHT_GREEN, this.__trafficLight.green))); + this.__pedestrian.setRequest(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.PEDESTRIAN_REQUEST, this.__pedestrian.request))); + this.__pedestrian.setRed(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.PEDESTRIAN_RED, this.__pedestrian.red))); + this.__pedestrian.setGreen(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.PEDESTRIAN_GREEN, this.__pedestrian.green))); + this.isExecuting = false; + } + getIsExecuting() { + return this.isExecuting; + } + setIsExecuting(value) { + this.isExecuting = value; + } + enter() { + if (this.timerService == null) { + throw Object.defineProperty(new Error("Timer service must be set."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.IllegalStateException', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.Exception'] }); + } + if (this.operationCallback == null) { + throw Object.defineProperty(new Error("Operation callback must be set."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.IllegalStateException', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.Exception'] }); + } + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_ENTER, this))); + this.timerService.setTimer(this, 11, 200, true); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_SET, this, null, null, 11))); + this.enterSequence_main_region_default(); + this.isExecuting = false; + } + exit() { + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_EXIT, this))); + this.exitSequence_main_region(); + this.timerService.unsetTimer(this, 11); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_UNSET, this, null, null, 11))); + this.isExecuting = false; + } + /** + * @see IStatemachine#isActive() + * @return {boolean} + */ + isActive() { + return this.stateVector[0] !== Statemachine.State.$NULLSTATE$; + } + /** + * + * Always returns 'false' since this state machine can never become final. + * + * @see IStatemachine#isFinal() + * @return {boolean} + */ + isFinal() { + return false; + } + clearInEvents() { + this.pedestrianRequest = false; + this.onOff = false; + this.timeEvents[0] = false; + this.timeEvents[1] = false; + this.timeEvents[2] = false; + this.timeEvents[3] = false; + this.timeEvents[4] = false; + this.timeEvents[5] = false; + this.timeEvents[6] = false; + this.timeEvents[7] = false; + this.timeEvents[8] = false; + this.timeEvents[9] = false; + this.timeEvents[10] = false; + this.timeEvents[11] = false; + } + microStep() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING_R1_WAITON: + this.main_region_on_r1_PedWaiting_r1_waitOn_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING_R1_WAITOFF: + this.main_region_on_r1_PedWaiting_r1_waitOff_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_STREETATTENTION: + this.main_region_on_r1_StreetAttention_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_STREETRED: + this.main_region_on_r1_StreetRed_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_PEDESTRIANGREEN: + this.main_region_on_r1_PedestrianGreen_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_PEDESTRIANRED: + this.main_region_on_r1_PedestrianRed_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_STREETPREPARE: + this.main_region_on_r1_StreetPrepare_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_SAFE: + this.main_region_on_r1_Safe_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_STREETGREEN: + this.main_region_on_r1_StreetGreen_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_OFF_R1_YELLOWON: + this.main_region_off_r1_YellowOn_react(-1); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_OFF_R1_YELLOWOFF: + this.main_region_off_r1_YellowOff_react(-1); + break; + default: + break; + } + } + runCycle() { + if (this.timerService == null) { + throw Object.defineProperty(new Error("Timer service must be set."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.IllegalStateException', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.Exception'] }); + } + if (this.operationCallback == null) { + throw Object.defineProperty(new Error("Operation callback must be set."), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.IllegalStateException', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.Exception'] }); + } + if (this.getIsExecuting()) { + return; + } + this.isExecuting = true; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_START, this))); + this.nextEvent(); + do { + { + this.microStep(); + this.clearInEvents(); + this.nextEvent(); + } + } while (((((((((((((((this.pedestrianRequest || this.onOff) || this.timeEvents[0]) || this.timeEvents[1]) || this.timeEvents[2]) || this.timeEvents[3]) || this.timeEvents[4]) || this.timeEvents[5]) || this.timeEvents[6]) || this.timeEvents[7]) || this.timeEvents[8]) || this.timeEvents[9]) || this.timeEvents[10]) || this.timeEvents[11]))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.MACHINE_RTS_STOP, this))); + this.isExecuting = false; + } + nextEvent() { + if (!(this.inEventQueue.length == 0)) { + (target => (typeof target === 'function') ? target() : target.run())(/* poll */ (a => a.length == 0 ? null : a.shift())(this.inEventQueue)); + return; + } + } + /** + * Returns true if the given state is currently active otherwise false. + * @param {sct.yakindu.io.Statemachine.State} state + * @return {boolean} + */ + isStateActive(state) { + switch ((state)) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_ON]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_ON_R1_STREETGREEN]]; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING_R1_WAITOFF]]; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING_R1_WAITON: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING_R1_WAITON; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING_R1_WAITOFF: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING_R1_WAITOFF; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_STREETATTENTION: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_ON_R1_STREETATTENTION; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_STREETRED: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_ON_R1_STREETRED; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_PEDESTRIANGREEN: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_ON_R1_PEDESTRIANGREEN; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_PEDESTRIANRED: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_ON_R1_PEDESTRIANRED; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_STREETPREPARE: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_ON_R1_STREETPREPARE; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_SAFE: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_ON_R1_SAFE; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_STREETGREEN: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_ON_R1_STREETGREEN; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_OFF: + return /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] >= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_OFF]] && /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[this.stateVector[0]]] <= /* Enum.ordinal */ sct.yakindu.io.Statemachine.State[sct.yakindu.io.Statemachine.State[Statemachine.State.MAIN_REGION_OFF_R1_YELLOWOFF]]; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_OFF_R1_YELLOWON: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_OFF_R1_YELLOWON; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_OFF_R1_YELLOWOFF: + return this.stateVector[0] === Statemachine.State.MAIN_REGION_OFF_R1_YELLOWOFF; + default: + return false; + } + } + setTimerService(timerService) { + this.timerService = timerService; + } + getTimerService() { + return this.timerService; + } + raiseTimeEvent(eventID) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_RAISED, this, null, null, eventID))); + /* add */ (this.inEventQueue.push(() => { + this.timeEvents[eventID] = true; + }) > 0); + this.runCycle(); + } + trafficLight() { + return this.__trafficLight; + } + pedestrian() { + return this.__pedestrian; + } + getTrace() { + return this.trace; + } + setOperationCallback(operationCallback) { + this.operationCallback = operationCallback; + } + raisePedestrianRequest() { + /* add */ (this.inEventQueue.push(() => { + this.pedestrianRequest = true; + }) > 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this, null, Statemachine.Feature.PEDESTRIANREQUEST, null))); + this.runCycle(); + } + raiseOnOff() { + /* add */ (this.inEventQueue.push(() => { + this.onOff = true; + }) > 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.EVENT_RAISED, this, null, Statemachine.Feature.ONOFF, null))); + this.runCycle(); + } + entryAction_main_region_on_r1_PedWaiting() { + this.timerService.setTimer(this, 0, (7 * 1000), false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_SET, this, null, null, 0))); + } + entryAction_main_region_on_r1_PedWaiting_r1_waitOn() { + this.timerService.setTimer(this, 1, 500, false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_SET, this, null, null, 1))); + this.__pedestrian.setRequest(true); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.PEDESTRIAN_REQUEST, this.__pedestrian.request))); + } + entryAction_main_region_on_r1_PedWaiting_r1_waitOff() { + this.timerService.setTimer(this, 2, 500, false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_SET, this, null, null, 2))); + this.__pedestrian.setRequest(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.PEDESTRIAN_REQUEST, this.__pedestrian.request))); + } + entryAction_main_region_on_r1_StreetAttention() { + this.timerService.setTimer(this, 3, (2 * 1000), false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_SET, this, null, null, 3))); + this.__trafficLight.setRed(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.TRAFFICLIGHT_RED, this.__trafficLight.red))); + this.__trafficLight.setYellow(true); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.TRAFFICLIGHT_YELLOW, this.__trafficLight.yellow))); + this.__trafficLight.setGreen(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.TRAFFICLIGHT_GREEN, this.__trafficLight.green))); + } + entryAction_main_region_on_r1_StreetRed() { + this.timerService.setTimer(this, 4, (2 * 1000), false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_SET, this, null, null, 4))); + this.__trafficLight.setRed(true); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.TRAFFICLIGHT_RED, this.__trafficLight.red))); + this.__trafficLight.setYellow(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.TRAFFICLIGHT_YELLOW, this.__trafficLight.yellow))); + this.__trafficLight.setGreen(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.TRAFFICLIGHT_GREEN, this.__trafficLight.green))); + } + entryAction_main_region_on_r1_PedestrianGreen() { + this.timerService.setTimer(this, 5, (7 * 1000), false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_SET, this, null, null, 5))); + this.__pedestrian.setRed(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.PEDESTRIAN_RED, this.__pedestrian.red))); + this.__pedestrian.setGreen(true); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.PEDESTRIAN_GREEN, this.__pedestrian.green))); + } + entryAction_main_region_on_r1_PedestrianRed() { + this.timerService.setTimer(this, 6, (5 * 1000), false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_SET, this, null, null, 6))); + this.__pedestrian.setRed(true); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.PEDESTRIAN_RED, this.__pedestrian.red))); + this.__pedestrian.setGreen(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.PEDESTRIAN_GREEN, this.__pedestrian.green))); + } + entryAction_main_region_on_r1_StreetPrepare() { + this.timerService.setTimer(this, 7, (2 * 1000), false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_SET, this, null, null, 7))); + this.__trafficLight.setRed(true); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.TRAFFICLIGHT_RED, this.__trafficLight.red))); + this.__trafficLight.setYellow(true); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.TRAFFICLIGHT_YELLOW, this.__trafficLight.yellow))); + this.__trafficLight.setGreen(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.TRAFFICLIGHT_GREEN, this.__trafficLight.green))); + } + entryAction_main_region_on_r1_Safe() { + this.timerService.setTimer(this, 8, (10 * 1000), false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_SET, this, null, null, 8))); + this.__trafficLight.setRed(true); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.TRAFFICLIGHT_RED, this.__trafficLight.red))); + this.__trafficLight.setYellow(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.TRAFFICLIGHT_YELLOW, this.__trafficLight.yellow))); + this.__trafficLight.setGreen(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.TRAFFICLIGHT_GREEN, this.__trafficLight.green))); + this.__pedestrian.setRed(true); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.PEDESTRIAN_RED, this.__pedestrian.red))); + this.__pedestrian.setGreen(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.PEDESTRIAN_GREEN, this.__pedestrian.green))); + this.__pedestrian.setRequest(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.PEDESTRIAN_REQUEST, this.__pedestrian.request))); + } + entryAction_main_region_on_r1_StreetGreen() { + this.__trafficLight.setRed(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.TRAFFICLIGHT_RED, this.__trafficLight.red))); + this.__trafficLight.setYellow(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.TRAFFICLIGHT_YELLOW, this.__trafficLight.yellow))); + this.__trafficLight.setGreen(true); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.TRAFFICLIGHT_GREEN, this.__trafficLight.green))); + this.__pedestrian.setRed(true); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.PEDESTRIAN_RED, this.__pedestrian.red))); + this.__pedestrian.setGreen(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.PEDESTRIAN_GREEN, this.__pedestrian.green))); + this.__pedestrian.setRequest(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.PEDESTRIAN_REQUEST, this.__pedestrian.request))); + } + entryAction_main_region_off() { + this.__trafficLight.setRed(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.TRAFFICLIGHT_RED, this.__trafficLight.red))); + this.__trafficLight.setGreen(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.TRAFFICLIGHT_GREEN, this.__trafficLight.green))); + this.__trafficLight.setYellow(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.TRAFFICLIGHT_YELLOW, this.__trafficLight.yellow))); + this.__pedestrian.setRed(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.PEDESTRIAN_RED, this.__pedestrian.red))); + this.__pedestrian.setGreen(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.PEDESTRIAN_GREEN, this.__pedestrian.green))); + } + entryAction_main_region_off_r1_YellowOn() { + this.timerService.setTimer(this, 9, 500, false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_SET, this, null, null, 9))); + this.__trafficLight.setYellow(true); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.TRAFFICLIGHT_YELLOW, this.__trafficLight.yellow))); + this.__pedestrian.setRequest(true); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.PEDESTRIAN_REQUEST, this.__pedestrian.request))); + } + entryAction_main_region_off_r1_YellowOff() { + this.timerService.setTimer(this, 10, 500, false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_SET, this, null, null, 10))); + this.__trafficLight.setYellow(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.TRAFFICLIGHT_YELLOW, this.__trafficLight.yellow))); + this.__pedestrian.setRequest(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.PEDESTRIAN_REQUEST, this.__pedestrian.request))); + } + exitAction_main_region_on_r1_PedWaiting() { + this.timerService.unsetTimer(this, 0); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_UNSET, this, null, null, 0))); + this.__pedestrian.setRequest(false); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this, null, Statemachine.Feature.PEDESTRIAN_REQUEST, this.__pedestrian.request))); + } + exitAction_main_region_on_r1_PedWaiting_r1_waitOn() { + this.timerService.unsetTimer(this, 1); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_UNSET, this, null, null, 1))); + } + exitAction_main_region_on_r1_PedWaiting_r1_waitOff() { + this.timerService.unsetTimer(this, 2); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_UNSET, this, null, null, 2))); + } + exitAction_main_region_on_r1_StreetAttention() { + this.timerService.unsetTimer(this, 3); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_UNSET, this, null, null, 3))); + } + exitAction_main_region_on_r1_StreetRed() { + this.timerService.unsetTimer(this, 4); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_UNSET, this, null, null, 4))); + } + exitAction_main_region_on_r1_PedestrianGreen() { + this.timerService.unsetTimer(this, 5); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_UNSET, this, null, null, 5))); + } + exitAction_main_region_on_r1_PedestrianRed() { + this.timerService.unsetTimer(this, 6); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_UNSET, this, null, null, 6))); + } + exitAction_main_region_on_r1_StreetPrepare() { + this.timerService.unsetTimer(this, 7); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_UNSET, this, null, null, 7))); + } + exitAction_main_region_on_r1_Safe() { + this.timerService.unsetTimer(this, 8); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_UNSET, this, null, null, 8))); + } + exitAction_main_region_off_r1_YellowOn() { + this.timerService.unsetTimer(this, 9); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_UNSET, this, null, null, 9))); + } + exitAction_main_region_off_r1_YellowOff() { + this.timerService.unsetTimer(this, 10); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.TIME_EVENT_UNSET, this, null, null, 10))); + } + enterSequence_main_region_on_default() { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_ON, null, null))); + this.enterSequence_main_region_on_r1_default(); + } + enterSequence_main_region_on_r1_PedWaiting_default() { + this.entryAction_main_region_on_r1_PedWaiting(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING, null, null))); + this.enterSequence_main_region_on_r1_PedWaiting_r1_default(); + } + enterSequence_main_region_on_r1_PedWaiting_r1_waitOn_default() { + this.entryAction_main_region_on_r1_PedWaiting_r1_waitOn(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING_R1_WAITON, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING_R1_WAITON; + } + enterSequence_main_region_on_r1_PedWaiting_r1_waitOff_default() { + this.entryAction_main_region_on_r1_PedWaiting_r1_waitOff(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING_R1_WAITOFF, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING_R1_WAITOFF; + } + enterSequence_main_region_on_r1_StreetAttention_default() { + this.entryAction_main_region_on_r1_StreetAttention(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_ON_R1_STREETATTENTION, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_ON_R1_STREETATTENTION; + } + enterSequence_main_region_on_r1_StreetRed_default() { + this.entryAction_main_region_on_r1_StreetRed(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_ON_R1_STREETRED, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_ON_R1_STREETRED; + } + enterSequence_main_region_on_r1_PedestrianGreen_default() { + this.entryAction_main_region_on_r1_PedestrianGreen(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_ON_R1_PEDESTRIANGREEN, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_ON_R1_PEDESTRIANGREEN; + } + enterSequence_main_region_on_r1_PedestrianRed_default() { + this.entryAction_main_region_on_r1_PedestrianRed(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_ON_R1_PEDESTRIANRED, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_ON_R1_PEDESTRIANRED; + } + enterSequence_main_region_on_r1_StreetPrepare_default() { + this.entryAction_main_region_on_r1_StreetPrepare(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_ON_R1_STREETPREPARE, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_ON_R1_STREETPREPARE; + } + enterSequence_main_region_on_r1_Safe_default() { + this.entryAction_main_region_on_r1_Safe(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_ON_R1_SAFE, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_ON_R1_SAFE; + } + enterSequence_main_region_on_r1_StreetGreen_default() { + this.entryAction_main_region_on_r1_StreetGreen(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_ON_R1_STREETGREEN, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_ON_R1_STREETGREEN; + } + enterSequence_main_region_off_default() { + this.entryAction_main_region_off(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_OFF, null, null))); + this.enterSequence_main_region_off_r1_default(); + } + enterSequence_main_region_off_r1_YellowOn_default() { + this.entryAction_main_region_off_r1_YellowOn(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_OFF_R1_YELLOWON, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_OFF_R1_YELLOWON; + } + enterSequence_main_region_off_r1_YellowOff_default() { + this.entryAction_main_region_off_r1_YellowOff(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_ENTERED, this, Statemachine.State.MAIN_REGION_OFF_R1_YELLOWOFF, null, null))); + this.stateVector[0] = Statemachine.State.MAIN_REGION_OFF_R1_YELLOWOFF; + } + enterSequence_main_region_default() { + this.react_main_region__entry_Default(); + } + enterSequence_main_region_on_r1_default() { + this.react_main_region_on_r1__entry_Default(); + } + enterSequence_main_region_on_r1_PedWaiting_r1_default() { + this.react_main_region_on_r1_PedWaiting_r1__entry_Default(); + } + enterSequence_main_region_off_r1_default() { + this.react_main_region_off_r1__entry_Default(); + } + exitSequence_main_region_on() { + this.exitSequence_main_region_on_r1(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON, null, null))); + } + exitSequence_main_region_on_r1_PedWaiting() { + this.exitSequence_main_region_on_r1_PedWaiting_r1(); + this.exitAction_main_region_on_r1_PedWaiting(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING, null, null))); + } + exitSequence_main_region_on_r1_PedWaiting_r1_waitOn() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.exitAction_main_region_on_r1_PedWaiting_r1_waitOn(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING_R1_WAITON, null, null))); + } + exitSequence_main_region_on_r1_PedWaiting_r1_waitOff() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.exitAction_main_region_on_r1_PedWaiting_r1_waitOff(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING_R1_WAITOFF, null, null))); + } + exitSequence_main_region_on_r1_StreetAttention() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.exitAction_main_region_on_r1_StreetAttention(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON_R1_STREETATTENTION, null, null))); + } + exitSequence_main_region_on_r1_StreetRed() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.exitAction_main_region_on_r1_StreetRed(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON_R1_STREETRED, null, null))); + } + exitSequence_main_region_on_r1_PedestrianGreen() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.exitAction_main_region_on_r1_PedestrianGreen(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON_R1_PEDESTRIANGREEN, null, null))); + } + exitSequence_main_region_on_r1_PedestrianRed() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.exitAction_main_region_on_r1_PedestrianRed(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON_R1_PEDESTRIANRED, null, null))); + } + exitSequence_main_region_on_r1_StreetPrepare() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.exitAction_main_region_on_r1_StreetPrepare(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON_R1_STREETPREPARE, null, null))); + } + exitSequence_main_region_on_r1_Safe() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.exitAction_main_region_on_r1_Safe(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON_R1_SAFE, null, null))); + } + exitSequence_main_region_on_r1_StreetGreen() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON_R1_STREETGREEN, null, null))); + } + exitSequence_main_region_off() { + this.exitSequence_main_region_off_r1(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_OFF, null, null))); + } + exitSequence_main_region_off_r1_YellowOn() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.exitAction_main_region_off_r1_YellowOn(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_OFF_R1_YELLOWON, null, null))); + } + exitSequence_main_region_off_r1_YellowOff() { + this.stateVector[0] = Statemachine.State.$NULLSTATE$; + this.exitAction_main_region_off_r1_YellowOff(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_OFF_R1_YELLOWOFF, null, null))); + } + exitSequence_main_region() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING_R1_WAITON: + this.exitSequence_main_region_on_r1_PedWaiting_r1_waitOn(); + this.exitAction_main_region_on_r1_PedWaiting(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING, null, null))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING_R1_WAITOFF: + this.exitSequence_main_region_on_r1_PedWaiting_r1_waitOff(); + this.exitAction_main_region_on_r1_PedWaiting(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING, null, null))); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_STREETATTENTION: + this.exitSequence_main_region_on_r1_StreetAttention(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_STREETRED: + this.exitSequence_main_region_on_r1_StreetRed(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_PEDESTRIANGREEN: + this.exitSequence_main_region_on_r1_PedestrianGreen(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_PEDESTRIANRED: + this.exitSequence_main_region_on_r1_PedestrianRed(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_STREETPREPARE: + this.exitSequence_main_region_on_r1_StreetPrepare(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_SAFE: + this.exitSequence_main_region_on_r1_Safe(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_STREETGREEN: + this.exitSequence_main_region_on_r1_StreetGreen(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_OFF_R1_YELLOWON: + this.exitSequence_main_region_off_r1_YellowOn(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_OFF, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_OFF_R1_YELLOWOFF: + this.exitSequence_main_region_off_r1_YellowOff(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_OFF, null, null))); + break; + default: + break; + } + } + exitSequence_main_region_on_r1() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING_R1_WAITON: + this.exitSequence_main_region_on_r1_PedWaiting_r1_waitOn(); + this.exitAction_main_region_on_r1_PedWaiting(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING_R1_WAITOFF: + this.exitSequence_main_region_on_r1_PedWaiting_r1_waitOff(); + this.exitAction_main_region_on_r1_PedWaiting(); + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_EXITED, this, Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING, null, null))); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_STREETATTENTION: + this.exitSequence_main_region_on_r1_StreetAttention(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_STREETRED: + this.exitSequence_main_region_on_r1_StreetRed(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_PEDESTRIANGREEN: + this.exitSequence_main_region_on_r1_PedestrianGreen(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_PEDESTRIANRED: + this.exitSequence_main_region_on_r1_PedestrianRed(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_STREETPREPARE: + this.exitSequence_main_region_on_r1_StreetPrepare(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_SAFE: + this.exitSequence_main_region_on_r1_Safe(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_STREETGREEN: + this.exitSequence_main_region_on_r1_StreetGreen(); + break; + default: + break; + } + } + exitSequence_main_region_on_r1_PedWaiting_r1() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING_R1_WAITON: + this.exitSequence_main_region_on_r1_PedWaiting_r1_waitOn(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING_R1_WAITOFF: + this.exitSequence_main_region_on_r1_PedWaiting_r1_waitOff(); + break; + default: + break; + } + } + exitSequence_main_region_off_r1() { + switch ((this.stateVector[0])) { + case sct.yakindu.io.Statemachine.State.MAIN_REGION_OFF_R1_YELLOWON: + this.exitSequence_main_region_off_r1_YellowOn(); + break; + case sct.yakindu.io.Statemachine.State.MAIN_REGION_OFF_R1_YELLOWOFF: + this.exitSequence_main_region_off_r1_YellowOff(); + break; + default: + break; + } + } + react_main_region_on_r1_PedWaiting_r1__entry_Default() { + this.enterSequence_main_region_on_r1_PedWaiting_r1_waitOn_default(); + } + react_main_region_on_r1__entry_Default() { + this.enterSequence_main_region_on_r1_Safe_default(); + } + react_main_region_off_r1__entry_Default() { + this.enterSequence_main_region_off_r1_YellowOn_default(); + } + react_main_region__entry_Default() { + this.enterSequence_main_region_off_default(); + } + react(transitioned_before) { + if (this.timeEvents[11]) { + this.operationCallback.synchronize(); + } + return transitioned_before; + } + main_region_on_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.onOff) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_ON, null, 0))); + this.exitSequence_main_region_on(); + this.enterSequence_main_region_off_default(); + this.react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_region_on_r1_PedWaiting_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.timeEvents[0]) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING, null, 0))); + this.exitSequence_main_region_on_r1_PedWaiting(); + this.timeEvents[0] = false; + this.enterSequence_main_region_on_r1_StreetAttention_default(); + this.main_region_on_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_on_react(transitioned_before); + } + return transitioned_after; + } + main_region_on_r1_PedWaiting_r1_waitOn_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.timeEvents[1]) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING_R1_WAITON, null, 0))); + this.exitSequence_main_region_on_r1_PedWaiting_r1_waitOn(); + this.timeEvents[1] = false; + this.enterSequence_main_region_on_r1_PedWaiting_r1_waitOff_default(); + this.main_region_on_r1_PedWaiting_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_on_r1_PedWaiting_react(transitioned_before); + } + return transitioned_after; + } + main_region_on_r1_PedWaiting_r1_waitOff_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.timeEvents[2]) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_ON_R1_PEDWAITING_R1_WAITOFF, null, 0))); + this.exitSequence_main_region_on_r1_PedWaiting_r1_waitOff(); + this.timeEvents[2] = false; + this.enterSequence_main_region_on_r1_PedWaiting_r1_waitOn_default(); + this.main_region_on_r1_PedWaiting_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_on_r1_PedWaiting_react(transitioned_before); + } + return transitioned_after; + } + main_region_on_r1_StreetAttention_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.timeEvents[3]) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_ON_R1_STREETATTENTION, null, 0))); + this.exitSequence_main_region_on_r1_StreetAttention(); + this.timeEvents[3] = false; + this.enterSequence_main_region_on_r1_StreetRed_default(); + this.main_region_on_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_on_react(transitioned_before); + } + return transitioned_after; + } + main_region_on_r1_StreetRed_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.timeEvents[4]) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_ON_R1_STREETRED, null, 0))); + this.exitSequence_main_region_on_r1_StreetRed(); + this.timeEvents[4] = false; + this.enterSequence_main_region_on_r1_PedestrianGreen_default(); + this.main_region_on_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_on_react(transitioned_before); + } + return transitioned_after; + } + main_region_on_r1_PedestrianGreen_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.timeEvents[5]) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_ON_R1_PEDESTRIANGREEN, null, 0))); + this.exitSequence_main_region_on_r1_PedestrianGreen(); + this.timeEvents[5] = false; + this.enterSequence_main_region_on_r1_PedestrianRed_default(); + this.main_region_on_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_on_react(transitioned_before); + } + return transitioned_after; + } + main_region_on_r1_PedestrianRed_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.timeEvents[6]) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_ON_R1_PEDESTRIANRED, null, 0))); + this.exitSequence_main_region_on_r1_PedestrianRed(); + this.timeEvents[6] = false; + this.enterSequence_main_region_on_r1_StreetPrepare_default(); + this.main_region_on_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_on_react(transitioned_before); + } + return transitioned_after; + } + main_region_on_r1_StreetPrepare_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.timeEvents[7]) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_ON_R1_STREETPREPARE, null, 0))); + this.exitSequence_main_region_on_r1_StreetPrepare(); + this.timeEvents[7] = false; + this.enterSequence_main_region_on_r1_StreetGreen_default(); + this.main_region_on_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_on_react(transitioned_before); + } + return transitioned_after; + } + main_region_on_r1_Safe_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.timeEvents[8]) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_ON_R1_SAFE, null, 0))); + this.exitSequence_main_region_on_r1_Safe(); + this.timeEvents[8] = false; + this.enterSequence_main_region_on_r1_StreetPrepare_default(); + this.main_region_on_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_on_react(transitioned_before); + } + return transitioned_after; + } + main_region_on_r1_StreetGreen_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.pedestrianRequest) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_ON_R1_STREETGREEN, null, 0))); + this.exitSequence_main_region_on_r1_StreetGreen(); + this.enterSequence_main_region_on_r1_PedWaiting_default(); + this.main_region_on_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_on_react(transitioned_before); + } + return transitioned_after; + } + main_region_off_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.onOff) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_OFF, null, 0))); + this.exitSequence_main_region_off(); + this.enterSequence_main_region_on_default(); + this.react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.react(transitioned_before); + } + return transitioned_after; + } + main_region_off_r1_YellowOn_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.timeEvents[9]) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_OFF_R1_YELLOWON, null, 0))); + this.exitSequence_main_region_off_r1_YellowOn(); + this.timeEvents[9] = false; + this.enterSequence_main_region_off_r1_YellowOff_default(); + this.main_region_off_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_off_react(transitioned_before); + } + return transitioned_after; + } + main_region_off_r1_YellowOff_react(transitioned_before) { + let transitioned_after = transitioned_before; + if (transitioned_after < 0) { + if (this.timeEvents[10]) { + this.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.STATE_TRANSITION, this, Statemachine.State.MAIN_REGION_OFF_R1_YELLOWOFF, null, 0))); + this.exitSequence_main_region_off_r1_YellowOff(); + this.timeEvents[10] = false; + this.enterSequence_main_region_off_r1_YellowOn_default(); + this.main_region_off_react(0); + transitioned_after = 0; + } + } + if (transitioned_after === transitioned_before) { + transitioned_after = this.main_region_off_react(transitioned_before); + } + return transitioned_after; + } + } + io.Statemachine = Statemachine; + Statemachine["__class"] = "sct.yakindu.io.Statemachine"; + Statemachine["__interfaces"] = ["com.yakindu.core.IStatemachine", "com.yakindu.core.ITimed"]; + (function (Statemachine) { + class TrafficLight { + constructor(parent) { + if (this.parent === undefined) { + this.parent = null; + } + if (this.red === undefined) { + this.red = false; + } + if (this.yellow === undefined) { + this.yellow = false; + } + if (this.green === undefined) { + this.green = false; + } + this.parent = parent; + } + getRed() { + return this.red; + } + setRed(value) { + this.red = value; + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this.parent, null, Statemachine.Feature.TRAFFICLIGHT_RED, this.red))); + } + getYellow() { + return this.yellow; + } + setYellow(value) { + this.yellow = value; + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this.parent, null, Statemachine.Feature.TRAFFICLIGHT_YELLOW, this.yellow))); + } + getGreen() { + return this.green; + } + setGreen(value) { + this.green = value; + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this.parent, null, Statemachine.Feature.TRAFFICLIGHT_GREEN, this.green))); + } + } + Statemachine.TrafficLight = TrafficLight; + TrafficLight["__class"] = "sct.yakindu.io.Statemachine.TrafficLight"; + class Pedestrian { + constructor(parent) { + if (this.parent === undefined) { + this.parent = null; + } + if (this.request === undefined) { + this.request = false; + } + if (this.red === undefined) { + this.red = false; + } + if (this.green === undefined) { + this.green = false; + } + this.parent = parent; + } + getRequest() { + return this.request; + } + setRequest(value) { + this.request = value; + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this.parent, null, Statemachine.Feature.PEDESTRIAN_REQUEST, this.request))); + } + getRed() { + return this.red; + } + setRed(value) { + this.red = value; + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this.parent, null, Statemachine.Feature.PEDESTRIAN_RED, this.red))); + } + getGreen() { + return this.green; + } + setGreen(value) { + this.green = value; + this.parent.trace.next((new com.yakindu.core.TraceEvent(com.yakindu.core.TraceEventType.VARIABLE_SET, this.parent, null, Statemachine.Feature.PEDESTRIAN_GREEN, this.green))); + } + } + Statemachine.Pedestrian = Pedestrian; + Pedestrian["__class"] = "sct.yakindu.io.Statemachine.Pedestrian"; + let State; + (function (State) { + State[State["MAIN_REGION_ON"] = 0] = "MAIN_REGION_ON"; + State[State["MAIN_REGION_ON_R1_PEDWAITING"] = 1] = "MAIN_REGION_ON_R1_PEDWAITING"; + State[State["MAIN_REGION_ON_R1_PEDWAITING_R1_WAITON"] = 2] = "MAIN_REGION_ON_R1_PEDWAITING_R1_WAITON"; + State[State["MAIN_REGION_ON_R1_PEDWAITING_R1_WAITOFF"] = 3] = "MAIN_REGION_ON_R1_PEDWAITING_R1_WAITOFF"; + State[State["MAIN_REGION_ON_R1_STREETATTENTION"] = 4] = "MAIN_REGION_ON_R1_STREETATTENTION"; + State[State["MAIN_REGION_ON_R1_STREETRED"] = 5] = "MAIN_REGION_ON_R1_STREETRED"; + State[State["MAIN_REGION_ON_R1_PEDESTRIANGREEN"] = 6] = "MAIN_REGION_ON_R1_PEDESTRIANGREEN"; + State[State["MAIN_REGION_ON_R1_PEDESTRIANRED"] = 7] = "MAIN_REGION_ON_R1_PEDESTRIANRED"; + State[State["MAIN_REGION_ON_R1_STREETPREPARE"] = 8] = "MAIN_REGION_ON_R1_STREETPREPARE"; + State[State["MAIN_REGION_ON_R1_SAFE"] = 9] = "MAIN_REGION_ON_R1_SAFE"; + State[State["MAIN_REGION_ON_R1_STREETGREEN"] = 10] = "MAIN_REGION_ON_R1_STREETGREEN"; + State[State["MAIN_REGION_OFF"] = 11] = "MAIN_REGION_OFF"; + State[State["MAIN_REGION_OFF_R1_YELLOWON"] = 12] = "MAIN_REGION_OFF_R1_YELLOWON"; + State[State["MAIN_REGION_OFF_R1_YELLOWOFF"] = 13] = "MAIN_REGION_OFF_R1_YELLOWOFF"; + State[State["$NULLSTATE$"] = 14] = "$NULLSTATE$"; + })(State = Statemachine.State || (Statemachine.State = {})); + /** + * Enumeration of all features of the statechart + * @enum + * @property {sct.yakindu.io.Statemachine.Feature} NO_FEATURE + * @property {sct.yakindu.io.Statemachine.Feature} TRAFFICLIGHT_RED + * @property {sct.yakindu.io.Statemachine.Feature} TRAFFICLIGHT_YELLOW + * @property {sct.yakindu.io.Statemachine.Feature} TRAFFICLIGHT_GREEN + * @property {sct.yakindu.io.Statemachine.Feature} PEDESTRIAN_REQUEST + * @property {sct.yakindu.io.Statemachine.Feature} PEDESTRIAN_RED + * @property {sct.yakindu.io.Statemachine.Feature} PEDESTRIAN_GREEN + * @property {sct.yakindu.io.Statemachine.Feature} PEDESTRIANREQUEST + * @property {sct.yakindu.io.Statemachine.Feature} ONOFF + * @class + */ + let Feature; + (function (Feature) { + Feature[Feature["NO_FEATURE"] = 0] = "NO_FEATURE"; + Feature[Feature["TRAFFICLIGHT_RED"] = 1] = "TRAFFICLIGHT_RED"; + Feature[Feature["TRAFFICLIGHT_YELLOW"] = 2] = "TRAFFICLIGHT_YELLOW"; + Feature[Feature["TRAFFICLIGHT_GREEN"] = 3] = "TRAFFICLIGHT_GREEN"; + Feature[Feature["PEDESTRIAN_REQUEST"] = 4] = "PEDESTRIAN_REQUEST"; + Feature[Feature["PEDESTRIAN_RED"] = 5] = "PEDESTRIAN_RED"; + Feature[Feature["PEDESTRIAN_GREEN"] = 6] = "PEDESTRIAN_GREEN"; + Feature[Feature["PEDESTRIANREQUEST"] = 7] = "PEDESTRIANREQUEST"; + Feature[Feature["ONOFF"] = 8] = "ONOFF"; + })(Feature = Statemachine.Feature || (Statemachine.Feature = {})); + })(Statemachine = io.Statemachine || (io.Statemachine = {})); + })(io = yakindu.io || (yakindu.io = {})); + })(yakindu = sct.yakindu || (sct.yakindu = {})); +})(sct || (sct = {})); diff --git a/org.yakindu.sct.examples.trafficlight.python/assets/context.json.js b/org.yakindu.sct.examples.trafficlight.python/assets/context.json.js new file mode 100644 index 00000000..cd53b446 --- /dev/null +++ b/org.yakindu.sct.examples.trafficlight.python/assets/context.json.js @@ -0,0 +1 @@ +const contextJson = {"elements":[{"elements":[{"kind":"variable","type":"boolean","name":"red","fqName":"TrafficLight.red","featureId":"TRAFFICLIGHT_RED","writable":true,"value":false},{"kind":"variable","type":"boolean","name":"yellow","fqName":"TrafficLight.yellow","featureId":"TRAFFICLIGHT_YELLOW","writable":true,"value":false},{"kind":"variable","type":"boolean","name":"green","fqName":"TrafficLight.green","featureId":"TRAFFICLIGHT_GREEN","writable":true,"value":false}],"kind":"composite","name":"TrafficLight","fqName":"TrafficLight","featureId":"","writable":true},{"elements":[{"kind":"variable","type":"boolean","name":"request","fqName":"Pedestrian.request","featureId":"PEDESTRIAN_REQUEST","writable":true,"value":false},{"kind":"variable","type":"boolean","name":"red","fqName":"Pedestrian.red","featureId":"PEDESTRIAN_RED","writable":true,"value":false},{"kind":"variable","type":"boolean","name":"green","fqName":"Pedestrian.green","featureId":"PEDESTRIAN_GREEN","writable":true,"value":false}],"kind":"composite","name":"Pedestrian","fqName":"Pedestrian","featureId":"","writable":true},{"elements":[{"kind":"event","name":"pedestrianRequest","fqName":"pedestrianRequest","featureId":"PEDESTRIANREQUEST","writable":true},{"kind":"event","name":"onOff","fqName":"onOff","featureId":"ONOFF","writable":true},{"kind":"operation","type":"void","name":"synchronize","fqName":"synchronize","featureId":"SYNCHRONIZE","writable":true}],"kind":"composite","name":"default","featureId":"","writable":true},{"elements":[],"kind":"composite","name":"internal","featureId":"","writable":true},{"elements":[{"kind":"event","type":"integer","name":"PedWaiting_time_event_0","fqName":"TrafficLightCtrl.main_region.on.r1.PedWaiting_time_event_0","featureId":"PEDWAITING_TIME_EVENT_0","writable":true,"value":0},{"kind":"event","type":"integer","name":"waitOn_time_event_0","fqName":"TrafficLightCtrl.main_region.on.r1.PedWaiting.r1.waitOn_time_event_0","featureId":"WAITON_TIME_EVENT_0","writable":true,"value":0},{"kind":"event","type":"integer","name":"waitOff_time_event_0","fqName":"TrafficLightCtrl.main_region.on.r1.PedWaiting.r1.waitOff_time_event_0","featureId":"WAITOFF_TIME_EVENT_0","writable":true,"value":0},{"kind":"event","type":"integer","name":"StreetAttention_time_event_0","fqName":"TrafficLightCtrl.main_region.on.r1.StreetAttention_time_event_0","featureId":"STREETATTENTION_TIME_EVENT_0","writable":true,"value":0},{"kind":"event","type":"integer","name":"StreetRed_time_event_0","fqName":"TrafficLightCtrl.main_region.on.r1.StreetRed_time_event_0","featureId":"STREETRED_TIME_EVENT_0","writable":true,"value":0},{"kind":"event","type":"integer","name":"PedestrianGreen_time_event_0","fqName":"TrafficLightCtrl.main_region.on.r1.PedestrianGreen_time_event_0","featureId":"PEDESTRIANGREEN_TIME_EVENT_0","writable":true,"value":0},{"kind":"event","type":"integer","name":"PedestrianRed_time_event_0","fqName":"TrafficLightCtrl.main_region.on.r1.PedestrianRed_time_event_0","featureId":"PEDESTRIANRED_TIME_EVENT_0","writable":true,"value":0},{"kind":"event","type":"integer","name":"StreetPrepare_time_event_0","fqName":"TrafficLightCtrl.main_region.on.r1.StreetPrepare_time_event_0","featureId":"STREETPREPARE_TIME_EVENT_0","writable":true,"value":0},{"kind":"event","type":"integer","name":"Safe_time_event_0","fqName":"TrafficLightCtrl.main_region.on.r1.Safe_time_event_0","featureId":"SAFE_TIME_EVENT_0","writable":true,"value":0},{"kind":"event","type":"integer","name":"YellowOn_time_event_0","fqName":"TrafficLightCtrl.main_region.off.r1.YellowOn_time_event_0","featureId":"YELLOWON_TIME_EVENT_0","writable":true,"value":0},{"kind":"event","type":"integer","name":"YellowOff_time_event_0","fqName":"TrafficLightCtrl.main_region.off.r1.YellowOff_time_event_0","featureId":"YELLOWOFF_TIME_EVENT_0","writable":true,"value":0},{"kind":"event","type":"integer","name":"TrafficLightCtrl_time_event_0","fqName":"TrafficLightCtrl_time_event_0","featureId":"TRAFFICLIGHTCTRL_TIME_EVENT_0","writable":true,"value":0}],"kind":"composite","name":"time events","featureId":"","writable":true}]} \ No newline at end of file diff --git a/org.yakindu.sct.examples.trafficlight.python/assets/hashes.json.js b/org.yakindu.sct.examples.trafficlight.python/assets/hashes.json.js new file mode 100644 index 00000000..48f595f6 --- /dev/null +++ b/org.yakindu.sct.examples.trafficlight.python/assets/hashes.json.js @@ -0,0 +1 @@ +const hashesJson = {"MAIN_REGION_ON_R1_STREETATTENTION_tr0":"bab1f141-8f91-4cbe-8c97-fdf2c89b4532","MAIN_REGION_OFF":"6e13ef4e-763d-44be-b081-9baf9b95e044","MAIN_REGION_ON_R1_STREETRED":"c0465af0-b699-4b17-b0ed-e580ac71cb06","MAIN_REGION_OFF_R1_YELLOWON_tr0":"20fb4796-d85b-4450-9cc3-7658f9ddd33e","MAIN_REGION_ON_R1_PEDESTRIANRED":"9a752fd7-7a2b-427b-a151-82bbb5f8aa8d","MAIN_REGION_ON_R1_STREETRED_tr0":"ea98de6e-fc01-4c6a-aa39-e758a6281085","MAIN_REGION_ON_R1_PEDWAITING_R1_WAITON":"90d7956d-a0cf-4c3e-be37-acc4a3a50012","MAIN_REGION_ON_R1_PEDWAITING":"7bfa1d9e-7adc-4898-bcd9-6409979f8d75","MAIN_REGION_OFF_R1_YELLOWOFF":"408d0fe2-15f1-410b-be97-643cf10b5b47","MAIN_REGION_ON_R1_PEDWAITING_tr0":"28e23c3f-5fc8-48f3-a84c-30cf2cfb9028","MAIN_REGION_ON_R1_SAFE_tr0":"82aa3c66-48b5-4579-82f0-8433de07f2a7","MAIN_REGION_ON_R1_PEDWAITING_R1_WAITOFF_tr0":"e6b60887-7238-4dd0-b0d6-96cb1a340632","MAIN_REGION_ON_tr0":"930962df-beac-4cac-91d3-f32cabfd38c5","MAIN_REGION_ON_R1_PEDESTRIANRED_tr0":"07838d1b-63ee-48c5-8b94-4fa7a248c975","MAIN_REGION_ON":"97fc7fcc-dc23-4672-a52f-c4b9463a9685","MAIN_REGION_ON_R1_STREETATTENTION":"5bffdf64-bf53-4b84-afa4-edeab25f6c11","MAIN_REGION_ON_R1_STREETPREPARE_tr0":"a62ae718-6828-4ddc-9e69-9dbf695e9fd3","MAIN_REGION_ON_R1_STREETPREPARE":"fb82d0bc-e7b4-4539-90e1-c329f2b63559","MAIN_REGION_ON_R1_PEDWAITING_R1_WAITON_tr0":"d31f0510-3e6c-4501-849e-01333f2bb365","MAIN_REGION_ON_R1_SAFE":"b3fc0d9a-7509-4c9f-a25b-06e768d29ad3","MAIN_REGION_ON_R1_STREETGREEN":"8190c123-9ed6-409c-b2bf-6f86c52b2fe8","MAIN_REGION_OFF_R1_YELLOWON":"5404bd57-79e1-4bb3-9794-0ade760aa0d6","MAIN_REGION_ON_R1_PEDESTRIANGREEN_tr0":"fe9286c1-5ba7-4d89-b621-918e4a14b2fb","MAIN_REGION_OFF_tr0":"46b2a85e-cde9-444f-a9ad-9ac812a1673d","MAIN_REGION_ON_R1_PEDESTRIANGREEN":"63ebebfd-6c73-4ab3-afd9-a45e87c9223a","MAIN_REGION_ON_R1_STREETGREEN_tr0":"71411f82-623c-4b43-8b2c-4d7b0daa11cc","MAIN_REGION_ON_R1_PEDWAITING_R1_WAITOFF":"04c2224a-0475-4d72-859c-e93ebbdd5ca8","MAIN_REGION_OFF_R1_YELLOWOFF_tr0":"d0329e74-aa42-4981-b499-032414fae6f3"} \ No newline at end of file diff --git a/org.yakindu.sct.examples.trafficlight.python/assets/statemachine.svg.js b/org.yakindu.sct.examples.trafficlight.python/assets/statemachine.svg.js new file mode 100644 index 00000000..9e90d5d4 --- /dev/null +++ b/org.yakindu.sct.examples.trafficlight.python/assets/statemachine.svg.js @@ -0,0 +1 @@ +let svg = `main region1onr1-PedWaitingexit / Pedestrian.request = falseStreetAttentionentry / TrafficLight.red = false; TrafficLight.yellow = true; TrafficLight.green = falseStreetRedentry / TrafficLight.red = true; TrafficLight.yellow = false; TrafficLight.green = falsePedestrianGreenentry / Pedestrian.red = false; Pedestrian.green = truePedestrianRedentry / Pedestrian.red = true; Pedestrian.green = falseStreetPrepareentry / TrafficLight.red = true; TrafficLight.yellow = true; TrafficLight.green = falseSafeentry / TrafficLight.red = true; TrafficLight.yellow = false; TrafficLight.green = false; Pedestrian.red = true; Pedestrian.green = false; Pedestrian.request = falseStreetGreenentry / TrafficLight.red = false; TrafficLight.yellow = false; TrafficLight.green = true; Pedestrian.red = true; Pedestrian.green = false; Pedestrian.request = falser1--waitOnentry / Pedestrian.request = truewaitOffentry / Pedestrian.request = false-after 10safter 10s1after 7safter 7s1pedestrianRequestpedestrianRequest1after 500msafter 500ms1-1after 500msafter 500ms1after 2safter 2s1after 2safter 2s1after 7safter 7s1after 5safter 5s1after 2safter 2s1-1offentry / TrafficLight.red = false; TrafficLight.green = false; TrafficLight.yellow = false; Pedestrian.red = false; Pedestrian.green = falser1-YellowOnentry / TrafficLight.yellow = true; Pedestrian.request = trueYellowOffentry / TrafficLight.yellow = false; Pedestrian.request = false-onOffonOff1onOffonOff1after 500msafter 500ms1after 500msafter 500ms1-1--1` \ No newline at end of file diff --git a/org.yakindu.sct.examples.trafficlight.python/assets/ypi.css b/org.yakindu.sct.examples.trafficlight.python/assets/ypi.css new file mode 100644 index 00000000..771aaa11 --- /dev/null +++ b/org.yakindu.sct.examples.trafficlight.python/assets/ypi.css @@ -0,0 +1,113 @@ +/*! + * itemis CREATE Player Styles + * Copyright 2021 itemis AG + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ + + + /*! + * Style definitions follow BEM pattern using and additional 'y' namespace (for itemis CREATE). + */ +.y-declaration { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; + background-color: #eee; + font-family: 'Courier New', Courier, monospace; +} + + +.y-entry { + padding: 3px; + border: 1px solid #aaa; + border-radius: 4px; +} + +.y-entry:after { + content: ' \25CF '; + font-size: larger; +} + +.y-state { + background-color: rgb(209, 223, 238); + padding: 3px; + border: 0.5pt;; + border: 0.5pt; + border-radius: 4px; + border-color: #bbb; + font-family: 'Courier New', Courier, monospace; +} + +.y-state--active { + background-color: rgb(244, 215, 66); +} + +.y-state--inactive { + background-color: rgb(209, 223, 238); +} + +.y-variable{ + background-color: #eee; + border-color: #aaa; + border: 0.5pt; + border: 0.5pt; + border-radius: 2px; + font-family: 'Courier New', Courier, monospace; +} + +.y-variable::after { + color: #aaa; + content: attr(value); + font-family: 'Courier New', Courier, monospace; +} + +.y-do-enter { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; +} + +.y-do-enter:before { + content: ' \2192 '; +} + +.y-do-exit { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer +} + +.y-do-exit:before { + content: ' \2192 '; +} + +.y-do-raise { + border: 1px solid #aaa; + border-radius: 4px; + cursor: pointer; + white-space: nowrap; +} + +.y-do-raise:before { + content: ' \2192 '; +} + +button.y-do-raise:before { + content: ''; +} + +button.y-do-raise { + cursor: pointer; +} + +.y-do--over { + color: blue; + background-color: #eee; + cursor: pointer; +} + +.y-player { + border-style: solid; + border-width: 1px; + border-color: ; +} diff --git a/org.yakindu.sct.examples.trafficlight.python/images/French-Pedestrian-Silhouette.svg b/org.yakindu.sct.examples.trafficlight.python/images/French-Pedestrian-Silhouette.svg new file mode 100644 index 00000000..1d88c2f0 --- /dev/null +++ b/org.yakindu.sct.examples.trafficlight.python/images/French-Pedestrian-Silhouette.svg @@ -0,0 +1,19 @@ + + + + + + diff --git a/org.yakindu.sct.examples.trafficlight.python/images/background.png b/org.yakindu.sct.examples.trafficlight.python/images/background.png new file mode 100644 index 00000000..8e5eb662 Binary files /dev/null and b/org.yakindu.sct.examples.trafficlight.python/images/background.png differ diff --git a/org.yakindu.sct.examples.trafficlight.python/images/graphic-910065_1280.png b/org.yakindu.sct.examples.trafficlight.python/images/graphic-910065_1280.png new file mode 100644 index 00000000..fb5707ca Binary files /dev/null and b/org.yakindu.sct.examples.trafficlight.python/images/graphic-910065_1280.png differ diff --git a/org.yakindu.sct.examples.trafficlight.python/images/graphic-910066.svg b/org.yakindu.sct.examples.trafficlight.python/images/graphic-910066.svg new file mode 100644 index 00000000..960aaead --- /dev/null +++ b/org.yakindu.sct.examples.trafficlight.python/images/graphic-910066.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/org.yakindu.sct.examples.trafficlight.python/images/graphic-910066_1280.png b/org.yakindu.sct.examples.trafficlight.python/images/graphic-910066_1280.png new file mode 100644 index 00000000..3a331112 Binary files /dev/null and b/org.yakindu.sct.examples.trafficlight.python/images/graphic-910066_1280.png differ diff --git a/org.yakindu.sct.examples.trafficlight.python/images/green.png b/org.yakindu.sct.examples.trafficlight.python/images/green.png new file mode 100644 index 00000000..fd50b2cb Binary files /dev/null and b/org.yakindu.sct.examples.trafficlight.python/images/green.png differ diff --git a/org.yakindu.sct.examples.trafficlight.python/images/omar-ram-vcRHpfrsaL8-unsplash.jpg b/org.yakindu.sct.examples.trafficlight.python/images/omar-ram-vcRHpfrsaL8-unsplash.jpg new file mode 100644 index 00000000..8f26cce5 Binary files /dev/null and b/org.yakindu.sct.examples.trafficlight.python/images/omar-ram-vcRHpfrsaL8-unsplash.jpg differ diff --git a/org.yakindu.sct.examples.trafficlight.python/images/pause.png b/org.yakindu.sct.examples.trafficlight.python/images/pause.png new file mode 100644 index 00000000..cc876377 Binary files /dev/null and b/org.yakindu.sct.examples.trafficlight.python/images/pause.png differ diff --git a/org.yakindu.sct.examples.trafficlight.python/images/play.png b/org.yakindu.sct.examples.trafficlight.python/images/play.png new file mode 100644 index 00000000..c984a88f Binary files /dev/null and b/org.yakindu.sct.examples.trafficlight.python/images/play.png differ diff --git a/org.yakindu.sct.examples.trafficlight.python/images/red.png b/org.yakindu.sct.examples.trafficlight.python/images/red.png new file mode 100644 index 00000000..98d86d99 Binary files /dev/null and b/org.yakindu.sct.examples.trafficlight.python/images/red.png differ diff --git a/org.yakindu.sct.examples.trafficlight.python/images/road.png b/org.yakindu.sct.examples.trafficlight.python/images/road.png new file mode 100644 index 00000000..114ed176 Binary files /dev/null and b/org.yakindu.sct.examples.trafficlight.python/images/road.png differ diff --git a/org.yakindu.sct.examples.trafficlight.python/images/traffic-light-2411796.svg b/org.yakindu.sct.examples.trafficlight.python/images/traffic-light-2411796.svg new file mode 100644 index 00000000..3bf41b24 --- /dev/null +++ b/org.yakindu.sct.examples.trafficlight.python/images/traffic-light-2411796.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/org.yakindu.sct.examples.trafficlight.python/images/traffic-light-2411796_1280.png b/org.yakindu.sct.examples.trafficlight.python/images/traffic-light-2411796_1280.png new file mode 100644 index 00000000..9a5d9884 Binary files /dev/null and b/org.yakindu.sct.examples.trafficlight.python/images/traffic-light-2411796_1280.png differ diff --git a/org.yakindu.sct.examples.trafficlight.python/images/trafficLightAllOff.png b/org.yakindu.sct.examples.trafficlight.python/images/trafficLightAllOff.png new file mode 100644 index 00000000..fbfde657 Binary files /dev/null and b/org.yakindu.sct.examples.trafficlight.python/images/trafficLightAllOff.png differ diff --git a/org.yakindu.sct.examples.trafficlight.python/images/yellow.png b/org.yakindu.sct.examples.trafficlight.python/images/yellow.png new file mode 100644 index 00000000..a1e08768 Binary files /dev/null and b/org.yakindu.sct.examples.trafficlight.python/images/yellow.png differ diff --git a/org.yakindu.sct.examples.trafficlight.python/index.html b/org.yakindu.sct.examples.trafficlight.python/index.html index ad551f7c..db5384be 100644 --- a/org.yakindu.sct.examples.trafficlight.python/index.html +++ b/org.yakindu.sct.examples.trafficlight.python/index.html @@ -1,26 +1,121 @@ + - -Traffic Light (Python) - + + Traffic Light (Python) + + + + + + - -
    - + + +
    +

    Traffic Light (Python)

    Demonstrates how to to generate Python source code from a statechart.

    +
    + +
    + +
    +

    Raise events:

    + onOff + pedestrianRequest +
    +
    +

    State changes:

    +
    + on + off + yellowOn + yellowOff + Safe + StreetPrepare + StreetGreen + PedestrianRed + PedestrianGreen + StreetRed + StreetAttention + PedWaiting + WaitOn + WaitOff +
    +

    +

    Variable changes:

    +

    PedestrianRequest:true

    +

    PedestrianRed:true

    +

    PedestrianGreen:true

    +

    TrafficLightRed:true

    +

    TrafficLightYellow:true

    +

    TrafficLightGreen:true

    +
    +
    +
    +
    -

    - Statechart -

    -

    How it works

    - +

    In summary, there are two traffic lights: one for the traffic on the street, and one for pedestrians who want to cross the street. They can push a button to request their traffic light to turn green, which @@ -35,7 +130,7 @@

    How it works

    light is indeed switched off and that the street should be crossed in a careful manner.

    -

    Run the program

    +

    Run the program

    The traffic light example is based on Python and contains a small GUI that demonstrate the state machine behaviour modelled in /model/TrafficLightCtrl.sct. This example combines generated Python code @@ -45,33 +140,105 @@

    Run the program

    src/Main.py. For this, double-click on 'Main.py', start it from the console or - if you already added the PyDev plugin to your IDE - just right-click on the project and select 'Run As > Python Run'.

    - +

    - Application + Application

    -

    Using the GUI:

    -
      -
    1. Press the 'OnOff' Button to activate the traffic light system.
    2. -
    3. Press the 'Go' button to send a request.
    4. -
    5. At the end press 'Exit' to exit the program. This makes sure that - everything shuts down safely.
    6. -
    +

    Using the GUI:

    +
      +
    1. Press the 'OnOff' Button to activate the traffic light system.
    2. +
    3. Press the 'Go' button to send a request.
    4. +
    5. At the end press 'Exit' to exit the program. This makes sure that + everything shuts down safely.
    6. +

    Known issues

    1. The example requires Python 3
    2. -
    3. It's recommended to install the PyDev plugin (or something similar) in - your IDE first (but not necessary).
    4. +
    5. It's recommended to install the PyDev plugin (or something similar) in + your IDE first (but not necessary).
    6. The example shows you a 'src' folder, because it follows the tradition - of all the other examples. Please use the auto-generated 'bin' folder for - your own projects if you like to write a little script showing the use of - your generated state machine (this refers to Python packaging).
    7. + of all the other examples. Please use the auto-generated 'bin' folder for + your own projects if you like to write a little script showing the use of + your generated state machine (this refers to Python packaging).
    + + \ No newline at end of file diff --git a/org.yakindu.sct.examples.trafficlight.python/player.html b/org.yakindu.sct.examples.trafficlight.python/player.html new file mode 100644 index 00000000..a40d8757 --- /dev/null +++ b/org.yakindu.sct.examples.trafficlight.python/player.html @@ -0,0 +1,52 @@ + +sct-web-player demo + + + + + + + + + + + + + + + +
    + +
    + + + + + \ No newline at end of file diff --git a/org.yakindu.sct.examples.trafficlight.python/scene.html b/org.yakindu.sct.examples.trafficlight.python/scene.html new file mode 100644 index 00000000..e1464411 --- /dev/null +++ b/org.yakindu.sct.examples.trafficlight.python/scene.html @@ -0,0 +1,96 @@ + + + + + + + + + Document + + + + +
    + + + + + + + + +
    + + + + \ No newline at end of file diff --git a/org.yakindu.sct.examples.trafficlight.python/src/traffic_light_ctrl.py b/org.yakindu.sct.examples.trafficlight.python/src/traffic_light_ctrl.py new file mode 100644 index 00000000..a5b4c641 --- /dev/null +++ b/org.yakindu.sct.examples.trafficlight.python/src/traffic_light_ctrl.py @@ -0,0 +1,984 @@ +"""Implementation of statechart traffic_light_ctrl. +Generated by itemis CREATE code generator. +""" + + +class TrafficLightCtrl: + """Implementation of the state machine TrafficLightCtrl. + """ + + class State: + """ State Enum + """ + ( + main_region_on, + main_region_on_r1street_green, + main_region_on_r1ped_waiting, + main_region_on_r1ped_waiting_r1wait_on, + main_region_on_r1ped_waiting_r1wait_off, + main_region_on_r1street_attention, + main_region_on_r1street_red, + main_region_on_r1pedestrian_green, + main_region_on_r1pedestrian_red, + main_region_on_r1street_prepare, + main_region_on_r1safe, + main_region_off, + main_region_off_r1yellow_on, + main_region_off_r1yellow_off, + null_state + ) = range(15) + + + class EvBuf: + """Implementation of internal scope. + """ + + def __init__(self): + self.pedestrian_request = False + self.on_off = False + + class TimeEventsEvBuf: + """Implementation of internal scope. + """ + + def __init__(self): + self.traffic_light_ctrl_main_region_on_r1ped_waiting_time_event_0 = False + self.traffic_light_ctrl_main_region_on_r1ped_waiting_r1wait_on_time_event_0 = False + self.traffic_light_ctrl_main_region_on_r1ped_waiting_r1wait_off_time_event_0 = False + self.traffic_light_ctrl_main_region_on_r1street_attention_time_event_0 = False + self.traffic_light_ctrl_main_region_on_r1street_red_time_event_0 = False + self.traffic_light_ctrl_main_region_on_r1pedestrian_green_time_event_0 = False + self.traffic_light_ctrl_main_region_on_r1pedestrian_red_time_event_0 = False + self.traffic_light_ctrl_main_region_on_r1street_prepare_time_event_0 = False + self.traffic_light_ctrl_main_region_on_r1safe_time_event_0 = False + self.traffic_light_ctrl_main_region_off_r1yellow_on_time_event_0 = False + self.traffic_light_ctrl_main_region_off_r1yellow_off_time_event_0 = False + self.traffic_light_ctrl_time_event_0 = False + + class TrafficLightCtrlEvBuf: + """Implementation of internal scope. + """ + + def __init__(self, iface, time_events): + self.iface = iface + self.time_events = time_events + + class TrafficLight: + """Implementation of scope TrafficLight. + """ + + def __init__(self, statemachine): + self.red = None + self.yellow = None + self.green = None + + self.statemachine = statemachine + + + class Pedestrian: + """Implementation of scope Pedestrian. + """ + + def __init__(self, statemachine): + self.request = None + self.red = None + self.green = None + + self.statemachine = statemachine + + + def __init__(self): + """ Declares all necessary variables including list of states, histories etc. + """ + self.traffic_light = TrafficLightCtrl.TrafficLight(self) + self.pedestrian = TrafficLightCtrl.Pedestrian(self) + + self.pedestrian_request = None + self.on_off = None + self.operation_callback = None + + + # enumeration of all states: + self.__State = TrafficLightCtrl.State + self.__state_conf_vector_changed = None + self.__state_vector = [None] * 1 + for __state_index in range(1): + self.__state_vector[__state_index] = self.State.null_state + + # for timed statechart: + self.timer_service = None + self.__time_events = [None] * 12 + + # initializations: + self.traffic_light.red = False + self.traffic_light.yellow = False + self.traffic_light.green = False + self.pedestrian.request = False + self.pedestrian.red = False + self.pedestrian.green = False + self.__current = self.TrafficLightCtrlEvBuf( + self.EvBuf(), + self.TimeEventsEvBuf() + ) + self.__is_executing = False + + def is_active(self): + """Checks if the state machine is active. + """ + return self.__state_vector[0] is not self.__State.null_state + + def is_final(self): + """Checks if the statemachine is final. + Always returns 'false' since this state machine can never become final. + """ + return False + + def is_state_active(self, state): + """Checks if the state is currently active. + """ + s = state + if s == self.__State.main_region_on: + return (self.__state_vector[0] >= self.__State.main_region_on)\ + and (self.__state_vector[0] <= self.__State.main_region_on_r1safe) + if s == self.__State.main_region_on_r1street_green: + return self.__state_vector[0] == self.__State.main_region_on_r1street_green + if s == self.__State.main_region_on_r1ped_waiting: + return (self.__state_vector[0] >= self.__State.main_region_on_r1ped_waiting)\ + and (self.__state_vector[0] <= self.__State.main_region_on_r1ped_waiting_r1wait_off) + if s == self.__State.main_region_on_r1ped_waiting_r1wait_on: + return self.__state_vector[0] == self.__State.main_region_on_r1ped_waiting_r1wait_on + if s == self.__State.main_region_on_r1ped_waiting_r1wait_off: + return self.__state_vector[0] == self.__State.main_region_on_r1ped_waiting_r1wait_off + if s == self.__State.main_region_on_r1street_attention: + return self.__state_vector[0] == self.__State.main_region_on_r1street_attention + if s == self.__State.main_region_on_r1street_red: + return self.__state_vector[0] == self.__State.main_region_on_r1street_red + if s == self.__State.main_region_on_r1pedestrian_green: + return self.__state_vector[0] == self.__State.main_region_on_r1pedestrian_green + if s == self.__State.main_region_on_r1pedestrian_red: + return self.__state_vector[0] == self.__State.main_region_on_r1pedestrian_red + if s == self.__State.main_region_on_r1street_prepare: + return self.__state_vector[0] == self.__State.main_region_on_r1street_prepare + if s == self.__State.main_region_on_r1safe: + return self.__state_vector[0] == self.__State.main_region_on_r1safe + if s == self.__State.main_region_off: + return (self.__state_vector[0] >= self.__State.main_region_off)\ + and (self.__state_vector[0] <= self.__State.main_region_off_r1yellow_off) + if s == self.__State.main_region_off_r1yellow_on: + return self.__state_vector[0] == self.__State.main_region_off_r1yellow_on + if s == self.__State.main_region_off_r1yellow_off: + return self.__state_vector[0] == self.__State.main_region_off_r1yellow_off + return False + + def time_elapsed(self, event_id): + """ Mark the corresponding time event as True. + """ + if event_id in range(12): + self.__time_events[event_id] = True + + def raise_pedestrian_request(self): + """Raise method for event pedestrian_request. + """ + self.pedestrian_request = True + + def raise_on_off(self): + """Raise method for event on_off. + """ + self.on_off = True + + def __entry_action_main_region_on_r1_street_green(self): + """Entry action for state 'StreetGreen'.. + """ + self.traffic_light.red = False + self.traffic_light.yellow = False + self.traffic_light.green = True + self.pedestrian.red = True + self.pedestrian.green = False + self.pedestrian.request = False + + def __entry_action_main_region_on_r1_ped_waiting(self): + """Entry action for state 'PedWaiting'.. + """ + self.timer_service.set_timer(self, 0, (7 * 1000), False) + + def __entry_action_main_region_on_r1_ped_waiting_r1_wait_on(self): + """Entry action for state 'waitOn'.. + """ + self.timer_service.set_timer(self, 1, 500, False) + self.pedestrian.request = True + + def __entry_action_main_region_on_r1_ped_waiting_r1_wait_off(self): + """Entry action for state 'waitOff'.. + """ + self.timer_service.set_timer(self, 2, 500, False) + self.pedestrian.request = False + + def __entry_action_main_region_on_r1_street_attention(self): + """Entry action for state 'StreetAttention'.. + """ + self.timer_service.set_timer(self, 3, (2 * 1000), False) + self.traffic_light.red = False + self.traffic_light.yellow = True + self.traffic_light.green = False + + def __entry_action_main_region_on_r1_street_red(self): + """Entry action for state 'StreetRed'.. + """ + self.timer_service.set_timer(self, 4, (2 * 1000), False) + self.traffic_light.red = True + self.traffic_light.yellow = False + self.traffic_light.green = False + + def __entry_action_main_region_on_r1_pedestrian_green(self): + """Entry action for state 'PedestrianGreen'.. + """ + self.timer_service.set_timer(self, 5, (7 * 1000), False) + self.pedestrian.red = False + self.pedestrian.green = True + + def __entry_action_main_region_on_r1_pedestrian_red(self): + """Entry action for state 'PedestrianRed'.. + """ + self.timer_service.set_timer(self, 6, (5 * 1000), False) + self.pedestrian.red = True + self.pedestrian.green = False + + def __entry_action_main_region_on_r1_street_prepare(self): + """Entry action for state 'StreetPrepare'.. + """ + self.timer_service.set_timer(self, 7, (2 * 1000), False) + self.traffic_light.red = True + self.traffic_light.yellow = True + self.traffic_light.green = False + + def __entry_action_main_region_on_r1_safe(self): + """Entry action for state 'Safe'.. + """ + self.timer_service.set_timer(self, 8, (10 * 1000), False) + self.traffic_light.red = True + self.traffic_light.yellow = False + self.traffic_light.green = False + self.pedestrian.red = True + self.pedestrian.green = False + self.pedestrian.request = False + + def __entry_action_main_region_off(self): + """Entry action for state 'off'.. + """ + self.traffic_light.red = False + self.traffic_light.green = False + self.traffic_light.yellow = False + self.pedestrian.red = False + self.pedestrian.green = False + + def __entry_action_main_region_off_r1_yellow_on(self): + """Entry action for state 'YellowOn'.. + """ + self.timer_service.set_timer(self, 9, 500, False) + self.traffic_light.yellow = True + self.pedestrian.request = True + + def __entry_action_main_region_off_r1_yellow_off(self): + """Entry action for state 'YellowOff'.. + """ + self.timer_service.set_timer(self, 10, 500, False) + self.traffic_light.yellow = False + self.pedestrian.request = False + + def __exit_action_main_region_on_r1_ped_waiting(self): + """Exit action for state 'PedWaiting'.. + """ + self.timer_service.unset_timer(self, 0) + self.pedestrian.request = False + + def __exit_action_main_region_on_r1_ped_waiting_r1_wait_on(self): + """Exit action for state 'waitOn'.. + """ + self.timer_service.unset_timer(self, 1) + + def __exit_action_main_region_on_r1_ped_waiting_r1_wait_off(self): + """Exit action for state 'waitOff'.. + """ + self.timer_service.unset_timer(self, 2) + + def __exit_action_main_region_on_r1_street_attention(self): + """Exit action for state 'StreetAttention'.. + """ + self.timer_service.unset_timer(self, 3) + + def __exit_action_main_region_on_r1_street_red(self): + """Exit action for state 'StreetRed'.. + """ + self.timer_service.unset_timer(self, 4) + + def __exit_action_main_region_on_r1_pedestrian_green(self): + """Exit action for state 'PedestrianGreen'.. + """ + self.timer_service.unset_timer(self, 5) + + def __exit_action_main_region_on_r1_pedestrian_red(self): + """Exit action for state 'PedestrianRed'.. + """ + self.timer_service.unset_timer(self, 6) + + def __exit_action_main_region_on_r1_street_prepare(self): + """Exit action for state 'StreetPrepare'.. + """ + self.timer_service.unset_timer(self, 7) + + def __exit_action_main_region_on_r1_safe(self): + """Exit action for state 'Safe'.. + """ + self.timer_service.unset_timer(self, 8) + + def __exit_action_main_region_off_r1_yellow_on(self): + """Exit action for state 'YellowOn'.. + """ + self.timer_service.unset_timer(self, 9) + + def __exit_action_main_region_off_r1_yellow_off(self): + """Exit action for state 'YellowOff'.. + """ + self.timer_service.unset_timer(self, 10) + + def __enter_sequence_main_region_on_default(self): + """'default' enter sequence for state on. + """ + self.__enter_sequence_main_region_on_r1_default() + + def __enter_sequence_main_region_on_r1_street_green_default(self): + """'default' enter sequence for state StreetGreen. + """ + self.__entry_action_main_region_on_r1_street_green() + self.__state_vector[0] = self.State.main_region_on_r1street_green + self.__state_conf_vector_changed = True + + def __enter_sequence_main_region_on_r1_ped_waiting_default(self): + """'default' enter sequence for state PedWaiting. + """ + self.__entry_action_main_region_on_r1_ped_waiting() + self.__enter_sequence_main_region_on_r1_ped_waiting_r1_default() + + def __enter_sequence_main_region_on_r1_ped_waiting_r1_wait_on_default(self): + """'default' enter sequence for state waitOn. + """ + self.__entry_action_main_region_on_r1_ped_waiting_r1_wait_on() + self.__state_vector[0] = self.State.main_region_on_r1ped_waiting_r1wait_on + self.__state_conf_vector_changed = True + + def __enter_sequence_main_region_on_r1_ped_waiting_r1_wait_off_default(self): + """'default' enter sequence for state waitOff. + """ + self.__entry_action_main_region_on_r1_ped_waiting_r1_wait_off() + self.__state_vector[0] = self.State.main_region_on_r1ped_waiting_r1wait_off + self.__state_conf_vector_changed = True + + def __enter_sequence_main_region_on_r1_street_attention_default(self): + """'default' enter sequence for state StreetAttention. + """ + self.__entry_action_main_region_on_r1_street_attention() + self.__state_vector[0] = self.State.main_region_on_r1street_attention + self.__state_conf_vector_changed = True + + def __enter_sequence_main_region_on_r1_street_red_default(self): + """'default' enter sequence for state StreetRed. + """ + self.__entry_action_main_region_on_r1_street_red() + self.__state_vector[0] = self.State.main_region_on_r1street_red + self.__state_conf_vector_changed = True + + def __enter_sequence_main_region_on_r1_pedestrian_green_default(self): + """'default' enter sequence for state PedestrianGreen. + """ + self.__entry_action_main_region_on_r1_pedestrian_green() + self.__state_vector[0] = self.State.main_region_on_r1pedestrian_green + self.__state_conf_vector_changed = True + + def __enter_sequence_main_region_on_r1_pedestrian_red_default(self): + """'default' enter sequence for state PedestrianRed. + """ + self.__entry_action_main_region_on_r1_pedestrian_red() + self.__state_vector[0] = self.State.main_region_on_r1pedestrian_red + self.__state_conf_vector_changed = True + + def __enter_sequence_main_region_on_r1_street_prepare_default(self): + """'default' enter sequence for state StreetPrepare. + """ + self.__entry_action_main_region_on_r1_street_prepare() + self.__state_vector[0] = self.State.main_region_on_r1street_prepare + self.__state_conf_vector_changed = True + + def __enter_sequence_main_region_on_r1_safe_default(self): + """'default' enter sequence for state Safe. + """ + self.__entry_action_main_region_on_r1_safe() + self.__state_vector[0] = self.State.main_region_on_r1safe + self.__state_conf_vector_changed = True + + def __enter_sequence_main_region_off_default(self): + """'default' enter sequence for state off. + """ + self.__entry_action_main_region_off() + self.__enter_sequence_main_region_off_r1_default() + + def __enter_sequence_main_region_off_r1_yellow_on_default(self): + """'default' enter sequence for state YellowOn. + """ + self.__entry_action_main_region_off_r1_yellow_on() + self.__state_vector[0] = self.State.main_region_off_r1yellow_on + self.__state_conf_vector_changed = True + + def __enter_sequence_main_region_off_r1_yellow_off_default(self): + """'default' enter sequence for state YellowOff. + """ + self.__entry_action_main_region_off_r1_yellow_off() + self.__state_vector[0] = self.State.main_region_off_r1yellow_off + self.__state_conf_vector_changed = True + + def __enter_sequence_main_region_default(self): + """'default' enter sequence for region main region. + """ + self.__react_main_region__entry_default() + + def __enter_sequence_main_region_on_r1_default(self): + """'default' enter sequence for region r1. + """ + self.__react_main_region_on_r1__entry_default() + + def __enter_sequence_main_region_on_r1_ped_waiting_r1_default(self): + """'default' enter sequence for region r1. + """ + self.__react_main_region_on_r1_ped_waiting_r1__entry_default() + + def __enter_sequence_main_region_off_r1_default(self): + """'default' enter sequence for region r1. + """ + self.__react_main_region_off_r1__entry_default() + + def __exit_sequence_main_region_on(self): + """Default exit sequence for state on. + """ + self.__exit_sequence_main_region_on_r1() + + def __exit_sequence_main_region_on_r1_street_green(self): + """Default exit sequence for state StreetGreen. + """ + self.__state_vector[0] = self.State.null_state + + def __exit_sequence_main_region_on_r1_ped_waiting(self): + """Default exit sequence for state PedWaiting. + """ + self.__exit_sequence_main_region_on_r1_ped_waiting_r1() + self.__exit_action_main_region_on_r1_ped_waiting() + + def __exit_sequence_main_region_on_r1_ped_waiting_r1_wait_on(self): + """Default exit sequence for state waitOn. + """ + self.__state_vector[0] = self.State.null_state + self.__exit_action_main_region_on_r1_ped_waiting_r1_wait_on() + + def __exit_sequence_main_region_on_r1_ped_waiting_r1_wait_off(self): + """Default exit sequence for state waitOff. + """ + self.__state_vector[0] = self.State.null_state + self.__exit_action_main_region_on_r1_ped_waiting_r1_wait_off() + + def __exit_sequence_main_region_on_r1_street_attention(self): + """Default exit sequence for state StreetAttention. + """ + self.__state_vector[0] = self.State.null_state + self.__exit_action_main_region_on_r1_street_attention() + + def __exit_sequence_main_region_on_r1_street_red(self): + """Default exit sequence for state StreetRed. + """ + self.__state_vector[0] = self.State.null_state + self.__exit_action_main_region_on_r1_street_red() + + def __exit_sequence_main_region_on_r1_pedestrian_green(self): + """Default exit sequence for state PedestrianGreen. + """ + self.__state_vector[0] = self.State.null_state + self.__exit_action_main_region_on_r1_pedestrian_green() + + def __exit_sequence_main_region_on_r1_pedestrian_red(self): + """Default exit sequence for state PedestrianRed. + """ + self.__state_vector[0] = self.State.null_state + self.__exit_action_main_region_on_r1_pedestrian_red() + + def __exit_sequence_main_region_on_r1_street_prepare(self): + """Default exit sequence for state StreetPrepare. + """ + self.__state_vector[0] = self.State.null_state + self.__exit_action_main_region_on_r1_street_prepare() + + def __exit_sequence_main_region_on_r1_safe(self): + """Default exit sequence for state Safe. + """ + self.__state_vector[0] = self.State.null_state + self.__exit_action_main_region_on_r1_safe() + + def __exit_sequence_main_region_off(self): + """Default exit sequence for state off. + """ + self.__exit_sequence_main_region_off_r1() + + def __exit_sequence_main_region_off_r1_yellow_on(self): + """Default exit sequence for state YellowOn. + """ + self.__state_vector[0] = self.State.null_state + self.__exit_action_main_region_off_r1_yellow_on() + + def __exit_sequence_main_region_off_r1_yellow_off(self): + """Default exit sequence for state YellowOff. + """ + self.__state_vector[0] = self.State.null_state + self.__exit_action_main_region_off_r1_yellow_off() + + def __exit_sequence_main_region(self): + """Default exit sequence for region main region. + """ + state = self.__state_vector[0] + if state == self.State.main_region_on_r1street_green: + self.__exit_sequence_main_region_on_r1_street_green() + elif state == self.State.main_region_on_r1ped_waiting_r1wait_on: + self.__exit_sequence_main_region_on_r1_ped_waiting_r1_wait_on() + self.__exit_action_main_region_on_r1_ped_waiting() + elif state == self.State.main_region_on_r1ped_waiting_r1wait_off: + self.__exit_sequence_main_region_on_r1_ped_waiting_r1_wait_off() + self.__exit_action_main_region_on_r1_ped_waiting() + elif state == self.State.main_region_on_r1street_attention: + self.__exit_sequence_main_region_on_r1_street_attention() + elif state == self.State.main_region_on_r1street_red: + self.__exit_sequence_main_region_on_r1_street_red() + elif state == self.State.main_region_on_r1pedestrian_green: + self.__exit_sequence_main_region_on_r1_pedestrian_green() + elif state == self.State.main_region_on_r1pedestrian_red: + self.__exit_sequence_main_region_on_r1_pedestrian_red() + elif state == self.State.main_region_on_r1street_prepare: + self.__exit_sequence_main_region_on_r1_street_prepare() + elif state == self.State.main_region_on_r1safe: + self.__exit_sequence_main_region_on_r1_safe() + elif state == self.State.main_region_off_r1yellow_on: + self.__exit_sequence_main_region_off_r1_yellow_on() + elif state == self.State.main_region_off_r1yellow_off: + self.__exit_sequence_main_region_off_r1_yellow_off() + + def __exit_sequence_main_region_on_r1(self): + """Default exit sequence for region r1. + """ + state = self.__state_vector[0] + if state == self.State.main_region_on_r1street_green: + self.__exit_sequence_main_region_on_r1_street_green() + elif state == self.State.main_region_on_r1ped_waiting_r1wait_on: + self.__exit_sequence_main_region_on_r1_ped_waiting_r1_wait_on() + self.__exit_action_main_region_on_r1_ped_waiting() + elif state == self.State.main_region_on_r1ped_waiting_r1wait_off: + self.__exit_sequence_main_region_on_r1_ped_waiting_r1_wait_off() + self.__exit_action_main_region_on_r1_ped_waiting() + elif state == self.State.main_region_on_r1street_attention: + self.__exit_sequence_main_region_on_r1_street_attention() + elif state == self.State.main_region_on_r1street_red: + self.__exit_sequence_main_region_on_r1_street_red() + elif state == self.State.main_region_on_r1pedestrian_green: + self.__exit_sequence_main_region_on_r1_pedestrian_green() + elif state == self.State.main_region_on_r1pedestrian_red: + self.__exit_sequence_main_region_on_r1_pedestrian_red() + elif state == self.State.main_region_on_r1street_prepare: + self.__exit_sequence_main_region_on_r1_street_prepare() + elif state == self.State.main_region_on_r1safe: + self.__exit_sequence_main_region_on_r1_safe() + + def __exit_sequence_main_region_on_r1_ped_waiting_r1(self): + """Default exit sequence for region r1. + """ + state = self.__state_vector[0] + if state == self.State.main_region_on_r1ped_waiting_r1wait_on: + self.__exit_sequence_main_region_on_r1_ped_waiting_r1_wait_on() + elif state == self.State.main_region_on_r1ped_waiting_r1wait_off: + self.__exit_sequence_main_region_on_r1_ped_waiting_r1_wait_off() + + def __exit_sequence_main_region_off_r1(self): + """Default exit sequence for region r1. + """ + state = self.__state_vector[0] + if state == self.State.main_region_off_r1yellow_on: + self.__exit_sequence_main_region_off_r1_yellow_on() + elif state == self.State.main_region_off_r1yellow_off: + self.__exit_sequence_main_region_off_r1_yellow_off() + + def __react_main_region__entry_default(self): + """Default react sequence for initial entry . + """ + self.__enter_sequence_main_region_off_default() + + def __react_main_region_on_r1_ped_waiting_r1__entry_default(self): + """Default react sequence for initial entry . + """ + self.__enter_sequence_main_region_on_r1_ped_waiting_r1_wait_on_default() + + def __react_main_region_on_r1__entry_default(self): + """Default react sequence for initial entry . + """ + self.__enter_sequence_main_region_on_r1_safe_default() + + def __react_main_region_off_r1__entry_default(self): + """Default react sequence for initial entry . + """ + self.__enter_sequence_main_region_off_r1_yellow_on_default() + + def __react(self, transitioned_before): + """Implementation of __react function. + """ + if self.__current.time_events.traffic_light_ctrl_time_event_0: + self.operation_callback.synchronize() + return transitioned_before + + + def __main_region_on_react(self, transitioned_before): + """Implementation of __main_region_on_react function. + """ + transitioned_after = transitioned_before + if transitioned_after < 0: + if self.__current.iface.on_off: + self.__exit_sequence_main_region_on() + self.__enter_sequence_main_region_off_default() + self.__react(0) + transitioned_after = 0 + if transitioned_after == transitioned_before: + transitioned_after = self.__react(transitioned_before) + return transitioned_after + + + def __main_region_on_r1_street_green_react(self, transitioned_before): + """Implementation of __main_region_on_r1_street_green_react function. + """ + transitioned_after = transitioned_before + if transitioned_after < 0: + if self.__current.iface.pedestrian_request: + self.__exit_sequence_main_region_on_r1_street_green() + self.__enter_sequence_main_region_on_r1_ped_waiting_default() + self.__main_region_on_react(0) + transitioned_after = 0 + if transitioned_after == transitioned_before: + transitioned_after = self.__main_region_on_react(transitioned_before) + return transitioned_after + + + def __main_region_on_r1_ped_waiting_react(self, transitioned_before): + """Implementation of __main_region_on_r1_ped_waiting_react function. + """ + transitioned_after = transitioned_before + if transitioned_after < 0: + if self.__current.time_events.traffic_light_ctrl_main_region_on_r1ped_waiting_time_event_0: + self.__exit_sequence_main_region_on_r1_ped_waiting() + self.__current.time_events.traffic_light_ctrl_main_region_on_r1ped_waiting_time_event_0 = False + self.__enter_sequence_main_region_on_r1_street_attention_default() + self.__main_region_on_react(0) + transitioned_after = 0 + if transitioned_after == transitioned_before: + transitioned_after = self.__main_region_on_react(transitioned_before) + return transitioned_after + + + def __main_region_on_r1_ped_waiting_r1_wait_on_react(self, transitioned_before): + """Implementation of __main_region_on_r1_ped_waiting_r1_wait_on_react function. + """ + transitioned_after = transitioned_before + if transitioned_after < 0: + if self.__current.time_events.traffic_light_ctrl_main_region_on_r1ped_waiting_r1wait_on_time_event_0: + self.__exit_sequence_main_region_on_r1_ped_waiting_r1_wait_on() + self.__current.time_events.traffic_light_ctrl_main_region_on_r1ped_waiting_r1wait_on_time_event_0 = False + self.__enter_sequence_main_region_on_r1_ped_waiting_r1_wait_off_default() + self.__main_region_on_r1_ped_waiting_react(0) + transitioned_after = 0 + if transitioned_after == transitioned_before: + transitioned_after = self.__main_region_on_r1_ped_waiting_react(transitioned_before) + return transitioned_after + + + def __main_region_on_r1_ped_waiting_r1_wait_off_react(self, transitioned_before): + """Implementation of __main_region_on_r1_ped_waiting_r1_wait_off_react function. + """ + transitioned_after = transitioned_before + if transitioned_after < 0: + if self.__current.time_events.traffic_light_ctrl_main_region_on_r1ped_waiting_r1wait_off_time_event_0: + self.__exit_sequence_main_region_on_r1_ped_waiting_r1_wait_off() + self.__current.time_events.traffic_light_ctrl_main_region_on_r1ped_waiting_r1wait_off_time_event_0 = False + self.__enter_sequence_main_region_on_r1_ped_waiting_r1_wait_on_default() + self.__main_region_on_r1_ped_waiting_react(0) + transitioned_after = 0 + if transitioned_after == transitioned_before: + transitioned_after = self.__main_region_on_r1_ped_waiting_react(transitioned_before) + return transitioned_after + + + def __main_region_on_r1_street_attention_react(self, transitioned_before): + """Implementation of __main_region_on_r1_street_attention_react function. + """ + transitioned_after = transitioned_before + if transitioned_after < 0: + if self.__current.time_events.traffic_light_ctrl_main_region_on_r1street_attention_time_event_0: + self.__exit_sequence_main_region_on_r1_street_attention() + self.__current.time_events.traffic_light_ctrl_main_region_on_r1street_attention_time_event_0 = False + self.__enter_sequence_main_region_on_r1_street_red_default() + self.__main_region_on_react(0) + transitioned_after = 0 + if transitioned_after == transitioned_before: + transitioned_after = self.__main_region_on_react(transitioned_before) + return transitioned_after + + + def __main_region_on_r1_street_red_react(self, transitioned_before): + """Implementation of __main_region_on_r1_street_red_react function. + """ + transitioned_after = transitioned_before + if transitioned_after < 0: + if self.__current.time_events.traffic_light_ctrl_main_region_on_r1street_red_time_event_0: + self.__exit_sequence_main_region_on_r1_street_red() + self.__current.time_events.traffic_light_ctrl_main_region_on_r1street_red_time_event_0 = False + self.__enter_sequence_main_region_on_r1_pedestrian_green_default() + self.__main_region_on_react(0) + transitioned_after = 0 + if transitioned_after == transitioned_before: + transitioned_after = self.__main_region_on_react(transitioned_before) + return transitioned_after + + + def __main_region_on_r1_pedestrian_green_react(self, transitioned_before): + """Implementation of __main_region_on_r1_pedestrian_green_react function. + """ + transitioned_after = transitioned_before + if transitioned_after < 0: + if self.__current.time_events.traffic_light_ctrl_main_region_on_r1pedestrian_green_time_event_0: + self.__exit_sequence_main_region_on_r1_pedestrian_green() + self.__current.time_events.traffic_light_ctrl_main_region_on_r1pedestrian_green_time_event_0 = False + self.__enter_sequence_main_region_on_r1_pedestrian_red_default() + self.__main_region_on_react(0) + transitioned_after = 0 + if transitioned_after == transitioned_before: + transitioned_after = self.__main_region_on_react(transitioned_before) + return transitioned_after + + + def __main_region_on_r1_pedestrian_red_react(self, transitioned_before): + """Implementation of __main_region_on_r1_pedestrian_red_react function. + """ + transitioned_after = transitioned_before + if transitioned_after < 0: + if self.__current.time_events.traffic_light_ctrl_main_region_on_r1pedestrian_red_time_event_0: + self.__exit_sequence_main_region_on_r1_pedestrian_red() + self.__current.time_events.traffic_light_ctrl_main_region_on_r1pedestrian_red_time_event_0 = False + self.__enter_sequence_main_region_on_r1_street_prepare_default() + self.__main_region_on_react(0) + transitioned_after = 0 + if transitioned_after == transitioned_before: + transitioned_after = self.__main_region_on_react(transitioned_before) + return transitioned_after + + + def __main_region_on_r1_street_prepare_react(self, transitioned_before): + """Implementation of __main_region_on_r1_street_prepare_react function. + """ + transitioned_after = transitioned_before + if transitioned_after < 0: + if self.__current.time_events.traffic_light_ctrl_main_region_on_r1street_prepare_time_event_0: + self.__exit_sequence_main_region_on_r1_street_prepare() + self.__current.time_events.traffic_light_ctrl_main_region_on_r1street_prepare_time_event_0 = False + self.__enter_sequence_main_region_on_r1_street_green_default() + self.__main_region_on_react(0) + transitioned_after = 0 + if transitioned_after == transitioned_before: + transitioned_after = self.__main_region_on_react(transitioned_before) + return transitioned_after + + + def __main_region_on_r1_safe_react(self, transitioned_before): + """Implementation of __main_region_on_r1_safe_react function. + """ + transitioned_after = transitioned_before + if transitioned_after < 0: + if self.__current.time_events.traffic_light_ctrl_main_region_on_r1safe_time_event_0: + self.__exit_sequence_main_region_on_r1_safe() + self.__current.time_events.traffic_light_ctrl_main_region_on_r1safe_time_event_0 = False + self.__enter_sequence_main_region_on_r1_street_prepare_default() + self.__main_region_on_react(0) + transitioned_after = 0 + if transitioned_after == transitioned_before: + transitioned_after = self.__main_region_on_react(transitioned_before) + return transitioned_after + + + def __main_region_off_react(self, transitioned_before): + """Implementation of __main_region_off_react function. + """ + transitioned_after = transitioned_before + if transitioned_after < 0: + if self.__current.iface.on_off: + self.__exit_sequence_main_region_off() + self.__enter_sequence_main_region_on_default() + self.__react(0) + transitioned_after = 0 + if transitioned_after == transitioned_before: + transitioned_after = self.__react(transitioned_before) + return transitioned_after + + + def __main_region_off_r1_yellow_on_react(self, transitioned_before): + """Implementation of __main_region_off_r1_yellow_on_react function. + """ + transitioned_after = transitioned_before + if transitioned_after < 0: + if self.__current.time_events.traffic_light_ctrl_main_region_off_r1yellow_on_time_event_0: + self.__exit_sequence_main_region_off_r1_yellow_on() + self.__current.time_events.traffic_light_ctrl_main_region_off_r1yellow_on_time_event_0 = False + self.__enter_sequence_main_region_off_r1_yellow_off_default() + self.__main_region_off_react(0) + transitioned_after = 0 + if transitioned_after == transitioned_before: + transitioned_after = self.__main_region_off_react(transitioned_before) + return transitioned_after + + + def __main_region_off_r1_yellow_off_react(self, transitioned_before): + """Implementation of __main_region_off_r1_yellow_off_react function. + """ + transitioned_after = transitioned_before + if transitioned_after < 0: + if self.__current.time_events.traffic_light_ctrl_main_region_off_r1yellow_off_time_event_0: + self.__exit_sequence_main_region_off_r1_yellow_off() + self.__current.time_events.traffic_light_ctrl_main_region_off_r1yellow_off_time_event_0 = False + self.__enter_sequence_main_region_off_r1_yellow_on_default() + self.__main_region_off_react(0) + transitioned_after = 0 + if transitioned_after == transitioned_before: + transitioned_after = self.__main_region_off_react(transitioned_before) + return transitioned_after + + + def __swap_in_events(self): + """Implementation of __swap_in_events function. + """ + self.__current.iface.pedestrian_request = self.pedestrian_request + self.pedestrian_request = False + self.__current.iface.on_off = self.on_off + self.on_off = False + self.__current.time_events.traffic_light_ctrl_main_region_on_r1ped_waiting_time_event_0 = self.__time_events[0] + self.__time_events[0] = False + self.__current.time_events.traffic_light_ctrl_main_region_on_r1ped_waiting_r1wait_on_time_event_0 = self.__time_events[1] + self.__time_events[1] = False + self.__current.time_events.traffic_light_ctrl_main_region_on_r1ped_waiting_r1wait_off_time_event_0 = self.__time_events[2] + self.__time_events[2] = False + self.__current.time_events.traffic_light_ctrl_main_region_on_r1street_attention_time_event_0 = self.__time_events[3] + self.__time_events[3] = False + self.__current.time_events.traffic_light_ctrl_main_region_on_r1street_red_time_event_0 = self.__time_events[4] + self.__time_events[4] = False + self.__current.time_events.traffic_light_ctrl_main_region_on_r1pedestrian_green_time_event_0 = self.__time_events[5] + self.__time_events[5] = False + self.__current.time_events.traffic_light_ctrl_main_region_on_r1pedestrian_red_time_event_0 = self.__time_events[6] + self.__time_events[6] = False + self.__current.time_events.traffic_light_ctrl_main_region_on_r1street_prepare_time_event_0 = self.__time_events[7] + self.__time_events[7] = False + self.__current.time_events.traffic_light_ctrl_main_region_on_r1safe_time_event_0 = self.__time_events[8] + self.__time_events[8] = False + self.__current.time_events.traffic_light_ctrl_main_region_off_r1yellow_on_time_event_0 = self.__time_events[9] + self.__time_events[9] = False + self.__current.time_events.traffic_light_ctrl_main_region_off_r1yellow_off_time_event_0 = self.__time_events[10] + self.__time_events[10] = False + self.__current.time_events.traffic_light_ctrl_time_event_0 = self.__time_events[11] + self.__time_events[11] = False + + + def __clear_in_events(self): + """Implementation of __clear_in_events function. + """ + self.pedestrian_request = False + self.on_off = False + self.__time_events[0] = False + self.__time_events[1] = False + self.__time_events[2] = False + self.__time_events[3] = False + self.__time_events[4] = False + self.__time_events[5] = False + self.__time_events[6] = False + self.__time_events[7] = False + self.__time_events[8] = False + self.__time_events[9] = False + self.__time_events[10] = False + self.__time_events[11] = False + + + def __micro_step(self): + """Implementation of __micro_step function. + """ + state = self.__state_vector[0] + if state == self.State.main_region_on_r1street_green: + self.__main_region_on_r1_street_green_react(-1) + elif state == self.State.main_region_on_r1ped_waiting_r1wait_on: + self.__main_region_on_r1_ped_waiting_r1_wait_on_react(-1) + elif state == self.State.main_region_on_r1ped_waiting_r1wait_off: + self.__main_region_on_r1_ped_waiting_r1_wait_off_react(-1) + elif state == self.State.main_region_on_r1street_attention: + self.__main_region_on_r1_street_attention_react(-1) + elif state == self.State.main_region_on_r1street_red: + self.__main_region_on_r1_street_red_react(-1) + elif state == self.State.main_region_on_r1pedestrian_green: + self.__main_region_on_r1_pedestrian_green_react(-1) + elif state == self.State.main_region_on_r1pedestrian_red: + self.__main_region_on_r1_pedestrian_red_react(-1) + elif state == self.State.main_region_on_r1street_prepare: + self.__main_region_on_r1_street_prepare_react(-1) + elif state == self.State.main_region_on_r1safe: + self.__main_region_on_r1_safe_react(-1) + elif state == self.State.main_region_off_r1yellow_on: + self.__main_region_off_r1_yellow_on_react(-1) + elif state == self.State.main_region_off_r1yellow_off: + self.__main_region_off_r1_yellow_off_react(-1) + + + def run_cycle(self): + """Implementation of run_cycle function. + """ + if self.timer_service is None: + raise ValueError('Timer service must be set.') + + if self.operation_callback is None: + raise ValueError("Operation callback must be set.") + + if self.__is_executing: + return + self.__is_executing = True + self.__swap_in_events() + self.__micro_step() + self.__is_executing = False + + + def enter(self): + """Implementation of enter function. + """ + if self.timer_service is None: + raise ValueError('Timer service must be set.') + + if self.operation_callback is None: + raise ValueError("Operation callback must be set.") + + if self.__is_executing: + return + self.__is_executing = True + self.timer_service.set_timer(self, 11, 200, True) + self.__enter_sequence_main_region_default() + self.__is_executing = False + + + def exit(self): + """Implementation of exit function. + """ + if self.__is_executing: + return + self.__is_executing = True + self.__exit_sequence_main_region() + self.timer_service.unset_timer(self, 11) + self.__is_executing = False + + diff --git a/org.yakindu.sct.examples.trafficlight.python/src/yakindu/__init__.py b/org.yakindu.sct.examples.trafficlight.python/src/yakindu/__init__.py new file mode 100644 index 00000000..6ead0472 --- /dev/null +++ b/org.yakindu.sct.examples.trafficlight.python/src/yakindu/__init__.py @@ -0,0 +1,5 @@ +""" + +Empty file that initializes the package it is contained in. + +""" diff --git a/org.yakindu.sct.examples.trafficlight.python/src/yakindu/timer/__init__.py b/org.yakindu.sct.examples.trafficlight.python/src/yakindu/timer/__init__.py new file mode 100644 index 00000000..6ead0472 --- /dev/null +++ b/org.yakindu.sct.examples.trafficlight.python/src/yakindu/timer/__init__.py @@ -0,0 +1,5 @@ +""" + +Empty file that initializes the package it is contained in. + +""" diff --git a/org.yakindu.sct.examples.trafficlight.python/src/yakindu/timer/timer_service.py b/org.yakindu.sct.examples.trafficlight.python/src/yakindu/timer/timer_service.py new file mode 100644 index 00000000..44689572 --- /dev/null +++ b/org.yakindu.sct.examples.trafficlight.python/src/yakindu/timer/timer_service.py @@ -0,0 +1,94 @@ +""" DefaultTimer module. +Generated by itemis CREATE code generator. +""" + +import threading +import time + +class TimerService: + """Default timer service for timed statecharts. + """ + + def __init__(self): + self.is_default_timer = True + self.timer_queue = {} + self.lock = threading.RLock() + + def set_timer(self, callback, event_id, interval, periodic): + """Schedule the time event. + + Checks if the given time event is already in queue and creates a + timer based on the `periodic`parameter (Single or Repeat). + + Note: statemachine class converts time from sec to milliseconds, + so do vice versa. + """ + timer_id = (callback, event_id) + if timer_id in self.timer_queue: + self.unset_timer(callback, event_id) + m_interval = float(interval)/1000.0 + if periodic is False: + self.timer_queue[timer_id] = SingleTimer(m_interval, callback, event_id) + else: + self.timer_queue[timer_id] = RepeatedTimer(m_interval, callback, event_id) + + def unset_timer(self, callback, event_id): + """Cancel a certain event identified bei `callback` and `event_id`. + """ + timer_id = (callback, event_id) + with self.lock: + if timer_id in self.timer_queue: + event_timer = self.timer_queue[timer_id] + if isinstance(event_timer, RepeatedTimer): + event_timer.stop() + else: + event_timer.single_timer.cancel() + del event_timer + + def cancel(self): + """Cancel all events that are currently running. + """ + with self.lock: + for (callback, event_id) in self.timer_queue: + self.unset_timer(callback, event_id) + + +class SingleTimer: + """Call `function` after `period` seconds. + """ + + def __init__(self, period, callback, event_id): + self.callback = callback + self.event_id = event_id + self.single_timer = threading.Timer(period, self.callback.time_elapsed, [self.event_id]) + self.single_timer.start() + +class RepeatedTimer: + """Repeat `callback` every `interval` seconds. + """ + + def __init__(self, interval, callback, event_id): + self.interval = interval + self.callback = callback + self.event_id = event_id + self.start = time.time() + self.event = threading.Event() + self.thread = threading.Thread(target=self._target) + self.thread.start() + + def _target(self): + while not self.event.wait(self._time): + self.callback.time_elapsed(self.event_id) + + @property + def _time(self): + return self.interval - ((time.time() - self.start) % self.interval) + + def stop(self): + """Stops the repeated timer. + """ + self.event.set() + try: + self.thread.join() + except RuntimeError: + print('Can not join thread') diff --git a/org.yakindu.sct.examples.trafficlight.scxml.qt/index.html b/org.yakindu.sct.examples.trafficlight.scxml.qt/index.html index e963afac..d6d34770 100644 --- a/org.yakindu.sct.examples.trafficlight.scxml.qt/index.html +++ b/org.yakindu.sct.examples.trafficlight.scxml.qt/index.html @@ -11,7 +11,7 @@

    [Pro] Traffic Light (SCXML) for QT

    - This is a simple example for the Qt SCXML integration of YAKINDU + This is a simple example for the Qt SCXML integration of itemis CREATE Statechart Tools. The example is inspired by the traffic light examples that can be found here. The @@ -118,12 +118,12 @@

    Run application

    Run Qt Unit tests

    You can run Qt Unit tests to test the traffic light - statemachine behaviour. For this YAKINDU Statechart Tools provides a + statemachine behaviour. For this itemis CREATE provides a SCTUnit code generator which generates a whole Qt Unit test project.

    • Right-click on 'QtSCXMLTests.sgen' in project folder - traffic_light_qt_scxml in 'Project Explorer' of YAKINDU Statechart + traffic_light_qt_scxml in 'Project Explorer' of itemis CREATE Statechart Tools

    • The folder 'test-gen' should be created containing the @@ -134,7 +134,7 @@

      Run Qt Unit tests

    Run statechart simulation

    -

    Additionally you can simulate the statechart in YAKINDU +

    Additionally you can simulate the statechart in itemis CREATE Statechart Tools by right-click on the 'TrafficLightStateMachine.sct' file and choose:

      diff --git a/org.yakindu.sct.examples.trafficlight.scxml.qt/metadata.json b/org.yakindu.sct.examples.trafficlight.scxml.qt/metadata.json index 0691da15..550d7fba 100644 --- a/org.yakindu.sct.examples.trafficlight.scxml.qt/metadata.json +++ b/org.yakindu.sct.examples.trafficlight.scxml.qt/metadata.json @@ -1,7 +1,7 @@ { "id": "org.yakindu.sct.examples.trafficlight.scxml.qt", "title": "Traffic Light (SCXML) for QT", - "description": "This traffic light is inspired by the Qt examples. It provides a simple traffic light that consists of the main states red, yellow and green. It demonstrates how to connect to the active properties of a state in a dynamically loaded statemachine within YAKINDU Statechart Tools and the Qt environment.", + "description": "This traffic light is inspired by the Qt examples. It provides a simple traffic light that consists of the main states red, yellow and green. It demonstrates how to connect to the active properties of a state in a dynamically loaded statemachine within itemis CREATE and the Qt environment.", "previewImage": "trafficlight.png", "author": "itemis AG", "license": "GNU Free Documentation License version 1.3", diff --git a/org.yakindu.sct.examples.trafficlight.scxml.qt/src/trafficlight-project.pro b/org.yakindu.sct.examples.trafficlight.scxml.qt/src/trafficlight-project.pro index 6086fc62..02eda03b 100644 --- a/org.yakindu.sct.examples.trafficlight.scxml.qt/src/trafficlight-project.pro +++ b/org.yakindu.sct.examples.trafficlight.scxml.qt/src/trafficlight-project.pro @@ -7,7 +7,7 @@ HEADERS = trafficlight.h # install target.path = . INSTALLS += target -TARGET = "YAKINDU Statechart Tools SCXML Example" +TARGET = "itemis CREATE SCXML Example" RESOURCES += \ trafficlight-project.qrc