[openrtm-commit:02193] r897 - in trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC: src/jp/go/aist/rtm/RTC tests/src/jp/go/aist/rtm/RTC
openrtm @ openrtm.org
openrtm @ openrtm.org
2016年 12月 28日 (水) 12:28:59 JST
Author: win-ei
Date: 2016-12-28 12:28:59 +0900 (Wed, 28 Dec 2016)
New Revision: 897
Removed:
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FsmStructureListenerArgument.java
Modified:
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ExtendedFsmServiceProvider.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FactoryInit.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FsmStructureListener.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FsmStructureListenerHolder.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FsmStructureListenerType.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SdoServiceAdmin.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SdoServiceProviderBase.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/ExtendedFsmServiceProviderTest.java
Log:
[FSM4RTC]Fixed bugs.
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ExtendedFsmServiceProvider.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ExtendedFsmServiceProvider.java 2016-12-26 08:45:18 UTC (rev 896)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ExtendedFsmServiceProvider.java 2016-12-28 03:28:59 UTC (rev 897)
@@ -9,15 +9,17 @@
import RTC.ReturnCode_t;
import _SDOPackage.NVListHolder;
+import _SDOPackage.SDOService;
import jp.go.aist.rtm.RTC.util.NVUtil;
+import jp.go.aist.rtm.RTC.util.POAUtil;
import jp.go.aist.rtm.RTC.util.Properties;
/**
*
*
*
*/
-public class ExtendedFsmServiceProvider extends ExtendedFsmServicePOA implements SdoServiceProviderBase , ObjectCreator<SdoServiceProviderBase>, ObjectDestructor{
+public class ExtendedFsmServiceProvider extends ExtendedFsmServicePOA implements SdoServiceProviderBase, ObjectCreator<SdoServiceProviderBase>, ObjectDestructor{
/**
* {@.ja ctor of ExtendedFsmServiceProvider}
* {@.en ctor of ExtendedFsmServiceProvider}
@@ -25,6 +27,7 @@
public ExtendedFsmServiceProvider(){
m_rtobj = null;
System.out.println("ExtendedFsmServiceProvider()");
+ m_objref = this._this();
// dummy code
m_fsmStructure.name = "dummy_name";
@@ -62,6 +65,33 @@
/**
+ * {@.ja 当該RTC.ExtendedFsmServiceのCORBAオブジェクト参照を取得する。}
+ * {@.en Gets CORBA object referense of this RTC.ExtendedFsmService}
+ *
+ * @return
+ * {@.ja 当該PortのCORBAオブジェクト参照}
+ * {@.en CORBA object referense of this OpenRTM.InPortCdr}
+ *
+ */
+ public RTC.ExtendedFsmService _this() {
+
+ if (this.m_objref == null) {
+ try {
+ this.m_objref =
+ ExtendedFsmServiceHelper.narrow(POAUtil.getRef(this));
+ } catch (Exception e) {
+ //rtcout.println(Logbuf.WARN, "The exception was caught.");
+ throw new IllegalStateException(e);
+ }
+ }
+
+ //System.out.println("this.m_objref="+this.m_objref);
+ return this.m_objref;
+ }
+ public _SDOPackage.SDOService getSDOService() {
+ return this._this();
+ }
+ /**
* {@.ja 初期化}
* {@.en Initialization}
*/
@@ -69,6 +99,7 @@
final _SDOPackage.ServiceProfile profile){
m_rtobj = rtobj;
m_profile = profile;
+ //m_profile.service = this._this();
/*
NVListHolder nvholder =
new NVListHolder(profile.properties);
@@ -166,6 +197,7 @@
public ReturnCode_t
set_fsm_structure(final RTC.FsmStructure fsm_structure) {
m_fsmStructure = fsm_structure;
+ setFsmStructure(m_fsmStructure);
return ReturnCode_t.RTC_OK;
}
@@ -206,6 +238,7 @@
public ReturnCode_t
get_fsm_structure(RTC.FsmStructureHolder fsm_structure) {
fsm_structure.value = m_fsmStructure;
+ getFsmStructure(m_fsmStructure);
return ReturnCode_t.RTC_OK;
}
@@ -315,7 +348,8 @@
*
*/
public static void ExtendedFsmServiceProviderInit() {
- final SdoServiceProviderFactory<SdoServiceProviderBase,String> factory
+// final SdoServiceProviderFactory<SdoServiceProviderBase,String> factory
+ final SdoServiceProviderFactory<ExtendedFsmServiceProvider,String> factory
= SdoServiceProviderFactory.instance();
factory.addFactory(ExtendedFsmServiceHelper.id(),
@@ -324,10 +358,39 @@
}
+ /**
+ * {@.ja FsmActionListener のホルダをセットする}
+ * {@.en Setting FsmActionListener holder}
+ * <p>
+ *
+ * @param fsmActionListeners
+ * {@.ja FsmActionListeners オブジェクトのポインタ}
+ * {@.en a pointer to FsmActionListeners}
+ *
+ */
+ public void setFsmActionListenerHolder(FsmActionListeners fsmActionListeners){
+ m_fsmActionListeners = fsmActionListeners;
+ }
+ protected void setFsmStructure(FsmStructure fstruct)
+ {
+
+ if (m_fsmActionListeners != null) {
+ m_fsmActionListeners.structure_[FsmStructureListenerType.SET_FSM_STRUCTURE].notify(fstruct);
+ }
+ }
+ protected void getFsmStructure(FsmStructure fstruct)
+ {
+ if (m_fsmActionListeners != null) {
+ m_fsmActionListeners.structure_[FsmStructureListenerType.GET_FSM_STRUCTURE].notify(fstruct);
+ }
+ }
+
private _SDOPackage.ServiceProfile m_profile;
private RTObject_impl m_rtobj;
private FsmStructure m_fsmStructure = new FsmStructure();
private String m_fsmState = new String();
+ private RTC.ExtendedFsmService m_objref;
+ protected FsmActionListeners m_fsmActionListeners = null;
};
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FactoryInit.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FactoryInit.java 2016-12-26 08:45:18 UTC (rev 896)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FactoryInit.java 2016-12-28 03:28:59 UTC (rev 897)
@@ -74,5 +74,7 @@
DefaultNumberingPolicy.DefaultNumberingPolicyInit();
NodeNumberingPolicy.NodeNumberingPolicyInit();
NamingServiceNumberingPolicy.NamingServiceNumberingPolicyInit();
+
+ ExtendedFsmServiceProvider.ExtendedFsmServiceProviderInit();
}
}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FsmStructureListener.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FsmStructureListener.java 2016-12-26 08:45:18 UTC (rev 896)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FsmStructureListener.java 2016-12-28 03:28:59 UTC (rev 897)
@@ -3,7 +3,7 @@
import java.util.Observable;
import java.util.Observer;
-import java.lang.Integer;
+import RTC.FsmStructure;
/**
* {@.ja FsmStructureListener クラス}
* {@.en FsmStructureListener class}
@@ -41,8 +41,8 @@
*/
public abstract class FsmStructureListener implements Observer{
public void update(Observable o, Object obj) {
- Integer arg = (Integer)obj;
- operator(arg.intValue());
+ FsmStructure arg = (FsmStructure)obj;
+ operator(arg);
}
/**
* {@.ja 仮想コールバック関数}
@@ -52,6 +52,6 @@
* {@.en This is a the Callback function for FsmStructureListener.}
*
*/
- public abstract void operator(final int exec_handle);
+ public abstract void operator(final FsmStructure fstruct);
}
Deleted: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FsmStructureListenerArgument.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FsmStructureListenerArgument.java 2016-12-26 08:45:18 UTC (rev 896)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FsmStructureListenerArgument.java 2016-12-28 03:28:59 UTC (rev 897)
@@ -1,26 +0,0 @@
-package jp.go.aist.rtm.RTC;
-
-import RTC.ReturnCode_t;
- /**
- * {@.ja FsmStructureListenerArgument クラス}
- * {@.en FsmStructureListenerArgument class}
- *
- *
- */
-public class FsmStructureListenerArgument {
- /**
- * {@.ja コンストラクタ}
- * {@.en Constructor}
- *
- */
- public FsmStructureListenerArgument(int handle,
- RTC.ReturnCode_t ret){
- m_exec_handle = handle;
- m_ret = ret;
- }
- public int m_exec_handle;
- public RTC.ReturnCode_t m_ret;
-}
-
-
-
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FsmStructureListenerHolder.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FsmStructureListenerHolder.java 2016-12-26 08:45:18 UTC (rev 896)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FsmStructureListenerHolder.java 2016-12-28 03:28:59 UTC (rev 897)
@@ -3,6 +3,8 @@
import java.util.Observable;
import RTC.ReturnCode_t;
+import RTC.FsmStructure;
+
/**
* {@.ja FsmStructureListener ホルダクラス}
* {@.en FsmStructureListener holder class}
@@ -14,11 +16,9 @@
*/
public class FsmStructureListenerHolder extends Observable{
- public void notify(final int ec_id, RTC.ReturnCode_t ret) {
+ public void notify(FsmStructure fstruct) {
super.setChanged();
- FsmStructureListenerArgument arg
- = new FsmStructureListenerArgument(ec_id,ret);
- super.notifyObservers((Object)arg);
+ super.notifyObservers(fstruct);
super.clearChanged();
}
}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FsmStructureListenerType.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FsmStructureListenerType.java 2016-12-26 08:45:18 UTC (rev 896)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FsmStructureListenerType.java 2016-12-28 03:28:59 UTC (rev 897)
@@ -17,11 +17,23 @@
public static final int SET_FSM_STRUCTURE = 0;
public static final int GET_FSM_STRUCTURE = 1;
- public static final int FSM_STRUCTURE_LISTENER_NUM = 2;
+ public static final int ADD_STATE = 2;
+ public static final int REMOVE_STATE = 3;
+ public static final int ADD_TRANSITION = 4;
+ public static final int REMOVE_TRANSITION = 5;
+ public static final int BIND_EVENT = 6;
+ public static final int UNBIND_EVENT = 7;
+ public static final int FSM_STRUCTURE_LISTENER_NUM = 8;
private static final String[] TypeString = {
"SET_FSM_STRUCTURE",
"GET_FSM_STRUCTURE",
+ "ADD_STATE",
+ "REMOVE_STATE",
+ "ADD_TRANSITION",
+ "REMOVE_TRANSITION",
+ "BIND_EVENT",
+ "UNBIND_EVENT",
"FSM_STRUCTURE_LISTENER_NUM",
};
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SdoServiceAdmin.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SdoServiceAdmin.java 2016-12-26 08:45:18 UTC (rev 896)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SdoServiceAdmin.java 2016-12-28 03:28:59 UTC (rev 897)
@@ -17,6 +17,7 @@
import _SDOPackage.ServiceProfileListHolder;
import _SDOPackage.SDOService;
import _SDOPackage.SDOServiceHolder;
+import _SDOPackage.SDOServiceHelper;
import jp.go.aist.rtm.RTC.log.Logbuf;
import jp.go.aist.rtm.RTC.util.CORBA_SeqUtil;
@@ -106,6 +107,7 @@
rtcout.println(Logbuf.DEBUG,"sdo.service.provider.available_services:"+
prop.getProperty("sdo.service.provider.available_services"));
+
// If types include '[Aa][Ll][Ll]', all types enabled in this RTC
Set activeProviderTypes = new HashSet();
@@ -133,7 +135,7 @@
ServiceProfile prof = new ServiceProfile();
prof.id = str;
prof.interface_type = str;
- prof.service = (SDOService)svc;
+ prof.service = (SDOService)svc.getSDOService();
String propkey = ifrToKey(str);
NVListHolder nvholder =
new NVListHolder(prof.properties);
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SdoServiceProviderBase.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SdoServiceProviderBase.java 2016-12-26 08:45:18 UTC (rev 896)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SdoServiceProviderBase.java 2016-12-28 03:28:59 UTC (rev 897)
@@ -2,6 +2,8 @@
import _SDOPackage.ServiceProfile;
import _SDOPackage.SDOServicePOA;
+import _SDOPackage.SDOService;
+import RTC.FsmService;
/**
* {@.ja SdoServiceProviderBase インターフェース。}
* {@.en SdoServiceProviderBase Interface.}
@@ -103,9 +105,9 @@
*/
-//public interface SdoServiceProviderBase extends SDOServicePOA{
public interface SdoServiceProviderBase {
+
/**
* {@.ja コンシューマクラスの初期化関数}
* {@.en Initialization function of the consumer class}
@@ -180,4 +182,6 @@
*/
public void finalize();
+ public _SDOPackage.SDOService getSDOService();
+
}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/ExtendedFsmServiceProviderTest.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/ExtendedFsmServiceProviderTest.java 2016-12-26 08:45:18 UTC (rev 896)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/ExtendedFsmServiceProviderTest.java 2016-12-28 03:28:59 UTC (rev 897)
@@ -18,6 +18,7 @@
import jp.go.aist.rtm.RTC.util.IntegerHolder;
import jp.go.aist.rtm.RTC.util.Properties;
import jp.go.aist.rtm.RTC.util.POAUtil;
+import jp.go.aist.rtm.RTC.util.ORBUtil;
import _SDOPackage.Configuration;
import _SDOPackage.ConfigurationSet;
@@ -37,8 +38,9 @@
import RTC.TimedLong;
import RTC.ReturnCode_t;
import RTC.ExecutionContextListHolder;
+import RTC.ExtendedFsmServiceHelper;
+import RTC.FsmStructure;
-
import org.omg.CORBA.ORB;
import org.omg.PortableServer.POA;
import org.omg.PortableServer.POAHelper;
@@ -247,14 +249,72 @@
m_mgr = null;
}
+ private class RTObject_impl_Mock extends RTObject_impl {
+ public RTObject_impl_Mock(Manager manager) {
+ super(manager);
+ }
+ FsmActionListeners getFsmActionListeners() {
+ return m_fsmActionListeners;
+ }
+ }
+ class Listener extends FsmStructureListener{
+ public Listener(final String name){
+ m_name = name;
+ }
+
+ public void operator(final FsmStructure arg){
+ System.out.println("------------------------------");
+ System.out.println("Listener: "+m_name);
+ System.out.println("FsmStructure::name: "+arg.name);
+ System.out.println("FsmStructure::structure: "+arg.structure);
+ System.out.println("------------------------------");
+ m_fsm_strcut = arg;
+ }
+ public String m_name;
+ public FsmStructure m_fsm_strcut;
+ public FsmStructure getFsmStructure() {
+ return m_fsm_strcut;
+ }
+
+ }
+
/**
*<pre>
*</pre>
*/
public void test_test001() {
- ExtendedFsmServiceProvider.ExtendedFsmServiceProviderInit();
+ //ExtendedFsmServiceProvider.ExtendedFsmServiceProviderInit();
+
+ Manager mgr = Manager.init(null);
+ try {
+ POA pPOA = mgr.getPOA();
+ pPOA.the_POAManager().activate();
+ }
+ catch (Exception ex) {
+ System.out.println("Exception:"+ex.getMessage());
+ }
+
+ RTObject_impl_Mock rtobj = new RTObject_impl_Mock(mgr);
+
+ rtobj.addFsmStructureListener(0,new Listener("SET_FSM_PROFILE"),true);
+ rtobj.addFsmStructureListener(1,new Listener("GET_FSM_PROFILE"),true);
+
+ final SdoServiceProviderFactory<ExtendedFsmServiceProvider,String>
+ factory = SdoServiceProviderFactory.instance();
+
+ ExtendedFsmServiceProvider provider;
+ provider = factory.createObject(ExtendedFsmServiceHelper.id());
+ provider.setFsmActionListenerHolder(rtobj.getFsmActionListeners());
+ RTC.FsmStructureHolder fsm_structure = new RTC.FsmStructureHolder();
+ provider.get_fsm_structure(fsm_structure);
+ fsm_structure.value.structure =
+ "<scxml xmlns=\"http://www.w3.org/2005/07/scxml\" "
+ +"version=\"1.0\""
+ +"initial=\"init-travel-plan\">";
+
+ provider.set_fsm_structure(fsm_structure.value);
}
}
More information about the openrtm-commit
mailing list