ExtTrigger/ConsoleOut.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # -*- Python -*-
4 
5 import sys
6 import time
7 
8 import RTC
9 import OpenRTM_aist
10 
11 consoleout_spec = ["implementation_id", "ConsoleOut",
12  "type_name", "ConsoleOut",
13  "description", "Console output component",
14  "version", "1.0",
15  "vendor", "Shinji Kurihara",
16  "category", "example",
17  "activity_type", "DataFlowComponent",
18  "max_instance", "10",
19  "language", "Python",
20  "lang_type", "script",
21  ""]
22 
23 
25  def __init__(self, manager):
26  OpenRTM_aist.DataFlowComponentBase.__init__(self, manager)
27  return
28 
29  def onInitialize(self):
30  self._data = RTC.TimedLong(RTC.Time(0,0),0)
31  self._inport = OpenRTM_aist.InPort("in", self._data)
32  # Set InPort buffer
33  self.addInPort("in", self._inport)
34  return RTC.RTC_OK
35 
36  def onExecute(self, ec_id):
37  if self._inport.isNew():
38  data = self._inport.read()
39  print "Received: ", data.data
40  print "TimeStamp: ", data.tm.sec, "[s] ", data.tm.nsec, "[ns]"
41  time.sleep(0.001)
42  return RTC.RTC_OK
43 
44 
45 def MyModuleInit(manager):
46  profile = OpenRTM_aist.Properties(defaults_str=consoleout_spec)
47  manager.registerFactory(profile,
48  ConsoleOut,
49  OpenRTM_aist.Delete)
50 
51  # Create a component
52  comp = manager.createComponent("ConsoleOut")
53 
54 
55 def main():
56  # Initialize manager
57  mgr = OpenRTM_aist.Manager.init(sys.argv)
58 
59  # Set module initialization proceduer
60  # This procedure will be invoked in activateManager() function.
61  mgr.setModuleInitProc(MyModuleInit)
62 
63  # Activate manager and register to naming service
64  mgr.activateManager()
65 
66  # run the manager in blocking mode
67  # runManager(False) is the default
68  mgr.runManager()
69 
70  # If you want to run the manager in non-blocking mode, do like this
71  # mgr.runManager(True)
72 
73 if __name__ == "__main__":
74  main()
The Properties class represents a persistent set of properties.
Definition: Properties.py:83
def addInPort(self, name, inport)
Definition: RTObject.py:2721
InPort template class.
Definition: InPort.py:58


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