Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docstrings to state machine operators #1080

Merged
merged 1 commit into from
Mar 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading