Go to the documentation of this file.00001
00002
00003
00004
00005 import sys
00006
00007 import RTC
00008 import OpenRTM_aist
00009
00010 consolein_spec = ["implementation_id", "ConsoleIn",
00011 "type_name", "ConsoleIn",
00012 "description", "Console input component",
00013 "version", "1.0",
00014 "vendor", "Shinji Kurihara",
00015 "category", "example",
00016 "activity_type", "DataFlowComponent",
00017 "max_instance", "10",
00018 "language", "Python",
00019 "lang_type", "script",
00020 ""]
00021
00022
00023 class ConsoleIn(OpenRTM_aist.DataFlowComponentBase):
00024 def __init__(self, manager):
00025 OpenRTM_aist.DataFlowComponentBase.__init__(self, manager)
00026 return
00027
00028 def onInitialize(self):
00029 self._data = RTC.TimedLong(RTC.Time(0,0),0)
00030 self._outport = OpenRTM_aist.OutPort("out", self._data)
00031
00032 self.addOutPort("out", self._outport)
00033 return RTC.RTC_OK
00034
00035 def onExecute(self, ec_id):
00036 print "Please input number: ",
00037 self._data.data = long(sys.stdin.readline())
00038 print "Sending to subscriber: ", self._data.data
00039 self._outport.write()
00040 return RTC.RTC_OK
00041
00042
00043 def MyModuleInit(manager):
00044 profile = OpenRTM_aist.Properties(defaults_str=consolein_spec)
00045 manager.registerFactory(profile,
00046 ConsoleIn,
00047 OpenRTM_aist.Delete)
00048
00049
00050 comp = manager.createComponent("ConsoleIn")
00051 return
00052
00053
00054 def main():
00055
00056 mgr = OpenRTM_aist.Manager.init(sys.argv)
00057
00058
00059
00060 mgr.setModuleInitProc(MyModuleInit)
00061
00062
00063 mgr.activateManager()
00064
00065
00066
00067 mgr.runManager()
00068
00069
00070
00071
00072 if __name__ == "__main__":
00073 main()