decision_state.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 from flexbe_core import EventState, Logger
3 
4 
5 class DecisionState(EventState):
6  '''
7  Evaluates a condition function in order to return one of the specified outcomes.
8  This state can be used if the further control flow of the behavior depends on an advanced condition.
9 
10  -- outcomes string[] A list containing all possible outcomes of this state
11  -- conditions function Implements the condition check and returns one of the available outcomes.
12  Has to expect one parameter which will be set to input_value.
13 
14  ># input_value object Input to the condition function.
15  '''
16 
17  def __init__(self, outcomes, conditions):
18  '''
19  Constructor
20  '''
21  super(DecisionState, self).__init__(outcomes=outcomes,
22  input_keys=['input_value'])
23  self._conditions = conditions
24 
25  def execute(self, userdata):
26  if self._conditions is not None:
27  outcome = None
28  try:
29  outcome = str(self._conditions(userdata.input_value))
30  except Exception as e:
31  Logger.logwarn('Passed no function as predicate!\n%s' % str(e))
32  outcome = None
33  if outcome is not None and outcome in self._outcomes:
34  return outcome
def __init__(self, outcomes, conditions)


flexbe_states
Author(s): Philipp Schillinger
autogenerated on Sun Dec 13 2020 04:01:46