[openrtm-commit:03012] r900 - in branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist: . examples/StaticFsm python3_examples/StaticFsm

openrtm @ openrtm.org openrtm @ openrtm.org
2017年 12月 13日 (水) 09:32:40 JST


Author: miyamoto
Date: 2017-12-13 09:32:40 +0900 (Wed, 13 Dec 2017)
New Revision: 900

Added:
   branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/MicrowaveFsm_pyfsm.py
   branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/Microwave_pyfsm.py
Modified:
   branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/EventDrivenExecutionContext.py
   branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/InPortPushConnector.py
   branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/StaticFSM.py
   branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/StaticFSM_pyfsm.py
   branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/examples/StaticFsm/Microwave.py
   branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/examples/StaticFsm/MicrowaveFsm.py
   branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/examples/StaticFsm/MicrowaveFsm_pyfsm.py
   branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/Display.py
   branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/Inputbutton.py
   branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/Microwave.py
   branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/MicrowaveFsm.py
Log:
[compat, bugfix, ->RELENG_2_0] bug fix.

Modified: branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/EventDrivenExecutionContext.py
===================================================================
--- branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/EventDrivenExecutionContext.py	2017-12-13 00:30:12 UTC (rev 899)
+++ branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/EventDrivenExecutionContext.py	2017-12-13 00:32:40 UTC (rev 900)
@@ -25,9 +25,9 @@
 # @class PeriodicExecutionContext
 # @brief PeriodicExecutionContext ¥¯¥é¥¹
 #
-# Periodic Sampled Data Processing(¼þ´ü¼Â¹ÔÍÑ)ExecutionContext¥¯¥é¥¹¡£
+# Periodic EventDrivenExecutionContext¥¯¥é¥¹¡£
 #
-# @since 0.4.0
+# @since 2.0.0
 #
 # @else
 # @class EventDrivenExecutionContext
@@ -67,7 +67,7 @@
 # @else
 #
 # @endif
-def PeriodicExecutionContextInit(manager):
+def EventDrivenExecutionContextInit(manager):
   OpenRTM_aist.ExecutionContextFactory.instance().addFactory("EventDrivenExecutionContext",
                                                              OpenRTM_aist.EventDrivenExecutionContext,
                                                              OpenRTM_aist.ECDelete)

Modified: branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/InPortPushConnector.py
===================================================================
--- branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/InPortPushConnector.py	2017-12-13 00:30:12 UTC (rev 899)
+++ branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/InPortPushConnector.py	2017-12-13 00:32:40 UTC (rev 900)
@@ -213,14 +213,16 @@
 
     cdr = [""]
     ret = self._buffer.read(cdr)
+
     
 
     if not self._dataType:
       return self.PRECONDITION_NOT_MET
     if self._endian is not None:
-      _data = cdrUnmarshal(any.to_any(self._dataType).typecode(),cdr[0],self._endian)
-      if type(data) == list:
-        data[0] = _data
+      if ret == OpenRTM_aist.BufferStatus.BUFFER_OK:
+        _data = cdrUnmarshal(any.to_any(self._dataType).typecode(),cdr[0],self._endian)
+        if type(data) == list:
+          data[0] = _data
     else:
       self._rtcout.RTC_ERROR("unknown endian from connector")
       return self.PRECONDITION_NOT_MET
@@ -417,10 +419,10 @@
     return
   def onBufferEmpty(self, data):
     if self._listeners and self._profile:
-      self._listeners.connectorData_[OpenRTM_aist.ConnectorDataListenerType.ON_BUFFER_EMPTY].notify(self._profile, data)
+      self._listeners.connector_[OpenRTM_aist.ConnectorListenerType.ON_BUFFER_EMPTY].notify(self._profile)
     return
   def onBufferReadTimeout(self, data):
     if self._listeners and self._profile:
-      self._listeners.connectorData_[OpenRTM_aist.ConnectorDataListenerType.ON_BUFFER_READ_TIMEOUT].notify(self._profile, data)
+      self._listeners.connector_[OpenRTM_aist.ConnectorListenerType.ON_BUFFER_READ_TIMEOUT].notify(self._profile)
     return
   
\ No newline at end of file

Modified: branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/StaticFSM.py
===================================================================
--- branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/StaticFSM.py	2017-12-13 00:30:12 UTC (rev 899)
+++ branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/StaticFSM.py	2017-12-13 00:32:40 UTC (rev 900)
@@ -24,15 +24,12 @@
     def __init__(self, instance):
       ret.__init__(self, instance)
     def on_entry(self, *argv):
