[openrtm-commit:02878] r1061 - in trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC: . executionContext
openrtm @ openrtm.org
openrtm @ openrtm.org
2017年 10月 20日 (金) 14:48:39 JST
Author: t-katami
Date: 2017-10-20 14:48:39 +0900 (Fri, 20 Oct 2017)
New Revision: 1061
Modified:
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObjectStateMachine.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/ExecutionContextWorker.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/PeriodicExecutionContext.java
Log:
[compat,bugfix->releng_1_2] Fixed processing of onRateChanged callback. refs #4261
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObjectStateMachine.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObjectStateMachine.java 2017-10-20 04:22:58 UTC (rev 1060)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObjectStateMachine.java 2017-10-20 05:48:39 UTC (rev 1061)
@@ -78,14 +78,14 @@
*/
private class onActivated implements StateAction {
public void doAction(StateHolder state) {
- // call Servant
- if (m_rtobjPtr != null) {
- if (m_rtobjPtr.on_activated(m_id) != ReturnCode_t.RTC_OK) {
- m_sm.goTo(LifeCycleState.ERROR_STATE);
- }
- return;
- }
- // call Object reference
+ // call Servant
+ if (m_rtobjPtr != null) {
+ if (m_rtobjPtr.on_activated(m_id) != ReturnCode_t.RTC_OK) {
+ m_sm.goTo(LifeCycleState.ERROR_STATE);
+ }
+ return;
+ }
+ // call Object reference
if (!m_ca) {
return;
}
@@ -153,14 +153,14 @@
*/
private class onStateUpdate implements StateAction {
public void doAction(StateHolder state) {
- // call Servant
- if (m_rtobjPtr != null) {
- if (m_rtobjPtr.on_state_update(m_id) != ReturnCode_t.RTC_OK) {
- m_sm.goTo(LifeCycleState.ERROR_STATE);
- }
- return;
- }
- // call Object reference
+ // call Servant
+ if (m_rtobjPtr != null) {
+ if (m_rtobjPtr.on_state_update(m_id) != ReturnCode_t.RTC_OK) {
+ m_sm.goTo(LifeCycleState.ERROR_STATE);
+ }
+ return;
+ }
+ // call Object reference
if (!m_dfc) {
return;
}
@@ -227,14 +227,14 @@
*/
private class onReset implements StateAction {
public void doAction(StateHolder state) {
- // call Servant
- if (m_rtobjPtr != null) {
- if (m_rtobjPtr.on_reset(m_id) != ReturnCode_t.RTC_OK) {
- m_sm.goTo(LifeCycleState.ERROR_STATE);
- }
- return;
- }
- // call Object reference
+ // call Servant
+ if (m_rtobjPtr != null) {
+ if (m_rtobjPtr.on_reset(m_id) != ReturnCode_t.RTC_OK) {
+ m_sm.goTo(LifeCycleState.ERROR_STATE);
+ }
+ return;
+ }
+ // call Object reference
if (!m_ca) {
return;
}
@@ -363,7 +363,7 @@
if (!m_ca) {
return;
}
- m_caVar.on_error(m_id);
+ m_caVar.on_aborting(m_id);
}
/**
*
@@ -441,23 +441,24 @@
/**
*
*/
- public void onRateChanged(){
+ public ReturnCode_t onRateChanged(){
// call Servant
if (m_rtobjPtr != null) {
- if (m_rtobjPtr.on_rate_changed(m_id) != ReturnCode_t.RTC_OK) {
+ ReturnCode_t ret = m_rtobjPtr.on_rate_changed(m_id);
+ if (!ret.equals(ReturnCode_t.RTC_OK)) {
m_sm.goTo(LifeCycleState.ERROR_STATE);
}
- return;
+ return ret;
}
// call Object reference
if (!m_dfc) {
- return;
+ return ReturnCode_t.RTC_ERROR;
}
- if (m_dfcVar.on_rate_changed(m_id) != ReturnCode_t.RTC_OK) {
+ ReturnCode_t ret = m_dfcVar.on_rate_changed(m_id);
+ if (!ret.equals(ReturnCode_t.RTC_OK)) {
m_sm.goTo(LifeCycleState.ERROR_STATE);
- return;
}
- return;
+ return ret;
}
// FsmParticipantAction
@@ -553,13 +554,14 @@
if (m_caVar==null) {
return;
}
- m_ca = true;
- Manager manager = Manager.instance();
- try {
- m_rtobjPtr = (RTObject_impl)manager.getPOA().reference_to_servant(comp);
- } catch (Exception ex) {
+ m_ca = true;
+ Manager manager = Manager.instance();
+ try {
+ m_rtobjPtr = (RTObject_impl)manager.getPOA().reference_to_servant(comp);
+ } catch (Exception ex) {
+ m_rtobjPtr = null;
- }
+ }
}
protected void setDataFlowComponentAction(final LightweightRTObject comp){
if(comp._is_a(DataFlowComponentActionHelper.id())) {
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/ExecutionContextWorker.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/ExecutionContextWorker.java 2017-10-20 04:22:58 UTC (rev 1060)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/ExecutionContextWorker.java 2017-10-20 05:48:39 UTC (rev 1061)
@@ -10,6 +10,7 @@
import jp.go.aist.rtm.RTC.util.TimeValue;
import jp.go.aist.rtm.RTC.log.Logbuf;
+import RTC.ExecutionContextListHolder;
import RTC.ExecutionContextService;
import RTC.LifeCycleState;
import RTC.LightweightRTObject;
@@ -164,6 +165,32 @@
}
/**
+ * {@.ja ExecutionContext の周期が変化した}
+ * {@.en Changing execution rate of the ExecutionContext}
+ * <p>
+ * @return
+ * {@.ja ReturnCode_t 型のリターンコード}
+ * {@.en The return code of ReturnCode_t type}
+ *
+ *
+ * RTC::ReturnCode_t rateChanged(void);
+ */
+ public ReturnCode_t rateChanged(){
+ rtcout.println(Logbuf.TRACE, "rateChanged()");
+ ReturnCode_t ret = ReturnCode_t.RTC_OK;
+ synchronized (m_mutex){
+ for (RTObjectStateMachine comp: m_comps) {
+ ReturnCode_t tmp = comp.onRateChanged();
+ if(!tmp.equals(ReturnCode_t.RTC_OK)){
+ ret = tmp;
+ }
+ }
+ }
+ return ret;
+
+ }
+
+ /**
* {@.ja RTコンポーネントをアクティブ化する}
* {@.en Activate an RT-component}
* <p>
@@ -210,8 +237,8 @@
"Component is in INACTIVE state. Going to ACTIVE state.");
rtobjhldr.rtobjsm.goTo(LifeCycleState.ACTIVE_STATE);
rtcout.println(Logbuf.DEBUG,"activateComponent() done.");
- return ReturnCode_t.RTC_OK;
}
+ return ReturnCode_t.RTC_OK;
}
public ReturnCode_t waitActivateComplete(RTObjectStateMachine rtobj,
TimeValue timeout,
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/PeriodicExecutionContext.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/PeriodicExecutionContext.java 2017-10-20 04:22:58 UTC (rev 1060)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/PeriodicExecutionContext.java 2017-10-20 05:48:39 UTC (rev 1061)
@@ -22,6 +22,7 @@
import jp.go.aist.rtm.RTC.util.TimeValue;
import jp.go.aist.rtm.RTC.util.equalFunctor;
import OpenRTM.DataFlowComponent;
+import RTC.ExecutionContextListHolder;
import RTC.ExecutionContextService;
import RTC.ExecutionContextServiceHelper;
import RTC.ExecutionContextServicePOA;
@@ -104,7 +105,7 @@
rtcout.println(Logbuf.TRACE, "PeriodicExecutionContext.setObjRef()");
m_worker.setECRef(ref);
m_profile.setObjRef(ref);
- m_ref = ref;
+ m_ref = ref;
}
/**
@@ -598,6 +599,15 @@
rtcout.println(Logbuf.ERROR, "Setting execution rate failed. " + rate);
return ret;
}
+
+ ret = m_worker.rateChanged();
+ if (ret != ReturnCode_t.RTC_OK)
+ {
+ rtcout.println(Logbuf.ERROR,
+ "Invoking on_rate_changed() for each RTC failed.");
+ return ret;
+ }
+
ret = onSetRate(rate);
if (ret != ReturnCode_t.RTC_OK)
{
@@ -1745,7 +1755,31 @@
*
*/
public ReturnCode_t setRate(double rate) {
- return m_profile.setRate(rate);
+ rtcout.println(Logbuf.TRACE, "setRate("+rate+")");
+ ReturnCode_t ret = m_profile.setRate(rate);
+ if(!ret.equals(ReturnCode_t.RTC_OK)){
+ rtcout.println(Logbuf.ERROR, "Setting execution rate failed. "
+ +rate);
+ return ret;
+ }
+
+ ret = m_worker.rateChanged();
+ if(!ret.equals(ReturnCode_t.RTC_OK)){
+ rtcout.println(Logbuf.ERROR,
+ "Invoking on_rate_changed() for each RTC failed.");
+ return ret;
+ }
+
+ ret = onSetRate(rate);
+ if(!ret.equals(ReturnCode_t.RTC_OK)){
+ rtcout.println(Logbuf.ERROR,
+ "onSetRate("+rate+" failed.");
+ return ret;
+ }
+
+
+ rtcout.println(Logbuf.INFO,"setRate("+rate+") done");
+ return ret;
}
/**
* {@.ja ExecutionContext の実行周期(Hz)を取得する}
More information about the openrtm-commit
mailing list