Bläddra i källkod

Added some changes to handle hiearchical states - unfinished

jos.itemis@gmail.com 13 år sedan
förälder
incheckning
3bd74fd2ff

+ 37 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/CustomStatemachineC.xpt

@@ -20,6 +20,21 @@ Templates for the main statechart c file.
 // ActionCode for Step not defined
 «ENDDEFINE»
 
+«DEFINE ActionCode FOR StateSwitch»
+// ActionCode for StateSwitch
+// «this.comment»
+	switch(((StatemachineBase*)handle)->state[0/* TODO: must be set correctly */]) {
+«FOREACH this.cases AS caseid»
+  case _«caseid.state.simpleName» : {
+  «EXPAND ActionCode FOR caseid.step»
+  break;
+  }
+«ENDFOREACH»
+  default:
+    break;
+	}
+«ENDDEFINE»
+
 «DEFINE ActionCode FOR Execution»
 	«this.statement.toCCode()»
 «ENDDEFINE»
@@ -56,9 +71,11 @@ ENDDEFINE
 if («EXPAND ActionCode FOR this.check») { 
   «EXPAND ActionCode FOR this.thenStep»
 }
+«IF (this.elseStep != null)»
 else {
   «EXPAND ActionCode FOR this.elseStep»
 }
+«ENDIF»
 «ENDDEFINE»
 
 «DEFINE ActionCode FOR EnterState»
@@ -203,6 +220,26 @@ void 
 «EXPAND EnterSequenceImplement FOREACH this.states»
 «EXPAND ExitSequenceImplement FOREACH this.states»
 
+«REM»
+boolean «stName()»_is_in(«StName()»* handle, States state)
+{
+	switch (((StatemachineBase*)handle)->state[0 /* TODO: change to correct parallel region (may need a for loop */]) {
+	«FOREACH this.states AS state»
+	    case _«state.simpleName»:
+			«IF state.leaf == true»
+			  return bool_true;
+			«ELSE»
+			  if ( bool_true == bool_true )
+			    return bool_true;
+			«ENDIF»  
+	        break;
+	«ENDFOREACH»
+	    default:
+	        break;
+	}
+	return bool_false;
+}
+«ENDREM»
 void «stName()»_init(«StName()»* handle, Timer* timer, EventPool* eventPool)
 {
 	statemachine_cy_init(&handle->base, MAX_PARALLEL_STATES,

+ 17 - 1
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/Expression.ext

@@ -84,7 +84,23 @@ String toCCode(ElementReferenceExpression ref) :
 	ref.value.toCCode();
 
 String toCCode(Declaration dec) :
-	"declartion type not specified";
+	"Declartion type not specified";
+
+String toCCode(Clock clockDef) :
+	"Clock to C not defined";
+	
+String toCCode(Operation op) :
+	"Operation to C not defined";
+
+String toCCode(LocalReaction localReac) :
+	"Local Reaction to C not defined";
+
+String toCCode(Entrypoint op) :
+	"Entrypoint to C not defined";
+
+String toCCode(Exitpoint op) :
+	"Exitpoint to C not defined";
+
 	
 String toCCode(EventDefinition evDef) :
     " ( eventSet_check( &handle->base.eventSet, ev_" + evDef.name.toLowerCase() + ") ) ";

+ 1 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/Interfaces.xpt

@@ -107,6 +107,7 @@ void 
 	
 «FOREACH interface.declarations.typeSelect(VariableDefinition) AS variable -»
 «IF variable.initialValue != null»
+«REM»change to correctLValue«ENDREM»
 	handle->«variable.name» = «variable.initialValue.correctLValue()»;
 «ENDIF»
 «ENDFOREACH»