[openrtm-commit:03060] r1098 - trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleService
openrtm @ openrtm.org
openrtm @ openrtm.org
2018年 1月 15日 (月) 16:04:41 JST
Author: t-katami
Date: 2018-01-15 16:04:41 +0900 (Mon, 15 Jan 2018)
New Revision: 1098
Modified:
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleService/MyServiceConsumerImpl.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleService/MyServiceSVC_impl.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleService/rtc.conf
Log:
[compat,example,->RELENG_1_2] Fixed SimpleService. refs #4411
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleService/MyServiceConsumerImpl.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleService/MyServiceConsumerImpl.java 2018-01-10 05:52:11 UTC (rev 1097)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleService/MyServiceConsumerImpl.java 2018-01-15 07:04:41 UTC (rev 1098)
@@ -8,6 +8,7 @@
import jp.go.aist.rtm.RTC.Manager;
import jp.go.aist.rtm.RTC.port.CorbaConsumer;
import jp.go.aist.rtm.RTC.port.CorbaPort;
+import jp.go.aist.rtm.RTC.util.DataRef;
import RTC.ReturnCode_t;
public class MyServiceConsumerImpl extends DataFlowComponentBase {
@@ -16,6 +17,7 @@
super(manager);
// <rtc-template block="initializer">
m_MyServicePort = new CorbaPort("MyService");
+ this.result = new DataRef<String>(resultVal);
}
// The initialize action (on CREATED->ALIVE transition)
@@ -112,10 +114,21 @@
std::cout << "arg : " << argv[1] << std::endl;
*/
+ if(async != null && !async.isAlive()){
+ System.out.println( "echo() finished: " + this.result.v );
+ async = null;
+ }
m_myservice0 = m_myservice0Base._ptr();
if( argv[0].equals("echo") && argv.length>1 ) {
- String retmsg = m_myservice0.echo(argv[1]);
- System.out.println( "echo return: " + retmsg );
+ if(async == null){
+ //String retmsg = m_myservice0.echo(argv[1]);
+ //System.out.println( "echo return: " + retmsg );
+ async = new Thread(
+ new echoFunctor(m_myservice0,argv[1],this.result));
+ async.start();
+ } else{
+ System.out.println("echo() still invoking");
+ }
return super.onExecute(ec_id);
}
@@ -217,4 +230,25 @@
protected MyService m_myservice0;
// </rtc-template>
+ Thread async;
+ String resultVal = new String();
+ DataRef<String> result;
+
+ class echoFunctor implements Runnable{
+ public echoFunctor(MyService comp,String arg,DataRef<String> result){
+ this.obj = comp;
+ this.arg = arg;
+ this.result = result;
+ }
+
+ @Override
+ public void run() {
+ result.v = obj.echo(this.arg);
+ }
+ MyService obj;
+ String arg;
+ DataRef<String> result;
+ }
+
+
}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleService/MyServiceSVC_impl.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleService/MyServiceSVC_impl.java 2018-01-10 05:52:11 UTC (rev 1097)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleService/MyServiceSVC_impl.java 2018-01-15 07:04:41 UTC (rev 1098)
@@ -23,7 +23,14 @@
if( m_echoList.value==null ) m_echoList.value = new String[0];
this.push_back(m_echoList, msg);
System.out.println( "MyService::echo() was called." );
- System.out.println( "Message: " + msg );
+ for(int ic=0;ic<10;++ic){
+ System.out.println( "Message: " + msg );
+ try{
+ Thread.sleep(1000L);
+ }catch(InterruptedException ex){
+ }
+ }
+ System.out.println( "MyService::echo() was finished." );
return msg;
}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleService/rtc.conf
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleService/rtc.conf 2018-01-10 05:52:11 UTC (rev 1097)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleService/rtc.conf 2018-01-15 07:04:41 UTC (rev 1098)
@@ -3,10 +3,12 @@
logger.enable:YES
logger.log_level:PARANOID
-#manager.modules.load_path:./RTMExamples/SimpleIO
-#manager.modules.preload: ConsoleOut
-#manager.components.precreate: ConsoleOut
+manager.modules.load_path:./RTMExamples/SimpleService
+#manager.modules.preload: MyServiceConsumer
+#manager.modules.preload: MyServiceProvider
+#manager.components.precreate: MyServiceConsumer
+#manager.components.precreate: MyServiceProvider
+#
+#Generic.MyServiceProvider.config_file: ../RTMExamples/SimpleService/component.conf
+#Generic.MyServiceConsumer.config_file: ../RTMExamples/SimpleService/component.conf
-#Generic.MyServiceProvider.config_file: ./RTMExamples/SimpleService/component.conf
-#Generic.MyServiceConsumer.config_file: ./RTMExamples/SimpleService/component.conf
-
More information about the openrtm-commit
mailing list