Page History
Info | ||
---|---|---|
| ||
Time in SCCharts. Alexander Schulz-Rosengarten and Reinhard von Hanxleden and Frédéric Mallet and Robert de Simone and Julien Deantoni. In Proc. Forum on Specification and Design Languages (FDL ’18), Munich, Germany, September 2018. |
Clocks
Clocks can be defined to gain access to real time and specify timed transitions.
This feature requires a dynamic tick environment to work. Then the time in all clocks will be automatically updated and the SCChart will requiest a sleep time such that it will wake up when a timed transition will be enabled.
Various annotations (for the root SCChart) can be used to modify the generated behavior.
Annotation | Effect |
---|---|
@NoSleep | Prevents declaration and calculation of sleepT. |
@DefaultSleep | Sets the default sleep time, requested if there is no timed transition for the active state. |
@SimulateSleep | Generates code that simulates the dynamic tick environment by assuming that between ticks always the requested sleep time passes. |
@IntegerClockType | Switches from type float to int for the sleepT and deltaT variables and related calculations. |
@ClocksUseSD | Enables support for concurrent and hierarchical usage of the clock variable. (experimental) |
Code Block | ||||
---|---|---|---|---|
| ||||
scchart SimpleTimes { clock c initial state A if c >= 5 do c = 0 go to B /** Will be reach at time T+5 */ state B if c >= 10 go to C /** Will be reach at time T+15 */ final state C } |
Greedy Bounds
Code Block | ||||
---|---|---|---|---|
| ||||
scchart FastAndSlowGreedy {
region Fast {
clock x = 0
initial state S ""
if x >= 333 do x = 0 go to S
}
region Slow {
clock x = 0
initial state S ""
if x >= 999 || x >= 1000 do x = 0 go to S
}
} |
Periodic Regions
Annotation | Effect |
---|---|
@SoftReset | Prevents declaration and calculation of sleepT |
@HardReset | (default) |
Code Block | ||||
---|---|---|---|---|
| ||||
@DefaultSleep 1000
scchart Motor {
output bool motorL = false, motorR = false
region Left {
@SoftReset
period 4.2
initial state Off ""
do motorL = true go to On
state On ""
do motorL = false go to Off
}
region Right {
@SoftReset
period 1.0
initial state Off ""
do motorR = true go to On
state On ""
do motorR = false go to Off
}
} |
Dynamic Ticks
Dynamic Ticks are based on an extended tick environment that provides deltaT and receives sleepT.
The simulation in KIELER supports a dynamic ticks mode to test models using this feature.
In the simulation view switch mode to Dynamic, see screenshot below.