19 sys.path.insert(1,
".")
45 self.
_observed = [
False for i
in range(OpenRTM.STATUS_KIND_NUM._v)]
88 def init(self, rtobj, profile):
89 if not self._observer.setObject(profile.service):
111 if not self._observer._ptr()._is_equivalent(profile.service):
113 if not tmp.setObject(profile.service):
115 self._observer.releaseObject()
116 self._observer.setObject(profile.service)
166 self._observer._ptr().update_status(statuskind, msg)
168 self._rtobj.removeSdoServiceConsumer(self._profile.id)
180 kinds = [
"COMPONENT_PROFILE",
186 if kind._v < OpenRTM.STATUS_KIND_NUM._v:
187 return kinds[kind._v]
200 if not prop.getProperty(
"observed_status"):
201 prop.setProperty(
"observed_status",
"ALL")
203 observed_ = [s.strip()
for s
in prop.getProperty(
"observed_status").
split(
",")]
204 flags_ = [
False for i
in range(OpenRTM.STATUS_KIND_NUM._v) ]
206 for i
in range(len(observed_)):
207 observed_[i] = observed_[i].upper()
208 if observed_[i] ==
"COMPONENT_PROFILE":
209 flags_[OpenRTM.COMPONENT_PROFILE._v] =
True 210 elif observed_[i] ==
"RTC_STATUS":
211 flags_[OpenRTM.RTC_STATUS._v] =
True 212 elif observed_[i] ==
"EC_STATUS":
213 flags_[OpenRTM.EC_STATUS._v] =
True 214 elif observed_[i] ==
"PORT_PROFILE":
215 flags_[OpenRTM.PORT_PROFILE._v] =
True 216 elif observed_[i] ==
"CONFIGURATION":
217 flags_[OpenRTM.CONFIGURATION._v] =
True 218 elif observed_[i] ==
"ALL":
219 for j
in range(OpenRTM.STATUS_KIND_NUM._v):
225 OpenRTM.COMPONENT_PROFILE._v,
231 OpenRTM.RTC_STATUS._v,
237 OpenRTM.EC_STATUS._v,
243 OpenRTM.PORT_PROFILE._v,
249 OpenRTM.CONFIGURATION._v,
267 if (
not pre[pre_idx])
and next:
270 elif pre[pre_idx]
and (
not next):
302 if OpenRTM_aist.toBool(prop.getProperty(
"heartbeat.enable"),
"YES",
"NO",
False):
303 interval_ = prop.getProperty(
"heartbeat.interval")
305 self._interval.set_time(1.0)
307 tmp_ = float(interval_)
308 self._interval.set_time(tmp_)
312 ComponentObserverConsumer.heartbeat,
354 if not self._compstat.activatedListener:
355 self._compstat.activatedListener = \
356 self._rtobj.addPostComponentActionListener(postclistener_.POST_ON_ACTIVATED,
357 self._compstat.onActivated)
358 if not self._compstat.deactivatedListener:
359 self._compstat.deactivatedListener = \
360 self._rtobj.addPostComponentActionListener(postclistener_.POST_ON_DEACTIVATED,
361 self._compstat.onDeactivated)
363 if not self._compstat.resetListener:
364 self._compstat.resetListener = \
365 self._rtobj.addPostComponentActionListener(postclistener_.POST_ON_RESET,
366 self._compstat.onReset)
368 if not self._compstat.abortingListener:
369 self._compstat.abortingListener = \
370 self._rtobj.addPostComponentActionListener(postclistener_.POST_ON_ABORTING,
371 self._compstat.onAborting)
373 if not self._compstat.finalizeListener:
374 self._compstat.finalizeListener = \
375 self._rtobj.addPostComponentActionListener(postclistener_.POST_ON_FINALIZE,
376 self._compstat.onFinalize)
391 if self._compstat.activatedListener:
392 self._rtobj.removePostComponentActionListener(postclistener_.POST_ON_ACTIVATED,
393 self._compstat.activatedListener)
394 self._compstat.activatedListener =
None 396 if self._compstat.deactivatedListener:
397 self._rtobj.removePostComponentActionListener(postclistener_.POST_ON_DEACTIVATED,
398 self._compstat.deactivatedListener)
399 self._compstat.deactivatedListener =
None 401 if self._compstat.resetListener:
402 self._rtobj.removePostComponentActionListener(postclistener_.POST_ON_RESET,
403 self._compstat.resetListener)
404 self._compstat.resetListener =
None 406 if self._compstat.abortingListener:
407 self._rtobj.removePostComponentActionListener(postclistener_.POST_ON_ABORTING,
408 self._compstat.abortingListener)
409 self._compstat.abortingListener =
None 411 if self._compstat.finalizeListener:
412 self._rtobj.removePostComponentActionListener(postclistener_.POST_ON_FINALIZE,
413 self._compstat.finalizeListener)
414 self._compstat.finalizeListener =
None 432 if not self._portaction.portAddListener:
433 self._portaction.portAddListener = \
434 self._rtobj.addPortActionListener(plistener_.ADD_PORT,
435 self._portaction.onAddPort)
437 if not self._portaction.portRemoveListener:
438 self._portaction.portRemoveListener = \
439 self._rtobj.addPortActionListener(plistener_.REMOVE_PORT,
440 self._portaction.onRemovePort)
443 if not self._portaction.portConnectListener:
444 self._portaction.portConnectListener = \
445 self._rtobj.addPortConnectRetListener(pclistener_.ON_CONNECTED,
446 self._portaction.onConnect)
448 if not self._portaction.portDisconnectListener:
449 self._portaction.portDisconnectListener = \
450 self._rtobj.addPortConnectRetListener(pclistener_.ON_DISCONNECTED,
451 self._portaction.onDisconnect)
465 if self._portaction.portAddListener:
466 self._rtobj.removePortActionListener(plistener_.ADD_PORT,
467 self._portaction.portAddListener)
468 self._portaction.portAddListener =
None 470 if self._portaction.portRemoveListener:
471 self._rtobj.removePortActionListener(plistener_.REMOVE_PORT,
472 self._portaction.portRemoveListener)
473 self._portaction.portRemoveListener =
None 476 if self._portaction.portConnectListener:
477 self._rtobj.removePortConnectRetListener(pclistener_.ON_CONNECTED,
478 self._portaction.portConnectListener)
479 self._portaction.portConnectListener =
None 481 if self._portaction.portDisconnectListener:
482 self._rtobj.removePortConnectRetListener(pclistener_.ON_DISCONNECTED,
483 self._portaction.portDisconnectListener)
484 self._portaction.portDisconnectListener =
None 502 if not self._ecaction.ecAttached:
503 self._ecaction.ecAttached = \
504 self._rtobj.addExecutionContextActionListener(ectype_.EC_ATTACHED,
505 self._ecaction.onAttached)
507 if not self._ecaction.ecDetached:
508 self._ecaction.ecDetached = \
509 self._rtobj.addExecutionContextActionListener(ectype_.EC_DETACHED,
510 self._ecaction.onDetached)
513 if not self._ecaction.ecRatechanged:
514 self._ecaction.ecRatechanged = \
515 self._rtobj.addPostComponentActionListener(pcaltype_.POST_ON_RATE_CHANGED,
516 self._ecaction.onRateChanged)
518 if not self._ecaction.ecStartup:
519 self._ecaction.ecStartup = \
520 self._rtobj.addPostComponentActionListener(pcaltype_.POST_ON_STARTUP,
521 self._ecaction.onStartup)
523 if not self._ecaction.ecShutdown:
524 self._ecaction.ecShutdown = \
525 self._rtobj.addPostComponentActionListener(pcaltype_.POST_ON_SHUTDOWN,
526 self._ecaction.onShutdown)
541 if self._ecaction.ecAttached:
542 self._rtobj.removeExecutionContextActionListener(ectype_.EC_ATTACHED,
543 self._ecaction.ecAttached)
545 if self._ecaction.ecDetached:
546 self._rtobj.removeExecutionContextActionListener(ectype_.EC_ATTACHED,
547 self._ecaction.ecDetached)
550 if self._ecaction.ecRatechanged:
551 self._rtobj.removePostComponentActionListener(pcaltype_.POST_ON_RATE_CHANGED,
552 self._ecaction.ecRatechanged)
554 if self._ecaction.ecStartup:
555 self._rtobj.removePostComponentActionListener(pcaltype_.POST_ON_STARTUP,
556 self._ecaction.ecStartup)
558 if self._ecaction.ecShutdown:
559 self._rtobj.removePostComponentActionListener(pcaltype_.POST_ON_SHUTDOWN,
560 self._ecaction.ecShutdown)
605 self._configMsg.updateConfigParamListener = \
606 self._rtobj.addConfigurationParamListener(confprmlistenertype_.ON_UPDATE_CONFIG_PARAM,
607 self._configMsg.updateConfigParam)
610 self._configMsg.setConfigSetListener = \
611 self._rtobj.addConfigurationSetListener(confsetlistenertype_.ON_SET_CONFIG_SET,
612 self._configMsg.setConfigSet)
614 self._configMsg.addConfigSetListener = \
615 self._rtobj.addConfigurationSetListener(confsetlistenertype_.ON_ADD_CONFIG_SET,
616 self._configMsg.addConfigSet)
619 self._configMsg.updateConfigSetListener = \
620 self._rtobj.addConfigurationSetNameListener(confsetnamelistenertype_.ON_UPDATE_CONFIG_SET,
621 self._configMsg.updateConfigSet)
623 self._configMsg.removeConfigSetListener = \
624 self._rtobj.addConfigurationSetNameListener(confsetnamelistenertype_.ON_REMOVE_CONFIG_SET,
625 self._configMsg.removeConfigSet)
626 self._configMsg.activateConfigSetListener = \
627 self._rtobj.addConfigurationSetNameListener(confsetnamelistenertype_.ON_ACTIVATE_CONFIG_SET,
628 self._configMsg.activateConfigSet)
642 if self._configMsg.updateConfigParamListener:
643 self._rtobj.removeConfigurationParamListener(confprmlistenertype_.ON_UPDATE_CONFIG_PARAM,
644 self._configMsg.updateConfigParamListener)
645 self._configMsg.updateConfigParamListener =
None 648 if self._configMsg.setConfigSetListener:
649 self._rtobj.removeConfigurationSetListener(confsetlistenertype_.ON_SET_CONFIG_SET,
650 self._configMsg.setConfigSetListener)
651 self._configMsg.setConfigSetListener =
None 653 if self._configMsg.addConfigSetListener:
654 self._rtobj.removeConfigurationSetListener(confsetlistenertype_.ON_ADD_CONFIG_SET,
655 self._configMsg.addConfigSetListener)
656 self._configMsg.addConfigSetListener =
None 659 if self._configMsg.updateConfigSetListener:
660 self._rtobj.removeConfigurationSetNameListener(confsetnamelistenertype_.ON_UPDATE_CONFIG_SET,
661 self._configMsg.updateConfigSetListener)
662 self._configMsg.updateConfigSetListener =
None 664 if self._configMsg.removeConfigSetListener:
665 self._rtobj.removeConfigurationSetNameListener(confsetnamelistenertype_.ON_REMOVE_CONFIG_SET,
666 self._configMsg.removeConfigSetListener)
667 self._configMsg.removeConfigSetListener =
None 669 if self._configMsg.activateConfigSetListener:
670 self._rtobj.removeConfigurationSetNameListener(confsetnamelistenertype_.ON_ACTIVATE_CONFIG_SET,
671 self._configMsg.activateConfigSetListener)
672 self._configMsg.activateConfigSetListener =
None 704 if ret == RTC.RTC_OK:
707 self._coc.updateStatus(OpenRTM.RTC_STATUS, msg_)
763 self._coc.updateStatus(OpenRTM.PORT_PROFILE, msg_)
773 self.
onGeneric(
"REMOVE:", str(pprof.name))
779 if ret == RTC.RTC_OK:
786 if ret == RTC.RTC_OK:
818 msg_ = _msg + str(ec_id)
819 self._coc.updateStatus(OpenRTM.EC_STATUS, msg_)
834 if ret == RTC.RTC_OK:
840 if ret == RTC.RTC_OK:
846 if ret == RTC.RTC_OK:
879 msg_ =
"UPDATE_CONFIG_PARAM: " 880 msg_ += configsetname
882 msg_ += configparamname
883 self._coc.updateStatus(OpenRTM.CONFIGURATION, msg_)
888 msg_ =
"SET_CONFIG_SET: " 889 msg_ += config_set.getName()
890 self._coc.updateStatus(OpenRTM.CONFIGURATION, msg_)
895 msg_ =
"ADD_CONFIG_SET: " 896 msg_ += config_set.getName()
897 self._coc.updateStatus(OpenRTM.CONFIGURATION, msg_)
902 msg_ =
"UPDATE_CONFIG_SET: " 903 msg_ += config_set_name
904 self._coc.updateStatus(OpenRTM.CONFIGURATION, msg_)
909 msg_ =
"REMOVE_CONFIG_SET: " 910 msg_ += config_set_name
911 self._coc.updateStatus(OpenRTM.CONFIGURATION, msg_)
916 msg_ =
"ACTIVATE_CONFIG_SET: " 917 msg_ += config_set_name
918 self._coc.updateStatus(OpenRTM.CONFIGURATION, msg_)
922 factory = OpenRTM_aist.SdoServiceConsumerFactory.instance()
923 factory.addFactory(OpenRTM.ComponentObserver._NP_RepositoryId,
924 ComponentObserverConsumer,
def onDetached(self, ec_id)
def activateConfigSet(self, config_set_name)
The types of ConnectorDataListener.
def updateConfigSet(self, config_set_name)
def finalize(self)
Finalizationvirtual void finalize();.
The types of ExecutionContextActionListener.
def reinit(self, profile)
Re-initializationvirtual bool reinit(const SDOPackage::ServiceProfile& profile);. ...
The types of PortActionListener.
def unsetPortProfileListeners(self)
Unsetting port profile listenervoid unsetPortProfileListeners();.
PostComponentActionListener class.
def split(input, delimiter)
Split string by delimiter.
def onConnect(self, portname, pprof, ret)
ExecutionContextActionListener.
def onActivated(self, ec_id, ret)
def removeConfigSet(self, config_set_name)
def setConfigSet(self, config_set)
def updateStatus(self, statuskind, msg)
Calling remote objectinline void updateStatus(OpenRTM::StatusKind statuskind, const char* msg) ...
def copyToProperties(prop, nvlist)
Copy to Proeprties from NVList.
def ComponentObserverConsumerInit(mgr=None)
def toString(self, kind)
Converting kind to stringinline const char* toString(OpenRTM::StatusKind kind)
The Properties class represents a persistent set of properties.
def onGeneric(self, _msg, portname)
def onRateChanged(self, ec_id, ret)
def onDisconnect(self, portname, pprof, ret)
def init(self, rtobj, profile)
Initializationvirtual bool init(RTObject_impl& rtobj, const SDOPackage::ServiceProfile& profile);...
def onAborting(self, ec_id, ret)
def onReset(self, ec_id, ret)
activateConfigSetListener
def setListeners(self, prop)
Connectiong listeners to RTObjectvoid setListeners(coil::Properties& prop);.
The types of ConfigurationSetNameListener.
def switchListeners(self, next, pre, pre_idx, setfunc, unsetfunc)
Switching listeners connecting/disconnectingvoid switchListeners(bool& next, bool& pre...
def unsetConfigurationListeners(self)
Unsetting Configurationlistenervoid unsetConfigurationListeners();.
The types of ConnectorDataListener.
def setHeartbeat(self, prop)
Setting heartbeatvoid setHeartbeat(coil::Properties& prop);.
def onFinalize(self, ec_id, ret)
updateConfigParamListener
def heartbeat(self)
Sending a heartbeart signal to observervoid heartbeat();.
def setComponentStatusListeners(self)
Setting RTC status listenersvoid setComponentStatusListeners();.
def setComponentProfileListeners(self)
Setting ComponentProfile listenervoid setComponentProfileListeners();.
def unsetComponentStatusListeners(self)
Unsetting RTC status listenersvoid unsetComponentStatusListeners();.
def unsetComponentProfileListeners(self)
Unsetting ComponentProfile listenervoid unsetComponentProfileListeners();.
The types of PortConnectRetListenerType.
def setPortProfileListeners(self)
Setting port profile listenervoid setPortProfileListeners();.
def onGeneric(self, _msg, ec_id)
def __init__(self)
ctor of ComponentObserverConsumer
def unsetExecutionContextListeners(self)
Unsetting EC status listenervoid unsetExecutionContextListeners();.
def onDeactivated(self, ec_id, ret)
def onRemovePort(self, pprof)
def onAttached(self, ec_id)
def updateConfigParam(self, configsetname, configparamname)
def onShutdown(self, ec_id, ret)
def setConfigurationListeners(self)
Setting Configuration listenervoid setConfigurationListeners();.
def setExecutionContextListeners(self)
Setting EC status listenervoid setExecutionContextListeners();.
def onAddPort(self, pprof)
The types of ConfigurationSetListener.
def onGeneric(self, msgprefix, ec_id, ret)
def unsetHeartbeat(self)
Unsetting heartbeatvoid unsetHeartbeat();.
def getProfile(self)
getting ServiceProfilevirtual const SDOPackage::ServiceProfile& getProfile() const; ...
def onStartup(self, ec_id, ret)
def addConfigSet(self, config_set)