-      OpenRTM_aist.Link.call_entry(self)
-      ret.on_entry(self, *argv)
+      ret.call_entry(self, ret, *argv)
     def on_exit(self, *argv):
-      OpenRTM_aist.Link.call_exit(self)
-      ret.on_exit(self, *argv)
+      ret.call_exit(self, ret, *argv)
     def on_init(self, *argv):
-      OpenRTM_aist.Link.call_init(self)
-      ret.on_init(self, *argv)
-  return ret
+      ret.call_init(self, ret, *argv)
+  return STATE
 
 
 def fsm_substate(superstate):
@@ -42,25 +39,22 @@
       def __init__(self, instance):
         ret.__init__(self, instance)
       def on_entry(self, *argv):
-        OpenRTM_aist.Link.call_entry(self)
-        ret.on_entry(self, *argv)
+        ret.call_entry(self, cls, *argv)
       def on_exit(self, *argv):
-        OpenRTM_aist.Link.call_exit(self)
-        ret.on_exit(self, *argv)
+        ret.call_exit(self, cls, *argv)
       def on_init(self, *argv):
-        OpenRTM_aist.Link.call_init(self)
-        ret.on_init(self, *argv)
+        ret.call_init(self, cls, *argv)
 
-    return ret
+    return STATE
   return _fsm_substate
 
 
 def FSM_TOPSTATE(TOP):
-  OpenRTM_aist.Macho.TOPSTATE(TOP)
+  return fsm_topstate(TOP)
 
 
-def FSM_SUBSTATE(STATE, SUPERSTATE):
-  OpenRTM_aist.Macho.SUBSTATE(STATE, SUPERSTATE)
+def FSM_SUBSTATE(SUPERSTATE):
+  return fsm_substate(SUPERSTATE)
 
 
 
@@ -96,31 +90,31 @@
     if machine:
       self._rtComponent = machine.getComp()
 
-  def call_entry(self):
+  def call_entry(self, cls, *argv):
     self.setrtc()
     if not self._rtComponent:
-      self.onEntry()
+      cls.onEntry(self, *argv)
     else:
       self._rtComponent.postOnFsmStateChange(self._state_name(), RTC.RTC_OK)
       self._rtComponent.preOnFsmEntry(self._state_name())
-      self._rtComponent.postOnFsmEntry(self._state_name(), self.onEntry())
+      self._rtComponent.postOnFsmEntry(self._state_name(),cls.onEntry(self, *argv))
 
-  def call_init(self):
+  def call_init(self, cls, *argv):
     self.setrtc()
     if not self._rtComponent:
-      self.onInit()
+      cls.onInit(self, *argv)
     else:
       self._rtComponent.preOnFsmInit(self._state_name())
-      self._rtComponent.postOnFsmInit(self._state_name(), self.onInit())
+      self._rtComponent.postOnFsmInit(self._state_name(), cls.onInit(self, *argv))
 
 
-  def call_exit(self):
+  def call_exit(self, cls, *argv):
     self.setrtc()
     if not self._rtComponent:
-      self.onExit()
+      cls.onExit(self, *argv)
     else:
       self._rtComponent.preOnFsmExit(self._state_name())
-      self._rtComponent.postOnFsmExit(self._state_name(), self.onExit())
+      self._rtComponent.postOnFsmExit(self._state_name(), cls.onExit(self, *argv))
       self._rtComponent.preOnFsmStateChange(self._state_name())
 
   def onEntry(self):

Modified: branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/StaticFSM_pyfsm.py
===================================================================
--- branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/StaticFSM_pyfsm.py	2017-12-13 00:30:12 UTC (rev 899)
+++ branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/StaticFSM_pyfsm.py	2017-12-13 00:32:40 UTC (rev 900)
@@ -24,15 +24,12 @@
     def __init__(self, instance):
       ret.__init__(self, instance)
     def on_entry(self, *argv):
-      OpenRTM_aist.Link.call_entry(self)
-      ret.on_entry(self, *argv)
+      ret.call_entry(self, ret, *argv)
     def on_exit(self, *argv):
-      OpenRTM_aist.Link.call_exit(self)
-      ret.on_exit(self, *argv)
+      ret.call_exit(self, ret, *argv)
     def on_init(self, *argv):
-      OpenRTM_aist.Link.call_init(self)
-      ret.on_init(self, *argv)
-  return ret
+      ret.call_init(self, ret, *argv)
+  return STATE
 
 
 def fsm_substate(superstate):
@@ -42,23 +39,26 @@
       def __init__(self, instance):
         ret.__init__(self, instance)
       def on_entry(self, *argv):
-        OpenRTM_aist.Link.call_entry(self)
-        ret.on_entry(self, *argv)
+        ret.call_entry(self, cls, *argv)
       def on_exit(self, *argv):
