[openrtm-commit:00586] r642 - in trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC: . util
openrtm @ openrtm.org
openrtm @ openrtm.org
2012年 1月 16日 (月) 14:54:22 JST
Author: fsi-katami
Date: 2012-01-16 14:54:22 +0900 (Mon, 16 Jan 2012)
New Revision: 642
Modified:
trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java
trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ManagerConfig.java
trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/util/StringUtil.java
Log:
Log messages have been added when RTC initialization failed. Now loaded RTC type/instance configuration file name are stored in the config_file property.
Modified: trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java 2012-01-16 01:33:20 UTC (rev 641)
+++ trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java 2012-01-16 05:54:22 UTC (rev 642)
@@ -6,6 +6,8 @@
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
+
+import java.util.ArrayList;
import java.util.Vector;
import java.util.logging.FileHandler;
import java.util.logging.ConsoleHandler;
@@ -1023,7 +1025,11 @@
rtcout.println(Logbuf.TRACE,
"RTC initialization failed: "
+ comp_id.getProperty("implementaion_id"));
- comp.exit();
+ if (comp.exit() != ReturnCode_t.RTC_OK) {
+ rtcout.println(Logbuf.DEBUG,
+ comp_id.getProperty("implementation_id")
+ + " finalization was failed.");
+ }
return null;
}
rtcout.println(Logbuf.TRACE,
@@ -2663,6 +2669,7 @@
String type_conf = category + "." + type_name + ".config_file";
String name_conf = category + "." + inst_name + ".config_file";
+ ArrayList<String> config_fname = new ArrayList<String>();
Properties type_prop = new Properties();
Properties name_prop = new Properties();
@@ -2674,7 +2681,14 @@
BufferedReader conff = new BufferedReader(
new FileReader(m_config.getProperty(name_conf)));
name_prop.load(conff);
-
+ rtcout.println(Logbuf.INFO,
+ "Component instance conf file: "
+ + m_config.getProperty(name_conf)
+ + " loaded.");
+ String str = new String();
+ str = name_prop._dump(str,name_prop,0);
+ rtcout.println(Logbuf.DEBUG, str);
+ config_fname.add(m_config.getProperty(name_conf));
} catch (FileNotFoundException e) {
rtcout.println(Logbuf.DEBUG,
"Exception: Caught FileNotFoundException"
@@ -2690,7 +2704,20 @@
}
if (m_config.findNode(category + "." + inst_name) != null) {
- name_prop.merge(m_config.getNode(category + "." + inst_name));
+ Properties temp = m_config.getNode(category + "." + inst_name);
+ Vector<String> keys = temp.propertyNames();
+ int length = keys.size();
+ if (!( length == 1 && keys.get(length-1).equals("config_file"))) {
+ name_prop.merge(m_config.getNode(category + "." + inst_name));
+ rtcout.println(Logbuf.INFO,
+ "Component type conf exists in rtc.conf. Merged.");
+ String str = new String();
+ str = name_prop._dump(str,name_prop,0);
+ rtcout.println(Logbuf.DEBUG,str);
+ if (m_config.findNode("config_file") != null) {
+ config_fname.add(m_config.getProperty("config_file"));
+ }
+ }
}
if (!(m_config.getProperty(type_conf) == null
@@ -2700,6 +2727,14 @@
BufferedReader conff = new BufferedReader(
new FileReader(m_config.getProperty(type_conf)));
type_prop.load(conff);
+ rtcout.println(Logbuf.INFO,
+ "Component type conf file: "
+ + m_config.getProperty(type_conf)
+ + " loaded.");
+ String str = new String();
+ str = type_prop._dump(str,type_prop,0);
+ rtcout.println(Logbuf.DEBUG,str);
+ config_fname.add(m_config.getProperty(type_conf));
} catch (FileNotFoundException e) {
rtcout.println(Logbuf.DEBUG,
@@ -2717,13 +2752,28 @@
}
}
if (m_config.findNode(category + "." + type_name) != null) {
- type_prop.merge(m_config.getNode(category + "." + type_name));
+ Properties temp = m_config.getNode(category + "." + type_name);
+ Vector<String> keys = temp.propertyNames();
+ int length = keys.size();
+ if (!(length == 1 && keys.get(length).equals("config_file"))) {
+ type_prop.merge(m_config.getNode(category + "." + type_name));
+ rtcout.println(Logbuf.INFO,
+ "Component type conf exists in rtc.conf. Merged.");
+ String str = new String();
+ str = type_prop._dump(str,type_prop,0);
+ rtcout.println(Logbuf.DEBUG,str);
+ if (m_config.findNode("config_file") != null) {
+ config_fname.add(m_config.getProperty("config_file"));
+ }
+ }
}
// Merge Properties. type_prop is merged properties
comp.setProperties(prop);
type_prop.merge(name_prop);
+ String fname = StringUtil.flatten(StringUtil.unique_sv(config_fname));
+ type_prop.setProperty("config_file",fname);
comp.setProperties(type_prop);
// ------------------------------------------------------------
Modified: trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ManagerConfig.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ManagerConfig.java 2012-01-16 01:33:20 UTC (rev 641)
+++ trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ManagerConfig.java 2012-01-16 05:54:22 UTC (rev 642)
@@ -182,6 +182,7 @@
// Properties from arguments are marged finally
properties.merge(m_argprop);
+ properties.setProperty("config_file", m_configFile);
}
/**
Modified: trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/util/StringUtil.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/util/StringUtil.java 2012-01-16 01:33:20 UTC (rev 641)
+++ trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/util/StringUtil.java 2012-01-16 05:54:22 UTC (rev 642)
@@ -230,6 +230,29 @@
}
return str;
}
+ /**
+ * {@.ja 与えられた文字列リストから重複を削除する}
+ * {@.en Deletes repetition from the given character string list.}
+ * <p>
+ * {@.ja 引数で与えられた文字列リストから重複を削除したリストを作成する。}
+ *
+ * @param sv
+ * {@.ja 確認元文字列リスト}
+ * {@.en Character string list}
+ * @return
+ * {@.ja 重複削除処理結果リスト}
+ * {@.en List of character string of result}
+ */
+ public static ArrayList<String> unique_sv(ArrayList<String> sv) {
+ ArrayList<String> str = new ArrayList<String>();
+ for( int intIdx=0; intIdx < sv.size(); ++intIdx ) {
+ if( !sv.get(intIdx).trim().equals("")
+ && !str.contains(sv.get(intIdx).trim()) ) {
+ str.add(sv.get(intIdx).trim());
+ }
+ }
+ return str;
+ }
/**
* {@.ja 与えられた文字列リストからCSVを生成する}
@@ -285,7 +308,34 @@
return str.toString();
}
+ /**
+ * {@.ja 与えられた文字列リストからCSVを生成する}
+ * {@.en generates CSV from the given character string list.}
+ * <p>
+ * {@.ja 引数で与えられた文字列リストの各要素を並べたCSVを生成する。
+ * 文字列リストが空の場合には空白文字を返す。}
+ *
+ * @param sv
+ * {@.ja CSV変換対象文字列リスト}
+ * {@.en Character string list to be converted}
+ * @return
+ * {@.ja CSV変換結果文字列}
+ * {@.en Character string of conversion result}
+ */
+ public static String flatten(ArrayList sv) {
+ if( sv.size() == 0) return "";
+ StringBuffer str = new StringBuffer();
+
+ int intIdx;
+ for(intIdx=0; intIdx < sv.size()-1; ++intIdx) {
+ str.append(sv.get(intIdx) + ", ");
+ }
+ str.append(sv.get(intIdx));
+
+ return str.toString();
+ }
+
/**
* {@.ja 文字列を分割文字で分割する}
* {@.en divides the character string by the division character.}
openrtm-commit メーリングリストの案内