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

Added exit() method to IStatemachine interface.
Extended ITimerService interface to gain the system time.

markus.muehlbrandt@gmail.com 13 лет назад
Родитель
Сommit
1b6d006dbe

+ 5 - 0
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/IStatemachine.xtend

@@ -48,6 +48,11 @@ class IStatemachine {
 			*/
 			*/
 			public void enter();
 			public void enter();
 		
 		
+			/**
+			* Exits the statemachine. Leaves the statemachine with a defined state.
+			*/
+			public void exit();
+		
 			/**
 			/**
 			* Start a run-to-completion cycle.
 			* Start a run-to-completion cycle.
 			*/
 			*/

+ 8 - 0
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/ITimerService.xtend

@@ -66,6 +66,14 @@ class ITimerService {
 			 * memory resources.
 			 * memory resources.
 			 */
 			 */
 			public void cancel();
 			public void cancel();
+		
+			/**
+			 * Returns the system time in milliseconds.
+			 * 
+			 * @return the difference, measured in milliseconds, between the current
+			 *         time and a defined point of time in the past.
+			 */
+			public long getSystemTimeMillis();
 		}
 		}
 		'''
 		'''
 	}
 	}

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

@@ -451,7 +451,7 @@ class Statemachine {
 		public void runCycle() {
 		public void runCycle() {
 			
 			
 			«IF flow.timed»
 			«IF flow.timed»
-			cycleStartTime = System.currentTimeMillis();
+			cycleStartTime = timerService.getSystemTimeMillis();
 			
 			
 			«ENDIF»
 			«ENDIF»
 			clearOutEvents();
 			clearOutEvents();
@@ -481,7 +481,7 @@ class Statemachine {
 			if (timerService == null) {
 			if (timerService == null) {
 				throw new IllegalStateException("TimerService not set.");
 				throw new IllegalStateException("TimerService not set.");
 			}
 			}
-			cycleStartTime = System.currentTimeMillis();
+			cycleStartTime = timerService.getSystemTimeMillis();
 			«ENDIF»
 			«ENDIF»
 			«enterSequence.code»
 			«enterSequence.code»
 		}
 		}

+ 4 - 3
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/TimerService.xtend

@@ -79,13 +79,14 @@ class TimerService {
 				timerTaskMap.remove(event);
 				timerTaskMap.remove(event);
 			}
 			}
 		
 		
-			/**
-			 * Cancels all running TimersTasks
-			 */
 			public void cancel() {
 			public void cancel() {
 				timer.cancel();
 				timer.cancel();
 				timer.purge();
 				timer.purge();
 			}
 			}
+		
+			public long getSystemTimeMillis() {
+				return System.currentTimeMillis();
+			}
 		}
 		}
 	'''
 	'''
 }
 }