[openrtm-commit:01811] r565 - trunk/rtmtools/jp.go.aist.rtm.rtcbuilder.java/src/jp/go/aist/rtm/rtcbuilder/java/template/java
openrtm @ openrtm.org
openrtm @ openrtm.org
2016年 3月 5日 (土) 18:42:44 JST
Author: ga
Date: 2016-03-05 18:42:44 +0900 (Sat, 05 Mar 2016)
New Revision: 565
Modified:
trunk/rtmtools/jp.go.aist.rtm.rtcbuilder.java/src/jp/go/aist/rtm/rtcbuilder/java/template/java/Java_RTC.java.vsl
trunk/rtmtools/jp.go.aist.rtm.rtcbuilder.java/src/jp/go/aist/rtm/rtcbuilder/java/template/java/Java_RTC_Impl.java.vsl
trunk/rtmtools/jp.go.aist.rtm.rtcbuilder.java/src/jp/go/aist/rtm/rtcbuilder/java/template/java/classpath.vsl
Log:
Modified Configuration Parameter #3072
Modified: trunk/rtmtools/jp.go.aist.rtm.rtcbuilder.java/src/jp/go/aist/rtm/rtcbuilder/java/template/java/Java_RTC.java.vsl
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.rtcbuilder.java/src/jp/go/aist/rtm/rtcbuilder/java/template/java/Java_RTC.java.vsl 2016-03-05 09:42:21 UTC (rev 564)
+++ trunk/rtmtools/jp.go.aist.rtm.rtcbuilder.java/src/jp/go/aist/rtm/rtcbuilder/java/template/java/Java_RTC.java.vsl 2016-03-05 09:42:44 UTC (rev 565)
@@ -47,8 +47,13 @@
#foreach($configParam in ${rtcParam.configParams})
"conf.default.${configParam.name}", "${configParam.defaultVal}",
#end
+
+#foreach($configParam in ${rtcParam.configParams})
+ "conf.default.__${configParam.name}", "${configParam.type}#if( ${configParam.step.length()} > 0 ).${configParam.step}#end",
#end
+#end
#if( ${rtcParam.configParams.size()} > 0 )
+
// Widget
#foreach($configParam in ${rtcParam.configParams})
#if( ${configParam.widget.length()} > 0 )
Modified: trunk/rtmtools/jp.go.aist.rtm.rtcbuilder.java/src/jp/go/aist/rtm/rtcbuilder/java/template/java/Java_RTC_Impl.java.vsl
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.rtcbuilder.java/src/jp/go/aist/rtm/rtcbuilder/java/template/java/Java_RTC_Impl.java.vsl 2016-03-05 09:42:21 UTC (rev 564)
+++ trunk/rtmtools/jp.go.aist.rtm.rtcbuilder.java/src/jp/go/aist/rtm/rtcbuilder/java/template/java/Java_RTC_Impl.java.vsl 2016-03-05 09:42:44 UTC (rev 565)
@@ -17,6 +17,14 @@
* \$Id$
*/
+#if( ${rtcParam.inports.size()} > 0 || ${rtcParam.outports.size()} > 0 )
+import java.lang.reflect.Array;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+#end
+
#foreach($type in ${javaConv.getPortTypes(${rtcParam})})
${javaConv.getDataportPackageName(${type})}
#end
@@ -90,6 +98,7 @@
// <rtc-template block="initializer">
#foreach($port in ${rtcParam.inports})
m_${port.tmplVarName}_val = new ${javaConv.getDataTypeName(${port.type})}();
+ initializeParam(m_${port.tmplVarName}_val);
m_${port.tmplVarName} = new DataRef<${javaConv.getDataTypeName(${port.type})}>(m_${port.tmplVarName}_val);
m_${port.name}In = new InPort<${javaConv.getDataTypeName(${port.type})}>("${port.name}", m_${port.tmplVarName});
#end
@@ -624,4 +633,62 @@
#if(${tmpltHelper.checkContents(${rtcParam.privateOpeSource})})${rtcParam.privateOpeSource}
#end
+#if( ${rtcParam.inports.size()} > 0 || ${rtcParam.outports.size()} > 0 )
+ private void initializeParam(Object target) {
+ Class<?> targetClass = target.getClass();
+ ClassLoader loader = target.getClass().getClassLoader();
+ //
+ Field[] fields = targetClass.getFields();
+ for(Field field : fields) {
+ if(field.getType().isPrimitive()) continue;
+
+ try {
+ if(field.getType().isArray()) {
+ Object arrayValue = null;
+ Class<?> clazz = null;
+ if(field.getType().getComponentType().isPrimitive()) {
+ clazz = field.getType().getComponentType();
+ } else {
+ clazz = loader.loadClass(field.getType().getComponentType().getName());
+ }
+ arrayValue = Array.newInstance(clazz, 1);
+ if(clazz.isPrimitive()==false) {
+ Object objArray = clazz.newInstance();
+ initializeParam(objArray);
+ Array.set(arrayValue, 0, objArray);
+ }
+ field.set(target, arrayValue);
+
+ } else {
+ Constructor<?>[] constList = field.getType().getConstructors();
+ if(constList.length==0) {
+ Method[] methodList = field.getType().getMethods();
+ for(Method method : methodList) {
+ if(method.getName().equals("from_int")==false) continue;
+ Object objFld = method.invoke(target, new Object[]{ new Integer(0) });
+ field.set(target, objFld);
+ break;
+ }
+
+ } else {
+ Class<?> classFld = Class.forName(field.getType().getName(), true, loader);
+ Object objFld = classFld.newInstance();
+ initializeParam(objFld);
+ field.set(target, objFld);
+ }
+ }
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+#end
}
Modified: trunk/rtmtools/jp.go.aist.rtm.rtcbuilder.java/src/jp/go/aist/rtm/rtcbuilder/java/template/java/classpath.vsl
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.rtcbuilder.java/src/jp/go/aist/rtm/rtcbuilder/java/template/java/classpath.vsl 2016-03-05 09:42:21 UTC (rev 564)
+++ trunk/rtmtools/jp.go.aist.rtm.rtcbuilder.java/src/jp/go/aist/rtm/rtcbuilder/java/template/java/classpath.vsl 2016-03-05 09:42:44 UTC (rev 565)
@@ -4,6 +4,7 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
#if( ${tmpltHelperJava.notNullRTMRoot()} )
<classpathentry kind="lib" path="${javaRoot}/jar/OpenRTM-aist-${rtcParam.rtmJavaVersion}.jar"/>
+ <classpathentry kind="lib" path="${javaRoot}/jar/commons-cli-1.1.jar"/>
#end
<classpathentry kind="output" path="bin"/>
</classpath>
\ No newline at end of file
More information about the openrtm-commit
mailing list