sdo.py
Go to the documentation of this file.
00001 # -*- Python -*-
00002 # -*- coding: utf-8 -*-
00003 
00004 '''rtctree
00005 
00006 Copyright (C) 2009-2014
00007     Geoffrey Biggs
00008     RT-Synthesis Research Group
00009     Intelligent Systems Research Institute,
00010     National Institute of Advanced Industrial Science and Technology (AIST),
00011     Japan
00012     All rights reserved.
00013 Licensed under the Eclipse Public License -v 1.0 (EPL)
00014 http://www.opensource.org/licenses/eclipse-1.0.txt
00015 
00016 SDO client objects.
00017 
00018 '''
00019 
00020 
00021 import OpenRTM__POA
00022 import RTC
00023 import SDOPackage
00024 
00025 
00026 class RTCObserver(OpenRTM__POA.ComponentObserver):
00027     def __init__(self, target):
00028         self._tgt = target
00029 
00030     def update_status(self, kind, hint):
00031         kind = str(kind)
00032         if kind == 'COMPONENT_PROFILE':
00033             self._tgt._profile_update([x.strip() for x in hint.split(',')])
00034         elif kind == 'RTC_STATUS':
00035             status, ec_handle = hint.split(':')
00036             if status == 'INACTIVE':
00037                 status = self._tgt.INACTIVE
00038             elif status == 'ACTIVE':
00039                 status = self._tgt.ACTIVE
00040             elif status == 'ERROR':
00041                 status = self._tgt.ERROR
00042             self._tgt._set_state_in_ec(int(ec_handle), status)
00043         elif kind == 'EC_STATUS':
00044             event, ec_handle = hint.split(':')
00045             if event == 'ATTACHED':
00046                 event = self._tgt.EC_ATTACHED
00047             elif event == 'DETACHED':
00048                 event = self._tgt.EC_DETACHED
00049             elif event == 'RATE_CHANGED':
00050                 event = self._tgt.EC_RATE_CHANGED
00051             elif event == 'STARTUP':
00052                 event = self._tgt.EC_STARTUP
00053             elif event == 'SHUTDOWN':
00054                 event = self._tgt.EC_SHUTDOWN
00055             self._tgt._ec_event(int(ec_handle), event)
00056         elif kind == 'PORT_PROFILE':
00057             event, port_name = hint.split(':')
00058             if event == 'ADD':
00059                 event = self._tgt.PORT_ADD
00060             elif event == 'REMOVE':
00061                 event = self._tgt.PORT_REMOVE
00062             elif event == 'CONNECT':
00063                 event = self._tgt.PORT_CONNECT
00064             elif event == 'DISCONNECT':
00065                 event = self._tgt.PORT_DISCONNECT
00066             self._tgt._port_event(port_name, event)
00067         elif kind == 'CONFIGURATION':
00068             event, arg = hint.split(':')
00069             if event == 'UPDATE_CONFIGSET':
00070                 event = self._tgt.CFG_UPDATE_SET
00071             elif event == 'UPDATE_PARAMETER':
00072                 event = self._tgt.CFG_UPDATE_PARAM
00073             elif event == 'SET_CONFIG_SET':
00074                 event = self._tgt.CFG_SET_SET
00075             elif event == 'ADD_CONFIG_SET':
00076                 event = self._tgt.CFG_ADD_SET
00077             elif event == 'REMOVE_CONFIG_SET':
00078                 event = self._tgt.CFG_REMOVE_SET
00079             elif event == 'ACTIVATE_CONFIG_SET':
00080                 event = self._tgt.CFG_ACTIVATE_SET
00081             self._tgt._config_event(arg, event)
00082         elif kind == 'HEARTBEAT':
00083             self._tgt._heartbeat()
00084 
00085 
00086 class RTCLogger(OpenRTM__POA.Logger):
00087     def __init__(self, target, callback):
00088         self._tgt = target
00089         self._cb = callback
00090 
00091     def publish(self, record):
00092         ts = record.time.sec + record.time.nsec / 1e9
00093         self._cb(self._tgt.name, ts, loggername, level, message)
00094 
00095 
00096 # vim: tw=79
00097 


rtctree
Author(s): Geoffrey Biggs
autogenerated on Wed Aug 26 2015 16:13:08