Просмотр исходного кода

Update for state chart reactions in codegen C and Java

benjamin.schwertfeger@gmail.com 14 лет назад
Родитель
Сommit
7f3a6fa0ba

+ 9 - 8
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/CustomStatemachineC.xpt

@@ -95,12 +95,9 @@ if (
   ENDDEFINE»
 
 «DEFINE ActionCode FOR CheckRef -»
-  «IF this.check != null -» 
- #error Action Code for CheckRef missing
-  «REM»
-  «this.check.functionName()»(handle) «
-  «ENDREM»
-  «ELSE -»
+  «IF this.check != null -»
+  «getComment()-»
+  «this.check.functionName()»(«statemachineHandleName()») «ELSE -»
  «getBoolTrue()» «
   ENDIF -»«
 ENDDEFINE»
@@ -154,13 +151,13 @@ sc_boolean 
 
 «DEFINE StatementMethodsProto FOR ExecutionNode -»
   «FOREACH reactions.select(e|e.effect.caller.size > 0) AS r -»
-static void «r.reactFunction()»;
+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.reactFunction()»
+void «r.effect.functionName()»(«handleAddition()»)
 {   
   «EXPAND ActionCode FOR r.effect -»
 }
@@ -294,8 +291,10 @@ static 
 static «StName()»* «statemachineHandleName()»;
 «ENDIF»
 
+«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 FOREACH this.states -»
@@ -309,8 +308,10 @@ static 
 «EXPAND ReactMethodsProto FOREACH this.states -»
 «EXPAND ReactMethodsProto FOREACH this.nodes -»
 
+«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 FOREACH this.states -»

+ 8 - 8
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/Naming.ext

@@ -1,8 +1,8 @@
 import ecore;
 import base;
-import sgraph;
 import stext;
 import sexec;
+import sgraph;
 import sgen; 
 
 
@@ -60,13 +60,13 @@ cached String functionName(Step step) :
 	(step.isReactSequence()) ? step.reactSequenceFunctionName() : (
 	(step.isShallowEnterSequence()) ? step.shallowEnterSequenceFunctionName() : (
 	(step.isDeepEnterSequence()) ? step.deepEnterSequenceFunctionName() : (
-	" !! unknown function type !!" )))))))));
+	" !! unknown function type "+step+" in "+step.eContainer.toString()+" !!" )))))))));
 
 
 ExecutionState state(Step this) : (ExecutionState) this.eContainer;
 ExecutionScope scope(Step this) : (ExecutionScope) this.eContainer;
 
-boolean isEffect(Step step) : Reaction.isInstance(step.eContainer) ;
+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;
@@ -127,6 +127,9 @@ String reactFunctionName(sexec::Reaction this) :
 
 String reactFunctionName(ExecutionNode this) :  
 	  this.stName() + "_react_" + this.getStateName();
+
+String reactFunctionName(ExecutionFlow this) :  
+	  this.stName() + "_react_" + this.getStateName();
  
 
 
@@ -156,10 +159,6 @@ String shallowEnterFunction(Step this) :
 String deepEnterFunction(Step this) :  
 	  this.deepEnterSequenceFunctionName() + "("+ handleAddition() + ")";
 
-/* for some reason, this is handled completely different */ 
-String reactFunction(sexec::Reaction this) :  
-	  this.reactFunctionName() + "("+ handleAddition() + ")";
-
 String reactFunction(ExecutionNode this) :  
 	  this.reactFunctionName() + "("+ handleAddition() + ")";
 
@@ -169,6 +168,7 @@ String getStateName(Step this) : this.eContainer.getStateName();
 String getStateName(emf::EObject this) : (this.eContainer != null)?this.eContainer.getStateName():"unkown";
 String getStateName(ExecutionEntry this) : this.getStateFqn();
 String getStateName(ExecutionState this) : this.getStateFqn();
+String getStateName(ExecutionFlow this) : this.name;
 String getStateName(ExecutionRegion this) : 
 	if (ExecutionState.isInstance(superScope)) 
 	then (
@@ -226,7 +226,7 @@ String getEventEnumName(types::Feature this) : "/* EventEnum requested, but got
 String getEventEnumName(Expression this) : "/* EventEnum requested, but got Expression: "+this+" */";
 
 String getEventName(Event this) : this.eContainer.getScopeName().toFirstUpper() + this.getNameWA().toFirstUpper();
-String getEventName(EventDefinition this) : name.toFirstUpper();
+String getEventName(EventDefinition this) : this.eContainer.getScopeName().toFirstUpper() + "_" +name.toFirstUpper();
 String getEventName(FeatureCall this) : feature.getEventName();
 String getEventName(base::NamedElement this) : "/* Event expected, but got NamedElement: "+this+" */";
 String getEventName(TypedElementReferenceExpression this) : reference.getEventName();

+ 2 - 0
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/templates/CustomCycleBasedStatemachine.xpt

@@ -519,8 +519,10 @@ public class 
 	«ENDIF»
 	
 
+«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 FOREACH this.states-»

+ 4 - 1
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/templates/Expression.ext

@@ -74,7 +74,10 @@ String toCode(BoolLiteral expression) :
 	
 String toCode(IntLiteral expression) :
 	expression.value.toString();
-	
+
+String toCode(HexLiteral expression) :
+	expression.value.toString();
+
 String toCode(RealLiteral expression) :
 	expression.value.toString();