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

OPEN - issue YAKHMI-895: Create new SCT C++ Code generator
https://intern.itemis.de/jira/browse/YAKHMI-895

markus.muehlbrandt@gmail.com 12 лет назад
Родитель
Сommit
cd45ff07d6

+ 4 - 0
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/Naming.xtend

@@ -94,4 +94,8 @@ class Naming extends org.yakindu.sct.generator.c.Naming {
 	override functionName(EObject it, List<String> segments) {
 		segments.fold("", [s, seg | s + if (seg.empty) "" else "_" + seg]).asIdentifier
 	}
+	
+	override nameOfIsActiveFunction(ExecutionFlow it) {
+		"isActive"
+	}
 }

+ 31 - 8
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/StatemachineHeader.xtend

@@ -64,9 +64,7 @@ class StatemachineHeader extends Statemachine {
 				
 				«FOR s : it.scopes»«s.createScope(entry)»«ENDFOR»
 				
-				«FOR s : it.scopes.filter( typeof(InternalScope) )»
-					«s.scopeFunctionPrototypes»
-				«ENDFOR»
+				«publicFunctionPrototypes»
 				
 				/*! Checks if the specified state is active. */
 				sc_boolean «nameOfIsActiveFunction»(«statesEnumType» state);
@@ -108,12 +106,11 @@ class StatemachineHeader extends Statemachine {
 		«scope.createOperationCallbackInterface»
 		
 		«scope.interfaceName»* get«scope.interfaceName»();
-		
 	'''
 	
 	def private createInterface(InterfaceScope scope, GeneratorEntry entry)
 	'''
-		//! Inner class for statechart «scope.interfaceName» interface scope.
+		//! Inner class for «scope.interfaceName» interface scope.
 		class «scope.interfaceName» {
 			
 			public:
@@ -137,7 +134,7 @@ class StatemachineHeader extends Statemachine {
 				«ENDFOR»
 			}
 			
-			virtual void set«internalOperationCallbackName»(«internalOperationCallbackName»* operationCallback) = 0;
+			void set«internalOperationCallbackName»(«internalOperationCallbackName»* operationCallback);
 		«ENDIF»
 		'''
 	}
@@ -171,10 +168,10 @@ class StatemachineHeader extends Statemachine {
 
 	override statemachineTypeDecl(ExecutionFlow it) '''
 		//! the maximum number of orthogonal states defines the dimension of the state configuration vector.
-		const sc_integer «orthogonalStatesConst» = «stateVector.size»
+		const sc_integer «orthogonalStatesConst» = «stateVector.size»;
 		«IF hasHistory»
 		//! dimension of the state configuration vector for history states
-		const sc_integer «historyStatesConst» = «historyVector.size»«ENDIF»
+		const sc_integer «historyStatesConst» = «historyVector.size»;«ENDIF»
 		
 		«IF timed»sc_boolean timeEvents[«timeEvents.size»];«ENDIF»
 		«statesEnumType» stateConfVector[«orthogonalStatesConst»];
@@ -182,6 +179,32 @@ class StatemachineHeader extends Statemachine {
 		sc_ushort stateConfVectorPosition;
 	'''
 
+	def publicFunctionPrototypes(ExecutionFlow it) '''
+		«IStatemachineFunctions»
+		
+		«IF timed»
+			«ITimedStatemachineFunctions»
+		«ENDIF»
+	'''
+	
+	def IStatemachineFunctions() '''
+		void init();
+		
+		void enter();
+		
+		void exit();
+		
+		void runCycle();
+	'''
+	
+	def ITimedStatemachineFunctions() '''
+		void setTimerService(ITimerService* timerService);
+		
+		ITimerService* getTimerService();
+		
+		void raiseTimeEvent(sc_eventid event);
+	'''
+	
 	override dispatch functionPrototypes(EventDefinition it) '''
 		«IF direction == Direction::IN»
 		/*! Raises the in event '«name»' that is defined in the «scope.scopeDescription». */ 

+ 8 - 8
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/StatemachineImplementation.xtend

@@ -66,22 +66,22 @@ class StatemachineImplementation {
 	
 	
 	def initFunction(ExecutionFlow it) '''
-		void «type.toFirstLower»_init(«scHandleDecl»)
+		void init()
 		{
 			int i;
 
-			for (i = 0; i < «type.toUpperCase»_MAX_ORTHOGONAL_STATES; ++i)
-				«scHandle»->stateConfVector[i] = «last_state»;
+			for (i = 0; i < «orthogonalStatesConst»; ++i)
+				stateConfVector[i] = «last_state»;
 			
 			«IF hasHistory»
-			for (i = 0; i < «type.toUpperCase»_MAX_HISTORY_STATES; ++i)
-				«scHandle»->historyVector[i] = «last_state»;
+			for (i = 0; i < «historyStatesConst»; ++i)
+				historyVector[i] = «last_state»;
 			«ENDIF»
 			
-			«scHandle»->stateConfVectorPosition = 0;
+			stateConfVectorPosition = 0;
 		
-		clearInEvents(handle);
-		clearOutEvents(handle);
+			clearInEvents();
+			clearOutEvents();
 		
 			// TODO: initialize all events ...
 

BIN
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/.Naming.java._trace


BIN
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/.StatemachineHeader.java._trace