Преглед изворни кода

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

markus.muehlbrandt@gmail.com пре 12 година
родитељ
комит
16df7a538e

+ 7 - 5
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/StatemachineHeader.xtend

@@ -57,6 +57,8 @@ class StatemachineHeader extends Statemachine {
 			
 			public:
 			
+				«statesEnumDecl»
+				
 				«FOR s : it.scopes»«s.createScope(entry)»«ENDFOR»
 				
 				«FOR s : it.scopes.filter( typeof(InternalScope) )»
@@ -64,13 +66,12 @@ class StatemachineHeader extends Statemachine {
 				«ENDFOR»
 				
 				/*! Checks if the specified state is active. */
-				virtual sc_boolean «nameOfIsActiveFunction»(«statesEnumType» state) = 0;
+				sc_boolean «nameOfIsActiveFunction»(«statesEnumType» state);
 			
 			private:
-				«statesEnumDecl»
-				
+			
 				«statemachineTypeDecl»
-		}
+		};
 		
 		#endif /* «module.define»_H_ */
 	'''
@@ -170,9 +171,10 @@ class StatemachineHeader extends Statemachine {
 		//! dimension of the state configuration vector for history states
 		#define «type.toUpperCase»_MAX_HISTORY_STATES «historyVector.size»«ENDIF»
 		
+		«IF timed»sc_boolean timeEvents[«timeEvents.size»];«ENDIF»
 		«statesEnumType» stateConfVector[«type.toUpperCase»_MAX_ORTHOGONAL_STATES];
 		«IF hasHistory»«statesEnumType» historyVector[«type.toUpperCase»_MAX_HISTORY_STATES];«ENDIF»
-		sc_ushort stateConfVectorPosition; 
+		sc_ushort stateConfVectorPosition;
 	'''
 
 	override dispatch functionPrototypes(EventDefinition it) '''

+ 1 - 0
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/Types.xtend

@@ -38,6 +38,7 @@ class Types {
 		typedef int				sc_integer;  
 		typedef double			sc_real;
 		typedef string			sc_string;
+		typedef bool			sc_boolean;
 		
 		typedef void*			sc_eventid;
 		

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


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


+ 24 - 9
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/StatemachineHeader.java

@@ -4,6 +4,7 @@ import com.google.common.base.Objects;
 import com.google.common.collect.Iterables;
 import com.google.inject.Inject;
 import java.util.Arrays;
+import java.util.LinkedList;
 import org.eclipse.emf.common.util.EList;
 import org.eclipse.xtend2.lib.StringConcatenation;
 import org.eclipse.xtext.generator.IFileSystemAccess;
@@ -16,6 +17,7 @@ import org.yakindu.sct.generator.cpp.Naming;
 import org.yakindu.sct.generator.cpp.Navigation;
 import org.yakindu.sct.model.sexec.ExecutionFlow;
 import org.yakindu.sct.model.sexec.StateVector;
+import org.yakindu.sct.model.sexec.TimeEvent;
 import org.yakindu.sct.model.sgen.GeneratorEntry;
 import org.yakindu.sct.model.sgraph.Declaration;
 import org.yakindu.sct.model.sgraph.Scope;
@@ -115,6 +117,12 @@ public class StatemachineHeader extends Statemachine {
     _builder.append("\t");
     _builder.newLine();
     _builder.append("\t\t");
+    CharSequence _statesEnumDecl = this.statesEnumDecl(it);
+    _builder.append(_statesEnumDecl, "		");
+    _builder.newLineIfNotEmpty();
+    _builder.append("\t\t");
+    _builder.newLine();
+    _builder.append("\t\t");
     {
       EList<Scope> _scopes = it.getScopes();
       for(final Scope s : _scopes) {
@@ -141,30 +149,26 @@ public class StatemachineHeader extends Statemachine {
     _builder.append("/*! Checks if the specified state is active. */");
     _builder.newLine();
     _builder.append("\t\t");
-    _builder.append("virtual sc_boolean ");
+    _builder.append("sc_boolean ");
     String _nameOfIsActiveFunction = this.cNaming.nameOfIsActiveFunction(it);
     _builder.append(_nameOfIsActiveFunction, "		");
     _builder.append("(");
     String _statesEnumType = this.cNaming.statesEnumType(it);
     _builder.append(_statesEnumType, "		");
-    _builder.append(" state) = 0;");
+    _builder.append(" state);");
     _builder.newLineIfNotEmpty();
     _builder.append("\t");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("private:");
     _builder.newLine();
-    _builder.append("\t\t");
-    CharSequence _statesEnumDecl = this.statesEnumDecl(it);
-    _builder.append(_statesEnumDecl, "		");
-    _builder.newLineIfNotEmpty();
-    _builder.append("\t\t");
+    _builder.append("\t");
     _builder.newLine();
     _builder.append("\t\t");
     CharSequence _statemachineTypeDecl = this.statemachineTypeDecl(it);
     _builder.append(_statemachineTypeDecl, "		");
     _builder.newLineIfNotEmpty();
-    _builder.append("}");
+    _builder.append("};");
     _builder.newLine();
     _builder.newLine();
     _builder.append("#endif /* ");
@@ -421,6 +425,17 @@ public class StatemachineHeader extends Statemachine {
     }
     _builder.newLineIfNotEmpty();
     _builder.newLine();
+    {
+      boolean _isTimed = this._navigation.isTimed(it);
+      if (_isTimed) {
+        _builder.append("sc_boolean timeEvents[");
+        LinkedList<TimeEvent> _timeEvents = this._navigation.getTimeEvents(it);
+        int _size_2 = _timeEvents.size();
+        _builder.append(_size_2, "");
+        _builder.append("];");
+      }
+    }
+    _builder.newLineIfNotEmpty();
     String _statesEnumType = this.cNaming.statesEnumType(it);
     _builder.append(_statesEnumType, "");
     _builder.append(" stateConfVector[");
@@ -442,7 +457,7 @@ public class StatemachineHeader extends Statemachine {
       }
     }
     _builder.newLineIfNotEmpty();
-    _builder.append("sc_ushort stateConfVectorPosition; ");
+    _builder.append("sc_ushort stateConfVectorPosition;");
     _builder.newLine();
     return _builder;
   }

+ 2 - 0
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/Types.java

@@ -54,6 +54,8 @@ public class Types {
     _builder.newLine();
     _builder.append("typedef string\t\t\tsc_string;");
     _builder.newLine();
+    _builder.append("typedef bool\t\t\tsc_boolean;");
+    _builder.newLine();
     _builder.newLine();
     _builder.append("typedef void*\t\t\tsc_eventid;");
     _builder.newLine();