-        OpenRTM_aist.Link.call_exit(self)
-        ret.on_exit(self, *argv)
+        ret.call_exit(self, cls, *argv)
       def on_init(self, *argv):
-        OpenRTM_aist.Link.call_init(self)
-        ret.on_init(self, *argv)
+        ret.call_init(self, cls, *argv)
 
-    return ret
+    return STATE
   return _fsm_substate
 
 
 
+def FSM_TOPSTATE(TOP):
+  return fsm_topstate(TOP)
 
 
+def FSM_SUBSTATE(SUPERSTATE):
+  return fsm_substate(SUPERSTATE)
 
+
+
 class Machine(pyfsm.Machine):
   def __init__(self, TOP, comp):
     self._rtComponent = comp
@@ -90,31 +90,31 @@
     if machine:
       self._rtComponent = machine.getComp()
 
-  def call_entry(self):
+  def call_entry(self, cls, *argv):
     self.setrtc()
     if not self._rtComponent:
-      self.onEntry()
+      self.onEntry(*argv)
     else:
       self._rtComponent.postOnFsmStateChange(self._state_name(), RTC.RTC_OK)
       self._rtComponent.preOnFsmEntry(self._state_name())
-      self._rtComponent.postOnFsmEntry(self._state_name(), self.onEntry())
+      self._rtComponent.postOnFsmEntry(self._state_name(),cls.onEntry(self, *argv))
 
-  def call_init(self):
+  def call_init(self, cls, *argv):
     self.setrtc()
     if not self._rtComponent:
-      self.onInit()
+      self.onInit(*argv)
     else:
       self._rtComponent.preOnFsmInit(self._state_name())
-      self._rtComponent.postOnFsmInit(self._state_name(), self.onInit())
+      self._rtComponent.postOnFsmInit(self._state_name(), cls.onInit(self, *argv))
 
 
-  def call_exit(self):
+  def call_exit(self, cls, *argv):
     self.setrtc()
     if not self._rtComponent:
-      self.onExit()
+      self.onExit(*argv)
     else:
       self._rtComponent.preOnFsmExit(self._state_name())
-      self._rtComponent.postOnFsmExit(self._state_name(), self.onExit())
+      self._rtComponent.postOnFsmExit(self._state_name(), cls.onExit(self, *argv))
       self._rtComponent.preOnFsmStateChange(self._state_name())
 
   def onEntry(self):

Modified: branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/examples/StaticFsm/Microwave.py
===================================================================
--- branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/examples/StaticFsm/Microwave.py	2017-12-13 00:30:12 UTC (rev 899)
+++ branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/examples/StaticFsm/Microwave.py	2017-12-13 00:32:40 UTC (rev 900)
@@ -45,10 +45,8 @@
     
     return
 
-  def onFinalize(self):
-    self._fsm.shutdown()
-    return RTC.RTC_OK
 
+
   def onInitialize(self):
     self._fsm = StaticFSM.Machine(MicrowaveFsm.TOP, self)
     #self._fsm.init()
@@ -66,6 +64,11 @@
 
     return RTC.RTC_OK
 
+
+  def onFinalize(self):
+    self._fsm.shutdown()
+    return RTC.RTC_OK
+
         
   def onExecute(self, ec_id):
     

Modified: branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/examples/StaticFsm/MicrowaveFsm.py
===================================================================
--- branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/examples/StaticFsm/MicrowaveFsm.py	2017-12-13 00:30:12 UTC (rev 899)
+++ branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/examples/StaticFsm/MicrowaveFsm.py	2017-12-13 00:32:40 UTC (rev 900)
@@ -15,15 +15,16 @@
 
 import sys
 
+
 import RTC
-import OpenRTM_aist
 import OpenRTM_aist.StaticFSM as StaticFSM
-import OpenRTM_aist.EventPort as EventPort
 
- at StaticFSM.fsm_topstate
+
+ at StaticFSM.FSM_TOPSTATE
 class TOP(StaticFSM.Link):
-  def on_init(self):
+  def onInit(self):
     self.set_state(StaticFSM.State(Operational))
+    return RTC.RTC_OK
 
 
   def open(self):
@@ -56,12 +57,14 @@
     
 
     
- at StaticFSM.fsm_substate(TOP)
+ at StaticFSM.FSM_SUBSTATE(TOP)
 class Disabled(StaticFSM.Link):
-  def on_entry(self):
+  def onEntry(self):
     print("  Microwave opened")
-  def on_exit(self):
+    return RTC.RTC_OK
+  def onExit(self):
     print("  Microwave closed")
