log_key_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 LogKeyState(EventState):
6  '''
7  A state that can log a predefined message including an input key
8  to precisely inform the operator about what happened to the behavior.
9 
10  -- text string The message to be logged to the terminal Example: 'Counter value: {}'.
11  -- severity uint8 Type of logging (Logger.REPORT_INFO / WARN / HINT / ERROR)
12 
13  #> data object The data provided to be printed in the message. The exact type depends on the request.
14 
15  <= done Indicates that the message has been logged.
16  '''
17 
18  def __init__(self, text, severity=Logger.REPORT_HINT):
19  super(LogKeyState, self).__init__(outcomes=['done'],
20  input_keys=['data'])
21  self._text = text
22  self._severity = severity
23 
24  def execute(self, userdata):
25  # Already logged. No need to wait for anything.
26  return 'done'
27 
28  def on_enter(self, userdata):
29  '''Log upon entering the state.'''
30  Logger.log(self._text.format(userdata.data), self._severity)
def __init__(self, text, severity=Logger.REPORT_HINT)


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