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

Added isStateActive(...) method to wrapper.

Refactoring of default prefix and suffix values.
Markus Mühlbrandt 10 лет назад
Родитель
Сommit
fee73f9aff

+ 11 - 1
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/CycleBasedSynchronizedWrapper.xtend

@@ -113,6 +113,15 @@ class CycleBasedSynchronizedWrapper {
 				}
 			}
 			
+			/**
+			 * isStateActive() will be delegated thread-safely to the wrapped state machine.  
+			 */
+			public boolean isStateActive(State state) {
+				synchronized(statemachine) {
+					return statemachine.isStateActive(state);
+				}
+			}
+			
 			/**
 			 * runCycle() will be delegated thread-safely to the wrapped state machine.  
 			 */ 
@@ -128,11 +137,13 @@ class CycleBasedSynchronizedWrapper {
 	def protected createImports(ExecutionFlow flow, GeneratorEntry entry) '''
 		«IF entry.createInterfaceObserver && flow.hasOutgoingEvents»
 			import java.util.List;
+			
 		«ENDIF»
 		«IF flow.timed»
 			import «entry.getBasePackageName()».ITimer;
 			import «entry.getBasePackageName()».ITimerCallback;
 		«ENDIF»
+		import «flow.getImplementationPackageName(entry)».«flow.statemachineClassName».State;
 	'''
 
 	def protected createFieldDeclarations(ExecutionFlow flow, GeneratorEntry entry) '''
@@ -293,7 +304,6 @@ class CycleBasedSynchronizedWrapper {
 			public void timeElapsed(int eventID) {
 				synchronized (statemachine) {
 					statemachine.timeElapsed(eventID);
-					statemachine.runCycle();
 				}
 			}
 		«ENDIF»

+ 1 - 1
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/Statemachine.xtend

@@ -240,7 +240,7 @@ class Statemachine {
 		/**
 		* Returns true if the given state is currently active otherwise false.
 		*/
-		public boolean isStateActive(State state){
+		public boolean isStateActive(State state) {
 			switch (state) {
 				«FOR s : flow.states»
 				case «s.stateName.asEscapedIdentifier» : 

+ 1 - 1
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/features/CycleBasedWrapperFeature.xtend

@@ -46,7 +46,7 @@ class CycleBasedWrapperFeature {
 	}
 
 	def cycleWrapperClassName(ExecutionFlow it, GeneratorEntry entry) {
-		entry.namePrefix + statemachineName + entry.nameSuffix
+		entry.namePrefix + statemachineClassName + entry.nameSuffix
 	}
 	
 	def wrapperInterfaceName(InterfaceScope it, GeneratorEntry entry) {

+ 1 - 1
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/features/EventBasedRunnableFeature.xtend

@@ -44,6 +44,6 @@ class EventBasedRunnableFeature {
 	}
 
 	def eventBasedWrapperClassName(ExecutionFlow it, GeneratorEntry entry) {
-		entry.namePrefix + statemachineName + entry.nameSuffix
+		entry.namePrefix + statemachineClassName + entry.nameSuffix
 	}
 }

+ 3 - 3
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/features/IJavaFeatureConstants.java

@@ -48,13 +48,13 @@ public interface IJavaFeatureConstants {
 	
 	public static final String RUNNABLE_WRAPPER_NAME_PREFIX_DEFAULT = "";
 	
-	public static final String RUNNABLE_WRAPPER_NAME_SUFFIX_DEFAULT = "StatemachineRunnable";
+	public static final String RUNNABLE_WRAPPER_NAME_SUFFIX_DEFAULT = "Runnable";
 	
 	public static final String FEATURE_SYCHRONIZED_WRAPPER = "SynchronizedWrapper";
 	
-	public static final String SYCHRONIZED_WRAPPER_NAME_PREFIX_DEFAULT = "";
+	public static final String SYCHRONIZED_WRAPPER_NAME_PREFIX_DEFAULT = "Synchronized";
 	
-	public static final String SYCHRONIZED_WRAPPER_NAME_SUFFIX_DEFAULT = "SynchronizedStatemachine";
+	public static final String SYCHRONIZED_WRAPPER_NAME_SUFFIX_DEFAULT = "";
 	
 	public static final String VALUE_NAME_PREFIX = "namePrefix";