log_key_state.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 from flexbe_core import EventState, Logger
00004 
00005 '''
00006 Created on 09.12.2013
00007 
00008 @author: Philipp Schillinger
00009 '''
00010 
00011 class LogKeyState(EventState):
00012         '''
00013         A state that can log a predefined message including an input key to precisely inform the operator about what happened to the behavior.
00014         
00015         -- text         string  The message to be logged to the terminal Example:  'Counter value:  {}'.
00016         -- severity uint8       Type of logging (Logger.REPORT_INFO / WARN / HINT / ERROR)
00017 
00018         #> data         object          The data provided to be printed in the message. The exact type depends on the request.
00019 
00020         <= done                         Indicates that the message has been logged.
00021         
00022         '''
00023         
00024         def __init__(self, text, severity = Logger.REPORT_HINT):
00025                 '''Constructor'''
00026                 super(LogKeyState, self).__init__(
00027                                                                                         outcomes=['done'],
00028                                                                                         input_keys=['data'])
00029                 
00030                 self._text = text
00031                 self._severity = severity
00032 
00033                 
00034         def execute(self, userdata):
00035                 '''Execute this state'''
00036                 
00037                 # Already logged. No need to wait for anything.
00038                 return 'done'
00039 
00040         
00041         def on_enter(self, userdata):
00042                 '''Log upon entering the state.'''
00043 
00044                 Logger.log(self._text.format(userdata.data), self._severity)


flexbe_states
Author(s): Philipp Schillinger
autogenerated on Thu Jun 6 2019 19:32:33