[openrtm-commit:02272] r908 - trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm
openrtm @ openrtm.org
openrtm @ openrtm.org
2017年 1月 19日 (木) 17:03:39 JST
Author: win-ei
Date: 2017-01-19 17:03:39 +0900 (Thu, 19 Jan 2017)
New Revision: 908
Modified:
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/Configuring.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/Idle.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/NotShooting.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/Off.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/ShootingCamera.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/ShootingCamera_Focused.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/ShootingCamera_Focusing.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/ShootingCamera_Shooting.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/ShootingCamera_Storing.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/StaticFsmImpl.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/Top.java
Log:
[FSM4RTC]Fixed FSM RTC samples. refs #3775
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/Configuring.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/Configuring.java 2017-01-18 08:53:24 UTC (rev 907)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/Configuring.java 2017-01-19 08:03:39 UTC (rev 908)
@@ -11,15 +11,24 @@
public class Configuring extends NotShooting {
@Override
- public void onInit() {
+ public void onEntry() {
+ System.out.println("Configuring::onEntry");
}
@Override
+ public void onExit() {
+ System.out.println("Configuring::onExit");
+ }
+
+ @Override
public void on_do() {
+ System.out.println("Configuring::on_do");
}
@Override
public void EvConfig(TimedLong param){
+ System.out.println("Configuring::EvConfig");
+ setState(new State(Idle.class));
}
}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/Idle.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/Idle.java 2017-01-18 08:53:24 UTC (rev 907)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/Idle.java 2017-01-19 08:03:39 UTC (rev 908)
@@ -11,15 +11,24 @@
public class Idle extends NotShooting {
@Override
- public void onInit() {
+ public void onEntry() {
+ System.out.println("Idle::onEntry");
}
@Override
+ public void onExit() {
+ System.out.println("Idle::onExit");
+ }
+
+ @Override
public void on_do() {
+ System.out.println("Idle::on_do");
}
@Override
public void EvConfig(TimedLong param){
+ System.out.println("Idle::EvConfig");
+ setState(new State(Configuring.class));
}
}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/NotShooting.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/NotShooting.java 2017-01-18 08:53:24 UTC (rev 907)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/NotShooting.java 2017-01-19 08:03:39 UTC (rev 908)
@@ -11,19 +11,36 @@
public class NotShooting extends Top {
@Override
+ public void onEntry() {
+ System.out.println("NotShooting::onEntry");
+ }
+
+ @Override
public void onInit() {
+ System.out.println("NotShooting::onInit");
+ setState(new State(Idle.class));
}
@Override
+ public void onExit() {
+ System.out.println("NotShooting::onExit");
+ }
+
+ @Override
public void on_do() {
+ System.out.println("NotShooting::on_do");
}
@Override
public void EvOff(TimedLong param){
+ System.out.println("NotShooting::EvOff");
+ setState(new State(Off.class));
}
@Override
public void EvShutterHalf(TimedLong param){
+ System.out.println("NotShooting::EvShutterHalf");
+ setState(new State(ShootingCamera.class));
}
}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/Off.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/Off.java 2017-01-18 08:53:24 UTC (rev 907)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/Off.java 2017-01-19 08:03:39 UTC (rev 908)
@@ -11,15 +11,23 @@
public class Off extends Top {
@Override
- public void onInit() {
+ public void onEntry() {
+ System.out.println("Off::onEntry");
}
@Override
+ public void onExit() {
+ System.out.println("Off::onExit");
+ }
+
+ @Override
public void on_do() {
+ System.out.println("Off::on_do");
}
@Override
public void EvOn(TimedLong param){
+ System.out.println("Off::EvOn");
}
}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/ShootingCamera.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/ShootingCamera.java 2017-01-18 08:53:24 UTC (rev 907)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/ShootingCamera.java 2017-01-19 08:03:39 UTC (rev 908)
@@ -11,15 +11,29 @@
public class ShootingCamera extends Top {
@Override
+ public void onEntry() {
+ System.out.println("ShootingCamera::onEntry");
+ }
+
+ @Override
public void onInit() {
+ System.out.println("ShootingCamera::onInit");
}
@Override
+ public void onExit() {
+ System.out.println("ShootingCamera::onExit");
+ }
+
+ @Override
public void on_do() {
+ System.out.println("ShootingCamera::on_do");
}
@Override
public void EvShutterReleased(TimedLong param){
+ System.out.println("ShootingCamera::EvShutterReleased");
+ setState(new State(NotShooting.class));
}
}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/ShootingCamera_Focused.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/ShootingCamera_Focused.java 2017-01-18 08:53:24 UTC (rev 907)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/ShootingCamera_Focused.java 2017-01-19 08:03:39 UTC (rev 908)
@@ -11,16 +11,24 @@
public class ShootingCamera_Focused extends ShootingCamera_Shooting {
@Override
- public void onInit() {
+ public void onEntry() {
+ System.out.println("ShootingCamera_Focused::onEntry");
}
@Override
+ public void onExit() {
+ System.out.println("ShootingCamera_Focused::onExit");
+ }
+
+ @Override
public void on_do() {
+ System.out.println("ShootingCamera_Focused::on_do");
}
-
@Override
public void EvShutterFull(TimedLong param){
+ System.out.println("ShootingCamera_Focused::EvShutterFull");
+ setState(new State(ShootingCamera_Storing.class));
}
}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/ShootingCamera_Focusing.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/ShootingCamera_Focusing.java 2017-01-18 08:53:24 UTC (rev 907)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/ShootingCamera_Focusing.java 2017-01-19 08:03:39 UTC (rev 908)
@@ -11,20 +11,29 @@
public class ShootingCamera_Focusing extends ShootingCamera_Shooting {
@Override
- public void onInit() {
+ public void onEntry() {
+ System.out.println("ShootingCamera_Focusing::onEntry");
}
@Override
+ public void onExit() {
+ System.out.println("ShootingCamera_Focusing::onExit");
+ }
+
+ @Override
public void on_do() {
+ System.out.println("ShootingCamera_Focusing::on_do");
}
-
@Override
public void EvInFocus(TimedLong param){
+ System.out.println("ShootingCamera_Focusing::EvInFocus");
+ setState(new State(ShootingCamera_Focused.class));
}
@Override
public void EvShutterFull(TimedLong param){
+ System.out.println("ShootingCamera_Focusing::EvShutterFull");
}
}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/ShootingCamera_Shooting.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/ShootingCamera_Shooting.java 2017-01-18 08:53:24 UTC (rev 907)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/ShootingCamera_Shooting.java 2017-01-19 08:03:39 UTC (rev 908)
@@ -11,11 +11,19 @@
public class ShootingCamera_Shooting extends ShootingCamera {
@Override
+ public void onEntry() {
+ System.out.println("ShootingCamera_Shooting::onEntry");
+ }
+
+ @Override
public void onInit() {
+ System.out.println("ShootingCamera_Shooting::onInit");
+ setState(new State(ShootingCamera_Focusing.class));
}
@Override
public void on_do() {
+ System.out.println("ShootingCamera_Shooting::on_do");
}
}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/ShootingCamera_Storing.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/ShootingCamera_Storing.java 2017-01-18 08:53:24 UTC (rev 907)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/ShootingCamera_Storing.java 2017-01-19 08:03:39 UTC (rev 908)
@@ -10,12 +10,20 @@
@DeepHistory
public class ShootingCamera_Storing extends ShootingCamera_Shooting {
+
@Override
- public void onInit() {
+ public void onEntry() {
+ System.out.println("ShootingCamera_Storing::onEntry");
}
@Override
+ public void onExit() {
+ System.out.println("ShootingCamera_Storing::onExit");
+ }
+
+ @Override
public void on_do() {
+ System.out.println("ShootingCamera_Storing::on_do");
}
}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/StaticFsmImpl.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/StaticFsmImpl.java 2017-01-18 08:53:24 UTC (rev 907)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/StaticFsmImpl.java 2017-01-19 08:03:39 UTC (rev 908)
@@ -10,9 +10,14 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.ArrayDeque;
+import java.util.Queue;
+
import jp.go.aist.rtm.RTC.DataFlowComponentBase;
import jp.go.aist.rtm.RTC.Manager;
+import jp.go.aist.rtm.RTC.jfsm.Event;
import jp.go.aist.rtm.RTC.jfsm.Machine;
+import jp.go.aist.rtm.RTC.jfsm.machine.EventBase;
import jp.go.aist.rtm.RTC.port.ConnectorBase;
import jp.go.aist.rtm.RTC.port.InPort;
import jp.go.aist.rtm.RTC.port.OutPort;
@@ -97,33 +102,38 @@
addInPort("EvShutterHalf", m_EvShutterHalfIn);
addInPort("EvShutterReleased", m_EvShutterReleasedIn);
+ machine_ = new Machine<>(Top.class, CameraProtocol.class, null);
+ m_que = new ArrayDeque<Event>();
+
+
m_EvConfigIn.addConnectorDataListener(
ConnectorDataListenerType.ON_RECEIVED,
- new DataListener("ON_RECEIVED"));
+ new DataListener("EvConfig",m_que));
m_EvInFocusIn.addConnectorDataListener(
ConnectorDataListenerType.ON_RECEIVED,
- new DataListener("ON_RECEIVED"));
+ new DataListener("EvInFocus",m_que));
m_EvOffIn.addConnectorDataListener(
ConnectorDataListenerType.ON_RECEIVED,
- new DataListener("ON_RECEIVED"));
+ new DataListener("EvOff",m_que));
m_EvOnIn.addConnectorDataListener(
ConnectorDataListenerType.ON_RECEIVED,
- new DataListener("ON_RECEIVED"));
+ new DataListener("EvOn",m_que));
m_EvShutterFullIn.addConnectorDataListener(
ConnectorDataListenerType.ON_RECEIVED,
- new DataListener("ON_RECEIVED"));
+ new DataListener("EvShutter",m_que));
m_EvShutterHalfIn.addConnectorDataListener(
ConnectorDataListenerType.ON_RECEIVED,
- new DataListener("ON_RECEIVED"));
+ new DataListener("EvShutterHalf",m_que));
m_EvShutterReleasedIn.addConnectorDataListener(
ConnectorDataListenerType.ON_RECEIVED,
- new DataListener("ON_RECEIVED"));
+ new DataListener("EvShutterReleased",m_que));
// Set OutPort buffer
addOutPort("out", m_outOut);
// </rtc-template>
- machine_ = new Machine<>(Top.class, CameraProtocol.class, null);
+
+
return super.onInitialize();
}
@@ -218,6 +228,12 @@
*/
@Override
protected ReturnCode_t onExecute(int ec_id) {
+ System.out.println(m_que.size());
+ while (!m_que.isEmpty()) {
+ Event ev = m_que.poll();
+ machine_.dispatch(ev);
+ //machine_.current().EvConfig(m_EvConfig_val);
+ }
return super.onExecute(ec_id);
}
@@ -356,7 +372,8 @@
*/
protected OutPort<TimedLong> m_outOut;
- Machine<Top, CameraProtocol> machine_;
+ private Machine<Top, CameraProtocol> machine_;
+ private Queue<Event> m_que;
// </rtc-template>
@@ -426,10 +443,12 @@
}
}
}
+
class DataListener extends ConnectorDataListenerT<TimedLong>{
- public DataListener(final String name){
+ public DataListener(final String name, Queue<Event> que){
super(TimedLong.class);
m_name = name;
+ m_que = que;
}
public void operator(final ConnectorBase.ConnectorInfo arg,
@@ -437,11 +456,12 @@
ConnectorBase.ConnectorInfo info =(ConnectorBase.ConnectorInfo)arg;
System.out.println("------------------------------");
System.out.println("Listener: "+m_name);
- System.out.println("Profile::name: "+info.name);
- System.out.println("Profile::id: "+info.id);
System.out.println("Data: "+data.data);
System.out.println("------------------------------");
+ m_que.offer(new Event(m_name,(Object)data));
}
- public String m_name;
+
+ private String m_name;
+ private Queue<Event> m_que;
}
}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/Top.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/Top.java 2017-01-18 08:53:24 UTC (rev 907)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/StaticFsm/Top.java 2017-01-19 08:03:39 UTC (rev 908)
@@ -64,16 +64,23 @@
@Override
public void onEntry() {
- System.out.println("Top::on_entry");
+ System.out.println("Top::onEntry");
}
@Override
public void onInit() {
- //setState(new State(Operational.class));
+ System.out.println("Top::onInit");
+ setState(new State(Off.class));
}
@Override
+ public void onExit() {
+ System.out.println("Top::onExit");
+ }
+
+ @Override
public void on_do() {
+ System.out.println("Top::on_do");
}
@Override
More information about the openrtm-commit
mailing list