1
|
h3. ModuleName.java の変点
|
2
|
|
3
|
<pre><code class="diff">
|
4
|
@@ -13,26 +13,27 @@
|
5
|
import jp.go.aist.rtm.RTC.RegisterModuleFunc;
|
6
|
import jp.go.aist.rtm.RTC.util.Properties;
|
7
|
|
8
|
-/*!
|
9
|
- * @class ModuleName
|
10
|
- * @brief ModuleDescription
|
11
|
+/**
|
12
|
+ * ModuleName
|
13
|
+ * <p>
|
14
|
+ * ModuleDescription
|
15
|
*/
|
16
|
public class ModuleName implements RtcNewFunc, RtcDeleteFunc, RegisterModuleFunc {
|
17
|
|
18
|
// Module specification
|
19
|
// <rtc-template block="module_spec">
|
20
|
public static String component_conf[] = {
|
21
|
- "implementation_id", "ModuleName",
|
22
|
- "type_name", "ModuleName",
|
23
|
- "description", "ModuleDescription",
|
24
|
- "version", "1.0.0",
|
25
|
- "vendor", "VenderName",
|
26
|
- "category", "Category",
|
27
|
- "activity_type", "STATIC",
|
28
|
- "max_instance", "1",
|
29
|
- "language", "Java",
|
30
|
- "lang_type", "compile",
|
31
|
- ""
|
32
|
+ "implementation_id", "ModuleName",
|
33
|
+ "type_name", "ModuleName",
|
34
|
+ "description", "ModuleDescription",
|
35
|
+ "version", "1.0.0",
|
36
|
+ "vendor", "VenderName",
|
37
|
+ "category", "Category",
|
38
|
+ "activity_type", "STATIC",
|
39
|
+ "max_instance", "1",
|
40
|
+ "language", "Java",
|
41
|
+ "lang_type", "compile",
|
42
|
+ ""
|
43
|
};
|
44
|
// </rtc-template>
|
45
|
|
46
|
|
47
|
</code></pre>
|
48
|
|
49
|
h3. ModuleNameComp.java の変点
|
50
|
|
51
|
<pre><code class="diff">
|
52
|
@@ -12,9 +12,10 @@
|
53
|
import jp.go.aist.rtm.RTC.RTObject_impl;
|
54
|
import jp.go.aist.rtm.RTC.util.Properties;
|
55
|
|
56
|
-/*!
|
57
|
- * @class ModuleNameComp
|
58
|
- * @brief Standalone component Class
|
59
|
+/**
|
60
|
+ * ModuleNameComp
|
61
|
+ * <p>
|
62
|
+ * Standalone component Class
|
63
|
*
|
64
|
*/
|
65
|
public class ModuleNameComp implements ModuleInitProc {
|
66
|
@@ -26,8 +27,8 @@
|
67
|
// Create a component
|
68
|
RTObject_impl comp = mgr.createComponent("ModuleName");
|
69
|
if( comp==null ) {
|
70
|
- System.err.println("Component create failed.");
|
71
|
- System.exit(0);
|
72
|
+ System.err.println("Component create failed.");
|
73
|
+ System.exit(0);
|
74
|
}
|
75
|
|
76
|
// Example
|
77
|
@@ -81,7 +82,7 @@
|
78
|
// Initialize manager
|
79
|
final Manager manager = Manager.init(args);
|
80
|
|
81
|
- // Set module initialization proceduer
|
82
|
+ // Set module initialization procedure
|
83
|
// This procedure will be invoked in activateManager() function.
|
84
|
ModuleNameComp init = new ModuleNameComp();
|
85
|
manager.setModuleInitProc(init);
|
86
|
</code></pre>
|
87
|
|
88
|
h3. ModuleNameImpl.java の変点
|
89
|
|
90
|
<pre><code class="diff">
|
91
|
@@ -25,18 +25,19 @@
|
92
|
|
93
|
import org.omg.PortableServer.POAPackage.WrongPolicy;
|
94
|
import RTC.ReturnCode_t;
|
95
|
|
96
|
-/*!
|
97
|
- * @class ModuleNameImpl
|
98
|
- * @brief ModuleDescription
|
99
|
+/**
|
100
|
+ * ModuleNameImpl
|
101
|
+ * <p>
|
102
|
+ * ModuleDescription
|
103
|
*
|
104
|
*/
|
105
|
public class ModuleNameImpl extends DataFlowComponentBase {
|
106
|
|
107
|
- /*!
|
108
|
- * @brief constructor
|
109
|
- * @param manager Maneger Object
|
110
|
+ /**
|
111
|
+ * constructor
|
112
|
+ * @param manager Manager Object
|
113
|
*/
|
114
|
- public ModuleNameImpl(Manager manager) {
|
115
|
+ public ModuleNameImpl(Manager manager) {
|
116
|
super(manager);
|
117
|
// <rtc-template block="initializer">
|
118
|
m_sen_val = new TimedString();
|
119
|
@@ -53,8 +54,8 @@
|
120
|
|
121
|
/**
|
122
|
*
|
123
|
- * The initialize action (on CREATED->ALIVE transition)
|
124
|
- * formaer rtc_init_entry()
|
125
|
+ * The initialize action (on CREATED->ALIVE transition)
|
126
|
+ * former rtc_init_entry()
|
127
|
*
|
128
|
* @return RTC::ReturnCode_t
|
129
|
*
|
130
|
@@ -72,7 +73,7 @@
|
131
|
|
132
|
// Set service provider to Ports
|
133
|
try {
|
134
|
- m_sv_namePort.registerProvider("if_name", "MyService", m_if_name);
|
135
|
+ m_sv_namePort.registerProvider("if_name", "MyService", m_if_name);
|
136
|
} catch (ServantAlreadyActive e) {
|
137
|
e.printStackTrace();
|
138
|
} catch (WrongPolicy e) {
|
139
|
@@ -89,10 +90,10 @@
|
140
|
return super.onInitialize();
|
141
|
}
|
142
|
|
143
|
- /***
|
144
|
+ /**
|
145
|
*
|
146
|
- * The finalize action (on ALIVE->END transition)
|
147
|
- * formaer rtc_exiting_entry()
|
148
|
+ * The finalize action (on ALIVE->END transition)
|
149
|
+ * former rtc_exiting_entry()
|
150
|
*
|
151
|
* @return RTC::ReturnCode_t
|
152
|
*
|
153
|
@@ -103,7 +104,7 @@
|
154
|
// return super.onFinalize();
|
155
|
// }
|
156
|
|
157
|
- /***
|
158
|
+ /**
|
159
|
*
|
160
|
* The startup action when ExecutionContext startup
|
161
|
* former rtc_starting_entry()
|
162
|
@@ -119,7 +120,7 @@
|
163
|
// return super.onStartup(ec_id);
|
164
|
// }
|
165
|
|
166
|
- /***
|
167
|
+ /**
|
168
|
*
|
169
|
* The shutdown action when ExecutionContext stop
|
170
|
* former rtc_stopping_entry()
|
171
|
@@ -135,7 +136,7 @@
|
172
|
// return super.onShutdown(ec_id);
|
173
|
// }
|
174
|
|
175
|
- /***
|
176
|
+ /**
|
177
|
*
|
178
|
* The activated action (Active state entry action)
|
179
|
* former rtc_active_entry()
|
180
|
@@ -151,7 +152,7 @@
|
181
|
// return super.onActivated(ec_id);
|
182
|
// }
|
183
|
|
184
|
- /***
|
185
|
+ /**
|
186
|
*
|
187
|
* The deactivated action (Active state exit action)
|
188
|
* former rtc_active_exit()
|
189
|
@@ -167,7 +168,7 @@
|
190
|
// return super.onDeactivated(ec_id);
|
191
|
// }
|
192
|
|
193
|
- /***
|
194
|
+ /**
|
195
|
*
|
196
|
* The execution action that is invoked periodically
|
197
|
* former rtc_active_do()
|
198
|
@@ -183,7 +184,7 @@
|
199
|
// return super.onExecute(ec_id);
|
200
|
// }
|
201
|
|
202
|
- /***
|
203
|
+ /**
|
204
|
*
|
205
|
* The aborting action when main logic error occurred.
|
206
|
* former rtc_aborting_entry()
|
207
|
@@ -199,7 +200,7 @@
|
208
|
// return super.onAborting(ec_id);
|
209
|
// }
|
210
|
|
211
|
- /***
|
212
|
+ /**
|
213
|
*
|
214
|
* The error action in ERROR state
|
215
|
* former rtc_error_do()
|
216
|
@@ -215,7 +216,7 @@
|
217
|
// return super.onError(ec_id);
|
218
|
// }
|
219
|
|
220
|
- /***
|
221
|
+ /**
|
222
|
*
|
223
|
* The reset action that is invoked resetting
|
224
|
* This is same but different the former rtc_init_entry()
|
225
|
@@ -231,7 +232,7 @@
|
226
|
// return super.onReset(ec_id);
|
227
|
// }
|
228
|
|
229
|
- /***
|
230
|
+ /**
|
231
|
*
|
232
|
* The state update action that is invoked after onExecute() action
|
233
|
* no corresponding operation exists in OpenRTm-aist-0.2.0
|
234
|
@@ -247,7 +248,7 @@
|
235
|
// return super.onStateUpdate(ec_id);
|
236
|
// }
|
237
|
|
238
|
- /***
|
239
|
+ /**
|
240
|
*
|
241
|
* The action that is invoked when execution context's rate is changed
|
242
|
* no corresponding operation exists in OpenRTm-aist-0.2.0
|
243
|
@@ -262,7 +263,9 @@
|
244
|
// protected ReturnCode_t onRateChanged(int ec_id) {
|
245
|
// return super.onRateChanged(ec_id);
|
246
|
// }
|
247
|
-//
|
248
|
+
|
249
|
+ /**
|
250
|
+ */
|
251
|
// DataInPort declaration
|
252
|
// <rtc-template block="inport_declare">
|
253
|
protected TimedString m_sen_val;
|
254
|
@@ -307,55 +310,55 @@
|
255
|
// </rtc-template>
|
256
|
|
257
|
|
258
|
- private void initializeParam(Object target) {
|
259
|
- Class<?> targetClass = target.getClass();
|
260
|
- ClassLoader loader = target.getClass().getClassLoader();
|
261
|
- //
|
262
|
- Field[] fields = targetClass.getFields();
|
263
|
- for(Field field : fields) {
|
264
|
- if(field.getType().isPrimitive()) continue;
|
265
|
-
|
266
|
- try {
|
267
|
- if(field.getType().isArray()) {
|
268
|
- Object arrayValue = null;
|
269
|
- Class<?> clazz = null;
|
270
|
- if(field.getType().getComponentType().isPrimitive()) {
|
271
|
- clazz = field.getType().getComponentType();
|
272
|
- } else {
|
273
|
- clazz = loader.loadClass(field.getType().getComponentType().getName());
|
274
|
- }
|
275
|
- arrayValue = Array.newInstance(clazz, 0);
|
276
|
- field.set(target, arrayValue);
|
277
|
-
|
278
|
- } else {
|
279
|
- Constructor<?>[] constList = field.getType().getConstructors();
|
280
|
- if(constList.length==0) {
|
281
|
- Method[] methodList = field.getType().getMethods();
|
282
|
- for(Method method : methodList) {
|
283
|
- if(method.getName().equals("from_int")==false) continue;
|
284
|
- Object objFld = method.invoke(target, new Object[]{ new Integer(0) });
|
285
|
- field.set(target, objFld);
|
286
|
- break;
|
287
|
- }
|
288
|
-
|
289
|
- } else {
|
290
|
- Class<?> classFld = Class.forName(field.getType().getName(), true, loader);
|
291
|
- Object objFld = classFld.newInstance();
|
292
|
- initializeParam(objFld);
|
293
|
- field.set(target, objFld);
|
294
|
- }
|
295
|
- }
|
296
|
- } catch (ClassNotFoundException e) {
|
297
|
- e.printStackTrace();
|
298
|
- } catch (InstantiationException e) {
|
299
|
- e.printStackTrace();
|
300
|
- } catch (IllegalAccessException e) {
|
301
|
- e.printStackTrace();
|
302
|
- } catch (IllegalArgumentException e) {
|
303
|
- e.printStackTrace();
|
304
|
- } catch (InvocationTargetException e) {
|
305
|
- e.printStackTrace();
|
306
|
- }
|
307
|
- }
|
308
|
- }
|
309
|
+ private void initializeParam(Object target) {
|
310
|
+ Class<?> targetClass = target.getClass();
|
311
|
+ ClassLoader loader = target.getClass().getClassLoader();
|
312
|
+ //
|
313
|
+ Field[] fields = targetClass.getFields();
|
314
|
+ for(Field field : fields) {
|
315
|
+ if(field.getType().isPrimitive()) continue;
|
316
|
+
|
317
|
+ try {
|
318
|
+ if(field.getType().isArray()) {
|
319
|
+ Object arrayValue = null;
|
320
|
+ Class<?> clazz = null;
|
321
|
+ if(field.getType().getComponentType().isPrimitive()) {
|
322
|
+ clazz = field.getType().getComponentType();
|
323
|
+ } else {
|
324
|
+ clazz = loader.loadClass(field.getType().getComponentType().getName());
|
325
|
+ }
|
326
|
+ arrayValue = Array.newInstance(clazz, 0);
|
327
|
+ field.set(target, arrayValue);
|
328
|
+
|
329
|
+ } else {
|
330
|
+ Constructor<?>[] constList = field.getType().getConstructors();
|
331
|
+ if(constList.length==0) {
|
332
|
+ Method[] methodList = field.getType().getMethods();
|
333
|
+ for(Method method : methodList) {
|
334
|
+ if(method.getName().equals("from_int")==false) continue;
|
335
|
+ Object objFld = method.invoke(target, new Object[]{ new Integer(0) });
|
336
|
+ field.set(target, objFld);
|
337
|
+ break;
|
338
|
+ }
|
339
|
+
|
340
|
+ } else {
|
341
|
+ Class<?> classFld = Class.forName(field.getType().getName(), true, loader);
|
342
|
+ Object objFld = classFld.newInstance();
|
343
|
+ initializeParam(objFld);
|
344
|
+ field.set(target, objFld);
|
345
|
+ }
|
346
|
+ }
|
347
|
+ } catch (ClassNotFoundException e) {
|
348
|
+ e.printStackTrace();
|
349
|
+ } catch (InstantiationException e) {
|
350
|
+ e.printStackTrace();
|
351
|
+ } catch (IllegalAccessException e) {
|
352
|
+ e.printStackTrace();
|
353
|
+ } catch (IllegalArgumentException e) {
|
354
|
+ e.printStackTrace();
|
355
|
+ } catch (InvocationTargetException e) {
|
356
|
+ e.printStackTrace();
|
357
|
+ }
|
358
|
+ }
|
359
|
+ }
|
360
|
}
|
361
|
</code></pre>
|
362
|
|
363
|
h3. MyServiceSVC_impl の変点
|
364
|
|
365
|
<pre><code class="diff">
|
366
|
@@ -4,8 +4,9 @@
|
367
|
* @brief Service implementation code of MyService.idl
|
368
|
*
|
369
|
*/
|
370
|
-/*!
|
371
|
- * @class MyServiceSVC_impl
|
372
|
+/**
|
373
|
+ * MyServiceSVC_impl
|
374
|
+ * <p>
|
375
|
* Example class implementing IDL interface MyService
|
376
|
*/
|
377
|
public class MyServiceSVC_impl extends MyServicePOA{
|
378
|
|
379
|
</code></pre>
|