+    return RTC.RTC_OK
   def close(self):
     #self.setStateHistory(OpenRTM_aist.Macho.State(Operational))
     self.set_state(StaticFSM.State(Operational))
@@ -68,14 +71,15 @@
 
 
 @StaticFSM.deephistory
- at StaticFSM.fsm_substate(TOP)
+ at StaticFSM.FSM_SUBSTATE(TOP)
 class Operational(StaticFSM.Link):
   def open(self):
     self.set_state(StaticFSM.State(Disabled))
   def stop(self):
     self.set_state(StaticFSM.State(Idle))
-  def on_init(self):
+  def onInit(self):
     self.set_state(StaticFSM.State(Idle))
+    return RTC.RTC_OK
 
 
   
@@ -85,21 +89,22 @@
 
 
 
- at StaticFSM.fsm_substate(Operational)
+ at StaticFSM.FSM_SUBSTATE(Operational)
 class Idle(StaticFSM.Link):
   def minute(self, time_):
     self.set_state(StaticFSM.State(Programmed))
     self.dispatch(StaticFSM.Event(TOP.minute,time_))
     
-  def on_entry(self):
+  def onEntry(self):
     self.data(TOP).resetTimer()
     print("  Microwave ready")
+    return RTC.RTC_OK
 
 
 
 
 
- at StaticFSM.fsm_substate(Operational)
+ at StaticFSM.FSM_SUBSTATE(Operational)
 class Programmed(StaticFSM.Link):
   def minute(self, time_):
     for t in range(time_.data):
@@ -112,7 +117,7 @@
 
 
 
- at StaticFSM.fsm_substate(Programmed)
+ at StaticFSM.FSM_SUBSTATE(Programmed)
 class Cooking(StaticFSM.Link):
   def tick(self):
     print("  Clock tick")
@@ -124,9 +129,11 @@
     else:
       tb.printTimer()
     
-  def on_entry(self):
+  def onEntry(self):
     print("  Heating on")
-  def on_exit(self):
+    return RTC.RTC_OK
+  def onExit(self):
     print("  Heating off")
+    return RTC.RTC_OK
 
 

Modified: branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/examples/StaticFsm/MicrowaveFsm_pyfsm.py
===================================================================
--- branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/examples/StaticFsm/MicrowaveFsm_pyfsm.py	2017-12-13 00:30:12 UTC (rev 899)
+++ branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/examples/StaticFsm/MicrowaveFsm_pyfsm.py	2017-12-13 00:32:40 UTC (rev 900)
@@ -15,15 +15,16 @@
 
 import sys
 
-import RTC
-import OpenRTM_aist
+
+
 import OpenRTM_aist.StaticFSM_pyfsm as StaticFSM
-import OpenRTM_aist.EventPort_pyfsm as EventPort
 
- at StaticFSM.fsm_topstate
+
+ at StaticFSM.FSM_TOPSTATE
 class TOP(StaticFSM.Link):
-  def on_init(self):
+  def onInit(self):
     self.set_state(StaticFSM.State(Operational))
+    return RTC.RTC_OK
 
 
   def open(self):
@@ -56,12 +57,14 @@
     
 
     
- at StaticFSM.fsm_substate(TOP)
+ at StaticFSM.FSM_SUBSTATE(TOP)
 class Disabled(StaticFSM.Link):
-  def on_entry(self):
+  def onEntry(self):
     print("  Microwave opened")
-  def on_exit(self):
+    return RTC.RTC_OK
+  def onExit(self):
     print("  Microwave closed")
+    return RTC.RTC_OK
   def close(self):
     #self.setStateHistory(OpenRTM_aist.Macho.State(Operational))
     self.set_state(StaticFSM.State(Operational))
@@ -68,14 +71,15 @@
 
 
 @StaticFSM.deephistory
- at StaticFSM.fsm_substate(TOP)
+ at StaticFSM.FSM_SUBSTATE(TOP)
 class Operational(StaticFSM.Link):
   def open(self):
     self.set_state(StaticFSM.State(Disabled))
   def stop(self):
     self.set_state(StaticFSM.State(Idle))
-  def on_init(self):
+  def onInit(self):
     self.set_state(StaticFSM.State(Idle))
+    return RTC.RTC_OK
 
 
   
@@ -85,21 +89,22 @@
 
 
 
- at StaticFSM.fsm_substate(Operational)
+ at StaticFSM.FSM_SUBSTATE(Operational)
 class Idle(StaticFSM.Link):
   def minute(self, time_):
     self.set_state(StaticFSM.State(Programmed))
     self.dispatch(StaticFSM.Event(TOP.minute,time_))
     
