6 from omniORB
import CORBA, URI
8 from omniORB
import any, cdrMarshal, cdrUnmarshal
14 from CorbaNaming
import *
24 def __init__(self, orb_args, nserver_names=["localhost"],
25 orb=None, naming=None):
27 orb = CORBA.ORB_init(orb_args)
33 for ns
in nserver_names :
37 self.
orb.shutdown(wait_for_completion=CORBA.FALSE)
44 def __init__(self, orb, server_name=None, naming=None):
57 ref = self.
naming.resolveStr(name)
58 if ref
is None:
return None 60 return ref._narrow(cl)
71 name_context = self.
naming._rootContext
73 b_list = name_context.list(self.
b_len)
75 rslt = rslt + self.
proc_bd(bd, name_context, parent)
77 t_list = b_list[1].next_n(self.
b_len)
80 rslt = rslt + self.
proc_bd(bd, name_context, parent)
81 t_list = b_list[1].next_n(self.
b_len)
84 def proc_bd(self, bd, name_context, parent) :
93 nam = pre + URI.nameToString(bd.binding_name)
94 if bd.binding_type == CosNaming.nobject :
95 tmp = name_context.resolve(bd.binding_name)
97 print 'objcet '+nam+
' was listed.' 99 tmp = tmp._narrow(RTC.RTObject)
101 print nam+
' is not RTC.' 107 print 'handle for '+nam+
' was created.' 111 print nam+
' is not alive.' , sys.exc_info()[0]
114 tmp = name_context.resolve(bd.binding_name)
115 tmp = tmp._narrow(CosNaming.NamingContext)
125 rslt[tmp.name]=tmp.value.value()
129 for tmp
in dict.keys() :
130 rslt.append(SDOPackage.NameValue(tmp, any.to_any(dict[tmp])))
137 def __init__(self, plist, name = None, id="", prop_dict={}) :
144 self.
name = string.join([tmp.name
for tmp
in plist],
'_')
153 for kk
in self.def_prop :
159 for pp
in self.
plist :
161 (
'Any' in pp.prop[kk])) :
177 if ret == RTC.RTC_OK :
192 def __init__(self, plist, name = None, id="", prop_dict={}) :
197 'dataport.interface_type':
'corba_cdr' ,
198 'dataport.subscription_type':
'flush'}
199 Connector.__init__(self, plist, name, id, prop_dict)
202 def __init__(self, plist, name = None, id="", prop_dict={}) :
204 Connector.__init__(self, plist, name, id, prop_dict)
208 def __init__(self, profile,nv_dict=None,handle=None) :
219 tmp2 = [pp.connector_id
for pp
in tmp1]
220 if self.
con.profile.connector_id
in tmp2 :
222 self.
con.disconnect()
225 return self.
port_profile.port_ref.get_connector_profiles()
231 self.
name = profile.instance_name
234 ref_key =
'port.' + self.
type +
'.' + self.
name 235 self.
ref=self.
port.con.prop_dict[ref_key]
236 if isinstance(self.
ref,str) :
237 self.
ref=port.handle.env.orb.string_to_object(self.
ref)
253 self.
name = profile.instance_name
262 def __init__(self, profile,nv_dict=None, handle=None) :
263 Port.__init__(self, profile, nv_dict, handle)
270 if itf.polarity == RTC.PROVIDED :
272 elif itf.polarity == RTC.REQUIRED :
289 tmp = data_class_str.split(
':')
291 return data_class_str
293 tmp = tmp[1].
split(
'/')
297 def __init__(self, profile, nv_dict=None, handle=None) :
298 Port.__init__(self, profile, nv_dict, handle)
302 self.
ref = self.
con.prop_dict[
'dataport.corba_cdr.inport_ref']
316 self.
ref = self.
con.prop_dict[
'dataport.corba_cdr.inport_ref']
319 return self.
con.disconnect()
322 def __init__(self, profile,nv_dict=None, handle=None) :
323 Port.__init__(self, profile, nv_dict, handle)
324 con_prop_dict={
'dataport.dataflow_type':
'pull',
325 'dataport.buffer.type':
'ringbuffer',
326 'dataport.buffer.read.empty_policy':
'last',
327 'dataport.buffer.length':
'1'}
332 if 'dataport.corba_cdr.outport_ref' in self.
con.prop_dict :
333 self.
ref = self.
con.prop_dict[
'dataport.corba_cdr.outport_ref']
346 tmp2= cdrUnmarshal(self.
data_tc,tmp1[1], 1)
352 print "not supported" 357 if 'dataport.corba_cdr.outport_ref' in self.
con.prop_dict :
358 self.
ref = self.
con.prop_dict[
'dataport.corba_cdr.outport_ref']
361 return self.
con.disconnect()
373 self.
rtc_ref = env.naming.resolve(name)._narrow(RTC.RTObject)
384 conf_set = self.
conf_ref.get_configuration_sets()
399 tmp = pp.get_port_profile()
401 tmp_name = tmp.name.lstrip(self.
name.
split(
'.')[0]).lstrip(
'.')
402 print 'port_name:', tmp_name
404 if tmp_prop[
'port.port_type']==
'DataInPort' :
407 elif tmp_prop[
'port.port_type']==
'DataOutPort' :
410 elif tmp_prop[
'port.port_type']==
'CorbaPort' :
414 def set_conf(self,conf_set_name,param_name,value) :
415 conf_set=self.
conf_set[conf_set_name]
417 conf_set_data[param_name]=value
418 conf_set.configuration_data=
dict2nvlist(conf_set_data)
420 self.
conf_ref.set_configuration_set_values(conf_set)
422 self.
set_conf(conf_set_name,param_name,value)
423 self.
conf_ref.activate_configuration_set(conf_set_name)
445 self.
pname=port.name.replace(
'.',
'_')
448 tmp = self.
pipe.getPortProfile()
462 self.
pname=port.name.replace(
'.',
'_')
465 tmp = self.
pipe.getPortProfile()
479 for i_port
in handle.inports :
480 handle.in_pipe[i_port]=
InPipe(comp, handle.inports[i_port])
482 for o_port
in handle.outports :
483 handle.out_pipe[o_port]=
OutPipe(comp, handle.outports[o_port])
def __init__(self, orb_args, nserver_names=["localhost"], orb=None, naming=None)
def __init__(self, plist, name=None, id="", prop_dict={})
def __init__(self, plist, name=None, id="", prop_dict={})
def __init__(self, plist, name=None, id="", prop_dict={})
def split(input, delimiter)
Split string by delimiter.
def __init__(self, profile, nv_dict=None, handle=None)
def set_conf_activate(self, conf_set_name, param_name, value)
def __init__(self, profile)
def get_object_by_name(self, name, cl=RTC.RTObject)
def list_obj1(self, name_context, parent)
def strip_data_class(data_class_str)
CORBA Naming Service helper class.
def __init__(self, profile, nv_dict=None, handle=None)
def proc_bd(self, bd, name_context, parent)
def __init__(self, comp, port)
def __init__(self, profile, port)
def __init__(self, orb, server_name=None, naming=None)
def __init__(self, name, env, ref=None)
def __init__(self, profile, nv_dict=None, handle=None)
def make_pipe(comp, handle)
def set_conf(self, conf_set_name, param_name, value)
def find(seq, f)
Return the index of CORBA sequence element that functor matches.
def narrow_ref(self, gls)
def get_connections(self)
def __init__(self, profile, nv_dict=None, handle=None)
def __init__(self, comp, port)