ExtTrigger/ConsoleIn.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 import RTC
8 import OpenRTM_aist
9 
10 consolein_spec = ["implementation_id", "ConsoleIn",
11  "type_name", "ConsoleIn",
12  "description", "Console input component",
13  "version", "1.0",
14  "vendor", "Shinji Kurihara",
15  "category", "example",
16  "activity_type", "DataFlowComponent",
17  "max_instance", "10",
18  "language", "Python",
19  "lang_type", "script",
20  ""]
21 
22 
24  def __init__(self, manager):
25  OpenRTM_aist.DataFlowComponentBase.__init__(self, manager)
26  return
27 
28  def onInitialize(self):
29  self._data = RTC.TimedLong(RTC.Time(0,0),0)
30  self._outport = OpenRTM_aist.OutPort("out", self._data)
31  # Set OutPort buffer
32  self.addOutPort("out", self._outport)
33  return RTC.RTC_OK
34 
35  def onExecute(self, ec_id):
36  print "Please input number: ",
37  self._data.data = long(sys.stdin.readline())
38  print "Sending to subscriber: ", self._data.data
39  self._outport.write()
40  return RTC.RTC_OK
41 
42 
43 def MyModuleInit(manager):
44  profile = OpenRTM_aist.Properties(defaults_str=consolein_spec)
45  manager.registerFactory(profile,
46  ConsoleIn,
47  OpenRTM_aist.Delete)
48 
49  # Create a component
50  comp = manager.createComponent("ConsoleIn")
51  return
52 
53 
54 def main():
55  # Initialize manager
56  mgr = OpenRTM_aist.Manager.init(sys.argv)
57 
58  # Set module initialization proceduer
59  # This procedure will be invoked in activateManager() function.
60  mgr.setModuleInitProc(MyModuleInit)
61 
62  # Activate manager and register to naming service
63  mgr.activateManager()
64 
65  # run the manager in blocking mode
66  # runManager(False) is the default
67  mgr.runManager()
68 
69  # If you want to run the manager in non-blocking mode, do like this
70  # mgr.runManager(True)
71 
72 if __name__ == "__main__":
73  main()
The Properties class represents a persistent set of properties.
Definition: Properties.py:83
def addOutPort(self, name, outport)
Definition: RTObject.py:2765


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Thu Jun 6 2019 19:11:34