FunctionalStateMachine.StateMachine
— Typemutable struct StateMachine{T}
Generic state machine functor type.
Example
bar!(usrdata) = IncrementalInference.exitStateMachine
foo!(usrdata) = bar!
sm = StateMachine(next=foo!)
usrdata = nothing
while st(usrdata); end
Notes
- Also see IncrementalInference/test/testStateMachine.jl
FunctionalStateMachine.StateMachine
— MethodRun state machine function (as functor).
Notes
timeout::Union{Real,Nothing}
is optional with default=nothing
.- this code is skipped in lowered and llvm code if not used
- subroutine will use
pollinterval::Real
[seconds] to interrogate duringtimeout::Real
[seconds] period.
- can stop FSM early by using any of the following:
breakafter
,iterlimit
.
- Can
injectDelayBefore
a functionst.next
to help with debugging. - can print FSM steps with
verbose=true
.verbosefid::IOStream
is used as destination for verbose output, default isstdout
.
- FSM steps and
userdata
can be recorded in standardhistory
format usingrecordhistory=true
. housekeeping_cb
is callback to give user access toStateMachine
internals and opportunity to insert bespoke operations.
Example
bar!(usrdata) = IncrementalInference.exitStateMachine
foo!(usrdata) = bar!
sm = StateMachine(next=foo!)
usrdata = nothing
while st(usrdata); end
FunctionalStateMachine.animateStateMachineHistoryByTime
— FunctionDraw simultaneously separate time synchronized frames from each of the desired state machines. These images can be produced into synchronous side-by-side videos which allows for easier debugging and comparison of concurrently running state machines.
FunctionalStateMachine.emptyState
— MethodemptyState(dummy)
Dummy function in case a statemachine.next
is not initialized properly.
FunctionalStateMachine.exitStateMachine
— MethodexitStateMachine(dummy)
Default function used for exiting any state machine.
FunctionalStateMachine.getIterCount
— MethodgetIterCount(st)
How many iterations has this ::StateMachine
stepped through.
FunctionalStateMachine.histGraphStateMachineTransitions
— FunctionCreate a Graphs.incdict
object and populate with nodes (states) and edges (transitions) according to the contents of parameters passed in.
Notes:
- Current implementation repeats duplicate transitions as new edges.
FunctionalStateMachine.sandboxStateMachineStep
— MethodsandboxStateMachineStep(hist, step)
Repeat a state machine step without changing history or primary values.