[openrtm-commit:01773] r776 - trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO
openrtm @ openrtm.org
openrtm @ openrtm.org
2016年 2月 27日 (土) 11:17:08 JST
Author: win-ei
Date: 2016-02-27 11:17:08 +0900 (Sat, 27 Feb 2016)
New Revision: 776
Added:
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/get_actual_ec.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/is_alive_in_default_ec.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/is_existing.java
Log:
Added testfiles for the debug.
Added: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/get_actual_ec.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/get_actual_ec.java (rev 0)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/get_actual_ec.java 2016-02-27 02:17:08 UTC (rev 776)
@@ -0,0 +1,121 @@
+package RTMExamples.SimpleIO;
+
+import java.lang.Thread;
+
+import jp.go.aist.rtm.RTC.Manager;
+import jp.go.aist.rtm.RTC.ModuleInitProc;
+import jp.go.aist.rtm.RTC.RTObject_impl;
+import jp.go.aist.rtm.RTC.CorbaNaming;
+import jp.go.aist.rtm.RTC.RTObject_impl;
+import jp.go.aist.rtm.RTC.port.CorbaConsumer;
+import jp.go.aist.rtm.RTC.util.CORBA_SeqUtil;
+import jp.go.aist.rtm.RTC.util.NVUtil;
+import jp.go.aist.rtm.RTC.util.ORBUtil;
+import jp.go.aist.rtm.RTC.util.StringUtil;
+import jp.go.aist.rtm.RTC.util.Properties;
+import jp.go.aist.rtm.RTC.util.RTShellUtil;
+
+import org.omg.CORBA.ORB;
+import org.omg.CosNaming.NamingContextPackage.CannotProceed;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+import org.omg.CosNaming.NamingContextPackage.NotFound;
+
+import RTC.ConnectorProfile;
+import RTC.ConnectorProfileHolder;
+import OpenRTM.DataFlowComponent;
+import RTC.ExecutionContext;
+import RTC.ExecutionContextListHolder;
+import RTC.PortService;
+import RTC.PortServiceListHolder;
+import RTC.RTObject;
+import RTC.RTObjectHelper;
+import RTC.ReturnCode_t;
+import _SDOPackage.NVListHolder;
+import _SDOPackage.NameValue;
+
+public class get_actual_ec {
+
+ public static void main(String[] args) {
+
+ final Manager manager = Manager.init(args);
+
+ manager.activateManager();
+ Properties prop_out = new Properties(ConsoleOut.component_conf);
+ manager.registerFactory(prop_out, new ConsoleOut(), new ConsoleOut());
+ RTObject_impl out_impl = manager.createComponent("ConsoleOut");
+ if(out_impl==null)
+ {
+ System.out.println("ConsoleOut is null.");
+ }
+ Properties prop_in = new Properties(ConsoleIn.component_conf);
+ manager.registerFactory(prop_in, new ConsoleIn(), new ConsoleIn());
+ RTObject_impl in_impl = manager.createComponent("ConsoleIn");
+ if(in_impl==null)
+ {
+ System.out.println("ConsoleIn is null.");
+ }
+ manager.runManager(true);
+
+ ExecutionContextListHolder eclisto = new ExecutionContextListHolder();
+ eclisto.value = new ExecutionContext[0];
+ eclisto.value = out_impl.get_owned_contexts();
+ System.out.println( "eclisto.value.length : "+ eclisto.value.length);
+
+ ExecutionContextListHolder eclisti = new ExecutionContextListHolder();
+ eclisti.value = new ExecutionContext[0];
+ eclisti.value = in_impl.get_owned_contexts();
+ System.out.println( "eclisti.value.length : "+ eclisti.value.length);
+
+ out_impl.bindContext(eclisti.value[0]);
+ eclisto.value = out_impl.get_owned_contexts();
+ System.out.println( "eclisto.value.length : "+ eclisto.value.length);
+
+ ORB orb = ORBUtil.getOrb(args);
+ CorbaNaming naming = null;
+ try {
+ naming = new CorbaNaming(orb, "localhost:2809");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ CorbaConsumer<DataFlowComponent> conout =
+ new CorbaConsumer<DataFlowComponent>(DataFlowComponent.class);
+ // find ConsoleOut0 component
+ try {
+ conout.setObject(naming.resolve(".host_cxt/ConsoleOut0.rtc"));
+ } catch (NotFound e) {
+ e.printStackTrace();
+ } catch (CannotProceed e) {
+ e.printStackTrace();
+ } catch (InvalidName e) {
+ e.printStackTrace();
+ }
+
+ // activate ConsoleOut0
+ ExecutionContextListHolder eclist = new ExecutionContextListHolder();
+ eclist.value = new ExecutionContext[0];
+ RTObject conoutRef = conout._ptr();
+ eclist.value = conoutRef.get_owned_contexts();
+ System.out.println( "eclist.value.length : "+ eclist.value.length);
+
+ ExecutionContext ec = RTShellUtil.get_actual_ec(conoutRef,0);
+ assert ec.equals(eclisto.value[0]);
+ if(ec.equals(eclisto.value[0])) {
+ System.out.println( "OK");
+ }
+ else{
+ System.out.println( "NG");
+ }
+
+ ec = RTShellUtil.get_actual_ec(conoutRef,1);
+ assert ec.equals(eclisto.value[1]);
+ if(ec.equals(eclisto.value[1])) {
+ System.out.println( "OK");
+ }
+ else{
+ System.out.println( "NG");
+ }
+
+ }
+}
+
Added: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/is_alive_in_default_ec.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/is_alive_in_default_ec.java (rev 0)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/is_alive_in_default_ec.java 2016-02-27 02:17:08 UTC (rev 776)
@@ -0,0 +1,71 @@
+package RTMExamples.SimpleIO;
+
+import org.omg.CORBA.ORB;
+import org.omg.CosNaming.NamingContextPackage.CannotProceed;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+import org.omg.CosNaming.NamingContextPackage.NotFound;
+
+import jp.go.aist.rtm.RTC.CorbaNaming;
+
+import jp.go.aist.rtm.RTC.port.CorbaConsumer;
+
+import jp.go.aist.rtm.RTC.util.Properties;
+import jp.go.aist.rtm.RTC.util.RTShellUtil;
+import jp.go.aist.rtm.RTC.util.ORBUtil;
+
+import RTC.RTObject;
+
+import OpenRTM.DataFlowComponent;
+
+public class is_alive_in_default_ec{
+
+ public static void main(String[] args) {
+ //
+ //
+ //
+ ORB orb = ORBUtil.getOrb(args);
+ CorbaNaming naming = null;
+ try {
+ naming = new CorbaNaming(orb, "localhost:2809");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ //
+ //
+ //
+ CorbaConsumer<DataFlowComponent> conin =
+ new CorbaConsumer<DataFlowComponent>(DataFlowComponent.class);
+ {
+ RTObject coninRef = conin._ptr();
+
+ if( RTShellUtil.is_alive_in_default_ec(coninRef)) {
+ System.out.println( "EC of " +args[0] + " exists." );
+ }
+ else {
+ System.out.println( "EC of " +args[0] + " doesn't exist." );
+ }
+ }
+ // find component
+ try {
+ conin.setObject(naming.resolve(args[0]));
+ } catch (NotFound e) {
+ //e.printStackTrace();
+ } catch (CannotProceed e) {
+ //e.printStackTrace();
+ } catch (InvalidName e) {
+ //e.printStackTrace();
+ }
+
+ RTObject coninRef = conin._ptr();
+ if( RTShellUtil.is_alive_in_default_ec(coninRef)) {
+ System.out.println( "EC of " +args[0] + " exist." );
+ }
+ else {
+ System.out.println( "EC of " +args[0] + " doesn't exist." );
+ }
+ }
+
+}
+
+
Added: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/is_existing.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/is_existing.java (rev 0)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/is_existing.java 2016-02-27 02:17:08 UTC (rev 776)
@@ -0,0 +1,72 @@
+package RTMExamples.SimpleIO;
+
+import org.omg.CORBA.ORB;
+import org.omg.CosNaming.NamingContextPackage.CannotProceed;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+import org.omg.CosNaming.NamingContextPackage.NotFound;
+
+import jp.go.aist.rtm.RTC.CorbaNaming;
+
+import jp.go.aist.rtm.RTC.port.CorbaConsumer;
+
+import jp.go.aist.rtm.RTC.util.Properties;
+import jp.go.aist.rtm.RTC.util.RTShellUtil;
+import jp.go.aist.rtm.RTC.util.ORBUtil;
+
+import RTC.RTObject;
+
+import OpenRTM.DataFlowComponent;
+
+public class is_existing{
+
+ public static void main(String[] args) {
+ //
+ //
+ //
+ ORB orb = ORBUtil.getOrb(args);
+ CorbaNaming naming = null;
+ try {
+ naming = new CorbaNaming(orb, "localhost:2809");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ //
+ //
+ //
+ CorbaConsumer<DataFlowComponent> conin =
+ new CorbaConsumer<DataFlowComponent>(DataFlowComponent.class);
+ {
+ RTObject coninRef = conin._ptr();
+
+ if( RTShellUtil.is_existing(coninRef)) {
+ System.out.println( args[0] + " exists." );
+ }
+ else {
+ System.out.println( args[0] + " doesn't exist." );
+ }
+ }
+ // find component
+ try {
+ conin.setObject(naming.resolve(args[0]));
+ } catch (NotFound e) {
+ e.printStackTrace();
+ } catch (CannotProceed e) {
+ e.printStackTrace();
+ } catch (InvalidName e) {
+ e.printStackTrace();
+ }
+ RTObject coninRef = conin._ptr();
+
+ if( RTShellUtil.is_existing(coninRef)) {
+ System.out.println( args[0] + " exist." );
+ }
+ else {
+ System.out.println( args[0] + " doesn't exist." );
+ }
+
+ }
+
+}
+
+
More information about the openrtm-commit
mailing list