def _config_event(self, name, event): with self._mutex: if self._conf_sets: if event == self.CFG_UPDATE_SET: # A configuration set has been updated cs = self._conf.get_configuration_set(name) self._conf_sets[name]._reload(cs, cs.description, utils.nvlist_to_dict(cs.configuration_data)) elif event == self.CFG_UPDATE_PARAM: # A parameter in a configuration set has been changed cset, param = name.split('.') cs = self._conf.get_configuration_set(cset) data = utils.nvlist_to_dict(cs.configuration_data) self._conf_sets[cset].set_param(param, data[param]) elif event == self.CFG_ADD_SET: # A new configuration set has been added cs = self._conf.get_configuration_set(name) self._conf_sets[name] = ConfigurationSet(self, cs, cs.description, utils.nvlist_to_dict(cs.configuration_data)) elif event == self.CFG_REMOVE_SET: # Remove the configuration set del self._conf_sets[name] elif event == self.CFG_ACTIVATE_SET: # Change the active configuration set self._active_conf_set = name # Call callbacks outside the mutex self._call_cb('config_event', (name, event))
def _config_event(self, name, event): with self._mutex: if self._conf_sets: if event == self.CFG_UPDATE_SET: # A configuration set has been updated cs = self._conf.get_configuration_set(name) self._conf_sets[name]._reload(cs, cs.description, utils.nvlist_to_dict(cs.configuration_data)) elif event == self.CFG_UPDATE_PARAM: # A parameter in a configuration set has been changed cset, param = name.split(".") cs = self._conf.get_configuration_set(cset) data = utils.nvlist_to_dict(cs.configuration_data) self._conf_sets[cset].set_param(param, data[param]) elif event == self.CFG_ADD_SET: # A new configuration set has been added cs = self._conf.get_configuration_set(name) self._conf_sets[name] = ConfigurationSet( self, cs, cs.description, utils.nvlist_to_dict(cs.configuration_data) ) elif event == self.CFG_REMOVE_SET: # Remove the configuration set del self._conf_sets[name] elif event == self.CFG_ACTIVATE_SET: # Change the active configuration set self._active_conf_set = name # Call callbacks outside the mutex self._call_cb("config_event", (name, event))
def _parse(self): # Parse the ConnectorProfile object. with self._mutex: self._name = self._obj.name self._id = self._obj.connector_id self._ports = None self._properties = utils.nvlist_to_dict(self._obj.properties)
def _parse_manager_children(self): # Parses the list returned by _obj.get_slave_managers into child nodes. with self._mutex: try: mgrs = self._obj.get_slave_managers() except CORBA.BAD_OPERATION: # This manager does not support slave managers; ignore return index = 0 for m in mgrs: # Add each slave manager as a child node. try: props = utils.nvlist_to_dict(m.get_profile().properties) except CORBA.TRANSIENT as e: if e.args[0] == TRANSIENT_ConnectFailed: print('{0}: Warning: zombie slave of '\ 'manager {1} found'.format(sys.argv[0], self.name), file=sys.stderr) continue else: raise if 'name' in props: name = props['name'] else: name = 'slave{0}'.format(index) index += 1 leaf = Manager(name, self, m) self._add_child(leaf)
def profile(self): '''The manager's profile.''' with self._mutex: if not self._profile: profile = self._obj.get_profile() self._profile = utils.nvlist_to_dict(profile.properties) return self._profile
def configuration(self): '''The configuration dictionary of the manager.''' with self._mutex: if not self._configuration: self._configuration = utils.nvlist_to_dict( self._obj.get_configuration()) return self._configuration
def profile(self): '''The manager's profile.''' with self._mutex: if not self._profile: profile = self._obj.get_profile() self._profile = nvlist_to_dict(profile.properties) return self._profile
def _parse(self): # Parse the ConnectorProfile object. with self._mutex: self._name = self._obj.name self._id = self._obj.connector_id self._ports = None self._properties = nvlist_to_dict(self._obj.properties)
def _parse_manager_children(self): # Parses the list returned by _obj.get_slave_managers into child nodes. with self._mutex: try: mgrs = self._obj.get_slave_managers() except CORBA.BAD_OPERATION: # This manager does not support slave managers; ignore return index = 0 for m in mgrs: # Add each slave manager as a child node. try: props = nvlist_to_dict(m.get_profile().properties) except CORBA.TRANSIENT as e: if e.args[0] == TRANSIENT_ConnectFailed: print('{0}: Warning: zombie slave of '\ 'manager {1} found'.format(sys.argv[0], self.name), file=sys.stderr) continue else: raise if 'name' in props: name = props['name'] else: name = 'slave{0}'.format(index) index += 1 leaf = Manager(name, self, m) self._add_child(leaf)
def _parse(self): # Parse the ExecutionContext object. with self._mutex: profile = self._obj.get_profile() self._owner = profile.owner self._participants = profile.participants self._properties = nvlist_to_dict(profile.properties)
def factory_profiles(self): '''The factory profiles of all loaded modules.''' with self._mutex: if not self._factory_profiles: self._factory_profiles = [] for fp in self._obj.get_factory_profiles(): self._factory_profiles.append(nvlist_to_dict(fp.properties)) return self._factory_profiles
def loaded_modules(self): '''The list of loaded module profile dictionaries.''' with self._mutex: if not self._loaded_modules: self._loaded_modules = [] for mp in self._obj.get_loaded_modules(): self._loaded_modules.append(nvlist_to_dict(mp.properties)) return self._loaded_modules
def factory_profiles(self): '''The factory profiles of all loaded modules.''' with self._mutex: if not self._factory_profiles: self._factory_profiles = [] for fp in self._obj.get_factory_profiles(): self._factory_profiles.append( utils.nvlist_to_dict(fp.properties)) return self._factory_profiles
def loaded_modules(self): '''The list of loaded module profile dictionaries.''' with self._mutex: if not self._loaded_modules: self._loaded_modules = [] for mp in self._obj.get_loaded_modules(): self._loaded_modules.append( utils.nvlist_to_dict(mp.properties)) return self._loaded_modules
def _parse(self): # Parse the PortService object to build a port profile. with self._mutex: profile = self._obj.get_port_profile() self._name = profile.name self._properties = nvlist_to_dict(profile.properties) if self.owner: prefix = self.owner.instance_name + '.' if self._name.startswith(prefix): self._name = self._name[len(prefix):]
def _parse(self): # Parse the PortService object to build a port profile. with self._mutex: profile = self._obj.get_port_profile() self._name = profile.name self._properties = utils.nvlist_to_dict(profile.properties) if self.owner: prefix = self.owner.instance_name + '.' if self._name.startswith(prefix): self._name = self._name[len(prefix):]
def _parse_configuration(self): # Parse the component's configuration sets with self._mutex: self._conf = self.object.get_configuration() self._conf_sets = {} for cs in self._conf.get_configuration_sets(): self._conf_sets[cs.id] = ConfigurationSet(self, cs, cs.description, nvlist_to_dict(cs.configuration_data)) try: self._active_conf_set = self._conf.get_active_configuration_set().id except SDOPackage.NotAvailable: self._active_conf_set = ''
def _parse(self): # Parse the ExecutionContext object. with self._mutex: if self._is_service: profile = self._obj.get_profile() self._owner = profile.owner self._participants = profile.participants self._properties = utils.nvlist_to_dict(profile.properties) else: self._owner = None self._participants = [] self._properties = []
def _parse_configuration(self): # Parse the component's configuration sets with self._mutex: self._conf = self.object.get_configuration() self._conf_sets = {} for cs in self._conf.get_configuration_sets(): self._conf_sets[cs.id] = ConfigurationSet(self, cs, cs.description, utils.nvlist_to_dict(cs.configuration_data)) try: self._active_conf_set = self._conf.get_active_configuration_set().id except SDOPackage.NotAvailable: self._active_conf_set = ''
def ListRecursive(context, rtclist, name): m_blLength = 100 bl = context.list(m_blLength) cont = True while cont: for i in bl[0]: if i.binding_type == CosNaming.ncontext: next_context = context.resolve(i.binding_name) name_buff = name[:] name.append(i.binding_name[0].id) ListRecursive(next_context,rtclist,name) name = name_buff elif i.binding_type == CosNaming.nobject: if len(rtclist) > m_blLength: break if i.binding_name[0].kind == 'rtc': name_buff = name[:] name_buff.append(i.binding_name[0].id) tkm = OpenRTM_aist.CorbaConsumer() tkm.setObject(context.resolve(i.binding_name)) inobj = tkm.getObject()._narrow(RTC.RTObject) pin = inobj.get_ports() for p in pin: name_buff2 = name_buff[:] profile = p.get_port_profile() props = nvlist_to_dict(profile.properties) tp_n = profile.name.split('.')[1] name_buff2.append(tp_n) rtclist.append([name_buff2,p]) else: pass if CORBA.is_nil(bl[1]): cont = False else: bl = i.next_n(m_blLength)
def _parse_profile(self): # Parse the component's profile with self._mutex: profile = self._obj.get_component_profile() self._instance_name = profile.instance_name self._type_name = profile.type_name self._description = profile.description self._version = profile.version self._vendor = profile.vendor self._category = profile.category if profile.parent: self._parent_obj = profile.parent.get_component_profile().instance_name else: self._parent_obj = "" self._properties = utils.nvlist_to_dict(profile.properties)
def _parse_profile(self): # Parse the component's profile with self._mutex: profile = self._obj.get_component_profile() self._instance_name = profile.instance_name self._type_name = profile.type_name self._description = profile.description self._version = profile.version self._vendor = profile.vendor self._category = profile.category if profile.parent: self._parent_obj = \ profile.parent.get_component_profile().instance_name else: self._parent_obj = '' self._properties = utils.nvlist_to_dict(profile.properties)
def GetDataType(m_port): basic = DataType.basic extended = DataType.extended profile = m_port.get_port_profile() props = nvlist_to_dict(profile.properties) data_type = props["dataport.data_type"] if data_type.startswith("IDL:"): data_type = data_type[4:] colon = data_type.rfind(":") if colon != -1: data_type = data_type[:colon] data_type = data_type.replace("RTC/", "") return GetDataSType(data_type)
def GetDataType(m_port): basic = DataType.basic extended = DataType.extended profile = m_port.get_port_profile() props = nvlist_to_dict(profile.properties) data_type = props['dataport.data_type'] if data_type.startswith('IDL:'): data_type = data_type[4:] colon = data_type.rfind(':') if colon != -1: data_type = data_type[:colon] data_type = data_type.replace('RTC/','') return GetDataSType(data_type)
def parse_port(port_obj, owner): '''Create a port object of the correct type. The correct port object type is chosen based on the port.port_type property of port_obj. @param port_obj The CORBA PortService object to wrap. @param owner The owner of this port. Should be a Component object or None. @return The created port object. ''' profile = port_obj.get_port_profile() props = utils.nvlist_to_dict(profile.properties) if props['port.port_type'] == 'DataInPort': return DataInPort(port_obj, owner) elif props['port.port_type'] == 'DataOutPort': return DataOutPort(port_obj, owner) elif props['port.port_type'] == 'CorbaPort': return CorbaPort(port_obj, owner) else: return Port(port_obj, owner)
def parse_port(port_obj, owner): '''Create a port object of the correct type. The correct port object type is chosen based on the port.port_type property of port_obj. @param port_obj The CORBA PortService object to wrap. @param owner The owner of this port. Should be a Component object or None. @return The created port object. ''' profile = port_obj.get_port_profile() props = nvlist_to_dict(profile.properties) if props['port.port_type'] == 'DataInPort': return DataInPort(port_obj, owner) elif props['port.port_type'] == 'DataOutPort': return DataOutPort(port_obj, owner) elif props['port.port_type'] == 'CorbaPort': return CorbaPort(port_obj, owner) else: return Port(port_obj, owner)
def __init__(self, manager): OpenRTM_aist.DataFlowComponentBase.__init__(self, manager) self.Port = {} _paths = getPathList("localhost",manager) print _paths for i,j in self.PortList.items(): for k in _paths: if j == k[0]: m_data, m_data_type = GetDataType(k[1]) profile = k[1].get_port_profile() props = nvlist_to_dict(profile.properties) if props['port.port_type'] == 'DataInPort': m_port = OpenRTM_aist.OutPort(i, m_data) self.Port[i] = MyPortObject(m_port, m_data) self.addOutPort(i, m_port) m_addport(m_port._objref, k[1], i) elif props['port.port_type'] == 'DataOutPort': m_port = OpenRTM_aist.InPort(i, m_data) self.Port[i] = MyPortObject(m_port, m_data) self.addOutPort(i, m_port) m_addport(m_port._objref, k[1], i) return
def LoadSheet(): if OOoRTC.draw_comp: draw = OOoRTC.draw_comp.draw OOoRTC.draw_comp.mRemoveAllPort() oDrawPages = draw.drawpages oDrawPage = oDrawPages.getByIndex(0) st_control = oDrawPage.getForms().getByIndex(0).getByName('SaveTextBox') text = str(st_control.Text) m_port = re.split(';',text) m_hostname = '' _path = [] for mp in m_port: m_list = re.split('#',mp) if len(m_list) > 10: m_name = re.split(':',m_list[0]) if len(m_name) < 2: return if len(m_name) == 2: for dn in DrawDataPort.DataType.DataTypeList: if m_name[1] == dn: m_name[1] = dn m_i,m_j,_ox,_oy,_or,_sx,_sy,_x,_y,_r,_obj,flag = LoadParam(m_list, oDrawPages) F_Name = m_name[1] + str(m_i) + str(m_j) if m_name[0] == "DataOutPort": OOoRTC.draw_comp.mAddOutPort(F_Name, [[m_name[0],m_name[1]],m_name[1]], [_ox,_oy,_or], [_sx,_sy], [_x, _y, _r], _obj, False) if m_name[0] == 'DataOutPort': OOoRTC.draw_comp.mAddInPort(F_Name, [[m_name[0],m_name[1]],m_name[1]], [_ox,_oy,_or], [_sx,_sy], [_x, _y, _r], _obj, False) else: if m_hostname == m_name[1]: pass else: _paths = OOoRTC.GetPathList(m_name[1], OOoRTC.mgr ,MyMsgBox) m_hostname = m_name[1] if _paths == None: return for p in _paths: if p[0] == m_name: profile = p[1].get_port_profile() props = nvlist_to_dict(profile.properties) m_i,m_j,_ox,_oy,_or,_sx,_sy,_x,_y,_r,_obj,flag = LoadParam(m_list, oDrawPages) F_Name = p[0][-2] + p[0][-1] + str(m_i) + str(m_j) if flag: if props['port.port_type'] == 'DataInPort': OOoRTC.draw_comp.mAddOutPort(F_Name, p, [_ox,_oy,_or], [_sx,_sy], [_x, _y, _r], _obj) if props['port.port_type'] == 'DataOutPort': OOoRTC.draw_comp.mAddInPort(F_Name, p, [_ox,_oy,_or], [_sx,_sy], [_x, _y, _r], _obj)
def GetDataType(m_port): sig = m_DataType.Single sec = m_DataType.Sequence m_string = m_DataType.String m_value = m_DataType.Value profile = m_port.get_port_profile() props = nvlist_to_dict(profile.properties) data_type = props['dataport.data_type'] if data_type.startswith('IDL:'): data_type = data_type[4:] colon = data_type.rfind(':') if colon != -1: data_type = data_type[:colon] data_type = data_type.replace('RTC/','') if data_type == 'TimedDouble': dt = RTC.TimedDouble(RTC.Time(0,0),0) return dt, [float, sig, m_value] elif data_type == 'TimedLong': dt = RTC.TimedLong(RTC.Time(0,0),0) return dt, [long, sig, m_value] elif data_type == 'TimedFloat': dt = RTC.TimedFloat(RTC.Time(0,0),0) return dt, [float, sig, m_value] elif data_type == 'TimedInt': dt = RTC.TimedInt(RTC.Time(0,0),0) return dt, [int, sig, m_value] elif data_type == 'TimedShort': dt = RTC.TimedShort(RTC.Time(0,0),0) return dt, [int, sig, m_value] elif data_type == 'TimedUDouble': dt = RTC.TimedUDouble(RTC.Time(0,0),0) return dt, [float, sig, m_value] elif data_type == 'TimedULong': dt = RTC.TimedULong(RTC.Time(0,0),0) return dt, [long, sig, m_value] elif data_type == 'TimedUFloat': dt = RTC.TimedUFloat(RTC.Time(0,0),0) return dt, [float, sig, m_value] elif data_type == 'TimedUInt': dt = RTC.TimedUInt(RTC.Time(0,0),0) return dt, [int, sig, m_value] elif data_type == 'TimedUShort': dt = RTC.TimedUShort(RTC.Time(0,0),0) return dt, [int, sig, m_value] elif data_type == 'TimedChar': dt = RTC.TimedChar(RTC.Time(0,0),0) return dt, [str, sig, m_string] elif data_type == 'TimedWChar': dt = RTC.TimedWChar(RTC.Time(0,0),0) return dt, [str, sig, m_string] elif data_type == 'TimedBoolean': dt = RTC.TimedBoolean(RTC.Time(0,0),0) return dt, [bool, sig, m_value] elif data_type == 'TimedOctet': dt = RTC.TimedOctet(RTC.Time(0,0),0) return dt, [int, sig, m_value] elif data_type == 'TimedString': dt = RTC.TimedString(RTC.Time(0,0),0) return dt, [str, sig, m_string] elif data_type == 'TimedWString': dt = RTC.TimedWString(RTC.Time(0,0),0) return dt, [str, sig, m_string] elif data_type == 'TimedDoubleSeq': dt = RTC.TimedDoubleSeq(RTC.Time(0,0),[]) return dt, [float, sec, m_value] elif data_type == 'TimedLongSeq': dt = RTC.TimedLongSeq(RTC.Time(0,0),[]) return dt, [long, sec, m_value] elif data_type == 'TimedFloatSeq': dt = RTC.TimedFloatSeq(RTC.Time(0,0),[]) return dt, [float, sec, m_value] elif data_type == 'TimedIntSeq': dt = RTC.TimedIntSeq(RTC.Time(0,0),[]) return dt, [int, sec, m_value] elif data_type == 'TimedShortSeq': dt = RTC.TimedShortSeq(RTC.Time(0,0),[]) return dt, [int, sec, m_value] elif data_type == 'TimedUDoubleSeq': dt = RTC.TimedUDoubleSeq(RTC.Time(0,0),[]) return dt, [float, sec, m_value] elif data_type == 'TimedULongSeq': dt = RTC.TimedULongSeq(RTC.Time(0,0),[]) return dt, [long, sec, m_value] elif data_type == 'TimedUFloatSeq': dt = RTC.TimedUFloatSeq(RTC.Time(0,0),[]) return dt, [float, sec, m_value] elif data_type == 'TimedUIntSeq': dt = RTC.TimedUIntSeq(RTC.Time(0,0),[]) return dt, [int, sec, m_value] elif data_type == 'TimedUShortSeq': dt = RTC.TimedUShortSeq(RTC.Time(0,0),[]) return dt, [int, sec, m_value] elif data_type == 'TimedCharSeq': dt = RTC.TimedCharSeq(RTC.Time(0,0),[]) return dt, [str, sec, m_string] elif data_type == 'TimedWCharSeq': dt = RTC.TimedWCharSeq(RTC.Time(0,0),[]) return dt, [str, sec, m_string] elif data_type == 'TimedBooleanSeq': dt = RTC.TimedBooleanSeq(RTC.Time(0,0),[]) return dt, [bool, sec, m_value] elif data_type == 'TimedOctetSeq': dt = RTC.TimedOctetSeq(RTC.Time(0,0),[]) return dt, [int, sec, m_value] elif data_type == 'TimedStringSeq': dt = RTC.TimedStringSeq(RTC.Time(0,0),[]) return dt, [str, sec, m_string] elif data_type == 'TimedWStringSeq': dt = RTC.TimedWStringSeq(RTC.Time(0,0),[]) return dt, [str, sec, m_string] else: return None
def actionPerformed(self, actionEvent): try: draw = OOoDraw() except NotOOoDrawException: return sobj = draw.document.CurrentSelection if sobj: if sobj.Count > 0: obj = sobj.getByIndex(0) jport, d_type = JudgeDrawObjRTC(obj) if jport: xo_control = self.dlg_control.getControl( ControlName.XoffsetBName ) yo_control = self.dlg_control.getControl( ControlName.YoffsetBName ) ro_control = self.dlg_control.getControl( ControlName.RoffsetBName ) xs_control = self.dlg_control.getControl( ControlName.XscaleBName ) ys_control = self.dlg_control.getControl( ControlName.YscaleBName ) jport._ox = long(xo_control.Text) jport._oy = long(yo_control.Text) jport._or = float(ro_control.Text) jport._sx = long(xs_control.Text) jport._sy = long(ys_control.Text) UpdateSaveSheet() return dtcb_control = self.dlg_control.getControl( ControlName.DataTypeCBName ) dt = str(dtcb_control.Text) if dt != "": F_Name = dt + str(OpenRTM_aist.uuid1()) ptcb_control = self.dlg_control.getControl( ControlName.PortTypeCBName ) pt = str(ptcb_control.Text) for d in DrawDataPort.DataType.DataTypeList: if dt == d: dt = d if pt == "DataOutPort": pt = "DataInPort" else: pt = "DataOutPort" CompAddPort(F_Name, [[pt,dt],dt], self.dlg_control, obj, pt, False) if pt == "DataInPort": MyMsgBox('',OOoRTC.SetCoding(dt+"型のOutPortを作成しました。",'utf-8')) else: MyMsgBox('',OOoRTC.SetCoding(dt+"型のInPortを作成しました。",'utf-8')) UpdateSaveSheet() info_control = self.dlg_control.getControl( ControlName.TextFName ) info_control.setText(OOoRTC.SetCoding('作成済み','utf-8')) return objectTree = self.dlg_control.getControl(ControlName.RTCTreeName) t_comp, nd = OOoRTC.JudgePort(objectTree, self._paths) if t_comp: m_i,m_j = JudgeRTCObjDraw(obj) F_Name = t_comp[0][-2] + t_comp[0][-1] + str(m_i) + str(m_j) profile = t_comp[1].get_port_profile() props = nvlist_to_dict(profile.properties) CompAddPort(F_Name, t_comp, self.dlg_control, obj, props['port.port_type']) t_str = str(m_i) + "ページの" + str(m_j) + "番目の図形と" + t_comp[0][-2] + t_comp[0][-1] + "を関連付けました" MyMsgBox('',OOoRTC.SetCoding(t_str,'utf-8')) UpdateSaveSheet() info_control = self.dlg_control.getControl( ControlName.TextFName ) info_control.setText(OOoRTC.SetCoding('作成済み','utf-8'))
def configuration(self): '''The configuration dictionary of the manager.''' with self._mutex: if not self._configuration: self._configuration = nvlist_to_dict(self._obj.get_configuration()) return self._configuration