Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 import os
00020 import time
00021 import yat
00022 import gen_base
00023
00024 readme = """#======================================================================
00025 # RTComponent: [basicInfo.name] specificatioin
00026 #
00027 # OpenRTM-aist-[version]
00028 #
00029 # Date: [date]
00030 #
00031 # This file is generated by rtc-template with the following argments.
00032 #
00033 [for args in fmtd_args]
00034 # [if-index args is first][else] [endif]
00035 [args][if-index args is last][else]\\[endif]
00036
00037 [endfor]
00038 #
00039 #======================================================================
00040 # Basic Information
00041 #======================================================================
00042 # <rtc-template block="module">
00043 # </rtc-template>
00044 #======================================================================
00045 # Activity definition
00046 #======================================================================
00047 # <rtc-template block="actions">
00048 # </rtc-template>
00049 #======================================================================
00050 # InPorts definition
00051 #======================================================================
00052 # <rtc-template block="inport">
00053 # </rtc-template>
00054 #======================================================================
00055 # OutPorts definition
00056 #======================================================================
00057 # <rtc-template block="outport">
00058 # </rtc-template>
00059 #======================================================================
00060 # Service definition
00061 #======================================================================
00062 # <rtc-template block="service">
00063 # </rtc-template>
00064 #======================================================================
00065 # Configuration definition
00066 #======================================================================
00067 # <rtc-template block="configuration">
00068 # </rtc-template>
00069 """
00070
00071 module = """Basic Information:
00072 Description: [basicInfo.description]
00073
00074 Version: [basicInfo.version]
00075
00076 Author: [basicInfo.vendor]
00077
00078 Category: [basicInfo.category]
00079
00080 Comp. Type: [basicInfo.componentType]
00081
00082 Act. Type: [basicInfo.activityType]
00083
00084 MAX Inst.: [basicInfo.maxInstances]
00085
00086 Lang:
00087 Lang Type:
00088 """
00089
00090 inport = """InPorts:
00091 [for inport in dataPorts]
00092 [if inport.portType is DataInPort]
00093 Name: [inport.name]
00094
00095 VarName: [inport.rtcExt::varname]
00096
00097 PortNumber: [inport.rtcDoc::doc.number]
00098
00099 Description: [inport.rtcDoc::doc.description]
00100
00101 Type: [inport.type]
00102
00103 InterfaceType: [inport.interfaceType]
00104
00105 DataflowType: [inport.dataflowType]
00106
00107 SubscriptionType: [inport.subscriptionType]
00108
00109 MaxOut:
00110
00111 [endif]
00112 [endfor]
00113 """
00114
00115 outport = """OutPorts:
00116 [for outport in dataPorts]
00117 [if outport.portType is DataOutPort]
00118 Name: [outport.name]
00119
00120 VarName: [outport.rtcExt::varname]
00121
00122 PortNumber: [outport.rtcDoc::doc.number]
00123
00124 Description: [outport.rtcDoc::doc.description]
00125
00126 Type: [outport.type]
00127
00128 InterfaceType: [outport.interfaceType]
00129
00130 DataflowType: [outport.dataflowType]
00131
00132 SubscriptionType: [outport.subscriptionType]
00133
00134 MaxOut:
00135
00136 [endif]
00137 [endfor]
00138 """
00139 service = """ServicePorts:
00140 [for service in servicePorts]
00141 PortName: [service.name]
00142
00143 Description: [service.rtcDoc::doc.description]
00144
00145 InterfaceDescription: [service.rtcDoc::doc.ifdescription]
00146
00147 Position: [service.rtcExt::position]
00148
00149 Interfaces:
00150 [for svcif in service.serviceInterface]
00151 Name: [svcif.name]
00152
00153 Description: [svcif.rtcDoc::doc.description]
00154
00155 Type: [svcif.type]
00156
00157 Direction: [svcif.direction]
00158
00159 InstanceName: [svcif.instanceName]
00160
00161 IDLfile: [svcif.idlFile]
00162
00163 FilePath: [svcif.path]
00164
00165 [endfor]
00166
00167 [endfor]
00168
00169 """
00170
00171 configuration = """Configuration:
00172 [for config in configurationSet.configuration]
00173 Name: [config.name]
00174
00175 Description: [config.rtcDoc::doc.description]
00176
00177 Type: [config.type]
00178
00179 DefaultValue: [config.defaultValue]
00180
00181 Range: [config.rtcDoc::doc.range]
00182
00183 Unit: [config.rtcDoc::doc.unit]
00184
00185 Constraint: [config.rtcDoc::doc.constraint]
00186
00187
00188 [endfor]"""
00189
00190 class README_gen(gen_base.gen_base):
00191 def __init__(self, data):
00192 self.data = data.copy()
00193 self.data['fname'] = "README." + self.data['basicInfo']['name']
00194 self.data['version'] = os.popen("rtm-config --version", "r").read()
00195 self.data['date'] = time.asctime()
00196
00197 self.tags = {}
00198 self.tags["module"] = module
00199 self.tags["actions"] = self.CreateActions()
00200 self.tags["inport"] = inport
00201 self.tags["outport"] = outport
00202 self.tags["service"] = service
00203 self.tags["configuration"] = configuration
00204 self.gen_tags(self.tags)
00205 return
00206
00207 def CreateActions(self):
00208 actnames = [
00209 "onInitialize",
00210 "onFinalize",
00211 "onActivated",
00212 "onDeactivated",
00213 "onAborting",
00214 "onError",
00215 "onReset",
00216 "onExecute",
00217 "onStateUpdate",
00218 "onShutdown",
00219 "onStartup",
00220 "onRateChanged",
00221 ]
00222 acttext = """ %s:
00223 Description:
00224 [actions.%s.rtcDoc::doc.description]
00225
00226 PreCondition:
00227 [actions.%s.rtcDoc::doc.preCondition]
00228
00229 PostCondition:
00230 [actions.%s.rtcDoc::doc.postCondition]
00231
00232
00233 """
00234 actions = """Actions:
00235 """
00236 for a in actnames:
00237 actions += acttext % (a,a,a,a)
00238 return actions
00239
00240 def print_readme(self):
00241 self.gen(self.data["fname"], readme, self.data, self.tags)
00242
00243 def print_all(self):
00244 self.print_readme()
00245
00246