-
Notifications
You must be signed in to change notification settings - Fork 1
/
TestComp.py
55 lines (41 loc) · 1.62 KB
/
TestComp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import OpenRTM_aist
import RTC
consolein_spec = ["implementation_id", "ConsoleIn",
"type_name", "ConsoleIn",
"description", "Console input component",
"version", "1.0",
"vendor", "sample",
"category", "example",
"activity_type", "DataFlowComponent",
"max_instance", "10",
"language", "Python",
"lang_type", "script",
""]
class ConsoleIn(OpenRTM_aist.DataFlowComponentBase):
def __init__(self, manager):
OpenRTM_aist.DataFlowComponentBase.__init__(self, manager)
self._data = RTC.TimedShort(RTC.Time(0,0),"")
self._outport = OpenRTM_aist.OutPort("out", self._data)
def onInitialize(self):
self.registerOutPort("out", self._outport)
return RTC.RTC_OK
def onExecute(self, ec_id):
self._data.data = int(sys.stdin.readline())
self._outport.write()
return RTC.RTC_OK
def MyModuleInit(manager):
profile = OpenRTM_aist.Properties(defaults_str=consolein_spec)
manager.registerFactory(profile,
ConsoleIn,
OpenRTM_aist.Delete)
comp = manager.createComponent("ConsoleIn")
def main():
mgr = OpenRTM_aist.Manager.init(sys.argv)
mgr.setModuleInitProc(MyModuleInit)
mgr.activateManager()
mgr.runManager()
if __name__ == "__main__":
main()