瀏覽代碼

Added handling for parallel states

jos.itemis@gmail.com 13 年之前
父節點
當前提交
ba403900a6

+ 1 - 1
plugins/org.yakindu.sct.generator.c/.settings/org.eclipse.core.resources.prefs

@@ -1,4 +1,4 @@
-#Wed Dec 14 17:02:06 CET 2011
+#Mon Jan 02 09:28:08 CET 2012
 eclipse.preferences.version=1
 encoding//.settings/org.eclipse.xtend.shared.ui.prefs=Cp1252
 encoding/<project>=Cp1252

+ 15 - 6
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/CustomStatemachineC.xpt

@@ -80,7 +80,7 @@ Templates for the main statechart c file.
   «REM»
   «this.check.functionName()»(handle) «
   «ENDREM»
-  ELSE -»
+  «ELSE -»
  «getBoolTrue()» «
   ENDIF -»«
 ENDDEFINE»
@@ -100,12 +100,15 @@ else {
 «ENDIF»
 «ENDDEFINE»
 
+
 «DEFINE ActionCode FOR EnterState»
-((StatemachineBase*)«statemachineHandleName()»)->state[0] = _«this.state.simpleName»;
+((StatemachineBase*)«statemachineHandleName()»)->state[«this.state.stateVector.offset»] = _«this.state.simpleName»;
+((Statemachine_cy*)«statemachineHandleName()»)->parallelPosition = «this.state.stateVector.offset»;
 «ENDDEFINE»
 
 «DEFINE ActionCode FOR ExitState»
-((StatemachineBase*)«statemachineHandleName()»)->state[0] = last_state;
+((StatemachineBase*)«statemachineHandleName()»)->state[«this.state.stateVector.offset»] = last_state;
+((Statemachine_cy*)«statemachineHandleName()»)->parallelPosition = «this.state.stateVector.offset»;
 «ENDDEFINE»
 
 «DEFINE ConditionMethodsProto(sgen::GeneratorEntry genEntry) FOR ExecutionNode -»
@@ -267,11 +270,16 @@ static 
 
 void «stName()»_init(«handleAdditionComma(genEntry)» Timer* timer, EventPool* eventPool)
 {
+	int i;
+	
 «IF isSingleton(genEntry)»
 	«statemachineHandleName()» = &static_«statemachineHandleName()»;
 «ENDIF»
 	statemachine_cy_init(&«statemachineHandleName()»->base, MAX_PARALLEL_STATES,
 			event_last, timer, eventPool);
+
+	for (i = 0; i<MAX_PARALLEL_STATES; ++i)
+		«statemachineHandleName()»->base.base.state[i] = last_state;
 			
 «FOREACH this.scopes.getUsableScopes() AS interface -»
 «IF isSingleton(genEntry) -»
@@ -337,9 +345,10 @@ boolean 
 
 void statemachine_cy__runCycle(Statemachine_cy* handle)
 {
-	uint32_t i;
-	for (i=0; i<MAX_PARALLEL_STATES; ++i) {
-		switch(((StatemachineBase*)handle)->state[i]) {
+	for (handle->parallelPosition=0; 
+	     handle->parallelPosition<MAX_PARALLEL_STATES; 
+	     ++handle->parallelPosition) {
+		switch(((StatemachineBase*)handle)->state[handle->parallelPosition]) {
 	«FOREACH this.states AS state»
 	    case _«state.simpleName»:
 	    	«this.stName()»_reaction_«state.simpleName»(«IF isSingleton(genEntry) == false»(«StName()»*) handle«ENDIF»);

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

@@ -37,6 +37,7 @@ void statemachine_cy_init(Statemachine_cy* handle, uint16_t maxStates,
 
 	/* eventPool must be initialized at this point */
 	handle->eventPool = eventPool;
+	handle->parallelPosition = 0;
 
 }
 

+ 3 - 2
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/Statemachine_cyH.xpt

@@ -26,9 +26,10 @@ Templates for the main statechart c file.
 
 typedef struct {
   StatemachineBase base;
-  EventSet eventSet;
-  _Event** eventList;
+  EventSet   eventSet;
+  _Event**   eventList;
   EventPool* eventPool;
+  uint32_t   parallelPosition; 
 } Statemachine_cy ;
 
 extern void statemachine_cy_init(Statemachine_cy* handle, uint16_t maxStates,