138 self.
_rtcout = OpenRTM_aist.Manager.instance().getLogbuf(
"SdoServiceAdmin")
140 self._rtcout.RTC_TRACE(
"SdoServiceAdmin::SdoServiceAdmin(%s)",
141 rtobj.getProperties().getProperty(
"instance_name"))
143 prop = self._rtobj.getProperties()
147 enabledProviderTypes = [s.strip()
for s
in prop.getProperty(
"sdo.service.provider.enabled_services").
split(
",")]
148 self._rtcout.RTC_DEBUG(
"sdo.service.provider.enabled_services: %s",
149 prop.getProperty(
"sdo.service.provider.enabled_services"))
151 availableProviderTypes = OpenRTM_aist.SdoServiceProviderFactory.instance().getIdentifiers()
152 prop.setProperty(
"sdo.service.provider.available_services",
153 str(OpenRTM_aist.flatten(availableProviderTypes)))
154 self._rtcout.RTC_DEBUG(
"sdo.service.provider.available_services: %s",
155 prop.getProperty(
"sdo.service.provider.available_services"))
159 activeProviderTypes = []
160 for i
in range(len(enabledProviderTypes)):
161 tmp = enabledProviderTypes[i].lower()
163 activeProviderTypes = availableProviderTypes
164 self._rtcout.RTC_DEBUG(
"sdo.service.provider.enabled_services: ALL")
167 for j
in range(len(availableProviderTypes)):
168 if availableProviderTypes[j] == enabledProviderTypes[i]:
169 activeProviderTypes.append(availableProviderTypes[j])
171 factory = OpenRTM_aist.SdoServiceProviderFactory.instance()
172 for i
in range(len(activeProviderTypes)):
173 svc = factory.createObject(activeProviderTypes[i])
174 propkey = self.
ifrToKey(activeProviderTypes[i])
177 prop.getNode(str(propkey)))
178 prof = SDOPackage.ServiceProfile(str(activeProviderTypes[i]),
179 str(activeProviderTypes[i]),
183 svc.init(rtobj, prof)
184 self._providers.append(svc)
189 constypes = prop.getProperty(
"sdo.service.consumer.enabled_services")
191 self._rtcout.RTC_DEBUG(
"sdo.service.consumer.enabled_services: %s",
194 prop.setProperty(
"sdo.service.consumer.available_services",
195 str(OpenRTM_aist.flatten(OpenRTM_aist.SdoServiceConsumerFactory.instance().getIdentifiers())))
196 self._rtcout.RTC_DEBUG(
"sdo.service.consumer.available_services: %s",
197 prop.getProperty(
"sdo.service.consumer.available_services"))
204 self._rtcout.RTC_DEBUG(
"sdo_service.consumer_types: ALL")
219 len_ = len(self._proiders)
220 for i
in range(len_):
228 for i
in range(len_):
266 if idstr == str(self.
_providers[i].getProfile().id):
269 raise SDOPackage.InvalidParameter()
296 self._rtcout.RTC_TRACE(
"SdoServiceAdmin::addSdoServiceProvider(if=%s)",
301 if id == str(self.
_providers[i].getProfile().id):
302 self._rtcout.RTC_ERROR(
"SDO service(id=%s, ifr=%s) already exists",
303 str(prof.id), str(prof.interface_type))
306 self._providers.append(provider)
319 self._rtcout.RTC_TRACE(
"removeSdoServiceProvider(%d)", id)
324 for i
in range(len_):
326 if strid == str(self.
_providers[idx].getProfile().id):
328 factory = OpenRTM_aist.SdoServiceProviderFactory.instance()
331 self._rtcout.RTC_INFO(
"SDO service provider has been deleted: %s", id)
333 self._rtcout.RTC_WARN(
"Specified SDO service provider not found: %s", id)
346 self._rtcout.RTC_TRACE(
"addSdoServiceConsumer(IFR = %s)",
347 sProfile.interface_type)
348 profile = copy.deepcopy(sProfile)
352 self._rtcout.RTC_ERROR(
"Not supported consumer type. %s", profile.id)
356 self._rtcout.RTC_ERROR(
"type %s already exists.", profile.id)
358 if str(profile.id) ==
"":
359 self._rtcout.RTC_WARN(
"No id specified. It should be given by clients.")
364 id = str(sProfile.id)
366 if id == str(self.
_consumers[i].getProfile().id):
367 self._rtcout.RTC_INFO(
"Existing consumer is reinitilized.")
368 self._rtcout.RTC_DEBUG(
"Propeteis are: %s",
369 NVUtil.toString(sProfile.properties))
374 factory = OpenRTM_aist.SdoServiceConsumerFactory.instance()
375 ctype = str(profile.interface_type)
376 consumer = factory.createObject(ctype)
378 self._rtcout.RTC_ERROR(
"Hmm... consumer must be created.")
382 if not consumer.init(self.
_rtobj, sProfile):
383 self._rtcout.RTC_WARN(
"SDO service initialization was failed.")
384 self._rtcout.RTC_DEBUG(
"id: %s", str(sProfile.id))
385 self._rtcout.RTC_DEBUG(
"IFR: %s", str(sProfile.interface_type))
387 factory.deleteObject(consumer)
388 self._rtcout.RTC_INFO(
"SDO consumer was deleted by initialization failure")
393 self._consumers.append(consumer)
408 if id ==
None or id[0] ==
'\0':
409 self._rtcout.RTC_ERROR(
"removeSdoServiceConsumer(): id is invalid.")
412 self._rtcout.RTC_TRACE(
"removeSdoServiceConsumer(id = %s)", id)
418 if strid == str(cons.getProfile().id):
421 factory = OpenRTM_aist.SdoServiceConsumerFactory.instance()
422 factory.deleteObject(cons)
423 self._rtcout.RTC_INFO(
"SDO service has been deleted: %s", id)
426 self._rtcout.RTC_WARN((
"Specified SDO consumer not found: %s", id))
445 self._rtcout.RTC_DEBUG(
"%s is supported SDO service.",
446 str(sProfile.interface_type))
449 self._rtcout.RTC_WARN(
"Consumer type is not supported: %s",
450 str(sProfile.interface_type))
463 factory = OpenRTM_aist.SdoServiceConsumerFactory.instance()
464 consumerTypes = factory.getIdentifiers()
465 for i
in range(len(consumerTypes)):
466 if consumerTypes[i] == str(sProfile.interface_type):
467 self._rtcout.RTC_DEBUG(
"%s exists in the SDO service factory.", str(sProfile.interface_type))
468 self._rtcout.RTC_PARANOID(
"Available SDO serices in the factory: %s", str(OpenRTM_aist.flatten(consumerTypes)))
470 self._rtcout.RTC_WARN(
"No available SDO service in the factory: %s",
471 str(sProfile.interface_type))
477 return str(OpenRTM_aist.uuid1())
481 ifrvstr = ifr.split(
":")
482 ifrvstr[1] = ifrvstr[1].lower()
483 ifrvstr[1] = ifrvstr[1].replace(
".",
"_")
484 ifrvstr[1] = ifrvstr[1].replace(
"/",
".")
def addSdoServiceConsumer(self, sProfile)
Add Service Consumer bool addSdoServiceConsumer(const SDOPackage::ServiceProfile& sProfile);...
def getServiceProviderProfiles(self)
Get ServiceProfileList of SDO Service ProviderSDOPackage::ServiceProfileList* SdoServiceAdmin::getSer...
def split(input, delimiter)
Split string by delimiter.
def isEnabledConsumerType(self, sProfile)
If it is enabled service typebool SdoServiceAdmin:: isEnabledConsumerType(const SDOPackage::ServicePr...
def addSdoServiceProvider(self, prof, provider)
Set a SDO service providerbool SdoServiceAdmin:: addSdoServiceProvider(const SDOPackage::ServiceProfi...
def __del__(self)
Virtual destractor Virtual destractor.
def removeSdoServiceConsumer(self, id)
Remove Service Consumer bool removeSdoServiceConsumer(const char* id);.
def getServiceProviderProfile(self, id)
Get ServiceProfile of an SDO Service ProviderSDOPackage::ServiceProfile* SdoServiceAdmin::getServiceP...
def toString(nv, name=None)
Get string value in NVList specified by name.
def isExistingConsumerType(self, sProfile)
If it is existing service type bool isExistingConsumerType(const SDOPackage::ServiceProfile& sProfile...
def getServiceProvider(self, id)
Get ServiceProfile of an SDO ServiceSDOPackage::SDOService_ptr SdoServiceAdmin::getServiceProvider(co...
def copyFromProperties(nv, prop)
Copy to NVList from Proeprties.
def __init__(self, rtobj)
Constructor Constructor.
def removeSdoServiceProvider(self, id)
Remove a SDO service providerbool SdoServiceAdmin::removeSdoServiceProvider(const char* id) ...