log_key_state.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 from flexbe_core import EventState, Logger
4 
5 '''
6 Created on 09.12.2013
7 
8 @author: Philipp Schillinger
9 '''
10 
11 class LogKeyState(EventState):
12  '''
13  A state that can log a predefined message including an input key to precisely inform the operator about what happened to the behavior.
14 
15  -- text string The message to be logged to the terminal Example: 'Counter value: {}'.
16  -- severity uint8 Type of logging (Logger.REPORT_INFO / WARN / HINT / ERROR)
17 
18  #> data object The data provided to be printed in the message. The exact type depends on the request.
19 
20  <= done Indicates that the message has been logged.
21 
22  '''
23 
24  def __init__(self, text, severity = Logger.REPORT_HINT):
25  '''Constructor'''
26  super(LogKeyState, self).__init__(
27  outcomes=['done'],
28  input_keys=['data'])
29 
30  self._text = text
31  self._severity = severity
32 
33 
34  def execute(self, userdata):
35  '''Execute this state'''
36 
37  # Already logged. No need to wait for anything.
38  return 'done'
39 
40 
41  def on_enter(self, userdata):
42  '''Log upon entering the state.'''
43 
44  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 Wed Jun 5 2019 21:52:08