README_gen.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- python -*-
3 #
4 # @file README_src.py
5 # @brief rtc-template RTComponent's README file generator class
6 # @date $Date: 2007/01/11 07:47:03 $
7 # @author Noriaki Ando <n-ando@aist.go.jp>
8 #
9 # Copyright (C) 2004-2005
10 # Task-intelligence Research Group,
11 # Intelligent Systems Research Institute,
12 # National Institute of
13 # Advanced Industrial Science and Technology (AIST), Japan
14 # All rights reserved.
15 #
16 # $Id: README_gen.py 775 2008-07-28 16:14:45Z n-ando $
17 #
18 
19 import os
20 import time
21 import yat
22 import gen_base
23 
24 readme = """#======================================================================
25 # RTComponent: [basicInfo.name] specificatioin
26 #
27 # OpenRTM-aist-[version]
28 #
29 # Date: [date]
30 #
31 # This file is generated by rtc-template with the following argments.
32 #
33 [for args in fmtd_args]
34 # [if-index args is first][else] [endif]
35 [args][if-index args is last][else]\\[endif]
36 
37 [endfor]
38 #
39 #======================================================================
40 # Basic Information
41 #======================================================================
42 # <rtc-template block="module">
43 # </rtc-template>
44 #======================================================================
45 # Activity definition
46 #======================================================================
47 # <rtc-template block="actions">
48 # </rtc-template>
49 #======================================================================
50 # InPorts definition
51 #======================================================================
52 # <rtc-template block="inport">
53 # </rtc-template>
54 #======================================================================
55 # OutPorts definition
56 #======================================================================
57 # <rtc-template block="outport">
58 # </rtc-template>
59 #======================================================================
60 # Service definition
61 #======================================================================
62 # <rtc-template block="service">
63 # </rtc-template>
64 #======================================================================
65 # Configuration definition
66 #======================================================================
67 # <rtc-template block="configuration">
68 # </rtc-template>
69 """
70 
71 module = """Basic Information:
72  Description: [basicInfo.description]
73 
74  Version: [basicInfo.version]
75 
76  Author: [basicInfo.vendor]
77 
78  Category: [basicInfo.category]
79 
80  Comp. Type: [basicInfo.componentType]
81 
82  Act. Type: [basicInfo.activityType]
83 
84  MAX Inst.: [basicInfo.maxInstances]
85 
86  Lang:
87  Lang Type:
88 """
89 
90 inport = """InPorts:
91 [for inport in dataPorts]
92 [if inport.portType is DataInPort]
93  Name: [inport.name]
94 
95  VarName: [inport.rtcExt::varname]
96 
97  PortNumber: [inport.rtcDoc::doc.number]
98 
99  Description: [inport.rtcDoc::doc.description]
100 
101  Type: [inport.type]
102 
103  InterfaceType: [inport.interfaceType]
104 
105  DataflowType: [inport.dataflowType]
106 
107  SubscriptionType: [inport.subscriptionType]
108 
109  MaxOut:
110 
111 [endif]
112 [endfor]
113 """
114 
115 outport = """OutPorts:
116 [for outport in dataPorts]
117 [if outport.portType is DataOutPort]
118  Name: [outport.name]
119 
120  VarName: [outport.rtcExt::varname]
121 
122  PortNumber: [outport.rtcDoc::doc.number]
123 
124  Description: [outport.rtcDoc::doc.description]
125 
126  Type: [outport.type]
127 
128  InterfaceType: [outport.interfaceType]
129 
130  DataflowType: [outport.dataflowType]
131 
132  SubscriptionType: [outport.subscriptionType]
133 
134  MaxOut:
135 
136 [endif]
137 [endfor]
138 """
139 service = """ServicePorts:
140 [for service in servicePorts]
141  PortName: [service.name]
142 
143  Description: [service.rtcDoc::doc.description]
144 
145  InterfaceDescription: [service.rtcDoc::doc.ifdescription]
146 
147  Position: [service.rtcExt::position]
148 
149  Interfaces:
150 [for svcif in service.serviceInterface]
151  Name: [svcif.name]
152 
153  Description: [svcif.rtcDoc::doc.description]
154 
155  Type: [svcif.type]
156 
157  Direction: [svcif.direction]
158 
159  InstanceName: [svcif.instanceName]
160 
161  IDLfile: [svcif.idlFile]
162 
163  FilePath: [svcif.path]
164 
165 [endfor]
166 
167 [endfor]
168 
169 """
170 
171 configuration = """Configuration:
172 [for config in configurationSet.configuration]
173  Name: [config.name]
174 
175  Description: [config.rtcDoc::doc.description]
176 
177  Type: [config.type]
178 
179  DefaultValue: [config.defaultValue]
180 
181  Range: [config.rtcDoc::doc.range]
182 
183  Unit: [config.rtcDoc::doc.unit]
184 
185  Constraint: [config.rtcDoc::doc.constraint]
186 
187 
188 [endfor]"""
189 
191  def __init__(self, data):
192  self.data = data.copy()
193  self.data['fname'] = "README." + self.data['basicInfo']['name']
194  self.data['version'] = os.popen("rtm-config --version", "r").read()
195  self.data['date'] = time.asctime()
196 
197  self.tags = {}
198  self.tags["module"] = module
199  self.tags["actions"] = self.CreateActions()
200  self.tags["inport"] = inport
201  self.tags["outport"] = outport
202  self.tags["service"] = service
203  self.tags["configuration"] = configuration
204  self.gen_tags(self.tags)
205  return
206 
207  def CreateActions(self):
208  actnames = [
209  "onInitialize",
210  "onFinalize",
211  "onActivated",
212  "onDeactivated",
213  "onAborting",
214  "onError",
215  "onReset",
216  "onExecute",
217  "onStateUpdate",
218  "onShutdown",
219  "onStartup",
220  "onRateChanged",
221  ]
222  acttext = """ %s:
223  Description:
224  [actions.%s.rtcDoc::doc.description]
225 
226  PreCondition:
227  [actions.%s.rtcDoc::doc.preCondition]
228 
229  PostCondition:
230  [actions.%s.rtcDoc::doc.postCondition]
231 
232 
233 """
234  actions = """Actions:
235 """
236  for a in actnames:
237  actions += acttext % (a,a,a,a)
238  return actions
239 
240  def print_readme(self):
241  self.gen(self.data["fname"], readme, self.data, self.tags)
242 
243  def print_all(self):
244  self.print_readme()
245 
246 
def __init__(self, data)
Definition: README_gen.py:191
def gen(self, fname, temp_txt, data, tags)
Definition: gen_base.py:86
def gen_tags(self, tags)
Definition: gen_base.py:79
def print_readme(self)
Definition: README_gen.py:240
def CreateActions(self)
Definition: README_gen.py:207


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Jun 6 2019 19:26:00