|
@@ -1,449 +1,449 @@
|
|
|
-«REM»
|
|
|
+«REM»
|
|
|
|
|
|
Templates for the main statechart c file.
|
|
|
|
|
|
@auther joern seger
|
|
|
|
|
|
-«ENDREM»
|
|
|
+«ENDREM»
|
|
|
|
|
|
-«IMPORT sexec»
|
|
|
-«IMPORT stext»
|
|
|
-«IMPORT sgraph»
|
|
|
-«IMPORT ecore»
|
|
|
-«IMPORT genmodel»
|
|
|
+«IMPORT sexec»
|
|
|
+«IMPORT stext»
|
|
|
+«IMPORT sgraph»
|
|
|
+«IMPORT ecore»
|
|
|
+«IMPORT genmodel»
|
|
|
|
|
|
-«IMPORT org::yakindu::sct::generator::c::templates»
|
|
|
+«IMPORT org::yakindu::sct::generator::c::templates»
|
|
|
|
|
|
-«EXTENSION org::yakindu::sct::generator::c::templates::Expression»
|
|
|
-«EXTENSION org::yakindu::sct::generator::c::templates::Constants»
|
|
|
-«EXTENSION org::yakindu::sct::generator::c::templates::Naming»
|
|
|
+«EXTENSION org::yakindu::sct::generator::c::templates::Expression»
|
|
|
+«EXTENSION org::yakindu::sct::generator::c::templates::Constants»
|
|
|
+«EXTENSION org::yakindu::sct::generator::c::templates::Naming»
|
|
|
|
|
|
-«DEFINE ActionCode FOR Step»
|
|
|
+«DEFINE ActionCode FOR Step»
|
|
|
#warning ActionCode for Step not defined
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE ActionCode FOR SaveHistory»
|
|
|
-«IF this.comment != null -»
|
|
|
- /* «this.comment» */
|
|
|
-«ENDIF»
|
|
|
- «statemachineHandleName()»->base.base.history[«region.historyVector.offset»] = «statemachineHandleName()»->base.base.state[«region.stateVector.offset»];
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE ActionCode FOR HistoryEntry»
|
|
|
-«IF this.comment != null -»
|
|
|
- /* «this.comment» */
|
|
|
-«ENDIF»
|
|
|
-if («statemachineHandleName()»->base.base.history[«region.historyVector.offset»] != last_state) {
|
|
|
- «EXPAND ActionCode FOR historyStep-»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ActionCode FOR SaveHistory»
|
|
|
+«IF this.comment != null -»
|
|
|
+ /* «this.comment» */
|
|
|
+«ENDIF»
|
|
|
+ «statemachineHandleName()»->base.base.history[«region.historyVector.offset»] = «statemachineHandleName()»->base.base.state[«region.stateVector.offset»];
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ActionCode FOR HistoryEntry»
|
|
|
+«IF this.comment != null -»
|
|
|
+ /* «this.comment» */
|
|
|
+«ENDIF»
|
|
|
+if («statemachineHandleName()»->base.base.history[«region.historyVector.offset»] != last_state) {
|
|
|
+ «EXPAND ActionCode FOR historyStep-»
|
|
|
} else {
|
|
|
- «EXPAND ActionCode FOR initialStep-»
|
|
|
+ «EXPAND ActionCode FOR initialStep-»
|
|
|
}
|
|
|
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE ActionCode FOR StateSwitch»
|
|
|
-«IF this.comment != null -»
|
|
|
- /* «this.comment» */
|
|
|
-«ENDIF -»
|
|
|
-«IF this.historyRegion != null»
|
|
|
- switch(((StatemachineBase*)«statemachineHandleName()»)->history[ «historyRegion.historyVector.offset» ]) {
|
|
|
-«ELSE»
|
|
|
- switch(((StatemachineBase*)«statemachineHandleName()»)->state[ «this.stateConfigurationIdx» ]) {
|
|
|
-«ENDIF»
|
|
|
-«FOREACH this.cases AS caseid -»
|
|
|
- case _«caseid.state.getStateName()» : {
|
|
|
-«EXPAND ActionCode FOR caseid.step-»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ActionCode FOR StateSwitch»
|
|
|
+«IF this.comment != null -»
|
|
|
+ /* «this.comment» */
|
|
|
+«ENDIF -»
|
|
|
+«IF this.historyRegion != null»
|
|
|
+ switch(((StatemachineBase*)«statemachineHandleName()»)->history[ «historyRegion.historyVector.offset» ]) {
|
|
|
+«ELSE»
|
|
|
+ switch(((StatemachineBase*)«statemachineHandleName()»)->state[ «this.stateConfigurationIdx» ]) {
|
|
|
+«ENDIF»
|
|
|
+«FOREACH this.cases AS caseid -»
|
|
|
+ case _«caseid.state.getStateName()» : {
|
|
|
+«EXPAND ActionCode FOR caseid.step-»
|
|
|
break;
|
|
|
}
|
|
|
-«ENDFOREACH»
|
|
|
+«ENDFOREACH»
|
|
|
default: break;
|
|
|
}
|
|
|
-«ENDDEFINE »
|
|
|
-
|
|
|
-«DEFINE ActionCode FOR ScheduleTimeEvent»
|
|
|
-«IF this.comment != null»
|
|
|
-/* «this.comment» */
|
|
|
-«ENDIF»
|
|
|
- (*((StatemachineBase*)«statemachineHandleName()»)->timer->setTimer)(«this.timeEvent.getEventEnumName()», «this.timeValue.toCCode()», «IF this.timeEvent.periodic == true -» «getBoolTrue()» «ELSE -» «getBoolFalse()» «ENDIF -»);
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE ActionCode FOR UnscheduleTimeEvent»
|
|
|
-«IF this.comment != null»
|
|
|
-/* «this.comment» */
|
|
|
-«ENDIF»
|
|
|
- (*((StatemachineBase*)«statemachineHandleName()»)->timer->unsetTimer)(«this.timeEvent.getEventEnumName()»);
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE ActionCode FOR Execution»
|
|
|
- «this.statement.toCCode()»;
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE ActionCode FOR Call»
|
|
|
-«this.step.functionName()»(«IF isSingleton() == false»«this.statemachineHandleName()»«ENDIF»);
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE ActionCode FOR Sequence -»
|
|
|
- «EXPAND ActionCode FOREACH this.steps -»
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE ActionCode FOR Check -»
|
|
|
- «IF this != null -»
|
|
|
-«this.condition.toCCode() -»
|
|
|
- «ELSE -»
|
|
|
- «getBoolTrue()» «
|
|
|
- ENDIF -»«
|
|
|
- ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE ActionCode FOR CheckRef -»
|
|
|
- «IF this.check != null -»
|
|
|
- «getComment()-»
|
|
|
- «this.check.functionName()»(«statemachineHandleName()») «ELSE -»
|
|
|
- «getBoolTrue()» «
|
|
|
- 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»
|
|
|
+«ENDDEFINE »
|
|
|
+
|
|
|
+«DEFINE ActionCode FOR ScheduleTimeEvent»
|
|
|
+«IF this.comment != null»
|
|
|
+/* «this.comment» */
|
|
|
+«ENDIF»
|
|
|
+ (*((StatemachineBase*)«statemachineHandleName()»)->timer->setTimer)(«this.timeEvent.getEventEnumName()», «this.timeValue.toCCode()», «IF this.timeEvent.periodic == true -» «getBoolTrue()» «ELSE -» «getBoolFalse()» «ENDIF -»);
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ActionCode FOR UnscheduleTimeEvent»
|
|
|
+«IF this.comment != null»
|
|
|
+/* «this.comment» */
|
|
|
+«ENDIF»
|
|
|
+ (*((StatemachineBase*)«statemachineHandleName()»)->timer->unsetTimer)(«this.timeEvent.getEventEnumName()»);
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ActionCode FOR Execution»
|
|
|
+ «this.statement.toCCode()»;
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ActionCode FOR Call»
|
|
|
+«this.step.functionName()»(«IF isSingleton() == false»«this.statemachineHandleName()»«ENDIF»);
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ActionCode FOR Sequence -»
|
|
|
+ «EXPAND ActionCode FOREACH this.steps -»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ActionCode FOR Check -»
|
|
|
+ «IF this != null -»
|
|
|
+«this.condition.toCCode() -»
|
|
|
+ «ELSE -»
|
|
|
+ «getBoolTrue()» «
|
|
|
+ ENDIF -»«
|
|
|
+ ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ActionCode FOR CheckRef -»
|
|
|
+ «IF this.check != null -»
|
|
|
+ «getComment()-»
|
|
|
+ «this.check.functionName()»(«statemachineHandleName()») «ELSE -»
|
|
|
+ «getBoolTrue()» «
|
|
|
+ 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»
|
|
|
}
|
|
|
-«IF (this.elseStep != null)»
|
|
|
+«IF (this.elseStep != null)»
|
|
|
else {
|
|
|
- «EXPAND ActionCode FOR this.elseStep»
|
|
|
+ «EXPAND ActionCode FOR this.elseStep»
|
|
|
}
|
|
|
-«ENDIF»
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-
|
|
|
-«DEFINE ActionCode FOR EnterState»
|
|
|
-((StatemachineBase*)«statemachineHandleName()»)->state[«this.state.stateVector.offset»] = _«this.state.getStateName()»;
|
|
|
-((Statemachine_cy*)«statemachineHandleName()»)->parallelPosition = «this.state.stateVector.offset»;
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE ActionCode FOR ExitState»
|
|
|
-((StatemachineBase*)«statemachineHandleName()»)->state[«this.state.stateVector.offset»] = last_state;
|
|
|
-((Statemachine_cy*)«statemachineHandleName()»)->parallelPosition = «this.state.stateVector.offset»;
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE ConditionMethodsProto FOR ExecutionNode -»
|
|
|
- «FOREACH reactions.select(e|e.check.refs.size > 0) AS r -»
|
|
|
- «IF r.check != null -»
|
|
|
-static sc_boolean «r.check.checkFunction()»;
|
|
|
- «ENDIF -»«ENDFOREACH -»
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE ConditionMethodsImplement FOR ExecutionNode -»
|
|
|
- «FOREACH reactions.select(e|e.check.refs.size > 0) AS r -»
|
|
|
- «IF r.check != null -»
|
|
|
-sc_boolean «r.check.checkFunction()» {
|
|
|
- sc_boolean retValue = «getBoolFalse()»;
|
|
|
- if («r.check.condition.toCCode()»)
|
|
|
- retValue = «getBoolTrue()»;
|
|
|
+«ENDIF»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+
|
|
|
+«DEFINE ActionCode FOR EnterState»
|
|
|
+((StatemachineBase*)«statemachineHandleName()»)->state[«this.state.stateVector.offset»] = _«this.state.getStateName()»;
|
|
|
+((Statemachine_cy*)«statemachineHandleName()»)->parallelPosition = «this.state.stateVector.offset»;
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ActionCode FOR ExitState»
|
|
|
+((StatemachineBase*)«statemachineHandleName()»)->state[«this.state.stateVector.offset»] = last_state;
|
|
|
+((Statemachine_cy*)«statemachineHandleName()»)->parallelPosition = «this.state.stateVector.offset»;
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ConditionMethodsProto FOR ExecutionNode -»
|
|
|
+ «FOREACH reactions.select(e|e.check.refs.size > 0) AS r -»
|
|
|
+ «IF r.check != null -»
|
|
|
+static sc_boolean «r.check.checkFunction()»;
|
|
|
+ «ENDIF -»«ENDFOREACH -»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ConditionMethodsImplement FOR ExecutionNode -»
|
|
|
+ «FOREACH reactions.select(e|e.check.refs.size > 0) AS r -»
|
|
|
+ «IF r.check != null -»
|
|
|
+sc_boolean «r.check.checkFunction()» {
|
|
|
+ sc_boolean retValue = «getBoolFalse()»;
|
|
|
+ if («r.check.condition.toCCode()»)
|
|
|
+ retValue = «getBoolTrue()»;
|
|
|
|
|
|
return retValue;
|
|
|
}
|
|
|
- «ENDIF -»
|
|
|
- «ENDFOREACH -»
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE StatementMethodsProto FOR ExecutionNode -»
|
|
|
- «FOREACH reactions.select(e|e.effect.caller.size > 0) AS r -»
|
|
|
-static void «r.effect.functionName()»(«handleAddition()»);
|
|
|
- «ENDFOREACH -»
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE StatementMethodsImplement FOR ExecutionNode -»
|
|
|
- «FOREACH reactions.select(e|e.effect.caller.size > 0) AS r -»
|
|
|
-void «r.effect.functionName()»(«handleAddition()»)
|
|
|
+ «ENDIF -»
|
|
|
+ «ENDFOREACH -»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE StatementMethodsProto FOR ExecutionNode -»
|
|
|
+ «FOREACH reactions.select(e|e.effect.caller.size > 0) AS r -»
|
|
|
+static void «r.effect.functionName()»(«handleAddition()»);
|
|
|
+ «ENDFOREACH -»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE StatementMethodsImplement FOR ExecutionNode -»
|
|
|
+ «FOREACH reactions.select(e|e.effect.caller.size > 0) AS r -»
|
|
|
+void «r.effect.functionName()»(«handleAddition()»)
|
|
|
{
|
|
|
- «EXPAND ActionCode FOR r.effect -»
|
|
|
+ «EXPAND ActionCode FOR r.effect -»
|
|
|
}
|
|
|
- «ENDFOREACH -»
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE ReactCode FOR Sequence»
|
|
|
-«EXPAND ActionCode FOREACH this.steps»
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE ReactMethodsProto FOR ExecutionNode -»
|
|
|
-«IF (ExecutionState.isInstance(this) || this.reactSequence.caller.size > 0) -»
|
|
|
-static void «this.reactFunction()»;
|
|
|
-«REM»«stName()»_react_«this.simpleName»(«StName()»* handle);«ENDREM»
|
|
|
-«ENDIF -»
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE ReactMethodsImplement FOR ExecutionNode -»
|
|
|
-«IF (ExecutionState.isInstance(this) || this.reactSequence.caller.size > 0) -»
|
|
|
-void «this.reactFunction()-»
|
|
|
-«REM»void «stName()»_react_«this.simpleName»(«StName()»* handle)«ENDREM»
|
|
|
+ «ENDFOREACH -»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ReactCode FOR Sequence»
|
|
|
+«EXPAND ActionCode FOREACH this.steps»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ReactMethodsProto FOR ExecutionNode -»
|
|
|
+«IF (ExecutionState.isInstance(this) || this.reactSequence.caller.size > 0) -»
|
|
|
+static void «this.reactFunction()»;
|
|
|
+«REM»«stName()»_react_«this.simpleName»(«StName()»* handle);«ENDREM»
|
|
|
+«ENDIF -»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ReactMethodsImplement FOR ExecutionNode -»
|
|
|
+«IF (ExecutionState.isInstance(this) || this.reactSequence.caller.size > 0) -»
|
|
|
+void «this.reactFunction()-»
|
|
|
+«REM»void «stName()»_react_«this.simpleName»(«StName()»* handle)«ENDREM»
|
|
|
{
|
|
|
- «EXPAND ReactCode FOR reactSequence»
|
|
|
+ «EXPAND ReactCode FOR reactSequence»
|
|
|
}
|
|
|
-«ENDIF -»
|
|
|
-«ENDDEFINE»
|
|
|
+«ENDIF -»
|
|
|
+«ENDDEFINE»
|
|
|
|
|
|
|
|
|
-«DEFINE EnterMethodProto FOR ExecutionFlow -»
|
|
|
-«IF this.entryAction != null && entryAction.caller.size > 0 -»
|
|
|
-static void «entryAction.statemachineEntryActionFunction() -»;
|
|
|
-«ENDIF -»
|
|
|
-«ENDDEFINE»
|
|
|
+«DEFINE EnterMethodProto FOR ExecutionFlow -»
|
|
|
+«IF this.entryAction != null && entryAction.caller.size > 0 -»
|
|
|
+static void «entryAction.statemachineEntryActionFunction() -»;
|
|
|
+«ENDIF -»
|
|
|
+«ENDDEFINE»
|
|
|
|
|
|
-«DEFINE EnterMethodImplement FOR ExecutionFlow -»
|
|
|
-«IF this.entryAction != null && entryAction.caller.size > 0»
|
|
|
-void «entryAction.statemachineEntryActionFunction()»
|
|
|
+«DEFINE EnterMethodImplement FOR ExecutionFlow -»
|
|
|
+«IF this.entryAction != null && entryAction.caller.size > 0»
|
|
|
+void «entryAction.statemachineEntryActionFunction()»
|
|
|
{
|
|
|
-«EXPAND ActionCode FOR this.entryAction -»
|
|
|
+«EXPAND ActionCode FOR this.entryAction -»
|
|
|
}
|
|
|
-«ENDIF -»
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE ExitMethodProto FOR ExecutionFlow -»
|
|
|
-«IF this.exitAction != null && exitAction.caller.size > 0 -»
|
|
|
-static void «this.exitAction.statemachineExitActionFunction() -»;
|
|
|
-«ENDIF -»
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE ExitMethodImplement FOR ExecutionFlow -»
|
|
|
-«IF this.exitAction != null && exitAction.caller.size > 0 -»
|
|
|
-void «this.exitAction.statemachineExitActionFunction()»
|
|
|
+«ENDIF -»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ExitMethodProto FOR ExecutionFlow -»
|
|
|
+«IF this.exitAction != null && exitAction.caller.size > 0 -»
|
|
|
+static void «this.exitAction.statemachineExitActionFunction() -»;
|
|
|
+«ENDIF -»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ExitMethodImplement FOR ExecutionFlow -»
|
|
|
+«IF this.exitAction != null && exitAction.caller.size > 0 -»
|
|
|
+void «this.exitAction.statemachineExitActionFunction()»
|
|
|
{
|
|
|
-«EXPAND ActionCode FOR this.exitAction -»
|
|
|
+«EXPAND ActionCode FOR this.exitAction -»
|
|
|
}
|
|
|
-«ENDIF -»
|
|
|
-«ENDDEFINE»
|
|
|
+«ENDIF -»
|
|
|
+«ENDDEFINE»
|
|
|
|
|
|
|
|
|
|
|
|
-«DEFINE EnterMethodProto FOR ExecutionState -»
|
|
|
-«IF this.entryAction != null && entryAction.caller.size > 0 -»
|
|
|
-static void «entryAction.entryActionFunction()»;
|
|
|
-«ENDIF -»
|
|
|
-«ENDDEFINE»
|
|
|
+«DEFINE EnterMethodProto FOR ExecutionState -»
|
|
|
+«IF this.entryAction != null && entryAction.caller.size > 0 -»
|
|
|
+static void «entryAction.entryActionFunction()»;
|
|
|
+«ENDIF -»
|
|
|
+«ENDDEFINE»
|
|
|
|
|
|
-«DEFINE EnterMethodImplement FOR ExecutionState -»
|
|
|
-«IF this.entryAction != null && entryAction.caller.size > 0»
|
|
|
-void «entryAction.entryActionFunction()»
|
|
|
+«DEFINE EnterMethodImplement FOR ExecutionState -»
|
|
|
+«IF this.entryAction != null && entryAction.caller.size > 0»
|
|
|
+void «entryAction.entryActionFunction()»
|
|
|
{
|
|
|
-«EXPAND ActionCode FOR this.entryAction»
|
|
|
+«EXPAND ActionCode FOR this.entryAction»
|
|
|
}
|
|
|
-«ENDIF -»
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE ExitMethodProto FOR ExecutionState -»
|
|
|
-«IF this.exitAction != null && exitAction.caller.size > 0 -»
|
|
|
-static void «this.exitAction.exitActionFunction()»;
|
|
|
-«ENDIF -»
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE ExitMethodImplement FOR ExecutionState -»
|
|
|
-«IF this.exitAction != null && exitAction.caller.size > 0 »
|
|
|
-void «this.exitAction.exitActionFunction()»
|
|
|
+«ENDIF -»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ExitMethodProto FOR ExecutionState -»
|
|
|
+«IF this.exitAction != null && exitAction.caller.size > 0 -»
|
|
|
+static void «this.exitAction.exitActionFunction()»;
|
|
|
+«ENDIF -»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ExitMethodImplement FOR ExecutionState -»
|
|
|
+«IF this.exitAction != null && exitAction.caller.size > 0 »
|
|
|
+void «this.exitAction.exitActionFunction()»
|
|
|
{
|
|
|
-«EXPAND ActionCode FOR this.exitAction»
|
|
|
+«EXPAND ActionCode FOR this.exitAction»
|
|
|
}
|
|
|
-«ENDIF -»
|
|
|
-«ENDDEFINE»
|
|
|
+«ENDIF -»
|
|
|
+«ENDDEFINE»
|
|
|
|
|
|
|
|
|
|
|
|
-«DEFINE EnterSequenceProto FOR ExecutionScope -»
|
|
|
-«IF this.enterSequence != null && enterSequence.caller.size > 0 -»
|
|
|
-static void «this.enterSequence.enterSequenceFunction()»;
|
|
|
-«ENDIF -»
|
|
|
-«ENDDEFINE»
|
|
|
+«DEFINE EnterSequenceProto FOR ExecutionScope -»
|
|
|
+«IF this.enterSequence != null && enterSequence.caller.size > 0 -»
|
|
|
+static void «this.enterSequence.enterSequenceFunction()»;
|
|
|
+«ENDIF -»
|
|
|
+«ENDDEFINE»
|
|
|
|
|
|
-«DEFINE EnterSequenceImplement FOR ExecutionScope -»
|
|
|
-«IF this.enterSequence != null && enterSequence .caller.size > 0 »
|
|
|
-void «this.enterSequence.enterSequenceFunction()»
|
|
|
+«DEFINE EnterSequenceImplement FOR ExecutionScope -»
|
|
|
+«IF this.enterSequence != null && enterSequence .caller.size > 0 »
|
|
|
+void «this.enterSequence.enterSequenceFunction()»
|
|
|
{
|
|
|
-«EXPAND ActionCode FOR this.enterSequence»
|
|
|
+«EXPAND ActionCode FOR this.enterSequence»
|
|
|
}
|
|
|
-«ENDIF -»
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE ExitSequenceProto FOR ExecutionScope -»
|
|
|
-«IF this.exitSequence != null && exitSequence.caller.size > 0 -»
|
|
|
-static void «this.exitSequence.exitSequenceFunction()»;
|
|
|
-«ENDIF -»
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE ExitSequenceImplement FOR ExecutionScope -»
|
|
|
-«IF this.exitSequence != null && exitSequence.caller.size > 0 -»
|
|
|
-void «this.exitSequence.exitSequenceFunction()»
|
|
|
+«ENDIF -»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ExitSequenceProto FOR ExecutionScope -»
|
|
|
+«IF this.exitSequence != null && exitSequence.caller.size > 0 -»
|
|
|
+static void «this.exitSequence.exitSequenceFunction()»;
|
|
|
+«ENDIF -»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ExitSequenceImplement FOR ExecutionScope -»
|
|
|
+«IF this.exitSequence != null && exitSequence.caller.size > 0 -»
|
|
|
+void «this.exitSequence.exitSequenceFunction()»
|
|
|
{
|
|
|
-«EXPAND ActionCode FOR exitSequence»
|
|
|
+«EXPAND ActionCode FOR exitSequence»
|
|
|
}
|
|
|
-«ENDIF -»
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE ShallowEnterSequenceProto FOR ExecutionRegion -»
|
|
|
-«IF shallowEnterSequence != null && shallowEnterSequence.caller.size > 0 -»
|
|
|
-static void «shallowEnterSequence.shallowEnterFunction()»;
|
|
|
-«ENDIF -»
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE ShallowEnterSequenceImplement FOR ExecutionRegion -»
|
|
|
-«IF shallowEnterSequence != null && shallowEnterSequence.caller.size > 0 -»
|
|
|
-void «shallowEnterSequence.shallowEnterFunction()»
|
|
|
+«ENDIF -»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ShallowEnterSequenceProto FOR ExecutionRegion -»
|
|
|
+«IF shallowEnterSequence != null && shallowEnterSequence.caller.size > 0 -»
|
|
|
+static void «shallowEnterSequence.shallowEnterFunction()»;
|
|
|
+«ENDIF -»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE ShallowEnterSequenceImplement FOR ExecutionRegion -»
|
|
|
+«IF shallowEnterSequence != null && shallowEnterSequence.caller.size > 0 -»
|
|
|
+void «shallowEnterSequence.shallowEnterFunction()»
|
|
|
{
|
|
|
-«EXPAND ActionCode FOR shallowEnterSequence»
|
|
|
+«EXPAND ActionCode FOR shallowEnterSequence»
|
|
|
}
|
|
|
-«ENDIF -»
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE DeepEnterSequenceProto FOR ExecutionRegion -»
|
|
|
-«IF deepEnterSequence != null && deepEnterSequence.caller.size > 0 -»
|
|
|
-static void «deepEnterSequence.deepEnterFunction()»;
|
|
|
-«ENDIF -»
|
|
|
-«ENDDEFINE»
|
|
|
-
|
|
|
-«DEFINE DeepEnterSequenceImplement FOR ExecutionRegion -»
|
|
|
-«IF deepEnterSequence != null && deepEnterSequence.caller.size > 0 -»
|
|
|
-void «deepEnterSequence.deepEnterFunction()»
|
|
|
+«ENDIF -»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE DeepEnterSequenceProto FOR ExecutionRegion -»
|
|
|
+«IF deepEnterSequence != null && deepEnterSequence.caller.size > 0 -»
|
|
|
+static void «deepEnterSequence.deepEnterFunction()»;
|
|
|
+«ENDIF -»
|
|
|
+«ENDDEFINE»
|
|
|
+
|
|
|
+«DEFINE DeepEnterSequenceImplement FOR ExecutionRegion -»
|
|
|
+«IF deepEnterSequence != null && deepEnterSequence.caller.size > 0 -»
|
|
|
+void «deepEnterSequence.deepEnterFunction()»
|
|
|
{
|
|
|
-«EXPAND ActionCode FOR deepEnterSequence»
|
|
|
+«EXPAND ActionCode FOR deepEnterSequence»
|
|
|
}
|
|
|
-«ENDIF -»
|
|
|
-«ENDDEFINE»
|
|
|
+«ENDIF -»
|
|
|
+«ENDDEFINE»
|
|
|
|
|
|
|
|
|
-«DEFINE file FOR ExecutionFlow»
|
|
|
-«FILE StName()+'.c'»
|
|
|
-«this.getLicenseHeader()»
|
|
|
+«DEFINE file FOR ExecutionFlow»
|
|
|
+«FILE StName()+'.c'»
|
|
|
+«this.getLicenseHeader()»
|
|
|
|
|
|
-#define «STNAME()»_FRIENDS
|
|
|
+#define «STNAME()»_FRIENDS
|
|
|
|
|
|
-#include "«StName()».h"
|
|
|
+#include "«StName()».h"
|
|
|
#include <stdlib.h>
|
|
|
#include <string.h>
|
|
|
|
|
|
-«IF this.isSingleton() == true»
|
|
|
+«IF this.isSingleton() == true»
|
|
|
/* singleton handle and singleton handle pointer declaration */
|
|
|
-static «StName()» static_«statemachineHandleName()»;
|
|
|
-static «StName()»* «statemachineHandleName()»;
|
|
|
-«ENDIF»
|
|
|
+static «StName()» static_«statemachineHandleName()»;
|
|
|
+static «StName()»* «statemachineHandleName()»;
|
|
|
+«ENDIF»
|
|
|
|
|
|
// function prototypes
|
|
|
|
|
|
-«EXPAND ConditionMethodsProto FOR this -»
|
|
|
-«EXPAND ConditionMethodsProto FOREACH this.states -»
|
|
|
-«EXPAND ConditionMethodsProto FOREACH this.nodes -»
|
|
|
-«EXPAND StatementMethodsProto FOR this -»
|
|
|
-«EXPAND StatementMethodsProto FOREACH this.states -»
|
|
|
-«EXPAND StatementMethodsProto FOREACH this.nodes -»
|
|
|
-«EXPAND EnterMethodProto FOR this -»
|
|
|
-«EXPAND ExitMethodProto FOR this -»
|
|
|
-«EXPAND EnterMethodProto FOREACH this.states -»
|
|
|
-«EXPAND ExitMethodProto FOREACH this.states -»
|
|
|
-«EXPAND EnterSequenceProto FOREACH this.states -»
|
|
|
-«EXPAND ExitSequenceProto FOREACH this.states -»
|
|
|
-«EXPAND EnterSequenceProto FOREACH this.regions -»
|
|
|
-«EXPAND ExitSequenceProto FOREACH this.regions -»
|
|
|
-«EXPAND ShallowEnterSequenceProto FOREACH this.regions -»
|
|
|
-«EXPAND DeepEnterSequenceProto FOREACH this.regions -»
|
|
|
-«EXPAND ReactMethodsProto FOREACH this.states -»
|
|
|
-«EXPAND ReactMethodsProto FOREACH this.nodes -»
|
|
|
+«EXPAND ConditionMethodsProto FOR this -»
|
|
|
+«EXPAND ConditionMethodsProto FOREACH this.states -»
|
|
|
+«EXPAND ConditionMethodsProto FOREACH this.nodes -»
|
|
|
+«EXPAND StatementMethodsProto FOR this -»
|
|
|
+«EXPAND StatementMethodsProto FOREACH this.states -»
|
|
|
+«EXPAND StatementMethodsProto FOREACH this.nodes -»
|
|
|
+«EXPAND EnterMethodProto FOR this -»
|
|
|
+«EXPAND ExitMethodProto FOR this -»
|
|
|
+«EXPAND EnterMethodProto FOREACH this.states -»
|
|
|
+«EXPAND ExitMethodProto FOREACH this.states -»
|
|
|
+«EXPAND EnterSequenceProto FOREACH this.states -»
|
|
|
+«EXPAND ExitSequenceProto FOREACH this.states -»
|
|
|
+«EXPAND EnterSequenceProto FOREACH this.regions -»
|
|
|
+«EXPAND ExitSequenceProto FOREACH this.regions -»
|
|
|
+«EXPAND ShallowEnterSequenceProto FOREACH this.regions -»
|
|
|
+«EXPAND DeepEnterSequenceProto FOREACH this.regions -»
|
|
|
+«EXPAND ReactMethodsProto FOREACH this.states -»
|
|
|
+«EXPAND ReactMethodsProto FOREACH this.nodes -»
|
|
|
|
|
|
|
|
|
// function implementations
|
|
|
|
|
|
-«EXPAND ConditionMethodsImplement FOR this -»
|
|
|
-«EXPAND ConditionMethodsImplement FOREACH this.states -»
|
|
|
-«EXPAND ConditionMethodsImplement FOREACH this.nodes -»
|
|
|
-«EXPAND StatementMethodsImplement FOR this -»
|
|
|
-«EXPAND StatementMethodsImplement FOREACH this.states -»
|
|
|
-«EXPAND StatementMethodsImplement FOREACH this.nodes -»
|
|
|
-«EXPAND EnterMethodImplement FOR this -»
|
|
|
-«EXPAND ExitMethodImplement FOR this -»
|
|
|
-«EXPAND EnterMethodImplement FOREACH this.states -»
|
|
|
-«EXPAND ExitMethodImplement FOREACH this.states -»
|
|
|
-«EXPAND EnterSequenceImplement FOREACH this.states -»
|
|
|
-«EXPAND ExitSequenceImplement FOREACH this.states -»
|
|
|
-«EXPAND EnterSequenceImplement FOREACH this.regions -»
|
|
|
-«EXPAND ExitSequenceImplement FOREACH this.regions -»
|
|
|
-«EXPAND ShallowEnterSequenceImplement FOREACH this.regions -»
|
|
|
-«EXPAND DeepEnterSequenceImplement FOREACH this.regions -»
|
|
|
-«EXPAND ReactMethodsImplement FOREACH this.states -»
|
|
|
-«EXPAND ReactMethodsImplement FOREACH this.nodes -»
|
|
|
-
|
|
|
-void «stName()»_init(«this.handleAdditionComma()» Timer* timer, EventPool* eventPool)
|
|
|
+«EXPAND ConditionMethodsImplement FOR this -»
|
|
|
+«EXPAND ConditionMethodsImplement FOREACH this.states -»
|
|
|
+«EXPAND ConditionMethodsImplement FOREACH this.nodes -»
|
|
|
+«EXPAND StatementMethodsImplement FOR this -»
|
|
|
+«EXPAND StatementMethodsImplement FOREACH this.states -»
|
|
|
+«EXPAND StatementMethodsImplement FOREACH this.nodes -»
|
|
|
+«EXPAND EnterMethodImplement FOR this -»
|
|
|
+«EXPAND ExitMethodImplement FOR this -»
|
|
|
+«EXPAND EnterMethodImplement FOREACH this.states -»
|
|
|
+«EXPAND ExitMethodImplement FOREACH this.states -»
|
|
|
+«EXPAND EnterSequenceImplement FOREACH this.states -»
|
|
|
+«EXPAND ExitSequenceImplement FOREACH this.states -»
|
|
|
+«EXPAND EnterSequenceImplement FOREACH this.regions -»
|
|
|
+«EXPAND ExitSequenceImplement FOREACH this.regions -»
|
|
|
+«EXPAND ShallowEnterSequenceImplement FOREACH this.regions -»
|
|
|
+«EXPAND DeepEnterSequenceImplement FOREACH this.regions -»
|
|
|
+«EXPAND ReactMethodsImplement FOREACH this.states -»
|
|
|
+«EXPAND ReactMethodsImplement FOREACH this.nodes -»
|
|
|
+
|
|
|
+void «stName()»_init(«this.handleAdditionComma()» Timer* timer, EventPool* eventPool)
|
|
|
{
|
|
|
int i;
|
|
|
|
|
|
-«IF this.isSingleton()»
|
|
|
- «statemachineHandleName()» = &static_«statemachineHandleName()»;
|
|
|
-«ENDIF»
|
|
|
- statemachine_cy_init(&«statemachineHandleName()»->base, MAX_PARALLEL_STATES, MAX_HISTORY_STATES,
|
|
|
+«IF this.isSingleton()»
|
|
|
+ «statemachineHandleName()» = &static_«statemachineHandleName()»;
|
|
|
+«ENDIF»
|
|
|
+ statemachine_cy_init(&«statemachineHandleName()»->base, MAX_PARALLEL_STATES, MAX_HISTORY_STATES,
|
|
|
event_last, timer, eventPool);
|
|
|
|
|
|
for (i = 0; i<MAX_PARALLEL_STATES; ++i)
|
|
|
- «statemachineHandleName()»->base.base.state[i] = last_state;
|
|
|
+ «statemachineHandleName()»->base.base.state[i] = last_state;
|
|
|
|
|
|
for (i = 0; i<MAX_HISTORY_STATES; ++i)
|
|
|
- «statemachineHandleName()»->base.base.history[i] = last_state;
|
|
|
-
|
|
|
-«FOREACH this.scopes.getUsableScopes() AS interface -»
|
|
|
-«IF this.isSingleton() -»
|
|
|
- «interface.interfaceName()»_set_interface_singleton(&«statemachineHandleName()»->«interface.interfaceObjectName()»);
|
|
|
- «interface.interfaceName()»_init(&«statemachineHandleName()»->base, &«statemachineHandleName()»->base.eventSet, eventPool);
|
|
|
-«ELSE -»
|
|
|
- «interface.interfaceName()»_init(&«statemachineHandleName()»->«interface.interfaceObjectName().toFirstLower()»,
|
|
|
- &«statemachineHandleName()»->base, &«statemachineHandleName()»->base.eventSet, eventPool);
|
|
|
-«ENDIF»
|
|
|
-
|
|
|
-«FOREACH interface.getInEvents() AS event -»
|
|
|
- eventSet_set_type(&«statemachineHandleName()»->base.eventSet, «event.getEventEnumName()», ev_type_input);
|
|
|
-«ENDFOREACH -»
|
|
|
-«FOREACH interface.getOutEvents() AS event -»
|
|
|
- eventSet_set_type(&«statemachineHandleName()»->base.eventSet, «event.getEventEnumName()», ev_type_output);
|
|
|
-«ENDFOREACH -»
|
|
|
-«FOREACH interface.getLocalEvents() AS event -»
|
|
|
- eventSet_set_type(&«statemachineHandleName()»->base.eventSet, «event.getEventEnumName()», ev_type_local);
|
|
|
-«ENDFOREACH -»
|
|
|
-«ENDFOREACH»
|
|
|
+ «statemachineHandleName()»->base.base.history[i] = last_state;
|
|
|
+
|
|
|
+«FOREACH this.scopes.getUsableScopes() AS interface -»
|
|
|
+«IF this.isSingleton() -»
|
|
|
+ «interface.interfaceName()»_set_interface_singleton(&«statemachineHandleName()»->«interface.interfaceObjectName()»);
|
|
|
+ «interface.interfaceName()»_init(&«statemachineHandleName()»->base, &«statemachineHandleName()»->base.eventSet, eventPool);
|
|
|
+«ELSE -»
|
|
|
+ «interface.interfaceName()»_init(&«statemachineHandleName()»->«interface.interfaceObjectName().toFirstLower()»,
|
|
|
+ &«statemachineHandleName()»->base, &«statemachineHandleName()»->base.eventSet, eventPool);
|
|
|
+«ENDIF»
|
|
|
+
|
|
|
+«FOREACH interface.getInEvents() AS event -»
|
|
|
+ eventSet_set_type(&«statemachineHandleName()»->base.eventSet, «event.getEventEnumName()», ev_type_input);
|
|
|
+«ENDFOREACH -»
|
|
|
+«FOREACH interface.getOutEvents() AS event -»
|
|
|
+ eventSet_set_type(&«statemachineHandleName()»->base.eventSet, «event.getEventEnumName()», ev_type_output);
|
|
|
+«ENDFOREACH -»
|
|
|
+«FOREACH interface.getLocalEvents() AS event -»
|
|
|
+ eventSet_set_type(&«statemachineHandleName()»->base.eventSet, «event.getEventEnumName()», ev_type_local);
|
|
|
+«ENDFOREACH -»
|
|
|
+«ENDFOREACH»
|
|
|
}
|
|
|
|
|
|
-«IF this.isSingleton() == true»
|
|
|
-«StName()»* «scName()»_get_handle()
|
|
|
-{ return «statemachineHandleName()»; }
|
|
|
-«ENDIF»
|
|
|
-«FOREACH this.scopes.typeSelect(InterfaceScope) AS interface»
|
|
|
-extern «interface.interfaceClassName()»* «stName()»_get_«interface.interfaceObjectName()»(«handleAddition()»)
|
|
|
-{ return &«statemachineHandleName()»->«interface.interfaceObjectName()»; }
|
|
|
-«ENDFOREACH»
|
|
|
+«IF this.isSingleton() == true»
|
|
|
+«StName()»* «scName()»_get_handle()
|
|
|
+{ return «statemachineHandleName()»; }
|
|
|
+«ENDIF»
|
|
|
+«FOREACH this.scopes.typeSelect(InterfaceScope) AS interface»
|
|
|
+extern «interface.interfaceClassName()»* «stName()»_get_«interface.interfaceObjectName()»(«handleAddition()»)
|
|
|
+{ return &«statemachineHandleName()»->«interface.interfaceObjectName()»; }
|
|
|
+«ENDFOREACH»
|
|
|
|
|
|
-void «stName()»_enter(«handleAddition()»)
|
|
|
+void «stName()»_enter(«handleAddition()»)
|
|
|
{
|
|
|
- «EXPAND ActionCode FOR this.enterSequence»
|
|
|
+ «EXPAND ActionCode FOR this.enterSequence»
|
|
|
}
|
|
|
|
|
|
-void «stName()»_exit(«handleAddition()»)
|
|
|
+void «stName()»_exit(«handleAddition()»)
|
|
|
{
|
|
|
- «EXPAND ActionCode FOR this.exitSequence»
|
|
|
+ «EXPAND ActionCode FOR this.exitSequence»
|
|
|
}
|
|
|
|
|
|
-void «stName()»_destruct(«handleAddition()»)
|
|
|
+void «stName()»_destruct(«handleAddition()»)
|
|
|
{
|
|
|
- statemachine_cy_destruct(&«statemachineHandleName()»->base);
|
|
|
+ statemachine_cy_destruct(&«statemachineHandleName()»->base);
|
|
|
}
|
|
|
|
|
|
-void «stName()»_runCycle(«handleAddition()»)
|
|
|
+void «stName()»_runCycle(«handleAddition()»)
|
|
|
{
|
|
|
- statemachine_cy_runCycle(&«statemachineHandleName()»->base);
|
|
|
+ statemachine_cy_runCycle(&«statemachineHandleName()»->base);
|
|
|
}
|
|
|
|
|
|
-void «stName()»_setEvent(«handleAdditionComma()» _Event* ev)
|
|
|
+void «stName()»_setEvent(«handleAdditionComma()» _Event* ev)
|
|
|
{
|
|
|
- statemachine_cy_setEvent(&«statemachineHandleName()»->base, ev);
|
|
|
+ statemachine_cy_setEvent(&«statemachineHandleName()»->base, ev);
|
|
|
}
|
|
|
|
|
|
-sc_boolean «stName()»_eventWaiting(«handleAddition()»)
|
|
|
+sc_boolean «stName()»_eventWaiting(«handleAddition()»)
|
|
|
{
|
|
|
- return statemachine_cy_eventWaiting(&«statemachineHandleName()»->base);
|
|
|
+ return statemachine_cy_eventWaiting(&«statemachineHandleName()»->base);
|
|
|
}
|
|
|
|
|
|
void statemachine_cy__runCycle(Statemachine_cy* handle)
|
|
@@ -452,17 +452,17 @@ void statemachine_cy__runCycle(Statemachine_cy* handle)
|
|
|
handle->parallelPosition<MAX_PARALLEL_STATES;
|
|
|
++handle->parallelPosition) {
|
|
|
switch(((StatemachineBase*)handle)->state[handle->parallelPosition]) {
|
|
|
- «FOREACH this.states AS state»
|
|
|
- case _«state.getStateName()»:
|
|
|
- «state.reactFunctionName()»(«IF isSingleton() == false»(«StName()»*) handle«ENDIF»);
|
|
|
+ «FOREACH this.states AS state»
|
|
|
+ case _«state.getStateName()»:
|
|
|
+ «state.reactFunctionName()»(«IF isSingleton() == false»(«StName()»*) handle«ENDIF»);
|
|
|
break;
|
|
|
- «ENDFOREACH»
|
|
|
+ «ENDFOREACH»
|
|
|
default:
|
|
|
/* no state found */
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-«ENDFILE»
|
|
|
+«ENDFILE»
|
|
|
|
|
|
-«ENDDEFINE»
|
|
|
+«ENDDEFINE»
|