SimpleService/Connector.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # -*- Python -*-
4 
5 import sys
6 
7 from omniORB import CORBA
8 
9 import RTC
10 import OpenRTM_aist
11 
12 def usage():
13  print "usage: ConnectorComp [options]"
14  print " python MyServiceProvider.py "
15  print " python MyServiceConsumer.py "
16  print " python Connector.py "
17 
18 
19 def main():
20 
21  # initialization of ORB
22  orb = CORBA.ORB_init(sys.argv)
23 
24  # get NamingService
25  naming = OpenRTM_aist.CorbaNaming(orb, "localhost")
26 
27  consumer = OpenRTM_aist.CorbaConsumer()
28  provider = OpenRTM_aist.CorbaConsumer()
29 
30  # find MyServiceConsumer0 component
31  consumer.setObject(naming.resolve("MyServiceConsumer0.rtc"))
32 
33  # get ports
34  consobj = consumer.getObject()._narrow(RTC.RTObject)
35  pcons = consobj.get_ports()
36  pcons[0].disconnect_all()
37 
38 
39  # find MyServiceProvider0 component
40  provider.setObject(naming.resolve("MyServiceProvider0.rtc"))
41 
42  # get ports
43  provobj = provider.getObject()._narrow(RTC.RTObject)
44  prov = provobj.get_ports()
45  prov[0].disconnect_all()
46 
47 
48  # connect ports
49  conprof = RTC.ConnectorProfile("connector0", "", [pcons[0],prov[0]], [])
50 
51  ret = pcons[0].connect(conprof)
52 
53  # activate ConsoleIn0
54  eclistin = consobj.get_owned_contexts()
55  eclistin[0].activate_component(consobj)
56 
57  # activate ConsoleOut0
58  eclistout = provobj.get_owned_contexts()
59  eclistout[0].activate_component(provobj)
60 
61 
62 
63 if __name__ == "__main__":
64  main()
CORBA Naming Service helper class.
Definition: CorbaNaming.py:61


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Mon Feb 28 2022 23:01:06