Browse Source

Extended templates to support different entry points.

markus.muehlbrandt@itemis.de 13 years ago
parent
commit
5c21437778

+ 16 - 3
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/templates/CustomAbstractBaseStatemachine.xpt

@@ -20,7 +20,11 @@ Contributors:
 «EXTENSION org::yakindu::sct::generator::java::templates::Naming»
 
 «DEFINE ActionCode FOR Step-»
-// ActionCode for Step not defined
+// ActionCode for Step «toString()» not defined
+«ENDDEFINE»
+
+«DEFINE EntryCode FOR Step-»
+// EntryCode for Step «toString()» not defined
 «ENDDEFINE»
 
 «DEFINE ActionCode FOR ScheduleTimeEvent-»
@@ -116,7 +120,7 @@ else {
 
 «DEFINE EnterMethodImplement FOR ExecutionState-»
 	«IF this.entryAction != null-»
-	private void «this.entryAction.entryActionFunctionName()»() {
+	private void «entryAction.entryActionFunctionName()»() {
 		«EXPAND ActionCode FOR this.entryAction-»
 	}
 	«ENDIF-»
@@ -130,6 +134,13 @@ else {
 «ENDIF-»
 «ENDDEFINE»
 
+«DEFINE EntryCode FOR EnterState-»
+	public void «statemachineEntryFunctionName()» {
+		«EXPAND ActionCode FOR this-»
+		«state.entryAction.entryActionFunctionName()»();
+	}
+«ENDDEFINE»
+
 «DEFINE file FOR ExecutionFlow-»
 «FILE getAbstractStatemachineName()+'.java'-»
 «getLicenseHeader()»
@@ -178,13 +189,15 @@ public abstract class 
 	protected abstract «interface.getAbstractInterfaceName()» get«interface.getAbstractInterfaceName()»();
 	«ENDFOREACH-»
 		
+	«EXPAND EntryCode FOREACH enterSequence.steps-»
+	
 	protected boolean eventOccured() {
 		return !getOccuredEvents().isEmpty();
 	}
 	
 	@Override
 	public void init() {
-		«EXPAND ActionCode FOREACH enterSequence.steps»
+		
 	}
 	
 	@Override

+ 15 - 9
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/templates/Naming.ext

@@ -114,15 +114,21 @@ cached String functionName(Step step) :
 	(step.isExitAction()) ? step.exitActionFunctionName() : 
 	" !! unknown function type !!" )));
  
-String actionFunctionName(Step this) : "actions" + getName(reaction().state()) + this.reaction().name.toFirstUpper(); 
-String checkFunctionName(Step this) : "condition" + getName(reaction().state()) + this.reaction().name.toFirstUpper(); 
-String entryActionFunctionName(Step this) : "entryActions" + getName(state()); 
-String exitActionFunctionName(Step this) : "exitActions" + getName(state()); 
-
-boolean isEffect(Step step) : (! Check.isInstance(step)) && Reaction.isInstance(step.eContainer) ;
-boolean isReactionCheck(Step step) : Reaction.isInstance(step.eContainer) && Check.isInstance(step);
-boolean isEntryAction(Step step) : ExecutionState.isInstance(step.eContainer) && step.state().entryAction == step;
-boolean isExitAction(Step step) : ExecutionState.isInstance(step.eContainer) && step.state().exitAction == step;
+statemachineEntryFunctionName(EnterState this):
+	if (this.name != null) then
+		"entry"+name.toFirstUpper().replaceAll(" ","")+"()"
+	else
+		"entry()";
+
+actionFunctionName(Step this) : "actions" + getName(reaction().state()) + this.reaction().name.toFirstUpper(); 
+checkFunctionName(Step this) : "condition" + getName(reaction().state()) + this.reaction().name.toFirstUpper(); 
+entryActionFunctionName(Step this) : "entryActions" + getName(state()); 
+exitActionFunctionName(Step this) : "exitActions" + getName(state()); 
+
+isEffect(Step step) : (! Check.isInstance(step)) && Reaction.isInstance(step.eContainer) ;
+isReactionCheck(Step step) : Reaction.isInstance(step.eContainer) && Check.isInstance(step);
+isEntryAction(Step step) : ExecutionState.isInstance(step.eContainer) && step.state().entryAction == step;
+isExitAction(Step step) : ExecutionState.isInstance(step.eContainer) && step.state().exitAction == step;
 
 Reaction reaction(Step this) : (Reaction) this.eContainer ;
 ExecutionState state(Reaction this) : (ExecutionState) eContainer;