-  def on_entry(self):
+  def onEntry(self):
     self.data(TOP).resetTimer()
     print("  Microwave ready")
+    return RTC.RTC_OK
 
 
 
 
 
- at StaticFSM.fsm_substate(Operational)
+ at StaticFSM.FSM_SUBSTATE(Operational)
 class Programmed(StaticFSM.Link):
   def minute(self, time_):
     for t in range(time_.data):
@@ -112,7 +117,7 @@
 
 
 
- at StaticFSM.fsm_substate(Programmed)
+ at StaticFSM.FSM_SUBSTATE(Programmed)
 class Cooking(StaticFSM.Link):
   def tick(self):
     print("  Clock tick")
@@ -124,9 +129,11 @@
     else:
       tb.printTimer()
     
-  def on_entry(self):
+  def onEntry(self):
     print("  Heating on")
-  def on_exit(self):
+    return RTC.RTC_OK
+  def onExit(self):
     print("  Heating off")
+    return RTC.RTC_OK
 
 

Modified: branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/Display.py
===================================================================
--- branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/Display.py	2017-12-13 00:30:12 UTC (rev 899)
+++ branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/Display.py	2017-12-13 00:32:40 UTC (rev 900)
@@ -38,16 +38,16 @@
     self._name = name
 
   def __del__(self):
-    print("dtor of ", self._name)
+    print "dtor of ", self._name
 
   def __call__(self, info, cdrdata):
     data = OpenRTM_aist.ConnectorDataListenerT.__call__(self, info, cdrdata, RTC.TimedLong(RTC.Time(0,0),0))
-    print("------------------------------")
-    print("Listener:       ", self._name)
-    print("Profile::name:  ", info.name)
-    print("Profile::id:    ", info.id)
-    print("Data:           ", data.data)
-    print("------------------------------")
+    print "------------------------------"
+    print "Listener:       ", self._name
+    print "Profile::name:  ", info.name
+    print "Profile::id:    ", info.id
+    print "Data:           ", data.data
+    print "------------------------------"
     return OpenRTM_aist.ConnectorListenerStatus.NO_CHANGE
 
 
@@ -56,14 +56,14 @@
     self._name = name
 
   def __del__(self):
-    print("dtor of ", self._name)
+    print "dtor of ", self._name
 
   def __call__(self, info):
-    print("------------------------------")
-    print("Listener:       ", self._name)
-    print("Profile::name:  ", info.name)
-    print("Profile::id:    ", info.id)
-    print("------------------------------")
+    print "------------------------------"
+    print "Listener:       ", self._name
+    print "Profile::name:  ", info.name
+    print "Profile::id:    ", info.id
+    print "------------------------------"
     return OpenRTM_aist.ConnectorListenerStatus.NO_CHANGE
 
 
@@ -127,9 +127,9 @@
   def onExecute(self, ec_id):
     if self._inIn.isNew():
       data = self._inIn.read()
-      print("Received: ", data.data)
-      print("TimeStamp: ", data.tm.sec,"[s]")
-      print("TimeStamp: ", data.tm.nsec,"[ns]")
+      print "Received: ", data.data
+      print "TimeStamp: ", data.tm.sec,"[s]"
+      print "TimeStamp: ", data.tm.nsec,"[ns]"
 
     
     return RTC.RTC_OK

Modified: branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/Inputbutton.py
===================================================================
--- branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/Inputbutton.py	2017-12-13 00:30:12 UTC (rev 899)
+++ branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/Inputbutton.py	2017-12-13 00:32:40 UTC (rev 900)
@@ -77,21 +77,21 @@
     print("  stop         : Stop the microwave.")
     print("  tick         : Proceed time.")
     print("  -> others are interpreted as tick commnad.")
-    #print ">> ",
-    print(">> ",end="")
+    print ">> ",
+    #print(">> ",end="")
     cmds = sys.stdin.readline()
     cmds = cmds.split(" ")
     OpenRTM_aist.StringUtil.eraseBlank(cmds)
     cmds[0] = cmds[0].replace("\n","")
     cmds[0] = cmds[0].replace("\r","")
-    print("[command]: ",cmds[0])
-    print("  [args]: ",end="")
-    #print "  [args]: ",
+    print "[command]: ",cmds[0]
+    #print("  [args]: ",end="")
+    print "  [args]: ",
     for n in range(len(cmds)):
       if n == 0:
         continue
-      print(cmds[n],end="")
-      #print cmds[n],
+      #print(cmds[n],end="")
+      print cmds[n],
     print("")
     if cmds[0] == "open":
       self._open.data = 0

