Operators of temporal logic
Temporal logic operators are mechanisms that specify the moment at which a finite automaton should execute certain operators of the Julia language and are set on transitions before/inside conditions and in states:
Where are used |
Example |
At transitions, within conditions, and within actions specified in square brackets |
|
Inside states together with the operator group on or inside Julia’s code |
For example, you can use temporal logic operators and the on
operator group to change the values of variables over time:
Here:
-
en, du: y = x
- when entering state A and while it is active, the variabley
is assigned the valuex
. This action is performed immediately and repeated while the state is active. -
on after(2.5, sec): y = 0
- if state A is active for2.5
or more seconds,y
becomes0
. -
on after(5, sec): y = -1
- if state A is active5
or more seconds, theny
becomes0
.5
or more seconds, theny
becomes equal to-1
.
The following temporal logic operators are available in Engee:
-
after
-after(5, sec)
triggers after a specified number of actions or times. For example,after(5, sec)
activates a transition5
seconds after the start of the current state; -
at
- triggers at a specific step. For example,at(10, tick)
will be true at the step when the associated state has a group ofduring
statements executed for the tenth time (starting the count at one); -
before
- remains true until a certain point in time or number of state machine clock cycles is reached. For example,before(3, sec)
is triggered until3
seconds have passed since the associated state was activated; -
count
. - counts how many times the state block has been executed since the logical expression in the parameters became true. For example, the commandon at(10, tick): y = count(true)
will assign they
variable the value10
if the state has been active for10
state machine steps…; -
duration
- is the analogue of thecount
operator, but instead of the number of steps, it returns the time for which the specified logical expression remains true. For example, the commandon after(10, sec): y = duration(true, sec)
will assign values to the variabley
that become greater than10
if the state remains active10
seconds after activation; -
`elapsed, et - returns the time elapsed since the current state was entered. For example,
et >= 2
will be true if the state has been active for two or more seconds; -
every
- triggers after the given number of state machine steps, as long as the associated state remains active. For example, if the associated state is active for10
steps,on every(3, tick): y += 1
will increment the variabley
by one three times consecutively. -
t, getSimulationTime
. - Returns the current simulation time. For example,t >= 10
will be true if the simulation time has reached10
seconds; -
temporalCount
. - is a counter that helps keep track of how many steps the state machine has completed or how much time has passed while the state remained active. For example, callingtemporalCount(tick)
will show how many steps the state machine has been in this state. And usage oftemporalCount(sec)
will return how many seconds have passed since this state was activated.
after
after is an operator that implements temporal logic on transitions. It has two variants of call:
Syntax | Description | Example |
---|---|---|
|
Returns |
[source,julia]. after(3,tick)[x>3] Exits the current state when the block has been activated at least three times since the state became active, provided that |
|
Returns |
[source,julia]. [after(1,tick) || x > 5] after(10,tick)[x > 5] after(n, tick){y = 20;} after(2, sec)[x < 3]{y = 0;} For a better understanding of the examples given, consider:
If the value of variable |
at
at is an operator that checks whether an action has occurred at a certain point in time. It has the following syntax:
Syntax | Description | Example |
---|---|---|
|
Returns |
[source,julia]. at(5, tick)[y < 3] For a better understanding of the examples given, consider:
If during the execution of the 4th clock cycle since the associated state was activated, the value of the |
before
before is an operator that checks whether an action has occurred before the specified point in time. It has the following syntax:
Syntax | Description | Example |
---|---|---|
|
Returns |
[source,julia]. before(3, sec)[x < 5] Transition occurs if less than 3 seconds have elapsed since the state became active, provided |
|
Returns |
[source,julia]. before(4, tick)[y > 2] before(n, sec){z = 0;} before(1, msec)[x != 10]{y = 2;} For a better understanding of the examples given, consider:
A transition occurs if less than |
count
.
count is an operator that counts the number of times the associated state block has been executed since the passed boolean expression became true. The count operator has the following syntax:
Syntax | Description | Example |
---|---|---|
|
Returns the number of state machine clock cycles since the expression |
[source,julia]. [count(x > 2) = 3] Transition occurs if the value of the variable |
duration
duration is an operator that checks how long a certain condition remains true. The duration operator has the following syntax:
Syntax | Description | Example |
---|---|---|
|
Returns the number of units of time elapsed since |
[source,julia]. duration(x > 5) > 3 Transition occurs if more than |
`elapsed, et
elapsed (et) is an operator that keeps track of how much time has passed since the state was activated. The elapsed operator has the following syntax:
Syntax | Description | Example |
---|---|---|
or
|
Returns the number of time units elapsed since the associated state became active. |
[source,julia]. elapsed(sec) >= 3 Transition occurs if 3 seconds or more have elapsed since the state became active. |
every
every is an operator that helps to perform actions at a given frequency. It has the following syntax:
Syntax | Description | Example |
---|---|---|
|
Returns |
[source,julia]. every(3, tick) For a better understanding of the examples given, consider:
If every fourth clock cycle since the activation of the associated state the value of variable |
t, getSimulationTime
.
t (getSimulationTime) is an operator that keeps track of the current simulation time. It has the following syntax:
Syntax | Description | Example |
---|---|---|
or
|
Returns the time in seconds elapsed since the start of the simulation. |
[source,julia]. t >= 5 Transition occurs if the current simulation time has reached 5 seconds or more. |
temporalCount
.
temporalCount is an operator that counts the number of clock cycles or time elapsed since the associated state was activated. The temporalCount operator has the following syntax:
Syntax | Syntax Description | Example |
---|---|---|
|
Returns the number of state machine ticks since the associated state was activated. |
[source,julia]. temporalCount(tick) |
|
Returns the number of specified time units elapsed since the associated state was activated. |
[source,julia]. temporalCount(msec) Returns the time elapsed since the associated state was activated, in milliseconds. |