[openrtm-commit:02985] r3119 - in trunk/OpenRTM-aist: examples examples/SeqIO examples/SimpleIO src/ext/sdo/fsm4rtc_observer src/lib/coil/tests/stringutil src/lib/hrtm src/lib/rtm
openrtm @ openrtm.org
openrtm @ openrtm.org
2017年 12月 11日 (月) 09:37:26 JST
Author: n-ando
Date: 2017-12-11 09:37:26 +0900 (Mon, 11 Dec 2017)
New Revision: 3119
Added:
trunk/OpenRTM-aist/examples/StaticFsm/
trunk/OpenRTM-aist/src/lib/rtm/EventPort.h
trunk/OpenRTM-aist/src/lib/rtm/StaticFSM.h
Modified:
trunk/OpenRTM-aist/examples/Makefile.am
trunk/OpenRTM-aist/examples/SeqIO/SeqIn.h
trunk/OpenRTM-aist/examples/SeqIO/SeqOut.h
trunk/OpenRTM-aist/examples/SimpleIO/ConsoleOut.h
trunk/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.cpp
trunk/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.h
trunk/OpenRTM-aist/src/lib/coil/tests/stringutil/stringutilTests.cpp
trunk/OpenRTM-aist/src/lib/hrtm/data_flow_component.cpp
trunk/OpenRTM-aist/src/lib/rtm/Macho.cpp
trunk/OpenRTM-aist/src/lib/rtm/Macho.h
trunk/OpenRTM-aist/src/lib/rtm/Makefile.am
trunk/OpenRTM-aist/src/lib/rtm/NVUtil.cpp
Log:
merged changes from branches/FSM4RTC/OpenRTM-aist r2893-2903:
[FSM4RTC,new file,->RELENG_2_0] Macho (Machine object state machine engine) and StaticFSM.h have been introduced to rtm. refs #3683
[compat,->RELENG_1_2,->RELENG_2_0] NVUtil dump() function outputs doubled CR. It is removed.
[FSM4RTC,example,->RELENG_2_0] StaticFsm sample which is for new Static FSM framework has been added. refs #3655
[FSM4RTC,example,->RELENG_2_0] StaticFsm sample which is for new Static FSM framework has been added. refs #3655
[FSM4RTC,->RELENG_1_2,->RELENG_2_0] Some sample components listener have been modified to follow ConnectorListener changes. refs #3871
[FSM4RTC,->RELENG_2_0] Experimental FSM has been implemented in ConsoleOut component.
[FSM4RTC,->RELENG_2_0] ComponentObserver implementation has been added. refs #3591
[FSM4RTC,->RELENG_2_0] FSm related callback operation has been changed. refs #3681
[coil,test,->RELENG_1_2,->RELENG_2_0] coil::stringutils tests added.
[FSM4RTC,->RELENG_2_0] EventPort class has been intorduced for FSm framework. refs #3683
[revert,->RELENG_2_0] FSM removed.
Modified: trunk/OpenRTM-aist/examples/Makefile.am
===================================================================
--- trunk/OpenRTM-aist/examples/Makefile.am 2017-12-11 00:30:28 UTC (rev 3118)
+++ trunk/OpenRTM-aist/examples/Makefile.am 2017-12-11 00:37:26 UTC (rev 3119)
@@ -8,9 +8,9 @@
AUTOMAKE_OPTIONS = 1.4
-SUBDIRS = Analyzer Composite ConfigSample SimpleIO SeqIO SimpleService ExtTrigger Fsm Templates Throughput @UNITTEST@
+SUBDIRS = Analyzer Composite ConfigSample SimpleIO SeqIO SimpleService ExtTrigger Fsm StaticFsm Templates Throughput @UNITTEST@
EXTRA_DIST = \
rtc.vcproj.yaml \
rtcdll.vcproj.yaml
-DIST_SUBDIRS = Analyzer Composite ConfigSample SimpleIO SeqIO SimpleService ExtTrigger Fsm AutoTest Templates Throughput tests
\ No newline at end of file
+DIST_SUBDIRS = Analyzer Composite ConfigSample SimpleIO SeqIO SimpleService ExtTrigger Fsm StaticFsm AutoTest Templates Throughput tests
\ No newline at end of file
Modified: trunk/OpenRTM-aist/examples/SeqIO/SeqIn.h
===================================================================
--- trunk/OpenRTM-aist/examples/SeqIO/SeqIn.h 2017-12-11 00:30:28 UTC (rev 3118)
+++ trunk/OpenRTM-aist/examples/SeqIO/SeqIn.h 2017-12-11 00:37:26 UTC (rev 3119)
@@ -34,6 +34,7 @@
class DataListener
: public ConnectorDataListenerT<RTC::TimedLong>
{
+ USE_CONNLISTENER_STATUS;
public:
DataListener(const char* name) : m_name(name) {}
virtual ~DataListener()
@@ -45,8 +46,8 @@
}
}
- virtual void operator()(const ConnectorInfo& info,
- const TimedLong& data)
+ virtual ReturnCode operator()(ConnectorInfo& info,
+ TimedLong& data)
{
// Connector Listener Dump check
if(g_Listener_dump_enabled)
@@ -61,6 +62,7 @@
std::cout << "Data: " << data.data << std::endl;
std::cout << "------------------------------" << std::endl;
}
+ return NO_CHANGE;
};
std::string m_name;
};
@@ -69,6 +71,7 @@
class ConnListener
: public ConnectorListener
{
+ USE_CONNLISTENER_STATUS;
public:
ConnListener(const char* name) : m_name(name) {}
virtual ~ConnListener()
@@ -80,7 +83,7 @@
}
}
- virtual void operator()(const ConnectorInfo& info)
+ virtual ReturnCode operator()(ConnectorInfo& info)
{
// Connector Listener Dump check
if(g_Listener_dump_enabled)
@@ -94,6 +97,7 @@
std::cout << std::endl;
std::cout << "------------------------------" << std::endl;
}
+ return NO_CHANGE;
};
std::string m_name;
};
Modified: trunk/OpenRTM-aist/examples/SeqIO/SeqOut.h
===================================================================
--- trunk/OpenRTM-aist/examples/SeqIO/SeqOut.h 2017-12-11 00:30:28 UTC (rev 3118)
+++ trunk/OpenRTM-aist/examples/SeqIO/SeqOut.h 2017-12-11 00:37:26 UTC (rev 3119)
@@ -35,6 +35,7 @@
class DataListener
: public ConnectorDataListenerT<RTC::TimedLong>
{
+ USE_CONNLISTENER_STATUS;
public:
DataListener(const char* name) : m_name(name) {}
virtual ~DataListener()
@@ -46,8 +47,8 @@
}
}
- virtual void operator()(const ConnectorInfo& info,
- const TimedLong& data)
+ virtual ReturnCode operator()(ConnectorInfo& info,
+ TimedLong& data)
{
// Connector Listener Dump check
if(g_Listener_dump_enabled)
@@ -62,6 +63,7 @@
std::cout << "Data: " << data.data << std::endl;
std::cout << "------------------------------" << std::endl;
}
+ return NO_CHANGE;
}
std::string m_name;
};
@@ -70,6 +72,7 @@
class ConnListener
: public ConnectorListener
{
+ USE_CONNLISTENER_STATUS;
public:
ConnListener(const char* name) : m_name(name) {}
virtual ~ConnListener()
@@ -81,7 +84,7 @@
}
}
- virtual void operator()(const ConnectorInfo& info)
+ virtual ReturnCode operator()(ConnectorInfo& info)
{
// Connector Listener Dump check
if(g_Listener_dump_enabled)
@@ -95,6 +98,7 @@
std::cout << std::endl;
std::cout << "------------------------------" << std::endl;
}
+ return NO_CHANGE;
};
std::string m_name;
};
Modified: trunk/OpenRTM-aist/examples/SimpleIO/ConsoleOut.h
===================================================================
--- trunk/OpenRTM-aist/examples/SimpleIO/ConsoleOut.h 2017-12-11 00:30:28 UTC (rev 3118)
+++ trunk/OpenRTM-aist/examples/SimpleIO/ConsoleOut.h 2017-12-11 00:37:26 UTC (rev 3119)
@@ -31,7 +31,6 @@
using namespace RTC;
-
class DataListener
: public ConnectorDataListenerT<RTC::TimedLong>
{
@@ -47,7 +46,7 @@
TimedLong& data)
{
std::cout << "------------------------------" << std::endl;
- std::cout << "Data Listener: " << m_name << std::endl;
+ std::cout << "Data Listener: " << m_name << "(OutPort)" << std::endl;
std::cout << "Profile::name: " << info.name << std::endl;
std::cout << "Profile::id: " << info.id << std::endl;
// std::cout << "Profile::properties: " << std::endl;
@@ -60,7 +59,6 @@
std::string m_name;
};
-
class ConnListener
: public ConnectorListener
{
Modified: trunk/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.cpp
===================================================================
--- trunk/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.cpp 2017-12-11 00:30:28 UTC (rev 3118)
+++ trunk/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.cpp 2017-12-11 00:37:26 UTC (rev 3119)
@@ -179,35 +179,35 @@
coil::toUpper(observed[i]);
if (observed[i] == "COMPONENT_PROFILE")
{
- flags[RTC::COMPONENT_PROFILE] = 1;
+ flags[RTC::COMPONENT_PROFILE] = true;
}
else if (observed[i] == "RTC_STATUS")
{
- flags[RTC::RTC_STATUS] = 1;
+ flags[RTC::RTC_STATUS] = true;
}
else if (observed[i] == "EC_STATUS")
{
- flags[RTC::EC_STATUS] = 1;
+ flags[RTC::EC_STATUS] = true;
}
else if (observed[i] == "PORT_PROFILE")
{
- flags[RTC::PORT_PROFILE] = 1;
+ flags[RTC::PORT_PROFILE] = true;
}
else if (observed[i] == "CONFIGURATION")
{
- flags[RTC::CONFIGURATION] = 1;
+ flags[RTC::CONFIGURATION] = true;
}
else if (observed[i] == "FSM_PROFILE")
{
- flags[RTC::FSM_PROFILE] = 1;
+ flags[RTC::FSM_PROFILE] = true;
}
else if (observed[i] == "FSM_STATUS")
{
- flags[RTC::FSM_STATUS] = 1;
+ flags[RTC::FSM_STATUS] = true;
}
else if (observed[i] == "FSM_STRUCTURE")
{
- flags[RTC::FSM_STRUCTURE] = 1;
+ flags[RTC::FSM_STRUCTURE] = true;
}
else if (observed[i] == "ALL")
{
@@ -763,10 +763,47 @@
*/
void ComponentObserverConsumer::setFSMStructureListeners()
{
- m_fsmaction.fsmActionListener =
+ m_fsmaction.preOnFsmInitListener =
+ m_rtobj->addPreFsmActionListener(PRE_ON_INIT,
+ m_fsmaction,
+ &FSMAction::preInit);
+ m_fsmaction.preOnFsmEntryListener =
+ m_rtobj->addPreFsmActionListener(PRE_ON_ENTRY,
+ m_fsmaction,
+ &FSMAction::preEntry);
+ m_fsmaction.preOnFsmDoListener =
+ m_rtobj->addPreFsmActionListener(PRE_ON_DO,
+ m_fsmaction,
+ &FSMAction::preDo);
+ m_fsmaction.preOnFsmExitListener =
+ m_rtobj->addPreFsmActionListener(PRE_ON_EXIT,
+ m_fsmaction,
+ &FSMAction::preExit);
+ m_fsmaction.preOnFsmStateChangeListener =
m_rtobj->addPreFsmActionListener(PRE_ON_STATE_CHANGE,
m_fsmaction,
- &FSMAction::updateFsmStatus);
+ &FSMAction::preStateChange);
+
+ m_fsmaction.postOnFsmInitListener =
+ m_rtobj->addPostFsmActionListener(POST_ON_INIT,
+ m_fsmaction,
+ &FSMAction::postInit);
+ m_fsmaction.postOnFsmEntryListener =
+ m_rtobj->addPostFsmActionListener(POST_ON_ENTRY,
+ m_fsmaction,
+ &FSMAction::postEntry);
+ m_fsmaction.postOnFsmDoListener =
+ m_rtobj->addPostFsmActionListener(POST_ON_DO,
+ m_fsmaction,
+ &FSMAction::postDo);
+ m_fsmaction.postOnFsmExitListener =
+ m_rtobj->addPostFsmActionListener(POST_ON_EXIT,
+ m_fsmaction,
+ &FSMAction::postExit);
+ m_fsmaction.postOnFsmStateChangeListener =
+ m_rtobj->addPostFsmActionListener(POST_ON_EXIT,
+ m_fsmaction,
+ &FSMAction::postStateChange);
}
/*!
@@ -778,6 +815,36 @@
*/
void ComponentObserverConsumer::unsetFSMStructureListeners()
{
+ m_rtobj->
+ removePreFsmActionListener(PRE_ON_INIT,
+ m_fsmaction.preOnFsmInitListener);
+ m_rtobj->
+ removePreFsmActionListener(PRE_ON_ENTRY,
+ m_fsmaction.preOnFsmEntryListener);
+ m_rtobj->
+ removePreFsmActionListener(PRE_ON_DO,
+ m_fsmaction.preOnFsmDoListener);
+ m_rtobj->
+ removePreFsmActionListener(PRE_ON_EXIT,
+ m_fsmaction.preOnFsmExitListener);
+ m_rtobj->
+ removePreFsmActionListener(PRE_ON_STATE_CHANGE,
+ m_fsmaction.preOnFsmStateChangeListener);
+ m_rtobj->
+ removePostFsmActionListener(POST_ON_INIT,
+ m_fsmaction.postOnFsmInitListener);
+ m_rtobj->
+ removePostFsmActionListener(POST_ON_ENTRY,
+ m_fsmaction.postOnFsmEntryListener);
+ m_rtobj->
+ removePostFsmActionListener(POST_ON_DO,
+ m_fsmaction.postOnFsmDoListener);
+ m_rtobj->
+ removePostFsmActionListener(POST_ON_EXIT,
+ m_fsmaction.postOnFsmExitListener);
+ m_rtobj->
+ removePostFsmActionListener(POST_ON_EXIT,
+ m_fsmaction.postOnFsmStateChangeListener);
}
//============================================================
@@ -859,8 +926,6 @@
m_configMsg.activateConfigSetListener = NULL;
}
}
-
-
}; // namespace RTC
extern "C"
Modified: trunk/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.h
===================================================================
--- trunk/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.h 2017-12-11 00:30:28 UTC (rev 3118)
+++ trunk/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.h 2017-12-11 00:37:26 UTC (rev 3119)
@@ -35,6 +35,89 @@
/*!
* @if jp
+ * @class ComponentObserverConsumer ¥¯¥é¥¹
+ * @brief ComponentObserver ¥â¥¸¥å¡¼¥ë
+ *
+ * ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤Î³Æ¼ï¾õÂÖ¤òComponentObserver¥µ¡¼¥Ó¥¹¤ËÂФ·¤Æ¥³¡¼¥ë
+ * ¥Ð¥Ã¥¯¤¹¤ë¤¿¤á¤Î¥¯¥é¥¹¡£¥Ä¡¼¥ëÅù¡¢¥³¥ó¥Ý¡¼¥Í¥ó¥È¤Î¾õÂÖÊѲ½¤òÃΤꤿ
+ * ¤¤¥¨¥ó¥Æ¥£¥Æ¥£¤¬¥µ¡¼¥Ó¥¹¥×¥í¥Ð¥¤¥À¤òÅö³º¥³¥ó¥Ý¡¼¥Í¥ó¥È¤ËÂФ·¤Æ¥»¥Ã
+ * ¥È¤¹¤ë¤È¡¢Âбþ¤¹¤ëËÜ¥³¥ó¥·¥å¡¼¥Þ¤¬¥¢¥¿¥Ã¥Á¤µ¤ì¡¢¥³¥ó¥Ý¡¼¥Í¥ó¥È¤Î¾õ
+ * ÂÖÊѲ½¤Ë±þ¤¸¤Æ¡¢update_status() ¥ª¥Ú¥ì¡¼¥·¥ç¥ó¤òSTATUS_KIND ¤È¥Ò¥ó
+ * ¥È¤ò°ú¿ô¤Ë¸Æ¤Ó½Ð¤¹¡£Ëܵ¡Ç½¤Ï¡¢OMG ¤Î FSM4RTC»ÅÍÍ
+ * (formal/16-04-01) 7.2.4.2 ComponentObserver Interface ¤Ëµ½Ò¤µ¤ì¤Æ
+ * ¤¤¤ë¡£
+ *
+ * STATUS_KIND ¤Ë¤Ï°Ê²¼¤Î¼ïÎब¤¢¤ë¡£
+ *
+ * - COMPONENT_PROFILE: ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤Î¥×¥í¥Õ¥¡¥¤¥ë¾ðÊó¤¬ÊѲ½
+ * - RTC_STATUS : ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤Î¾õÂÖ (Init, Alive) ¤¬ÊѲ½
+ * - EC_STATUS : EC¤Î¾õÂÖ (Inavtive, Active, Error) ¤¬ÊѲ½
+ * - PORT_PROFILE : ¥Ý¡¼¥È¤Î¥×¥í¥Õ¥¡¥¤¥ë¤¬ÊѲ½
+ * - CONFIGURATION : ¥³¥ó¥Õ¥£¥®¥å¥ì¡¼¥·¥ç¥ó¤¬ÊѲ½
+ * - RTC_HEARTBEAT : RTC¤ÎÀ¸Â¸³Îǧ¤Î¥Ï¡¼¥È¥Ó¡¼¥É
+ * - EC_HEARTBEAT : EC¤ÎÀ¸Â¸³Îǧ¤Î¥Ï¡¼¥È¥Ó¡¼¥È
+ * - FSM_PROFILE : FSM¤Î¥×¥í¥Õ¥¡¥¤¥ë¤¬ÊѲ½
+ * - FSM_STATUS : FSM¤Î¾õÂÖ¤¬ÊѲ½
+ * - FSM_STRUCTURE : FSM¤Î¹½Â¤¤¬ÊѲ½
+ * - USER_DEFINED : ¥æ¡¼¥¶ÄêµÁ
+ *
+ * \subsection COMPONENT_PROFILE COMPONENT_PROFILE
+ * ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤Î¥×¥í¥Õ¥¡¥¤¥ë¾ðÊó¤¬ÊѲ½¤·¤¿ºÝ¤Ë¤³¤Î¥¿¥°Ì¾(enumÃÍ)¤ò
+ * Âè1°ú¿ô¤Ë¤·¤Æ update_status() ¥ª¥Ú¥ì¡¼¥·¥ç¥ó¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¡£(̤¼ÂÁõ)
+ *
+ * \subsection RTC_STATUS RTC_STATUS
+ *
+ * ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤Î¾õÂÖ (Init, Alive) ¤¬ÊѲ½¤·¤¿ºÝ¤Ë¤³¤Î¥¿¥°Ì¾
+ * (enumÃÍ)¤òÂè1°ú¿ô¤Ë¤·¤Æ update_status() ¥ª¥Ú¥ì¡¼¥·¥ç¥ó¤¬¸Æ¤Ó½Ð¤µ¤ì
+ * ¤ë¡£¸·Ì©¤Ë¤ÏEC¤Î¾õÂ֤Ǥ¢¤ë¤¬¡¢Inavtive, Active, Error, Finalize ¤Î
+ * 4¤Ä¤Î¾õÂÖ¤ËÊѲ½¤·¤¿¤³¤È¤ò¸¡ÃΤ¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£°Ê²¼¤Î¾õÂÖÊѲ½»þ¤Ë¡¢
+ * ¤½¤ì¤¾¤ì¥Ò¥ó¥È¤È¤·¤Æ°Ê²¼¤Îʸ»úÎó¤È¤È¤â¤Ë¥³¡¼¥ë¥Ð¥Ã¥¯¤µ¤ì¤ë¡£
+ *
+ * - onActivated ¸Æ¤Ó½Ð¤·À®¸ù»þ: ACTIVE: <EC id>
+ * - onDeactivated ¸Æ¤Ó½Ð¤·À®¸ù»þ: INACTIVE: <EC id>
+ * - onReset ¸Æ¤Ó½Ð¤·À®¸ù»þ: INACTIVE: <EC id>
+ * - onAborting ¸Æ¤Ó½Ð¤·À®¸ù»þ: ERROR: <EC id>
+ * - onFinalize ¸Æ¤Ó½Ð¤·À®¸ù»þ: FINALIZE: <EC id>
+ *
+ * \subsection EC_STATUS EC_STATUS
+ *
+ * EC¤Î¾õÂÖ (Inavtive, Active, Error) ¤¬ÊѲ½¤·¤¿ºÝ¤Ë¤³¤Î¥¿¥°Ì¾(enumÃÍ)¤ò
+ * Âè1°ú¿ô¤Ë¤·¤Æ update_status() ¥ª¥Ú¥ì¡¼¥·¥ç¥ó¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¡£
+ *
+ * \subsection PORT_PROFILE PORT_PROFILE
+ * ¥Ý¡¼¥È¤Î¥×¥í¥Õ¥¡¥¤¥ë¤¬ÊѲ½¤·¤¿ºÝ¤Ë¤³¤Î¥¿¥°Ì¾(enumÃÍ)¤ò
+ * Âè1°ú¿ô¤Ë¤·¤Æ update_status() ¥ª¥Ú¥ì¡¼¥·¥ç¥ó¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¡£
+ *
+ * \subsection CONFIGURATION CONFIGURATION
+ * ¥³¥ó¥Õ¥£¥®¥å¥ì¡¼¥·¥ç¥ó¤¬ÊѲ½¤·¤¿ºÝ¤Ë¤³¤Î¥¿¥°Ì¾(enumÃÍ)¤ò
+ * Âè1°ú¿ô¤Ë¤·¤Æ update_status() ¥ª¥Ú¥ì¡¼¥·¥ç¥ó¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¡£
+ *
+ * \subsection RTC_HEARTBEAT RTC_HEARTBEAT
+ * RTC¤ÎÀ¸Â¸³Îǧ¤Î¥Ï¡¼¥È¥Ó¡¼¥É¤·¤¿ºÝ¤Ë¤³¤Î¥¿¥°Ì¾(enumÃÍ)¤ò
+ * Âè1°ú¿ô¤Ë¤·¤Æ update_status() ¥ª¥Ú¥ì¡¼¥·¥ç¥ó¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¡£
+ *
+ * \subsection EC_HEARTBEAT EC_HEARTBEAT
+ * EC¤ÎÀ¸Â¸³Îǧ¤Î¥Ï¡¼¥È¥Ó¡¼¥È¤·¤¿ºÝ¤Ë¤³¤Î¥¿¥°Ì¾(enumÃÍ)¤ò
+ * Âè1°ú¿ô¤Ë¤·¤Æ update_status() ¥ª¥Ú¥ì¡¼¥·¥ç¥ó¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¡£
+ *
+ * \subsection FSM_PROFILE FSM_PROFILE
+ * FSM¤Î¥×¥í¥Õ¥¡¥¤¥ë¤¬ÊѲ½¤·¤¿ºÝ¤Ë¤³¤Î¥¿¥°Ì¾(enumÃÍ)¤ò
+ * Âè1°ú¿ô¤Ë¤·¤Æ update_status() ¥ª¥Ú¥ì¡¼¥·¥ç¥ó¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¡£
+ *
+ * \subsection FSM_STATUS FSM_STATUS
+ * FSM¤Î¾õÂÖ¤¬ÊѲ½¤·¤¿ºÝ¤Ë¤³¤Î¥¿¥°Ì¾(enumÃÍ)¤ò
+ * Âè1°ú¿ô¤Ë¤·¤Æ update_status() ¥ª¥Ú¥ì¡¼¥·¥ç¥ó¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¡£
+ *
+ * \subsection FSM_STRUCTURE FSM_STRUCTURE
+ * FSM¤Î¹½Â¤¤¬ÊѲ½¤·¤¿ºÝ¤Ë¤³¤Î¥¿¥°Ì¾(enumÃÍ)¤ò
+ * Âè1°ú¿ô¤Ë¤·¤Æ update_status() ¥ª¥Ú¥ì¡¼¥·¥ç¥ó¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¡£
+ *
+ * \subsection USER_DEFINED USER_DEFINED
+ * ¥æ¡¼¥¶ÄêµÁ¤·¤¿ºÝ¤Ë¤³¤Î¥¿¥°Ì¾(enumÃÍ)¤ò
+ * Âè1°ú¿ô¤Ë¤·¤Æ update_status() ¥ª¥Ú¥ì¡¼¥·¥ç¥ó¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¡£
+ *
+ *
+ *
* @else
* @endif
*/
@@ -631,9 +714,71 @@
std::cout << "ComponentObserver::updateFsmStatus(" << state << ")" << std::endl;
m_coc.updateStatus(RTC::FSM_STATUS, state);
}
+
+ void preInit(const char* state)
+ {
+ std::string msg(state); msg += " PRE_ON_INIT";
+ m_coc.updateStatus(RTC::FSM_STATUS, msg.c_str());
+ }
+ void preEntry(const char* state)
+ {
+ std::string msg(state); msg += " PRE_ONENTRY";
+ m_coc.updateStatus(RTC::FSM_STATUS, msg.c_str());
+ }
+ void preDo(const char* state)
+ {
+ std::string msg(state); msg += " PRE_ON_DO";
+ m_coc.updateStatus(RTC::FSM_STATUS, msg.c_str());
+ }
+ void preExit(const char* state)
+ {
+ std::string msg(state); msg += " PRE_ON_EXIT";
+ m_coc.updateStatus(RTC::FSM_STATUS, msg.c_str());
+ }
+ void preStateChange(const char* state)
+ {
+ std::string msg(state); msg += " PRE_ON_STATE_CHANGE";
+ m_coc.updateStatus(RTC::FSM_STATUS, msg.c_str());
+ }
+
+ void postInit(const char* state, ReturnCode_t ret)
+ {
+ std::string msg(state); msg += " POST_ON_INIT";
+ m_coc.updateStatus(RTC::FSM_STATUS, msg.c_str());
+ }
+ void postEntry(const char* state, ReturnCode_t ret)
+ {
+ std::string msg(state); msg += " POST_ONENTRY";
+ m_coc.updateStatus(RTC::FSM_STATUS, msg.c_str());
+ }
+ void postDo(const char* state, ReturnCode_t ret)
+ {
+ std::string msg(state); msg += " POST_ON_DO";
+ m_coc.updateStatus(RTC::FSM_STATUS, msg.c_str());
+ }
+ void postExit(const char* state, ReturnCode_t ret)
+ {
+ std::string msg(state); msg += " POST_ON_EXIT";
+ m_coc.updateStatus(RTC::FSM_STATUS, msg.c_str());
+ }
+ void postStateChange(const char* state, ReturnCode_t ret)
+ {
+ std::string msg(state); msg += " POST_ON_STATE_CHNAGE";
+ m_coc.updateStatus(RTC::FSM_STATUS, msg.c_str());
+ }
+
+ // Listener object's pointer holder
+ PreFsmActionListener* preOnFsmInitListener;
+ PreFsmActionListener* preOnFsmEntryListener;
+ PreFsmActionListener* preOnFsmDoListener;
+ PreFsmActionListener* preOnFsmExitListener;
+ PreFsmActionListener* preOnFsmStateChangeListener;
- // Listener object's pointer holder
- PreFsmActionListener* fsmActionListener;
+ PostFsmActionListener* postOnFsmInitListener;
+ PostFsmActionListener* postOnFsmEntryListener;
+ PostFsmActionListener* postOnFsmDoListener;
+ PostFsmActionListener* postOnFsmExitListener;
+ PostFsmActionListener* postOnFsmStateChangeListener;
private:
ComponentObserverConsumer& m_coc;
Modified: trunk/OpenRTM-aist/src/lib/coil/tests/stringutil/stringutilTests.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/tests/stringutil/stringutilTests.cpp 2017-12-11 00:30:28 UTC (rev 3118)
+++ trunk/OpenRTM-aist/src/lib/coil/tests/stringutil/stringutilTests.cpp 2017-12-11 00:37:26 UTC (rev 3119)
@@ -53,6 +53,8 @@
CPPUNIT_TEST(test_toBool);
CPPUNIT_TEST(test_isAbsolutePath);
CPPUNIT_TEST(test_isURL);
+ CPPUNIT_TEST(test_isIPv4);
+ CPPUNIT_TEST(test_isIPv6);
CPPUNIT_TEST(test_otos);
CPPUNIT_TEST(test_stringTo);
CPPUNIT_TEST(test_stringToBool);
@@ -136,6 +138,76 @@
void test_isURL()
{
}
+ void test_isIPv4()
+ {
+ std::string addr;
+ addr = "255.250.255.255"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), true);
+ addr = "0.0.0.0"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), true);
+ addr = "192.168.0.1"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), true);
+ addr = "192.168.100.0"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), true);
+
+ addr = "255.250.255"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), false);
+ addr = "255,250.255.0"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), false);
+ addr = "192.168.0.256"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), false);
+ addr = "ff.ff.ff.ff"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), false);
+ addr = "xx.yy.zz.00"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), false);
+
+ addr = "255.250.255.255:92183"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), true);
+ addr = "0.0.0.0:97763"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), true);
+ addr = "192.168.0.1:98657"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), true);
+ addr = "192.168.100.0:4689"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), true);
+
+ addr = "255.250.255:8686"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), false);
+ addr = "255,250.255.0:86545"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), false);
+ addr = "1293:192.168.0.1"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), false);
+ addr = "ff.ff.ff.ff.ff:9763"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), false);
+ addr = "xx.yy.zz.00:98767"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv4(addr), false);
+ }
+ void test_isIPv6()
+ {
+ std::string addr;
+ addr = "fe80:0:0:0:21c:42ff:fe87:d3d4"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv6(addr), true);
+ addr = "::1"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv6(addr), true);
+ addr = "fe80::21c:42ff:fe87:d3d4"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv6(addr), true);
+
+ addr = "fe80::21c:42ff:fe87:1ffff"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv6(addr), false);
+ addr = "ffe80::21c:42ff:fe87:d3d4"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv6(addr), false);
+
+ addr = "[fe80:0:0:0:21c:42ff:fe87:d3d4]"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv6(addr), true);
+ addr = "[::1]:9679"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv6(addr), true);
+ addr = "[fe80::21c:42ff:fe87:d3d4]:7657"; // OK
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv6(addr), true);
+
+ addr = "[ffe80::21c:42ff:fe87:d3d4]:5678"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv6(addr), false);
+ addr = "fe80::21c:42ff:fe87:d3d4]:87654"; // NG
+ CPPUNIT_ASSERT_EQUAL(coil::isIPv6(addr), false);
+ }
void test_otos()
{
}
Modified: trunk/OpenRTM-aist/src/lib/hrtm/data_flow_component.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/hrtm/data_flow_component.cpp 2017-12-11 00:30:28 UTC (rev 3118)
+++ trunk/OpenRTM-aist/src/lib/hrtm/data_flow_component.cpp 2017-12-11 00:37:26 UTC (rev 3119)
@@ -33,6 +33,6 @@
void DataFlowComponent::updateFsmStatus(RTC::StatusKind status_kind,
const char* state)
{
- onFsmStateChanged(state);
+ postOnFsmStateChange(state, RTC::RTC_OK);
}
}; // namespace hrtm
Copied: trunk/OpenRTM-aist/src/lib/rtm/EventPort.h (from rev 2903, branches/FSM4RTC/OpenRTM-aist/src/lib/rtm/EventPort.h)
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/EventPort.h (rev 0)
+++ trunk/OpenRTM-aist/src/lib/rtm/EventPort.h 2017-12-11 00:37:26 UTC (rev 3119)
@@ -0,0 +1,289 @@
+// -*- C++ -*-
+/*!
+ * @file EventInPort.h
+ * @brief EventInPort template class
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2017
+ * Noriaki Ando
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#ifndef RTC_EVENTINPORT_H
+#define RTC_EVENTINPORT_H
+
+#include <string>
+#include <vector>
+#include <iostream>
+
+#include <coil/TimeValue.h>
+#include <coil/Time.h>
+#include <coil/OS.h>
+#include <coil/Mutex.h>
+#include <coil/Guard.h>
+
+#include <rtm/RTC.h>
+#include <rtm/Typename.h>
+#include <rtm/InPortBase.h>
+#include <rtm/CdrBufferBase.h>
+#include <rtm/PortCallback.h>
+#include <rtm/InPortConnector.h>
+#include <rtm/Timestamp.h>
+#include <rtm/StaticFSM.h>
+
+namespace RTC
+{
+ template <class FSM, class TOP, class R>
+ class EventBinder0
+ : public ConnectorDataListener
+ {
+ USE_CONNLISTENER_STATUS;
+ public:
+ EventBinder0(FSM& fsm,
+ const char* event_name,
+ R (TOP::*handler)())
+ : m_fsm(fsm), m_eventName(event_name), m_handler(handler) {}
+
+ virtual ~EventBinder0() {}
+
+ virtual ReturnCode operator()(ConnectorInfo& info,
+ cdrMemoryStream& data)
+ {
+ if (info.properties["fsm_event_name"] == m_eventName ||
+ info.name == m_eventName)
+ {
+ m_fsm.dispatch(Macho::Event(m_handler));
+ std::cout << "Event dispatched: " << m_eventName << std::endl;
+ return NO_CHANGE;
+ }
+ return NO_CHANGE;
+ }
+
+ FSM& m_fsm;
+ std::string m_eventName;
+ R (TOP::*m_handler)();
+ };
+
+ template <class FSM, class TOP, class R, class P0>
+ class EventBinder1
+ : public ConnectorDataListenerT<P0>
+ {
+ USE_CONNLISTENER_STATUS;
+ public:
+ EventBinder1(FSM& fsm,
+ const char* event_name,
+ R (TOP::*handler)(P0))
+ : m_fsm(fsm), m_eventName(event_name), m_handler(handler) {}
+
+ virtual ~EventBinder1() {}
+
+ virtual ReturnCode operator()(ConnectorInfo& info, P0& data)
+ {
+ if (info.properties["fsm_event_name"] == m_eventName ||
+ info.name == m_eventName)
+ {
+ m_fsm.dispatch(Macho::Event(m_handler, data));
+ std::cout << "Event dispatched: " << m_eventName << std::endl;
+ return NO_CHANGE;
+ }
+ return NO_CHANGE;
+ }
+
+ FSM& m_fsm;
+ std::string m_eventName;
+ R (TOP::*m_handler)(P0);
+ };
+
+
+ /*!
+ * @if jp
+ *
+ * @class EventInPort
+ *
+ * @brief EventInPort ¥Æ¥ó¥×¥ì¡¼¥È¥¯¥é¥¹
+ *
+ * EventInPort ¤Î¼ÂÁõ¤Ç¤¢¤ë EventInPort<T> ¤Î¥Æ¥ó¥×¥ì¡¼¥È¥¯¥é¥¹¡£
+ * <T> ¤ÏBasicDataType.idl ¤Ë¤ÆÄêµÁ¤µ¤ì¤Æ¤¤¤ë·¿¤Ç¡¢¥á¥ó¥Ð¤È¤·¤Æ
+ * Time ·¿¤Î tm , ¤ª¤è¤Ó T·¿¤Î data ¤ò»ý¤Ä¹½Â¤ÂΤǤʤ¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
+ * EventInPort ¤ÏÆâÉô¤Ë¥ê¥ó¥°¥Ð¥Ã¥Õ¥¡¤ò»ý¤Á¡¢³°Éô¤«¤éÁ÷¿®¤µ¤ì¤¿¥Ç¡¼¥¿¤ò½ç¼¡
+ * ¤³¤Î¥ê¥ó¥°¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤¹¤ë¡£¥ê¥ó¥°¥Ð¥Ã¥Õ¥¡¤Î¥µ¥¤¥º¤Ï¥Ç¥Õ¥©¥ë¥È¤Ç64¤È
+ * ¤Ê¤Ã¤Æ¤¤¤ë¤¬¡¢¥³¥ó¥¹¥È¥é¥¯¥¿°ú¿ô¤Ë¤è¤ê¥µ¥¤¥º¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤¤ë¡£
+ * ¥Ç¡¼¥¿¤Ï¥Õ¥é¥°¤Ë¤è¤Ã¤Æ̤ÆÉ¡¢´ûÆɾõÂÖ¤¬´ÉÍý¤µ¤ì¡¢isNew(), write(), read(),
+ * isFull(), isEmpty() Åù¤Î¥á¥½¥Ã¥É¤Ë¤è¤ê¥Ï¥ó¥É¥ê¥ó¥°¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£
+ *
+ * OnRead·Ï¥³¡¼¥ë¥Ð¥Ã¥¯ (Æɤ߽Ф·¤Ëµ¯°ø¤¹¤ë¥¤¥Ù¥ó¥È¤Ë¤è¤ê¥³¡¼¥ë¤µ¤ì¤ë)
+ *
+ * - void OnRead::operator():
+ * EventInPort::read() ¤ò¸Æ¤Ó½Ð¤·Æɤ߽Ф·¤ò¹Ô¤¦ºÝ¤Ë¥³¡¼¥ë¤µ¤ì¤ë¡£
+ *
+ * - DataType OnReadConvert::operator(DataType):
+ * EventInPort::read() ¤ò¸Æ¤Ó½Ð¤·¡¢¥Ç¡¼¥¿¤ò¥Ð¥Ã¥Õ¥¡¤«¤éÆɤߤÀ¤¹ºÝ¤Ë¸Æ¤Ð¤ì
+ * ¥Ç¡¼¥¿¤ÎÊÑ´¹¤ò¹Ô¤¦¡£°ú¿ô¤Ë¤Ï¥Ð¥Ã¥Õ¥¡¤«¤éÆɤ߽Фµ¤ì¤¿Ãͤ¬Í¿¤¨¤é¤ì¡¢
+ * ÊÑ´¹¸å¤Î¥Ç¡¼¥¿¤òÌá¤êÃͤȤ·¤ÆÊÖ¤¹¡£¤³¤ÎÃͤ¬read()¤ÎÊÖ¤¹ÃͤȤʤ롣
+ *
+ * @since 0.2.0
+ *
+ * @else
+ *
+ * @class EventInPort
+ *
+ * @brief EventInPort template class
+ *
+ * This is a template class that implements EventInPort. <T> is the type
+ * defined in BasicDataType.idl and must be the structure which has
+ * both Time type tm and type-T data as a member. EventInPort has a ring
+ * buffer internally, and stores the received data externally in
+ * this buffer one by one. The size of ring buffer can be specified
+ * according to the argument of constructor, though the default size
+ * is 64. Unread data and data which is already read are managed
+ * with the flag, and the data can be handled by the isNew(),
+ * write(), read(), isFull() and isEmpty() method etc.
+ *
+ * @since 0.2.0
+ *
+ * @endif
+ */
+ template <class FsmType>
+ class EventInPort
+ : public InPortBase
+ {
+ public:
+ DATAPORTSTATUS_ENUM
+ /*!
+ * @if jp
+ *
+ * @brief ¥³¥ó¥¹¥È¥é¥¯¥¿
+ *
+ * ¥³¥ó¥¹¥È¥é¥¯¥¿¡£
+ * ¥Ñ¥é¥á¡¼¥¿¤È¤·¤ÆÍ¿¤¨¤é¤ì¤ë T ·¿¤ÎÊÑ¿ô¤Ë¥Ð¥¤¥ó¥É¤µ¤ì¤ë¡£
+ *
+ * @param name EventInPort ̾¡£EventInPortBase:name() ¤Ë¤è¤ê»²¾È¤µ¤ì¤ë¡£
+ * @param value ¤³¤Î EventInPort ¤Ë¥Ð¥¤¥ó¥É¤µ¤ì¤ë T ·¿¤ÎÊÑ¿ô
+ * @param bufsize EventInPort ÆâÉô¤Î¥ê¥ó¥°¥Ð¥Ã¥Õ¥¡¤Î¥Ð¥Ã¥Õ¥¡Ä¹(¥Ç¥Õ¥©¥ë¥ÈÃÍ:64)
+ * @param read_block Æɹþ¥Ö¥í¥Ã¥¯¥Õ¥é¥°¡£
+ * ¥Ç¡¼¥¿Æɹþ»þ¤Ë̤Æɥǡ¼¥¿¤¬¤Ê¤¤¾ì¹ç¡¢¼¡¤Î¥Ç¡¼¥¿¼õ¿®¤Þ¤Ç¥Ö¥í¥Ã¥¯¤¹¤ë
+ * ¤«¤É¤¦¤«¤òÀßÄê(¥Ç¥Õ¥©¥ë¥ÈÃÍ:false)
+ * @param write_block ½ñ¹þ¥Ö¥í¥Ã¥¯¥Õ¥é¥°¡£
+ * ¥Ç¡¼¥¿½ñ¹þ»þ¤Ë¥Ð¥Ã¥Õ¥¡¤¬¥Õ¥ë¤Ç¤¢¤Ã¤¿¾ì¹ç¡¢¥Ð¥Ã¥Õ¥¡¤Ë¶õ¤¤¬¤Ç¤¤ë
+ * ¤Þ¤Ç¥Ö¥í¥Ã¥¯¤¹¤ë¤«¤É¤¦¤«¤òÀßÄê(¥Ç¥Õ¥©¥ë¥ÈÃÍ:false)
+ * @param read_timeout Æɹþ¥Ö¥í¥Ã¥¯¤ò»ØÄꤷ¤Æ¤¤¤Ê¤¤¾ì¹ç¤Î¡¢¥Ç¡¼¥¿Æɼ西¥¤¥à
+ * ¥¢¥¦¥È»þ´Ö(¥ß¥êÉÃ)(¥Ç¥Õ¥©¥ë¥ÈÃÍ:0)
+ * @param write_timeout ½ñ¹þ¥Ö¥í¥Ã¥¯¤ò»ØÄꤷ¤Æ¤¤¤Ê¤¤¾ì¹ç¤Î¡¢¥Ç¡¼¥¿½ñ¹þ¥¿¥¤¥à
+ * ¥¢¥¦¥È»þ´Ö(¥ß¥êÉÃ)(¥Ç¥Õ¥©¥ë¥ÈÃÍ:0)
+ *
+ * @else
+ *
+ * @brief A constructor.
+ *
+ * constructor.
+ * This is bound to type-T variable given as a parameter.
+ *
+ * @param name A name of the EventInPort. This name is referred by
+ * EventInPortBase::name().
+ * @param value type-T variable that is bound to this EventInPort.
+ * @param bufsize Buffer length of internal ring buffer of EventInPort
+ * (The default value:64)
+ * @param read_block Flag of reading block.
+ * When there are not unread data at reading data,
+ * set whether to block data until receiving the next
+ * data. (The default value:false)
+ * @param write_block Flag of writing block.
+ * If the buffer was full at writing data, set whether
+ * to block data until the buffer has space.
+ * (The default value:false)
+ * @param read_timeout Data reading timeout time (millisecond)
+ * when not specifying read blocking.
+ * (The default value:0)
+ * @param write_timeout Data writing timeout time (millisecond)
+ * when not specifying writing block.
+ * (The default value:0)
+ *
+ * @endif
+ */
+ EventInPort(const char* name, FsmType& fsm,
+ int bufsize=64,
+ bool read_block = false, bool write_block = false,
+ int read_timeout = 0, int write_timeout = 0)
+ : InPortBase(name, "any"),
+ m_name(name), m_fsm(fsm)
+ {
+ }
+
+ /*!
+ * @if jp
+ *
+ * @brief ¥Ç¥¹¥È¥é¥¯¥¿
+ *
+ * ¥Ç¥¹¥È¥é¥¯¥¿¡£
+ *
+ * @else
+ *
+ * @brief Destructor
+ *
+ * Destructor
+ *
+ * @endif
+ */
+ virtual ~EventInPort(void){};
+
+ /*!
+ * @if jp
+ *
+ * @brief ¥Ý¡¼¥È̾¾Î¤ò¼èÆÀ¤¹¤ë¡£
+ *
+ * ¥Ý¡¼¥È̾¾Î¤ò¼èÆÀ¤¹¤ë¡£
+ *
+ * @return ¥Ý¡¼¥È̾¾Î
+ *
+ * @else
+ *
+ * @brief Get port name
+ *
+ * Get port name.
+ *
+ * @return The port name
+ *
+ * @endif
+ */
+ virtual const char* name()
+ {
+ return m_name.c_str();
+ }
+
+ template <class TOP, class R, class P0>
+ void bindEvent(const char* name,
+ R (TOP::*handler)(P0))
+ {
+ this->addConnectorDataListener
+ (ON_RECEIVED,
+ new EventBinder1<FsmType, TOP, R, P0>(m_fsm, name, handler));
+ }
+ template <typename TOP, class R>
+ void bindEvent(const char* name,
+ R (TOP::*handler)())
+ {
+ this->addConnectorDataListener
+ (ON_RECEIVED,
+ new EventBinder0<FsmType, TOP, R>(m_fsm, name, handler));
+ }
+ virtual bool read() { return true; }
+ private:
+ /*!
+ * @if jp
+ * @brief ¥Ý¡¼¥È̾
+ * @else
+ * @berif Port's name
+ * @endif
+ */
+ std::string m_name;
+ FsmType& m_fsm;
+ };
+}; // End of namesepace RTM
+
+#endif // RTC_EVENTINPORT_H
Modified: trunk/OpenRTM-aist/src/lib/rtm/Macho.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/Macho.cpp 2017-12-11 00:30:28 UTC (rev 3118)
+++ trunk/OpenRTM-aist/src/lib/rtm/Macho.cpp 2017-12-11 00:37:26 UTC (rev 3119)
@@ -331,7 +331,6 @@
// Perform entry actions on next state's parents (which exactly depends on previous state).
myCurrentState->entry(*previous);
- std::cout << "### State ### " << myCurrentState->name() << std::endl;
// State transition complete.
// Clear 'pending' information just now so that setState would assert in exits and entries, but not in init.
myPendingState = 0;
Modified: trunk/OpenRTM-aist/src/lib/rtm/Macho.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/Macho.h 2017-12-11 00:30:28 UTC (rev 3118)
+++ trunk/OpenRTM-aist/src/lib/rtm/Macho.h 2017-12-11 00:37:26 UTC (rev 3119)
@@ -1367,11 +1367,11 @@
class _MachineBase {
public:
class Alias currentState() const;
-
+
protected:
_MachineBase();
- ~_MachineBase();
-
+ virtual ~_MachineBase();
+
// Transition to new state.
void setState(_StateInstance & instance, _Initializer * init);
Modified: trunk/OpenRTM-aist/src/lib/rtm/Makefile.am
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/Makefile.am 2017-12-11 00:30:28 UTC (rev 3118)
+++ trunk/OpenRTM-aist/src/lib/rtm/Makefile.am 2017-12-11 00:37:26 UTC (rev 3119)
@@ -162,6 +162,7 @@
DataPortStatus.h \
DefaultConfiguration.h \
ExecutionContextBase.h \
+ EventPort.h \
InPort.h \
InPortConsumer.h \
NumberingPolicyBase.h \
Modified: trunk/OpenRTM-aist/src/lib/rtm/NVUtil.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/NVUtil.cpp 2017-12-11 00:30:28 UTC (rev 3118)
+++ trunk/OpenRTM-aist/src/lib/rtm/NVUtil.cpp 2017-12-11 00:37:26 UTC (rev 3119)
@@ -397,7 +397,7 @@
{
for (CORBA::ULong i(0), n(nv.length()); i < n; ++i)
{
- out << nv[i] << std::endl;
+ out << nv[i];
}
return out;
}
Copied: trunk/OpenRTM-aist/src/lib/rtm/StaticFSM.h (from rev 2903, branches/FSM4RTC/OpenRTM-aist/src/lib/rtm/StaticFSM.h)
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/StaticFSM.h (rev 0)
+++ trunk/OpenRTM-aist/src/lib/rtm/StaticFSM.h 2017-12-11 00:37:26 UTC (rev 3119)
@@ -0,0 +1,203 @@
+// -*- C++ -*-
+/*!
+ * @file StaticFSM.h
+ * @brief Static FSM framework based on Macho
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2017
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#ifndef RTC_STATICFSM_H
+#define RTC_STATICFSM_H
+
+#include <rtm/RTObject.h>
+#include <rtm/Macho.h>
+
+/*!
+ * @brief State machine definition macros
+ *
+ * FSM basic structure
+ *
+ * namespace <FSM name>
+ * {
+ * FSM_TOPSTATE(Top)
+ * {
+ * struct Box
+ * {
+ * Box() : <initializer> {}
+ * :
+ * <some operations>
+ * :
+ * };
+ * FSM_STATE(Top);
+ * :
+ * virtual void event_operations() {};
+ * :
+ * private:
+ * virtual RTC::ReturnCode_t onInit();
+ * virtual RTC::ReturnCode_t onEntry();
+ * virtual RTC::ReturnCode_t onExit();
+ * };
+ *
+ * FSM_SUBSTATE(OtherState, Top)
+ * {
+ * FSM_STATE(OtherState);
+ * virtual void event_operation();
+ * private:
+ * virtual RTC::ReturnCode_t onEntry();
+ * virtual RTC::ReturnCode_t onExit();
+ * };
+ *
+ * FSM_SUBSTATE(OtherState2, Top)
+ * : other states
+ *
+ * }; // end of <FSM name>
+ */
+
+
+/*!
+ * @brief Macho's TOPSTATE macro for RTC::Link
+ */
+#define FSM_TOPSTATE(TOP) \
+ struct TOP \
+ : public ::RTC::Link< TOP, ::Macho::TopBase< TOP > >
+
+/*!
+ * @brief Macho's SUBSTATE macro for RTC::Link
+ */
+#define FSM_SUBSTATE(STATE, SUPERSTATE) \
+ struct STATE \
+ : public ::RTC::Link< STATE, SUPERSTATE >
+
+/*!
+ * @brief Macho's STATE macro for RTC::Link
+ */
+#define FSM_STATE(S) \
+ public: \
+ typedef S SELF; \
+ S(::Macho::_StateInstance & instance) \
+ : ::RTC::Link<S, SUPER>(instance) \
+ { \
+ typedef ::__SameType< ::RTC::Link<S, SUPER>, LINK>::Check \
+ MustDeriveFromLink; \
+ } \
+ ~S() {} \
+ static const char * _state_name() { return #S; } \
+ Box & box() { return *static_cast<Box *>(_box()); } \
+ friend class ::_VS8_Bug_101615;
+
+
+using namespace Macho;
+
+
+namespace RTC
+{
+ /*!
+ * @class RTC::Machine class template
+ *
+ * This is modified version of Macho::Machine class. In this
+ * version, the constructor receives RTObject_impl* and it is kept
+ * to call callback functions.
+ *
+ */
+ template<class TOP>
+ class Machine : public Macho::Machine<TOP>
+ {
+ public:
+ Machine(RTC::RTObject_impl* comp)
+ : Macho::Machine<TOP>(), rtComponent(comp)
+ {
+ }
+ virtual ~Machine() {}
+
+ private:
+ Machine(const Machine<TOP> & other);
+ Machine<TOP> & operator=(const Machine<TOP> & other);
+
+ template<class C, class P>
+ friend class Link;
+
+#ifdef MACHO_SNAPSHOTS
+ friend class Macho::Snapshot<TOP>;
+#endif
+ template<class T> friend class Macho::StateID;
+
+ RTObject_impl* rtComponent;
+ };
+
+ /*!
+ * @class Link class
+ *
+ * This is modified version of Macho::Link<C, P> class
+ * template. Link class itself State object class.
+ *
+ * Default state operation entry/init/exit is used internally, and
+ * new state operations onEntry/onInit/onExit are added. These onXXX
+ * state operations should be override from state implementations.
+ *
+ */
+ template<class C, class P>
+ class Link
+ : public Macho::Link<C, P>
+ {
+ protected:
+ Link(_StateInstance & instance)
+ : Macho::Link<C, P>(instance), rtComponent(NULL)
+ {
+ const RTC::Machine<C>* machine;
+ machine = dynamic_cast<const RTC::Machine<C>*>(&P::machine());
+ if (machine != NULL)
+ {
+ rtComponent = machine->rtComponent;
+ }
+ }
+ public:
+ typedef Link<C, P> LINK;
+
+ virtual void entry()
+ {
+ if (rtComponent == NULL)
+ {
+ onEntry();
+ return;
+ }
+ rtComponent->preOnFsmEntry(C::_state_name());
+ rtComponent->postOnFsmEntry(C::_state_name(), onEntry());
+ }
+ virtual void init()
+ {
+ if (rtComponent == NULL)
+ {
+ onInit();
+ return;
+ }
+ rtComponent->preOnFsmInit(C::_state_name());
+ rtComponent->postOnFsmInit(C::_state_name(), onInit());
+ }
+ virtual void exit()
+ {
+ if (rtComponent == NULL)
+ {
+ onExit();
+ return;
+ }
+ rtComponent->preOnFsmExit(C::_state_name());
+ rtComponent->postOnFsmExit(C::_state_name(), onExit());
+ }
+
+ virtual ReturnCode_t onEntry() { return RTC::RTC_OK; }
+ virtual ReturnCode_t onInit() { return RTC::RTC_OK; }
+ virtual ReturnCode_t onExit() { return RTC::RTC_OK; }
+
+ private:
+ RTObject_impl* rtComponent;
+ };
+};
+#endif // RTC_STATICFSM_H
More information about the openrtm-commit
mailing list