[openrtm-commit:02464] r686 - in branches/FSM4RTC/jp.go.aist.rtm.rtcbuilder/src/jp/go/aist/rtm/rtcbuilder: manager template/cpp
openrtm @ openrtm.org
openrtm @ openrtm.org
2017年 2月 20日 (月) 01:12:33 JST
Author: ga
Date: 2017-02-20 01:12:33 +0900 (Mon, 20 Feb 2017)
New Revision: 686
Modified:
branches/FSM4RTC/jp.go.aist.rtm.rtcbuilder/src/jp/go/aist/rtm/rtcbuilder/manager/CXXGenerateManager.java
branches/FSM4RTC/jp.go.aist.rtm.rtcbuilder/src/jp/go/aist/rtm/rtcbuilder/template/cpp/CXX_RTC.cpp.vsl
branches/FSM4RTC/jp.go.aist.rtm.rtcbuilder/src/jp/go/aist/rtm/rtcbuilder/template/cpp/CXX_RTC.h.vsl
Log:
Modified generated FSM code (RTC source/header) #3877
Modified: branches/FSM4RTC/jp.go.aist.rtm.rtcbuilder/src/jp/go/aist/rtm/rtcbuilder/manager/CXXGenerateManager.java
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.rtcbuilder/src/jp/go/aist/rtm/rtcbuilder/manager/CXXGenerateManager.java 2017-02-19 06:13:36 UTC (rev 685)
+++ branches/FSM4RTC/jp.go.aist.rtm.rtcbuilder/src/jp/go/aist/rtm/rtcbuilder/manager/CXXGenerateManager.java 2017-02-19 16:12:33 UTC (rev 686)
@@ -71,6 +71,23 @@
List<GeneratedResult> result = new ArrayList<GeneratedResult>();
RtcParam rtcParam = (RtcParam) contextMap.get("rtcParam");
+ boolean isStaticFSM = false;
+ PropertyParam fsm = rtcParam.getProperty(IRtcBuilderConstants.PROP_TYPE_FSM);
+ if(fsm!=null) {
+ if(Boolean.valueOf(fsm.getValue())) {
+ PropertyParam fsmType = rtcParam.getProperty(IRtcBuilderConstants.PROP_TYPE_FSMTYTPE);
+ if(fsmType.getValue().equals(IRtcBuilderConstants.FSMTYTPE_STATIC)) {
+ isStaticFSM = true;
+ }
+ }
+ }
+
+ if(isStaticFSM) {
+ StateParam stateParam = rtcParam.getFsmParam();
+ contextMap.put("fsmParam", stateParam);
+ }
+
+
GeneratedResult gr;
gr = generateCompSource(contextMap);
result.add(gr);
@@ -79,17 +96,11 @@
gr = generateRTCSource(contextMap);
result.add(gr);
- PropertyParam fsm = rtcParam.getProperty(IRtcBuilderConstants.PROP_TYPE_FSM);
- if(fsm!=null) {
- if(Boolean.valueOf(fsm.getValue())) {
- PropertyParam fsmType = rtcParam.getProperty(IRtcBuilderConstants.PROP_TYPE_FSMTYTPE);
- if(fsmType.getValue().equals(IRtcBuilderConstants.FSMTYTPE_STATIC)) {
- gr = generateFSMHeader(contextMap);
- result.add(gr);
- gr = generateFSMSource(contextMap);
- result.add(gr);
- }
- }
+ if(isStaticFSM) {
+ gr = generateFSMHeader(contextMap);
+ result.add(gr);
+ gr = generateFSMSource(contextMap);
+ result.add(gr);
}
for (IdlFileParam idl : rtcParam.getProviderIdlPathes()) {
@@ -151,9 +162,6 @@
public GeneratedResult generateFSMHeader(Map<String, Object> contextMap) {
RtcParam rtcParam = (RtcParam) contextMap.get("rtcParam");
- StateParam stateParam = rtcParam.getFsmParam();
- contextMap.put("fsmParam", stateParam);
-
String outfile = null;
outfile = "include/" + rtcParam.getName() + "/" + rtcParam.getName() + "FSM.h";
String infile = "fsm/CXX_FSM.h.vsl";
Modified: branches/FSM4RTC/jp.go.aist.rtm.rtcbuilder/src/jp/go/aist/rtm/rtcbuilder/template/cpp/CXX_RTC.cpp.vsl
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.rtcbuilder/src/jp/go/aist/rtm/rtcbuilder/template/cpp/CXX_RTC.cpp.vsl 2017-02-19 06:13:36 UTC (rev 685)
+++ branches/FSM4RTC/jp.go.aist.rtm.rtcbuilder/src/jp/go/aist/rtm/rtcbuilder/template/cpp/CXX_RTC.cpp.vsl 2017-02-19 16:12:33 UTC (rev 686)
@@ -66,7 +66,7 @@
*/
${rtcParam.name}::${rtcParam.name}(RTC::Manager* manager)
// <rtc-template block="initializer">
- : RTC::${rtcParam.componentKind}Base(manager)#foreach($port in ${rtcParam.inports})#if(${port.type}!=""),
+ : RTC::${rtcParam.componentKind}Base(manager)#foreach($port in ${rtcParam.inports})#if(${port.type}!="" && ${port.name}!="FSMEvent"),
${rtcParam.commonPrefix}${rtcParam.dataPortPrefix}${port.tmplVarName}In${rtcParam.dataPortSuffix}${rtcParam.commonSuffix}("${port.name}", ${rtcParam.commonPrefix}${rtcParam.dataPortPrefix}${port.tmplVarName}${rtcParam.dataPortSuffix}${rtcParam.commonSuffix})#end#end#foreach($port in ${rtcParam.outports})#if(${port.type}!=""),
${rtcParam.commonPrefix}${rtcParam.dataPortPrefix}${port.tmplVarName}Out${rtcParam.dataPortSuffix}${rtcParam.commonSuffix}("${port.name}", ${rtcParam.commonPrefix}${rtcParam.dataPortPrefix}${port.tmplVarName}${rtcParam.dataPortSuffix}${rtcParam.commonSuffix})#end#end
#if(${rtcParam.servicePorts.size()}>0)
@@ -74,6 +74,10 @@
#if(${servicePort.servicePortInterfaces.size()}>0)
,
${rtcParam.commonPrefix}${rtcParam.servicePortPrefix}${servicePort.name}Port${rtcParam.servicePortSuffix}${rtcParam.commonSuffix}("${servicePort.name}")#end#end#end
+#if( ${tmpltHelper.checkFSM(${rtcParam})} ),
+ m_fsm(this),
+ m_eventIn("event", m_fsm)
+#end
// </rtc-template>
@@ -99,7 +103,7 @@
// <rtc-template block="registration">
// Set InPort buffers
#foreach($port in ${rtcParam.inports})
-#if(${port.type}!="") addInPort("${port.name}", ${rtcParam.commonPrefix}${rtcParam.dataPortPrefix}${port.tmplVarName}In${rtcParam.dataPortSuffix}${rtcParam.commonSuffix});
+#if(${port.type}!="" && ${port.name}!="FSMEvent") addInPort("${port.name}", ${rtcParam.commonPrefix}${rtcParam.dataPortPrefix}${port.tmplVarName}In${rtcParam.dataPortSuffix}${rtcParam.commonSuffix});
#end
#end
@@ -146,6 +150,15 @@
// </rtc-template>
#if(${tmpltHelper.checkDetailContent(0,${rtcParam})})${rtcParam.getDetailContent(0)}
#end
+#if( ${tmpltHelper.checkFSM(${rtcParam})} )
+ // <rtc-template block="fsm">
+ addInPort("event", m_eventIn);
+
+#foreach($eachTrans in ${fsmParam.getAllTransList()})
+ m_eventIn.bindEvent("${eachTrans.event}", &${rtcParam.name}FSM::${fsmParam.name}::${eachTrans.event});
+#end
+ // </rtc-template>
+#end
return RTC::RTC_OK;
}
Modified: branches/FSM4RTC/jp.go.aist.rtm.rtcbuilder/src/jp/go/aist/rtm/rtcbuilder/template/cpp/CXX_RTC.h.vsl
===================================================================
--- branches/FSM4RTC/jp.go.aist.rtm.rtcbuilder/src/jp/go/aist/rtm/rtcbuilder/template/cpp/CXX_RTC.h.vsl 2017-02-19 06:13:36 UTC (rev 685)
+++ branches/FSM4RTC/jp.go.aist.rtm.rtcbuilder/src/jp/go/aist/rtm/rtcbuilder/template/cpp/CXX_RTC.h.vsl 2017-02-19 16:12:33 UTC (rev 686)
@@ -41,7 +41,8 @@
// FSM headers
// <rtc-template block="fsm_h">
${sharp}include <${rtcParam.name}FSM.h>
-// </rtc-template>#end
+// </rtc-template>
+#end
${sharp}include <rtm/Manager.h>
${sharp}include <rtm/${rtcParam.componentKind}Base.h>
@@ -365,7 +366,7 @@
// DataInPort declaration
// <rtc-template block="inport_declare">
#foreach($port in ${rtcParam.inports})
-#if(${port.type}!="") ${port.type} ${rtcParam.commonPrefix}${rtcParam.dataPortPrefix}${port.tmplVarName}${rtcParam.dataPortSuffix}${rtcParam.commonSuffix};
+#if(${port.type}!="" && ${port.name}!="FSMEvent") ${port.type} ${rtcParam.commonPrefix}${rtcParam.dataPortPrefix}${port.tmplVarName}${rtcParam.dataPortSuffix}${rtcParam.commonSuffix};
/*!
#if(${port.docDescription.length()}>0) * ${tmpltHelper.convertDescDoc(${port.docDescription})}
#end
@@ -484,10 +485,15 @@
// </rtc-template>
#if( ${tmpltHelper.checkFSM(${rtcParam})} )
- // FSM declaration
+ // State machine declaration
// <rtc-template block="fsm_declare">
- ${rtcParam.name}FSM::Machine<${tmpltHelper.getTopFSMName(${rtcParam})}>* machine_;
+ RTC::Machine<${rtcParam.name}FSM::${fsmParam.name}> m_fsm;
// </rtc-template>
+
+ // EventPort declaration
+ // <rtc-template block="event_declare">
+ EventInPort< RTC::Machine<${rtcParam.name}FSM::${fsmParam.name}> > m_eventIn;
+ // </rtc-template>
#end
private:
openrtm-commit メーリングリストの案内