Modified: branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/Microwave.py
===================================================================
--- branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/Microwave.py	2017-12-13 00:30:12 UTC (rev 899)
+++ branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/Microwave.py	2017-12-13 00:32:40 UTC (rev 900)
@@ -17,6 +17,8 @@
 
 import RTC
 import OpenRTM_aist
+import OpenRTM_aist.StaticFSM as StaticFSM
+import OpenRTM_aist.EventPort as EventPort
 
 
 import MicrowaveFsm
@@ -43,14 +45,12 @@
     
     return
 
-  def onFinalize(self):
-    self._fsm.exit()
-    return RTC.RTC_OK
 
+
   def onInitialize(self):
-    self._fsm = OpenRTM_aist.Machine(MicrowaveFsm.TOP, self)
+    self._fsm = StaticFSM.Machine(MicrowaveFsm.TOP, self)
     #self._fsm.init()
-    self._eventIn = OpenRTM_aist.EventInPort("event", self._fsm)
+    self._eventIn = EventPort.EventInPort("event", self._fsm)
     
     self.addInPort("event", self._eventIn)
     self._eventIn.bindEvent0("open", MicrowaveFsm.TOP.open)
@@ -64,6 +64,11 @@
 
     return RTC.RTC_OK
 
+
+  def onFinalize(self):
+    self._fsm.shutdown()
+    return RTC.RTC_OK
+
         
   def onExecute(self, ec_id):
     

Modified: branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/MicrowaveFsm.py
===================================================================
--- branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/MicrowaveFsm.py	2017-12-13 00:30:12 UTC (rev 899)
+++ branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/MicrowaveFsm.py	2017-12-13 00:32:40 UTC (rev 900)
@@ -15,16 +15,18 @@
 
 import sys
 
+
 import RTC
-import OpenRTM_aist
-import OpenRTM_aist.Macho
+import OpenRTM_aist.StaticFSM as StaticFSM
 
- at OpenRTM_aist.fsm_topstate
-class TOP(OpenRTM_aist.Link):
-  def on_init(self):
-    self.set_state(OpenRTM_aist.Macho.State(Operational))
 
+ at StaticFSM.FSM_TOPSTATE
+class TOP(StaticFSM.Link):
+  def onInit(self):
+    self.set_state(StaticFSM.State(Operational))
+    return RTC.RTC_OK
 
+
   def open(self):
     pass
   def close(self):
@@ -55,27 +57,29 @@
     
 
     
- at OpenRTM_aist.fsm_substate(TOP)
-class Disabled(OpenRTM_aist.Link):
-  def on_entry(self):
+ at StaticFSM.FSM_SUBSTATE(TOP)
+class Disabled(StaticFSM.Link):
+  def onEntry(self):
     print("  Microwave opened")
-  def on_exit(self):
+    return RTC.RTC_OK
+  def onExit(self):
     print("  Microwave closed")
+    return RTC.RTC_OK
   def close(self):
     #self.setStateHistory(OpenRTM_aist.Macho.State(Operational))
-    self.set_state(OpenRTM_aist.Macho.State(Operational))
-    
+    self.set_state(StaticFSM.State(Operational))
 
 
- at OpenRTM_aist.Macho.deephistory
- at OpenRTM_aist.fsm_substate(TOP)
-class Operational(OpenRTM_aist.Link):
+ at StaticFSM.deephistory
+ at StaticFSM.FSM_SUBSTATE(TOP)
+class Operational(StaticFSM.Link):
   def open(self):
-    self.set_state(OpenRTM_aist.Macho.State(Disabled))
+    self.set_state(StaticFSM.State(Disabled))
   def stop(self):
-    self.set_state(OpenRTM_aist.Macho.State(Idle))
-  def on_init(self):
-    self.set_state(OpenRTM_aist.Macho.State(Idle))
+    self.set_state(StaticFSM.State(Idle))
+  def onInit(self):
+    self.set_state(StaticFSM.State(Idle))
+    return RTC.RTC_OK
 
 
   
@@ -85,35 +89,36 @@
 
 
 
- at OpenRTM_aist.fsm_substate(Operational)
-class Idle(OpenRTM_aist.Link):
+ at StaticFSM.FSM_SUBSTATE(Operational)
+class Idle(StaticFSM.Link):
   def minute(self, time_):
-    self.set_state(OpenRTM_aist.Macho.State(Programmed))
-    self.dispatch(OpenRTM_aist.Macho.Event(TOP.minute,time_))
+    self.set_state(StaticFSM.State(Programmed))
+    self.dispatch(StaticFSM.Event(TOP.minute,time_))
     
-  def on_entry(self):
+  def onEntry(self):
     self.data(TOP).resetTimer()
     print("  Microwave ready")
