Connector.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: utf-8 -*-
00003 # -*- Python -*-
00004 
00005 import sys
00006 
00007 from omniORB import CORBA
00008 
00009 import RTC
00010 import OpenRTM_aist
00011 
00012 def usage():
00013     print "usage: ConnectorComp [options]"
00014     print " python MyServiceProvider.py  "
00015     print " python MyServiceConsumer.py  "
00016     print " python Connector.py  "
00017 
00018 
00019 def main():
00020 
00021     # initialization of ORB
00022     orb = CORBA.ORB_init(sys.argv)
00023 
00024     # get NamingService
00025     naming = OpenRTM_aist.CorbaNaming(orb, "localhost")
00026     
00027     consumer = OpenRTM_aist.CorbaConsumer()
00028     provider = OpenRTM_aist.CorbaConsumer()
00029 
00030     # find MyServiceConsumer0 component
00031     consumer.setObject(naming.resolve("MyServiceConsumer0.rtc"))
00032 
00033     # get ports
00034     consobj = consumer.getObject()._narrow(RTC.RTObject)
00035     pcons = consobj.get_ports()
00036     pcons[0].disconnect_all()
00037 
00038 
00039     # find MyServiceProvider0 component
00040     provider.setObject(naming.resolve("MyServiceProvider0.rtc"))
00041 
00042     # get ports
00043     provobj = provider.getObject()._narrow(RTC.RTObject)
00044     prov = provobj.get_ports()
00045     prov[0].disconnect_all()
00046 
00047 
00048     # connect ports
00049     conprof = RTC.ConnectorProfile("connector0", "", [pcons[0],prov[0]], [])
00050 
00051     ret = pcons[0].connect(conprof)
00052     
00053     # activate ConsoleIn0
00054     eclistin = consobj.get_owned_contexts()
00055     eclistin[0].activate_component(consobj)
00056 
00057     # activate ConsoleOut0
00058     eclistout = provobj.get_owned_contexts()
00059     eclistout[0].activate_component(provobj)
00060 
00061 
00062 
00063 if __name__ == "__main__":
00064         main()


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Thu Aug 27 2015 14:17:28