SdoOrganization.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: euc-jp -*-
3 
4 
16 
17 import sys
18 import omniORB.any
19 from omniORB import CORBA
20 import threading
21 
22 import OpenRTM_aist
23 import SDOPackage, SDOPackage__POA
24 
25 
26 
47 class Organization_impl(SDOPackage__POA.Organization):
48  """
49  """
50 
51 
61  def __init__(self, sdo):
62  self._pId = str(OpenRTM_aist.uuid1())
63  self._org_mutex = threading.RLock()
64 
65  self._orgProperty = SDOPackage.OrganizationProperty([])
66  self._varOwner = sdo
67  self._memberList = []
68  self._dependency = SDOPackage.OWN
69  self._objref = self._this()
70  self.__rtcout = OpenRTM_aist.Manager.instance().getLogbuf("rtobject.sdo_organization")
71 
72 
73  #============================================================
74  #
75  # <<< CORBA interfaces >>>
76  #
77  #============================================================
78 
111  self.__rtcout.RTC_TRACE("get_organization_id() = %s", self._pId)
112  return self._pId
113 
114 
115 
151  self.__rtcout.RTC_TRACE("get_organization_property()")
152  guard = OpenRTM_aist.ScopedLock(self._org_mutex)
153  prop = SDOPackage.OrganizationProperty(self._orgProperty.properties)
154  return prop
155 
156 
157 
198  self.__rtcout.RTC_TRACE("get_organization_property_value(%s)", name)
199  if not name:
200  raise SDOPackage.InvalidParameter("Empty name.")
201 
202  index = OpenRTM_aist.CORBA_SeqUtil.find(self._orgProperty.properties, self.nv_name(name))
203 
204  if index < 0:
205  raise SDOPackage.InvalidParameter("Not found.")
206 
207  try:
208  value = omniORB.any.to_any(self._orgProperty.properties[index].value)
209  return value
210  except:
211  self.__rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
212  raise SDOPackage.InternalError("get_organization_property_value()")
213 
214  # never reach here
215  return None
216 
217 
218 
258  def add_organization_property(self, org_property):
259  self.__rtcout.RTC_TRACE("add_organization_property()")
260  if org_property is None:
261  raise SDOPackage.InvalidParameter("org_property is Empty.")
262 
263  try:
264  guard = OpenRTM_aist.ScopedLock(self._org_mutex)
265  self._orgProperty = org_property
266  return True
267  except:
268  self.__rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
269  raise SDOPackage.InternalError("add_organization_property()")
270 
271  return False
272 
273 
274 
319  def set_organization_property_value(self, name, value):
320  self.__rtcout.RTC_TRACE("set_organization_property_value(name=%s)", name)
321  if not name:
322  raise SDOPackage.InvalidParameter("set_organization_property_value(): Enpty name.")
323 
324  index = OpenRTM_aist.CORBA_SeqUtil.find(self._orgProperty.properties, self.nv_name(name))
325 
326  if index < 0:
327  nv = SDOPackage.NameValue(name, value)
328  OpenRTM_aist.CORBA_SeqUtil.push_back(self._orgProperty.properties, nv)
329  else:
330  self._orgProperty.properties[index].value = value
331 
332  return True
333 
334 
335 
377  self.__rtcout.RTC_TRACE("remove_organization_property(%s)", name)
378  if not name:
379  raise SDOPackage.InvalidParameter("remove_organization_property_value(): Enpty name.")
380 
381  index = OpenRTM_aist.CORBA_SeqUtil.find(self._orgProperty.properties, self.nv_name(name))
382 
383  if index < 0:
384  raise SDOPackage.InvalidParameter("remove_organization_property_value(): Not found.")
385 
386  try:
387  OpenRTM_aist.CORBA_SeqUtil.erase(self._orgProperty.properties, index)
388  return True
389  except:
390  self.__rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
391  raise SDOPackage.InternalError("remove_organization_property_value()")
392 
393  return False
394 
395 
396 
429  def get_owner(self):
430  self.__rtcout.RTC_TRACE("get_owner()")
431  return self._varOwner
432 
433 
434 
475  def set_owner(self, sdo):
476  self.__rtcout.RTC_TRACE("set_owner()")
477  if CORBA.is_nil(sdo):
478  raise SDOPackage.InvalidParameter("set_owner()")
479 
480  try:
481  self._varOwner = sdo
482  return True
483  except:
484  self.__rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
485  raise SDOPackage.InternalError("set_owner()")
486 
487  return True
488 
489 
490 
525  def get_members(self):
526  self.__rtcout.RTC_TRACE("get_members()")
527  try:
528  return self._memberList
529  except:
530  self.__rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
531  raise SDOPackage.InternalError("get_members()")
532 
533 
534 
578  def set_members(self, sdos):
579  self.__rtcout.RTC_TRACE("set_members()")
580  if sdos is None:
581  raise SDOPackage.InvalidParameter("set_members(): SDOList is empty.")
582 
583  try:
584  self._memberList = sdos
585  return True
586  except:
587  self.__rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
588  raise SDOPackage.InternalError("set_members()")
589 
590  return True
591 
592 
593 
631  def add_members(self, sdo_list):
632  self.__rtcout.RTC_TRACE("add_members()")
633  if not sdo_list:
634  raise SDOPackage.InvalidParameter("add_members(): SDOList is empty.")
635 
636  try:
638  return True
639  except:
640  self.__rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
641  raise SDOPackage.InternalError("add_members()")
642 
643  return False
644 
645 
646 
683  def remove_member(self, id):
684  self.__rtcout.RTC_TRACE("remove_member(%s)", id)
685  if not id:
686  self.__rtcout.RTC_ERROR("remove_member(): Enpty name.")
687  raise SDOPackage.InvalidParameter("remove_member(): Empty name.")
688 
689  index = OpenRTM_aist.CORBA_SeqUtil.find(self._memberList, self.sdo_id(id))
690 
691  if index < 0:
692  self.__rtcout.RTC_ERROR("remove_member(): Not found.")
693  raise SDOPackage.InvalidParameter("remove_member(): Not found.")
694 
695  try:
697  return True
698  except:
699  self.__rtcout.RTC_ERROR("unknown exception")
700  raise SDOPackage.InternalError("remove_member(): Not found.")
701 
702  return False
703 
704 
705 
743  def get_dependency(self):
744  self.__rtcout.RTC_TRACE("get_dependency()")
745  return self._dependency
746 
747 
748 
791  def set_dependency(self, dependency):
792  self.__rtcout.RTC_TRACE("set_dependency()")
793  if dependency is None:
794  raise SDOPackage.InvalidParameter("set_dependency(): Empty dependency.")
795 
796  try:
797  self._dependency = dependency
798  return True
799  except:
800  self.__rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
801  raise SDOPackage.InternalError("set_dependency(): Unknown.")
802 
803  return False
804 
805 
806  def getObjRef(self):
807  return self._objref
808 
809 
810 
811  # end of CORBA interface definition
812  #============================================================
813 
814 
815 
822  class nv_name:
823  def __init__(self, name):
824  self._name = name
825 
826  def __call__(self, nv):
827  return str(self._name) == str(nv.name)
828 
829 
836  class sdo_id:
837  def __init__(self, id_):
838  self._id = id_
839 
840  def __call__(self, sdo):
841  id_ = sdo.get_sdo_id()
842  return str(self._id) == str(id_)
843 
def erase(seq, index)
Erase the element of the specified index.
def push_back_list(seq1, seq2)
def push_back(seq, elem)
Push the new element back to the CORBA sequence.
def set_organization_property_value(self, name, value)
[CORBA interface] Set specified value of OrganizationProperty
def set_members(self, sdos)
[CORBA interface] Set SDO&#39;s ServiceProfile
def remove_member(self, id)
[CORBA interface] Remove menber SDO from Organization
def add_members(self, sdo_list)
[CORBA interface] Add the menebr SDOs
def get_dependency(self)
[CORBA interface] Get the DependencyType of the Organization
def add_organization_property(self, org_property)
[CORBA interface] Set OrganizationProperty
def get_organization_id(self)
[CORBA interface] Get Organization Id
def set_owner(self, sdo)
[CORBA interface] Set the orner of the Organization
def get_members(self)
[CORBA interface] Get a menber list of the Organization
def set_dependency(self, dependency)
[CORBA interface] Set the DependencyType of the Organization
Organization implementation class.
def get_organization_property(self)
[CORBA interface] Get OrganizationProperty
def find(seq, f)
Return the index of CORBA sequence element that functor matches.
def get_owner(self)
[CORBA interface] Get the owner of the SDO
def get_organization_property_value(self, name)
[CORBA interface] Get specified value of OrganizationProperty
def remove_organization_property(self, name)
[CORBA interface] Remove specified OrganizationProperty


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Thu Jun 6 2019 19:11:34