betfsm.TickingState
Implements a 'ticking' state, i.e. a state that takes a longer time, but cooperatively yields the initiative back to the caller (cooperative concurrency):
note
You can choose whether to tick between entry() and doo() by letting entry() return CONTINUE
note
exit() is always called when execute is called for the last time, even when there are exceptions.
note
expects the following methods to be overridden by subclases:
- entry()
- doo()
- exit()
- reset() (but call super().reset() )
warning
use is similar to State, but if it returns TICKING, it is expected to be called again,
if not, the user needs to call reset() before using the state again.
__init__(name, outcomes)
| Parameters: |
|
|---|
accept(visitor)
calls the visitor with itself and possibly iterates over its children.
See also
Visitor
doo(blackboard)
is repeatedly called after the first time execute() is called.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Note
if this throws an exception, outcome=ABORT and and exit() is called immediately If one likes more detailed behavior, doo needs to catch the exception itself.
entry(blackboard)
called the first time execute() is called.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Note
can raise exception, equivalent to returning ABORT. In that case exit() is called. If one likes more detailed behavior, entry needs to catch the exception itself.
exit()
method that is always called when execute is called the last time
| Returns: |
|
|---|
Note
method has no blackboard parameter, since it could be called from reset() which does not and should not know the blackboard parameter.
Warning
can't raise an exception!
get_global_registry()
classmethod
A log where nodes are only added, a single publisher can periodically erase all nodes from this log. This allows to capture all notes that where active during a period. This is only done when it is turned on by assigning an empty dict to global_publish_log
reset()
External reset of the TickingState to its initial condition. Subclasses should also reset all the children of themselves exit() is called when appropriate