+    return RTC.RTC_OK
 
 
 
 
 
- at OpenRTM_aist.fsm_substate(Operational)
-class Programmed(OpenRTM_aist.Link):
+ at StaticFSM.FSM_SUBSTATE(Operational)
+class Programmed(StaticFSM.Link):
   def minute(self, time_):
     for t in range(time_.data):
       self.data(TOP).incrementTimer()
     self.data(TOP).printTimer()
   def start(self):
-    self.setState(Cooking)
+    self.set_state(StaticFSM.State(Cooking))
 
 
 
 
 
- at OpenRTM_aist.fsm_substate(Programmed)
-class Cooking(OpenRTM_aist.Link):
+ at StaticFSM.FSM_SUBSTATE(Programmed)
+class Cooking(StaticFSM.Link):
   def tick(self):
     print("  Clock tick")
     tb = self.data(TOP)
@@ -120,13 +125,15 @@
     tb.decrementTimer()
     if tb.getRemainingTime() == 0:
       print("  Finished")
-      self.setState(Idle)
+      self.set_state(StaticFSM.State(Idle))
     else:
       tb.printTimer()
     
-  def on_entry(self):
+  def onEntry(self):
     print("  Heating on")
-  def on_exit(self):
+    return RTC.RTC_OK
+  def onExit(self):
     print("  Heating off")
+    return RTC.RTC_OK
 
 

Added: branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/MicrowaveFsm_pyfsm.py
===================================================================
--- branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/MicrowaveFsm_pyfsm.py	                        (rev 0)
+++ branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/MicrowaveFsm_pyfsm.py	2017-12-13 00:32:40 UTC (rev 900)
@@ -0,0 +1,139 @@
+#!/usr/bin/env python
+# -*- coding: euc-jp -*-
+
+##
+# @file Microwave.py
+# @brief example StaticFSM
+# @date $Date: $
+# @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
+#
+# Copyright (C) 2017
+#     Intelligent Systems Research Institute,
+#     National Institute of
+#         Advanced Industrial Science and Technology (AIST), Japan
+#     All rights reserved.
+
+import sys
+
+
+
+import OpenRTM_aist.StaticFSM_pyfsm as StaticFSM
+
+
+ at StaticFSM.FSM_TOPSTATE
+class TOP(StaticFSM.Link):
+  def onInit(self):
+    self.set_state(StaticFSM.State(Operational))
+    return RTC.RTC_OK
+
+
+  def open(self):
+    pass
+  def close(self):
+    pass
+  def minute(self, time_):
+    pass
+  def start(self):
+    pass
+  def stop(self):
+    pass
+  def tick(self):
+    pass
+
+  class Data:
+    def __init__(self):
+      self.myCookingTime = 0
+    def printTimer(self):
+      print " Timer set to ", self.myCookingTime, " minutes"
+    def incrementTimer(self):
+      self.myCookingTime+=1
+    def decrementTimer(self):
+      self.myCookingTime-=1
+    def resetTimer(self):
+      self.myCookingTime = 0
+    def getRemainingTime(self):
+      return self.myCookingTime
+  
+    
+
+    
+ at StaticFSM.FSM_SUBSTATE(TOP)
+class Disabled(StaticFSM.Link):
+  def onEntry(self):
+    print("  Microwave opened")
+    return RTC.RTC_OK
+  def onExit(self):
+    print("  Microwave closed")
+    return RTC.RTC_OK
+  def close(self):
+    #self.setStateHistory(OpenRTM_aist.Macho.State(Operational))
+    self.set_state(StaticFSM.State(Operational))
+
+
+ at StaticFSM.deephistory
+ at StaticFSM.FSM_SUBSTATE(TOP)
+class Operational(StaticFSM.Link):
+  def open(self):
+    self.set_state(StaticFSM.State(Disabled))
+  def stop(self):
+    self.set_state(StaticFSM.State(Idle))
+  def onInit(self):
+    self.set_state(StaticFSM.State(Idle))
+    return RTC.RTC_OK
+
+
+  
+
+
+
+
+
+
+ at StaticFSM.FSM_SUBSTATE(Operational)
+class Idle(StaticFSM.Link):
+  def minute(self, time_):
+    self.set_state(StaticFSM.State(Programmed))
+    self.dispatch(StaticFSM.Event(TOP.minute,time_))
+    
+  def onEntry(self):
+    self.data(TOP).resetTimer()
+    print("  Microwave ready")
+    return RTC.RTC_OK
+
+
+
+
+
+ at StaticFSM.FSM_SUBSTATE(Operational)
+class Programmed(StaticFSM.Link):
+  def minute(self, time_):
+    for t in range(time_.data):
+      self.data(TOP).incrementTimer()
+    self.data(TOP).printTimer()
+  def start(self):
+    self.set_state(StaticFSM.State(Cooking))
+
+
+
+
+
+ at StaticFSM.FSM_SUBSTATE(Programmed)
+class Cooking(StaticFSM.Link):
+  def tick(self):
+    print("  Clock tick")
+    tb = self.data(TOP)
+    tb.decrementTimer()
+    if tb.getRemainingTime() == 0:
+      print("  Finished")
+      self.set_state(StaticFSM.State(Idle))
+    else:
+      tb.printTimer()
+    
+  def onEntry(self):
+    print("  Heating on")
+    return RTC.RTC_OK
+  def onExit(self):
+    print("  Heating off")
+    return RTC.RTC_OK
+
+

