betfsm.betfsm.While

Bases: GeneratorWithState

State that contiuously evaluates an underlying state as long as a condition is satisfied.

stateDiagram-v2 direction LR classDef successClass fill:darkgreen,color:white classDef tickingClass fill:yellow,color:black classDef otherClass fill:darkorange,color:white classDef abortClass fill:darkred,color:white state ConditionWhile { direction TB [*] --> my_state state "State" as my_state } [*] --> ConditionWhile my_state --> OTHER : other outcome my_state --> TICKING : ticking<br>condition_cb()==True my_state --> CANCEL : condition_cb()==False class OTHER otherClass class TICKING tickingClass class CANCEL abortClass

__init__(name, condition_cb, state)

Same behavior as the underlying state state, but returns CANCEL if condition_cb(self,condition_cb) ever gets false.

Parameters:
  • name (str) –

    name of the instance

  • condition_cb (Callable) –

    callback function with signature condition(blackboard:Blackboard) -> bool

  • state (TickingState) –

    at each tick of the underlying state, the condition_cb is checked