Temporal logic operators
Temporal logic operators are mechanisms that specify the moment when a finite automaton must execute certain Julia language operators and are set at transitions before/inside conditions and in states:
Where they are used |
Example |
On transitions, inside conditions, as well as inside actions specified in square brackets |
|
Inside states together with a group of operators on or inside the Julia code |
For example, using temporal logic operators and the on
group of operators, you can 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 value `x'. This action is performed immediately and repeated while the state is active. -
on after(2.5, sec): y = 0
— if state A is active2.5
or more seconds, theny
becomes '0`. -
on after(5, sec): y = -1
— if state A is active5
or more seconds, theny
becomes equal to-1
.
The following temporal logic operators are available in Engee:
-
after
— it is triggered after a set number of actions or time. For example,after(5, sec)
activates the transition5
seconds after the start of the current state; -
at
— it is triggered at a specific step. For example,at(10, tick)
will be true in the step when the associated state has a group ofduring
statements executed for the tenth time (starting counting from one); -
before
— remains true until a certain point in time or the number of clock cycles of the state machine is reached. For example,before(3, sec)
is triggered until3
seconds have passed since the activation of the associated state; -
count
— counts the number of times the status block has been executed since the boolean expression in the parameter became true. For example, the commandon at(10, tick): y = count(true)
will assign the value10
to the variabley
if the state is active during the10
steps of the state machine.; -
duration
is an analog of thecount
operator, but instead of the number of steps, it returns the time during which the specified boolean expression remains true. For example, the commandon after(10, sec): y = duration(true, sec)`will assign values to the variable `y
that become greater than10
if the state remains active after10
seconds after activation; -
elapsed, et
— returns the time elapsed since entering the current state. For example,et >= 2
will be true if the state has been active for two or more seconds.; -
every
— is triggered after a set number of steps of the state machine, while the associated state remains active. For example, if the associated state is active for10
steps, thenon 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 you 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 usingtemporalCount(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 call options:
Syntax | Description | Example |
---|---|---|
|
Returns |
Exit from the current state when the block has been activated at least three times since the state became active, provided that `x > 3'. |
|
Returns |
For a better understanding of the examples given, consider:
If the value of the 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 |
For a better understanding of the examples given, consider:
If, during the execution of the 4th clock cycle from the moment of activation of the associated state, the value of the variable |
before
before is an operator that checks whether the action occurred before the specified time. It has the following syntax:
Syntax | Description | Example |
---|---|---|
|
Returns |
The transition occurs if less than 3 seconds have passed since the activation of the state, provided that |
|
Returns |
For a better understanding of the examples given, consider:
The transition occurs if less than |
count
count is an operator that counts the number of executions of the associated status block from the moment when the passed boolean expression became true. The count operator has the following syntax:
Syntax | Description | Example |
---|---|---|
|
Returns the number of state machine clock cycles that have elapsed since the expression |
The 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 that have elapsed since the |
The 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 that have elapsed since the associated state became active. |
The transition occurs if 3 or more seconds have passed since the activation of the state. |
every
every is an operator that helps you perform actions with a specified frequency. It has the following syntax:
Syntax | Description | Example |
---|---|---|
|
Returns |
For a better understanding of the examples given, consider:
If every fourth clock cycle since the activation of the associated state, the value of the 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 that has passed since the start of the simulation. |
The 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 the time elapsed since the activation of the associated state. The temporalCount operator has the following syntax:
Syntax | Description | Example |
---|---|---|
|
Returns the number of state machine clock cycles that have elapsed since the associated state was activated. |
|
|
Returns the number of specified time units that have elapsed since the associated state was activated. |
Returns the time elapsed since the associated state was activated, in milliseconds. |