Skip to content

Commit

Permalink
Merge pull request #1080 from JuliaSymbolics/baggepinnen-patch-4
Browse files Browse the repository at this point in the history
Add docstrings to state machine operators
  • Loading branch information
ChrisRackauckas authored Mar 3, 2024
2 parents d24b4c6 + 374c115 commit c2cd249
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions src/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,70 @@ for (s, T) in [(:timeInState, :Real),
@eval $s() = wrap(term($s))
end
end

"""
timeInState()
timeInState(state)
Get the time (in seconds) spent in a state in a finite state machine.
When used to query the time spent in the enclosing state, the method without arguments is used, i.e.,
```
@mtkmodel FSM begin
...
@equations begin
var(k+1) ~ timeInState() >= 2 ? 0.0 : var(k)
end
end
```
If used to query the residence time of another state, the state is passed as an argument.
This operator can be used in both equations and transition conditions.
See also [`ticksInState`](@ref) and [`entry`](@ref)
"""
timeInState

"""
ticksInState()
ticksInState(state)
Get the number of ticks spent in a state in a finite state machine.
When used to query the number of ticks spent in the enclosing state, the method without arguments is used, i.e.,
```
@mtkmodel FSM begin
...
@equations begin
var(k+1) ~ ticksInState() >= 2 ? 0.0 : var(k)
end
end
```
If used to query the number of ticks in another state, the state is passed as an argument.
This operator can be used in both equations and transition conditions.
See also [`timeInState`](@ref) and [`entry`](@ref)
"""
ticksInState

"""
entry()
entry(state)
When used in a finite-state machine, this operator returns true at the first tick when the state is active, and false otherwise.
When used to query the entry of the enclosing state, the method without arguments is used, when used to query the entry of another state, the state is passed as an argument.
This can be used to perform a unique action when entering a state.
"""
entry

"""
activeState(state)
When used in a finite state machine, this operator returns `true` if the queried state is active and false otherwise.
"""
activeState

0 comments on commit c2cd249

Please sign in to comment.