|
|
@@ -0,0 +1,178 @@
|
|
|
+«REM»
|
|
|
+
|
|
|
+Templates for the main statechart cpp file.
|
|
|
+
|
|
|
+@auther joern seger
|
|
|
+
|
|
|
+«ENDREM»
|
|
|
+
|
|
|
+«IMPORT sexec»
|
|
|
+«IMPORT stext»
|
|
|
+«IMPORT sgraph»
|
|
|
+«IMPORT ecore»
|
|
|
+
|
|
|
+«IMPORT org::yakindu::sct::generator::cpp::templates»
|
|
|
+«EXTENSION org::yakindu::sct::generator::cpp::templates::Expression»
|
|
|
+«EXTENSION org::yakindu::sct::generator::cpp::templates::Naming»
|
|
|
+
|
|
|
+«DEFINE ActionCode FOR Step»
|
|
|
+// ActionCode for Step not defined
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ActionCode FOR Execution»
|
|
|
+ «this.statement.toCppCode()»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ActionCode FOR Call»
|
|
|
+«this.step.functionName()»();
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ActionCode FOR Sequence»
|
|
|
+ «EXPAND ActionCode FOREACH this.steps»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ActionCode FOR Check -»
|
|
|
+ «IF this != null -»
|
|
|
+«this.condition.toCppCode() -»
|
|
|
+ «ELSE -»
|
|
|
+ true «
|
|
|
+ ENDIF -»«
|
|
|
+ ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ActionCode FOR CheckRef -»
|
|
|
+ «IF this.check != null -»
|
|
|
+ «this.check.functionName()»(ev) «
|
|
|
+ ELSE -»
|
|
|
+ true «
|
|
|
+ ENDIF -»«
|
|
|
+ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ActionCode FOR Reaction»
|
|
|
+ «EXPAND ActionCode FOR this.effect»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ActionCode FOR If»
|
|
|
+if («EXPAND ActionCode FOR this.check») {
|
|
|
+ «EXPAND ActionCode FOR this.thenStep»
|
|
|
+}
|
|
|
+else {
|
|
|
+ «EXPAND ActionCode FOR this.elseStep»
|
|
|
+}
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ActionCode FOR EnterState»
|
|
|
+state[0] = _«this.state.simpleName»;
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ActionCode FOR ExitState»
|
|
|
+state[0] = last_state;
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ConditionMethodsImplement FOR ExecutionState»
|
|
|
+ «FOREACH reactions AS r»
|
|
|
+ «IF r.check != null -»
|
|
|
+bool «StNameEv()»::«r.check.functionName()»(const _Event& ev) {
|
|
|
+ return ( «r.check.condition.toCppCode()» );
|
|
|
+}
|
|
|
+ «ENDIF -»
|
|
|
+ «ENDFOREACH»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE StatementMethodsImplement FOR ExecutionState»
|
|
|
+ «FOREACH reactions AS r»
|
|
|
+void «this.StName()»::«r.effect.functionName()»() {
|
|
|
+ «EXPAND ActionCode FOR r.effect»
|
|
|
+}
|
|
|
+ «ENDFOREACH»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE CycleCode FOR Cycle»
|
|
|
+«EXPAND ActionCode FOREACH this.steps»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE CycleMethodsImplement FOR ExecutionState»
|
|
|
+void «StNameEv()»::cycle_«this.simpleName»(const _Event& ev)
|
|
|
+{
|
|
|
+ «EXPAND CycleCode FOR cycle»
|
|
|
+}
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE EnterMethodImplement FOR ExecutionState»
|
|
|
+«IF this.entryAction != null»
|
|
|
+void «StNameEv()»::«this.entryAction.entryActionFunctionName()»()
|
|
|
+{
|
|
|
+«EXPAND ActionCode FOR this.entryAction»
|
|
|
+}
|
|
|
+«ENDIF»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ExitMethodImplement FOR ExecutionState»
|
|
|
+«IF this.exitAction != null»
|
|
|
+void «StNameEv()»::«this.exitAction.exitActionFunctionName()»()
|
|
|
+{
|
|
|
+«EXPAND ActionCode FOR this.exitAction»
|
|
|
+}
|
|
|
+«ENDIF»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE file FOR ExecutionFlow»
|
|
|
+«FILE StName()+'_ev.cpp'»
|
|
|
+#include <iostream>
|
|
|
+#include "«StNameEv()».h"
|
|
|
+
|
|
|
+«StNameEv()»::«StNameEv()»(Timer* _timer) : Statemachine_ev(«((ExecutionFlow)this.eRootContainer).stateVector.size», event_last, _timer) {
|
|
|
+}
|
|
|
+
|
|
|
+«StNameEv()»::~«StNameEv()»() {
|
|
|
+}
|
|
|
+
|
|
|
+«EXPAND ConditionMethodsImplement FOREACH this.states»
|
|
|
+
|
|
|
+«EXPAND StatementMethodsImplement FOREACH this.states»
|
|
|
+
|
|
|
+«EXPAND CycleMethodsImplement FOREACH this.states»
|
|
|
+
|
|
|
+«EXPAND EnterMethodImplement FOREACH this.states»
|
|
|
+
|
|
|
+«EXPAND ExitMethodImplement FOREACH this.states»
|
|
|
+
|
|
|
+
|
|
|
+void «StNameEv()»::init()
|
|
|
+{
|
|
|
+ «EXPAND ActionCode FOREACH this.enterSequence.steps»
|
|
|
+}
|
|
|
+
|
|
|
+/* Yet unimplemented
|
|
|
+void «StNameEv()»::exit()
|
|
|
+{
|
|
|
+}
|
|
|
+*/
|
|
|
+
|
|
|
+void «StNameEv()»::_setActualEventData(Event ev)
|
|
|
+{
|
|
|
+ setEventData(ev);
|
|
|
+}
|
|
|
+
|
|
|
+void «StNameEv()»::_removeActualEventData()
|
|
|
+{
|
|
|
+ clearEventData();
|
|
|
+}
|
|
|
+
|
|
|
+void «StNameEv()»::_runCycle(Event ev)
|
|
|
+{
|
|
|
+ for (int i=0; i<MAX_PARALLEL_STATES; ++i) {
|
|
|
+ switch(state[i]) {
|
|
|
+ «FOREACH this.states AS state»
|
|
|
+ case _«state.simpleName»:
|
|
|
+ cycle_«state.simpleName»(*ev);
|
|
|
+ break;
|
|
|
+ «ENDFOREACH»
|
|
|
+ default:
|
|
|
+ /* no state found */
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+«ENDFILE»
|
|
|
+
|
|
|
+«ENDDEFINE»
|