Added: branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/Microwave_pyfsm.py
===================================================================
--- branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/Microwave_pyfsm.py	                        (rev 0)
+++ branches/FSM4RTC/OpenRTM-aist-Python/OpenRTM_aist/python3_examples/StaticFsm/Microwave_pyfsm.py	2017-12-13 00:32:40 UTC (rev 900)
@@ -0,0 +1,108 @@
+#!/usr/bin/env python
+# -*- coding: euc-jp -*-
+
+##
+# @file Microwave.py
+# @brief example StaticFSM
+# @date $Date: $
+# @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
+#
+# Copyright (C) 2017
+#     Intelligent Systems Research Institute,
+#     National Institute of
+#         Advanced Industrial Science and Technology (AIST), Japan
+#     All rights reserved.
+
+import sys
+
+import RTC
+import OpenRTM_aist
+import OpenRTM_aist.StaticFSM_pyfsm as StaticFSM
+import OpenRTM_aist.EventPort_pyfsm as EventPort
+
+
+import MicrowaveFsm_pyfsm
+
+microwave_spec = ["implementation_id", "Microwave",
+                  "type_name",         "Microwave",
+                  "description",       "Console input component",
+                  "version",           "1.0",
+                  "vendor",            "Nobuhiko Miyamoto",
+                  "category",          "example",
+                  "activity_type",     "DataFlowComponent",
+                  "max_instance",      "10",
+                  "language",          "Python",
+                  "lang_type",         "script",
+                  ""]
+
+
+
+
+
+class Microwave(OpenRTM_aist.DataFlowComponentBase):
+  def __init__(self, manager):
+    OpenRTM_aist.DataFlowComponentBase.__init__(self, manager)
+    
+    return
+
+  def onFinalize(self):
+    self._fsm.exit()
+    return RTC.RTC_OK
+
+  def onInitialize(self):
+    self._fsm = StaticFSM.Machine(MicrowaveFsm.TOP, self)
+    #self._fsm.init()
+    self._eventIn = EventPort.EventInPort("event", self._fsm)
+    
+    self.addInPort("event", self._eventIn)
+    self._eventIn.bindEvent0("open", MicrowaveFsm.TOP.open)
+    self._eventIn.bindEvent0("close", MicrowaveFsm.TOP.close)
+    self._eventIn.bindEvent1("minute", MicrowaveFsm.TOP.minute, RTC.TimedLong(RTC.Time(0,0),0))
+    self._eventIn.bindEvent0("start", MicrowaveFsm.TOP.start)
+    self._eventIn.bindEvent0("stop", MicrowaveFsm.TOP.stop)
+    self._eventIn.bindEvent0("tick", MicrowaveFsm.TOP.tick)
+    
+
+
+    return RTC.RTC_OK
+
+        
+  def onExecute(self, ec_id):
+    
+    
+    return RTC.RTC_OK
+
+
+def MicrowaveInit(manager):
+  profile = OpenRTM_aist.Properties(defaults_str=microwave_spec)
+  manager.registerFactory(profile,
+                          Microwave,
+                          OpenRTM_aist.Delete)
+
+
+def MyModuleInit(manager):
+  MicrowaveInit(manager)
+
+  # Create a component
+  comp = manager.createComponent("Microwave")
+
+def main():
+  # Initialize manager
+  mgr = OpenRTM_aist.Manager.init(sys.argv)
+
+  # Set module initialization proceduer
+  # This procedure will be invoked in activateManager() function.
+  mgr.setModuleInitProc(MyModuleInit)
+
+  # Activate manager and register to naming service
+  mgr.activateManager()
+
+  # run the manager in blocking mode
+  # runManager(False) is the default
+  mgr.runManager()
+
+  # If you want to run the manager in non-blocking mode, do like this
+  # mgr.runManager(True)
+
+if __name__ == "__main__":
+  main()



More information about the openrtm-commit mailing list