Browse Source

Added documentation of operation calls, interface observers and variable and events access.

markus.muehlbrandt@gmail.com 12 years ago
parent
commit
ebe1369dbb
14 changed files with 2601 additions and 2227 deletions
  1. 2 2
      examples/org.yakindu.sct.examples.trafficlight/.settings/org.eclipse.core.resources.prefs
  2. 27 29
      examples/org.yakindu.sct.examples.trafficlight/src-gen/org/yakindu/sct/examples/trafficlight/cyclebased/IStatemachine.java
  3. 30 30
      examples/org.yakindu.sct.examples.trafficlight/src-gen/org/yakindu/sct/examples/trafficlight/cyclebased/ITimedStatemachine.java
  4. 46 46
      examples/org.yakindu.sct.examples.trafficlight/src-gen/org/yakindu/sct/examples/trafficlight/cyclebased/ITimerService.java
  5. 207 207
      examples/org.yakindu.sct.examples.trafficlight/src-gen/org/yakindu/sct/examples/trafficlight/cyclebased/RuntimeService.java
  6. 58 58
      examples/org.yakindu.sct.examples.trafficlight/src-gen/org/yakindu/sct/examples/trafficlight/cyclebased/TimeEvent.java
  7. 60 60
      examples/org.yakindu.sct.examples.trafficlight/src-gen/org/yakindu/sct/examples/trafficlight/cyclebased/TimerService.java
  8. 42 42
      examples/org.yakindu.sct.examples.trafficlight/src-gen/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/ITrafficLightWaitingStatemachine.java
  9. 1750 1750
      examples/org.yakindu.sct.examples.trafficlight/src-gen/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/TrafficLightWaitingStatemachine.java
  10. BIN
      plugins/org.yakindu.sct.doc.user/help/04_Reference/images/OperationExample.png
  11. 3 0
      plugins/org.yakindu.sct.doc.user/help/04_Reference/reference-toc.xml
  12. 183 0
      plugins/org.yakindu.sct.doc.user/help/04_Reference/reference.html
  13. 190 0
      plugins/org.yakindu.sct.doc.user/help/04_Reference/reference.textile
  14. 3 3
      plugins/org.yakindu.sct.generator.c/.settings/org.eclipse.core.resources.prefs

+ 2 - 2
examples/org.yakindu.sct.examples.trafficlight/.settings/org.eclipse.core.resources.prefs

@@ -1,2 +1,2 @@
-eclipse.preferences.version=1
-encoding/TrafficLightWaiting.sct=UTF-8
+eclipse.preferences.version=1
+encoding/TrafficLightWaiting.sct=UTF-8

+ 27 - 29
examples/org.yakindu.sct.examples.trafficlight/src-gen/org/yakindu/sct/examples/trafficlight/cyclebased/IStatemachine.java

@@ -1,29 +1,27 @@
-package org.yakindu.sct.examples.trafficlight.cyclebased;
-
-/**
- * Basic interface for statemachines.
- * 
- * 
- */
-public interface IStatemachine {
-
-	/**
-	* Initializes the statemachine. Use to init internal variables etc.
-	*/
-	public void init();
-
-	/**
-	* Enters the statemachine. Sets the statemachine in a defined state.
-	*/
-	public void enter();
-
-	/**
-	* Exits the statemachine. Leaves the statemachine with a defined state.
-	*/
-	public void exit();
-
-	/**
-	* Start a run-to-completion cycle.
-	*/
-	public void runCycle();
-}
+package org.yakindu.sct.examples.trafficlight.cyclebased;
+
+/**
+ * Basic interface for statemachines.
+ */
+public interface IStatemachine {
+
+	/**
+	* Initializes the statemachine. Use to init internal variables etc.
+	*/
+	public void init();
+
+	/**
+	* Enters the statemachine. Sets the statemachine in a defined state.
+	*/
+	public void enter();
+
+	/**
+	* Exits the statemachine. Leaves the statemachine with a defined state.
+	*/
+	public void exit();
+
+	/**
+	* Start a run-to-completion cycle.
+	*/
+	public void runCycle();
+}

+ 30 - 30
examples/org.yakindu.sct.examples.trafficlight/src-gen/org/yakindu/sct/examples/trafficlight/cyclebased/ITimedStatemachine.java

@@ -1,30 +1,30 @@
-package org.yakindu.sct.examples.trafficlight.cyclebased;
-
-/**
-* Interface for state machines which use timed event triggers.
-*/
-public interface ITimedStatemachine {
-
-	/**
-	* Set the {@link ITimerService} for the state machine. It must be set
-	* externally on a timed state machine before a run cycle can be correct
-	* executed.
-	* 
-	* @param timerService
-	*/
-	public void setTimerService(ITimerService timerService);
-
-	/**
-	* Returns the currently used timer service.
-	* 
-	* @return {@link ITimerService}
-	*/
-	public ITimerService getTimerService();
-
-	/**
-	* Callback method if a {@link TimeEvent} occurred.
-	* 
-	* @param timeEvent
-	*/
-	public void onTimeEventRaised(TimeEvent timeEvent);
-}
+package org.yakindu.sct.examples.trafficlight.cyclebased;
+
+/**
+* Interface for state machines which use timed event triggers.
+*/
+public interface ITimedStatemachine {
+
+	/**
+	* Set the {@link ITimerService} for the state machine. It must be set
+	* externally on a timed state machine before a run cycle can be correct
+	* executed.
+	* 
+	* @param timerService
+	*/
+	public void setTimerService(ITimerService timerService);
+
+	/**
+	* Returns the currently used timer service.
+	* 
+	* @return {@link ITimerService}
+	*/
+	public ITimerService getTimerService();
+
+	/**
+	* Callback method if a {@link TimeEvent} occurred.
+	* 
+	* @param timeEvent
+	*/
+	public void onTimeEventRaised(TimeEvent timeEvent);
+}

+ 46 - 46
examples/org.yakindu.sct.examples.trafficlight/src-gen/org/yakindu/sct/examples/trafficlight/cyclebased/ITimerService.java

@@ -1,46 +1,46 @@
-package org.yakindu.sct.examples.trafficlight.cyclebased;
-
-/**
- * Interface a timer service has to implement. Use to implement your own timer
- * service. A timer service has to be added to a timed state machine.
- * 
- */
-public interface ITimerService {
-
-	/**
-	 * Starts the timing for a given {@link TimeEvent}.
-	 * 
-	 * @param event
-	 *            : The TimeEvent the timer service should throw if timed out.
-	 * @param time
-	 *            : Time in milliseconds after the given time event should be
-	 *            triggered
-	 * @param cycleStartTime
-	 *            : The absolute start time in milliseconds at which the last
-	 *            run cycle was called. Can be used to produce a more accurate
-	 *            timing behavior.
-	 */
-	public void setTimer(TimeEvent event, long time, long cycleStartTime);
-
-	/**
-	 * Unset the given {@link TimeEvent}. Use to unset cyclic repeated time
-	 * events.
-	 * 
-	 * @param event
-	 */
-	public void resetTimer(TimeEvent event);
-
-	/**
-	 * Cancel timer service. Use this to end possible timing threads and free
-	 * memory resources.
-	 */
-	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();
-}
+package org.yakindu.sct.examples.trafficlight.cyclebased;
+
+/**
+ * Interface a timer service has to implement. Use to implement your own timer
+ * service. A timer service has to be added to a timed state machine.
+ * 
+ */
+public interface ITimerService {
+
+	/**
+	 * Starts the timing for a given {@link TimeEvent}.
+	 * 
+	 * @param event
+	 *            : The TimeEvent the timer service should throw if timed out.
+	 * @param time
+	 *            : Time in milliseconds after the given time event should be
+	 *            triggered
+	 * @param cycleStartTime
+	 *            : The absolute start time in milliseconds at which the last
+	 *            run cycle was called. Can be used to produce a more accurate
+	 *            timing behavior.
+	 */
+	public void setTimer(TimeEvent event, long time, long cycleStartTime);
+
+	/**
+	 * Unset the given {@link TimeEvent}. Use to unset cyclic repeated time
+	 * events.
+	 * 
+	 * @param event
+	 */
+	public void resetTimer(TimeEvent event);
+
+	/**
+	 * Cancel timer service. Use this to end possible timing threads and free
+	 * memory resources.
+	 */
+	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();
+}

+ 207 - 207
examples/org.yakindu.sct.examples.trafficlight/src-gen/org/yakindu/sct/examples/trafficlight/cyclebased/RuntimeService.java

@@ -1,207 +1,207 @@
-package org.yakindu.sct.examples.trafficlight.cyclebased;
-
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-/**
- * Runtime service for state machines to execute a run to completion step
- * periodically.
- * 
- */
-public class RuntimeService {
-
-	private static RuntimeService runtimeService;
-
-	private Timer timer = null;
-
-	private Map<Long, StatemachineTimerTask> timerTasks = new HashMap<Long, StatemachineTimerTask>();
-
-	private class StatemachineTimerTask extends TimerTask {
-
-		private List<IStatemachine> statemachineList = new LinkedList<IStatemachine>();
-
-		private ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
-
-		private boolean isPaused = false;
-
-		@Override
-		public void run() {
-			lock.readLock().lock();
-			if (!isPaused) {
-				for (IStatemachine statemachine : statemachineList) {
-					statemachine.runCycle();
-				}
-			}
-			lock.readLock().unlock();
-		}
-
-		/**
-		 * Adds the given state machine to the TimerTask.
-		 * 
-		 * @param statemachine
-		 * @return {@code true} if state machine is added properly.
-		 */
-		public boolean addStatemachine(IStatemachine statemachine) {
-			lock.writeLock().lock();
-			boolean ret = statemachineList.add(statemachine);
-			lock.writeLock().unlock();
-			return ret;
-		}
-
-		/**
-		 * Removes the given state machine from the TimerTask.
-		 * 
-		 * @param statemachine
-		 * @return {@code true} if state machine is removed properly.
-		 */
-		public boolean removeStatemachine(IStatemachine statemachine) {
-			lock.writeLock().lock();
-			boolean ret = statemachineList.remove(statemachine);
-			lock.writeLock().unlock();
-			return ret;
-		}
-
-		public void pause() {
-			isPaused = true;
-		}
-
-		public void resume() {
-			isPaused = false;
-		}
-	}
-
-	private RuntimeService() {
-		// Not intended to be instantiated.
-	}
-
-	/**
-	 * Returns the {@code RuntimeService} instance as singleton.
-	 * 
-	 * @return The singleton {@code RuntimeService} instance
-	 */
-	public static RuntimeService getInstance() {
-		if (runtimeService == null) {
-			runtimeService = new RuntimeService();
-		}
-		return runtimeService;
-	}
-
-	/**
-	 * Registers an {@link IStatemachine} for scheduled fixed rate execution
-	 * 
-	 * @param statemachine
-	 *            - The statemachine to execute
-	 * @param cyclePeriod
-	 *            - the fixed rate cycle period for scheduling
-	 * @return {@code true} if state machine is added properly.
-	 */
-	public boolean registerStatemachine(IStatemachine statemachine,
-			long cyclePeriod) {
-
-		if (timerTasks.containsKey(cyclePeriod)) {
-			// TimerTask for cycle time already existing -> add statemachine
-			return timerTasks.get(cyclePeriod).addStatemachine(statemachine);
-		} else {
-			// Create new TimerTask for cycle period and add statemachine
-			StatemachineTimerTask timerTask = new StatemachineTimerTask();
-			timerTasks.put(cyclePeriod, timerTask);
-			boolean ret = timerTask.addStatemachine(statemachine);
-			// Create a new Timer instance if runtime service was cancelled
-			// before
-			if (timer == null) {
-				timer = new Timer();
-			}
-			timer.scheduleAtFixedRate(timerTask, 0, cyclePeriod);
-			return ret;
-		}
-	}
-
-	/**
-	 * Removes the given state machine from runtime service.
-	 * 
-	 * @param statemachine
-	 *            - the statemachine which should be removed
-	 * @param cyclePeriod
-	 *            - the scheduling cycle period of the statemachine
-	 * @return {@code true} if state machine is removed properly.
-	 */
-	public boolean unregisterStatemachine(IStatemachine statemachine,
-			long cyclePeriod) {
-		if (timerTasks.containsKey(cyclePeriod)) {
-			boolean ret = timerTasks.get(cyclePeriod).removeStatemachine(
-					statemachine);
-
-			return ret;
-		}
-		return false;
-	}
-
-	/**
-	 * Cancels the execution of statemachines for the given cycle period. This
-	 * stops the execution of statemachines which are registered for the given
-	 * cycle period and cancels the executing {@link TimerTask}.
-	 * 
-	 * @return {@code true} if poperly cancelled
-	 */
-	public boolean cancelAll(long cyclePeriod) {
-		if (timer != null && timerTasks.containsKey(cyclePeriod)) {
-			TimerTask task = timerTasks.get(cyclePeriod);
-			task.cancel();
-			timer.purge();
-			timerTasks.remove(cyclePeriod);
-			return true;
-		}
-		return false;
-	}
-
-	/**
-	 * Pauses the execution of all statemachine which are registered for the
-	 * given cyclePeriod.
-	 * 
-	 * @param cyclePeriod
-	 * @return {@code true} if poperly paused
-	 * 
-	 */
-	public boolean pauseAll(long cyclePeriod) {
-		if (timerTasks.containsKey(cyclePeriod)) {
-			timerTasks.get(cyclePeriod).pause();
-			return true;
-		}
-		return false;
-	}
-
-	/**
-	 * Resumes the execution of all statemachine which are registered for the
-	 * given cyclePeriod.
-	 * 
-	 * @param cyclePeriod
-	 * @return {@code true} if poperly resumed
-	 * 
-	 */
-	public boolean resumeAll(long cyclePeriod) {
-		if (timerTasks.containsKey(cyclePeriod)) {
-			timerTasks.get(cyclePeriod).resume();
-			return true;
-		}
-		return false;
-	}
-
-	/**
-	 * Cancels the execution of all registered statemachines. This cancels the
-	 * executing {@link Timer} freeing all allocated resources and terminates
-	 * all existing execution threads.
-	 */
-	public void cancelTimer() {
-		if (timer != null) {
-			timer.cancel();
-			timer.purge();
-			timerTasks.clear();
-			timer = null;
-		}
-	}
-}
+package org.yakindu.sct.examples.trafficlight.cyclebased;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/**
+ * Runtime service for state machines to execute a run to completion step
+ * periodically.
+ * 
+ */
+public class RuntimeService {
+
+	private static RuntimeService runtimeService;
+
+	private Timer timer = null;
+
+	private Map<Long, StatemachineTimerTask> timerTasks = new HashMap<Long, StatemachineTimerTask>();
+
+	private class StatemachineTimerTask extends TimerTask {
+
+		private List<IStatemachine> statemachineList = new LinkedList<IStatemachine>();
+
+		private ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
+
+		private boolean isPaused = false;
+
+		@Override
+		public void run() {
+			lock.readLock().lock();
+			if (!isPaused) {
+				for (IStatemachine statemachine : statemachineList) {
+					statemachine.runCycle();
+				}
+			}
+			lock.readLock().unlock();
+		}
+
+		/**
+		 * Adds the given state machine to the TimerTask.
+		 * 
+		 * @param statemachine
+		 * @return {@code true} if state machine is added properly.
+		 */
+		public boolean addStatemachine(IStatemachine statemachine) {
+			lock.writeLock().lock();
+			boolean ret = statemachineList.add(statemachine);
+			lock.writeLock().unlock();
+			return ret;
+		}
+
+		/**
+		 * Removes the given state machine from the TimerTask.
+		 * 
+		 * @param statemachine
+		 * @return {@code true} if state machine is removed properly.
+		 */
+		public boolean removeStatemachine(IStatemachine statemachine) {
+			lock.writeLock().lock();
+			boolean ret = statemachineList.remove(statemachine);
+			lock.writeLock().unlock();
+			return ret;
+		}
+
+		public void pause() {
+			isPaused = true;
+		}
+
+		public void resume() {
+			isPaused = false;
+		}
+	}
+
+	private RuntimeService() {
+		// Not intended to be instantiated.
+	}
+
+	/**
+	 * Returns the {@code RuntimeService} instance as singleton.
+	 * 
+	 * @return The singleton {@code RuntimeService} instance
+	 */
+	public static RuntimeService getInstance() {
+		if (runtimeService == null) {
+			runtimeService = new RuntimeService();
+		}
+		return runtimeService;
+	}
+
+	/**
+	 * Registers an {@link IStatemachine} for scheduled fixed rate execution
+	 * 
+	 * @param statemachine
+	 *            - The statemachine to execute
+	 * @param cyclePeriod
+	 *            - the fixed rate cycle period for scheduling
+	 * @return {@code true} if state machine is added properly.
+	 */
+	public boolean registerStatemachine(IStatemachine statemachine,
+			long cyclePeriod) {
+
+		if (timerTasks.containsKey(cyclePeriod)) {
+			// TimerTask for cycle time already existing -> add statemachine
+			return timerTasks.get(cyclePeriod).addStatemachine(statemachine);
+		} else {
+			// Create new TimerTask for cycle period and add statemachine
+			StatemachineTimerTask timerTask = new StatemachineTimerTask();
+			timerTasks.put(cyclePeriod, timerTask);
+			boolean ret = timerTask.addStatemachine(statemachine);
+			// Create a new Timer instance if runtime service was cancelled
+			// before
+			if (timer == null) {
+				timer = new Timer();
+			}
+			timer.scheduleAtFixedRate(timerTask, 0, cyclePeriod);
+			return ret;
+		}
+	}
+
+	/**
+	 * Removes the given state machine from runtime service.
+	 * 
+	 * @param statemachine
+	 *            - the statemachine which should be removed
+	 * @param cyclePeriod
+	 *            - the scheduling cycle period of the statemachine
+	 * @return {@code true} if state machine is removed properly.
+	 */
+	public boolean unregisterStatemachine(IStatemachine statemachine,
+			long cyclePeriod) {
+		if (timerTasks.containsKey(cyclePeriod)) {
+			boolean ret = timerTasks.get(cyclePeriod).removeStatemachine(
+					statemachine);
+
+			return ret;
+		}
+		return false;
+	}
+
+	/**
+	 * Cancels the execution of statemachines for the given cycle period. This
+	 * stops the execution of statemachines which are registered for the given
+	 * cycle period and cancels the executing {@link TimerTask}.
+	 * 
+	 * @return {@code true} if poperly cancelled
+	 */
+	public boolean cancelAll(long cyclePeriod) {
+		if (timer != null && timerTasks.containsKey(cyclePeriod)) {
+			TimerTask task = timerTasks.get(cyclePeriod);
+			task.cancel();
+			timer.purge();
+			timerTasks.remove(cyclePeriod);
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Pauses the execution of all statemachines which are registered for the
+	 * given cyclePeriod.
+	 * 
+	 * @param cyclePeriod
+	 * @return {@code true} if properly paused
+	 * 
+	 */
+	public boolean pauseAll(long cyclePeriod) {
+		if (timerTasks.containsKey(cyclePeriod)) {
+			timerTasks.get(cyclePeriod).pause();
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Resumes the execution of all statemachines which are registered for the
+	 * given cyclePeriod.
+	 * 
+	 * @param cyclePeriod
+	 * @return {@code true} if properly resumed
+	 * 
+	 */
+	public boolean resumeAll(long cyclePeriod) {
+		if (timerTasks.containsKey(cyclePeriod)) {
+			timerTasks.get(cyclePeriod).resume();
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Cancels the execution of all registered statemachines. This cancels the
+	 * executing {@link Timer} freeing all allocated resources and terminates
+	 * all existing execution threads.
+	 */
+	public void cancelTimer() {
+		if (timer != null) {
+			timer.cancel();
+			timer.purge();
+			timerTasks.clear();
+			timer = null;
+		}
+	}
+}

+ 58 - 58
examples/org.yakindu.sct.examples.trafficlight/src-gen/org/yakindu/sct/examples/trafficlight/cyclebased/TimeEvent.java

@@ -1,58 +1,58 @@
-package org.yakindu.sct.examples.trafficlight.cyclebased;
-
-/**
- * Event that reflects a time event. It's internally used by
- * {@link ITimedStatemachine}.
- * 
- * @author muehlbrandt
- * 
- * @param <T>
- */
-public class TimeEvent {
-
-	private boolean periodic;
-
-	private ITimedStatemachine statemachine;
-	
-	int index;
-
-	/**
-	 * Constructor for a time event.
-	 * 
-	 * @param periodic
-	 *            : Set to {@code true} if event should be repeated
-	 *            periodically.
-	 * 
-	 * @param index
-	 *            : Index position within the state machine's timeEvent array.
-	 */
-	public TimeEvent(boolean periodic, int index) {
-		this.periodic = periodic;
-		this.index = index;
-	}
-
-	/**
-	 * Returns the state machine reference of the event.
-	 * 
-	 */
-	public ITimedStatemachine getStatemachine() {
-		return statemachine;
-	}
-
-	/**
-	 * Sets the state machine reference of the event.
-	 * 
-	 * @param statemachine
-	 */
-	public void setStatemachine(ITimedStatemachine statemachine) {
-		this.statemachine = statemachine;
-	}
-
-	public boolean isPeriodic() {
-		return periodic;
-	}
-
-	public int getIndex() {
-		return index;
-	}
-}
+package org.yakindu.sct.examples.trafficlight.cyclebased;
+
+/**
+ * Event that reflects a time event. It's internally used by
+ * {@link ITimedStatemachine}.
+ * 
+ * @author muehlbrandt
+ * 
+ * @param <T>
+ */
+public class TimeEvent {
+
+	private boolean periodic;
+
+	private ITimedStatemachine statemachine;
+	
+	int index;
+
+	/**
+	 * Constructor for a time event.
+	 * 
+	 * @param periodic
+	 *            : Set to {@code true} if event should be repeated
+	 *            periodically.
+	 * 
+	 * @param index
+	 *            : Index position within the state machine's timeEvent array.
+	 */
+	public TimeEvent(boolean periodic, int index) {
+		this.periodic = periodic;
+		this.index = index;
+	}
+
+	/**
+	 * Returns the state machine reference of the event.
+	 * 
+	 */
+	public ITimedStatemachine getStatemachine() {
+		return statemachine;
+	}
+
+	/**
+	 * Sets the state machine reference of the event.
+	 * 
+	 * @param statemachine
+	 */
+	public void setStatemachine(ITimedStatemachine statemachine) {
+		this.statemachine = statemachine;
+	}
+
+	public boolean isPeriodic() {
+		return periodic;
+	}
+
+	public int getIndex() {
+		return index;
+	}
+}

+ 60 - 60
examples/org.yakindu.sct.examples.trafficlight/src-gen/org/yakindu/sct/examples/trafficlight/cyclebased/TimerService.java

@@ -1,60 +1,60 @@
-package org.yakindu.sct.examples.trafficlight.cyclebased;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Timer;
-import java.util.TimerTask;
-
-/**
- * Default timer service implementation.
- * 
- */
-public class TimerService implements ITimerService {
-
-	private final Timer timer = new Timer();
-
-	private final Map<TimeEvent, TimerTask> timerTaskMap = new HashMap<TimeEvent, TimerTask>();
-
-	public void setTimer(final TimeEvent event, long time,
-			long cycleStartTime) {
-		// Reset existing TimerTask for event. This step isn't necessary if
-		// timer tasks are properly reset by sexec model.
-		if (timerTaskMap.containsKey(event)) {
-			resetTimer(event);
-		}
-
-		// Create a new TimerTask for given event.
-		timerTaskMap.put(event, new TimerTask() {
-			@Override
-			public void run() {
-				event.getStatemachine().onTimeEventRaised(event);
-			}
-		});
-
-		// start scheduling the timer
-		if (event.isPeriodic()) {
-			timer.scheduleAtFixedRate(timerTaskMap.get(event),
-					time - (System.currentTimeMillis() - cycleStartTime), time);
-		} else {
-			timer.schedule(timerTaskMap.get(event),
-					time - (System.currentTimeMillis() - cycleStartTime));
-		}
-	}
-
-	public void resetTimer(TimeEvent event) {
-		if (timerTaskMap.containsKey(event) && timerTaskMap.get(event) != null) {
-			timerTaskMap.get(event).cancel();
-			timer.purge();
-		}
-		timerTaskMap.remove(event);
-	}
-
-	public void cancel() {
-		timer.cancel();
-		timer.purge();
-	}
-
-	public long getSystemTimeMillis() {
-		return System.currentTimeMillis();
-	}
-}
+package org.yakindu.sct.examples.trafficlight.cyclebased;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
+
+/**
+ * Default timer service implementation.
+ * 
+ */
+public class TimerService implements ITimerService {
+
+	private final Timer timer = new Timer();
+
+	private final Map<TimeEvent, TimerTask> timerTaskMap = new HashMap<TimeEvent, TimerTask>();
+
+	public void setTimer(final TimeEvent event, long time,
+			long cycleStartTime) {
+		// Reset existing TimerTask for event. This step isn't necessary if
+		// timer tasks are properly reset by sexec model.
+		if (timerTaskMap.containsKey(event)) {
+			resetTimer(event);
+		}
+
+		// Create a new TimerTask for given event.
+		timerTaskMap.put(event, new TimerTask() {
+			@Override
+			public void run() {
+				event.getStatemachine().onTimeEventRaised(event);
+			}
+		});
+
+		// start scheduling the timer
+		if (event.isPeriodic()) {
+			timer.scheduleAtFixedRate(timerTaskMap.get(event),
+					time - (System.currentTimeMillis() - cycleStartTime), time);
+		} else {
+			timer.schedule(timerTaskMap.get(event),
+					time - (System.currentTimeMillis() - cycleStartTime));
+		}
+	}
+
+	public void resetTimer(TimeEvent event) {
+		if (timerTaskMap.containsKey(event) && timerTaskMap.get(event) != null) {
+			timerTaskMap.get(event).cancel();
+			timer.purge();
+		}
+		timerTaskMap.remove(event);
+	}
+
+	public void cancel() {
+		timer.cancel();
+		timer.purge();
+	}
+
+	public long getSystemTimeMillis() {
+		return System.currentTimeMillis();
+	}
+}

+ 42 - 42
examples/org.yakindu.sct.examples.trafficlight/src-gen/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/ITrafficLightWaitingStatemachine.java

@@ -1,42 +1,42 @@
-package org.yakindu.sct.examples.trafficlight.cyclebased.trafficlightwaiting;
-import org.yakindu.sct.examples.trafficlight.cyclebased.IStatemachine;
-import org.yakindu.sct.examples.trafficlight.cyclebased.ITimedStatemachine;
-
-public interface ITrafficLightWaitingStatemachine
-		extends
-			ITimedStatemachine,
-			IStatemachine {
-
-	public interface SCITrafficLight {
-		public boolean getRed();
-		public void setRed(boolean value);
-		public boolean getYellow();
-		public void setYellow(boolean value);
-		public boolean getGreen();
-		public void setGreen(boolean value);
-
-	}
-
-	public SCITrafficLight getSCITrafficLight();
-
-	public interface SCIPedestrian {
-		public boolean getRequest();
-		public void setRequest(boolean value);
-		public boolean getRed();
-		public void setRed(boolean value);
-		public boolean getGreen();
-		public void setGreen(boolean value);
-
-	}
-
-	public SCIPedestrian getSCIPedestrian();
-
-	public interface SCIDefault {
-		public void raisePedestrianRequest();
-		public void raiseOnOff();
-
-	}
-
-	public SCIDefault getSCIDefault();
-
-}
+package org.yakindu.sct.examples.trafficlight.cyclebased.trafficlightwaiting;
+import org.yakindu.sct.examples.trafficlight.cyclebased.IStatemachine;
+import org.yakindu.sct.examples.trafficlight.cyclebased.ITimedStatemachine;
+
+public interface ITrafficLightWaitingStatemachine
+		extends
+			ITimedStatemachine,
+			IStatemachine {
+
+	public interface SCITrafficLight {
+		public boolean getRed();
+		public void setRed(boolean value);
+		public boolean getYellow();
+		public void setYellow(boolean value);
+		public boolean getGreen();
+		public void setGreen(boolean value);
+
+	}
+
+	public SCITrafficLight getSCITrafficLight();
+
+	public interface SCIPedestrian {
+		public boolean getRequest();
+		public void setRequest(boolean value);
+		public boolean getRed();
+		public void setRed(boolean value);
+		public boolean getGreen();
+		public void setGreen(boolean value);
+
+	}
+
+	public SCIPedestrian getSCIPedestrian();
+
+	public interface SCInterface {
+		public void raisePedestrianRequest();
+		public void raiseOnOff();
+
+	}
+
+	public SCInterface getSCInterface();
+
+}

File diff suppressed because it is too large
+ 1750 - 1750
examples/org.yakindu.sct.examples.trafficlight/src-gen/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/TrafficLightWaitingStatemachine.java


BIN
plugins/org.yakindu.sct.doc.user/help/04_Reference/images/OperationExample.png


+ 3 - 0
plugins/org.yakindu.sct.doc.user/help/04_Reference/reference-toc.xml

@@ -84,6 +84,9 @@
 				<topic href="help/04_Reference/reference.html#Timedstatemachines" label="Timed statemachines"></topic>
 				<topic href="help/04_Reference/reference.html#DefaultimplementationofITimerService" label="Default implementation of ITimerService"></topic>
 				<topic href="help/04_Reference/reference.html#Runtimeservice" label="Runtime service"></topic>
+				<topic href="help/04_Reference/reference.html#InterfacesVariableandEventaccess" label="Interfaces, Variable and Event access"></topic>
+				<topic href="help/04_Reference/reference.html#Interfaceobservers" label="Interface observers"></topic>
+				<topic href="help/04_Reference/reference.html#Operationcallbacks" label="Operation callbacks"></topic>
 				<topic href="help/04_Reference/reference.html#Integrationofgeneratedcode" label="Integration of generated code"></topic>
 			</topic>
 			<topic href="help/04_Reference/reference.html#SpecificationsofCcode" label="Specifications of C code"></topic>

+ 183 - 0
plugins/org.yakindu.sct.doc.user/help/04_Reference/reference.html

@@ -1057,9 +1057,192 @@ public class TimerService implements ITimerService {
 	}
 }
 
+
 </code></pre>
 		<h4 id="Runtimeservice">Runtime service</h4>
 		<p>The runtime service class can be used by client implementations to execute a run to completion step of a statemachine periodically.</p>
+		<h4 id="InterfacesVariableandEventaccess">Interfaces, Variable and Event access</h4>
+		<p>In a yakindu statechart variables and events are contained in interfaces. There could be one default interface defined (without a name) and several named interfaces. In the generated code these interfaces are defined as internal java interfaces of an interface that has the same name as the statemachine. Let&#8217;s have a look at following example statechart interface declaration:</p>
+		<pre><code>interface:
+	var a:boolean
+	in event evA:boolean
+	out event evB:integer
+
+</code></pre>
+		<p>The generated interface code looks like following:</p>
+		<pre><code>public interface IDefaultSMStatemachine extends IStatemachine {
+
+	public interface SCInterface {
+		public void raiseEvA(boolean value);
+		public boolean isRaisedEvB();
+		public int getEvBValue();
+		public boolean getA();
+		public void setA(boolean value);
+	}
+
+	public SCInterface getSCInterface();
+}
+
+</code></pre>
+		<p>For the unnamed statechart interface a java interface 
+			<code>SCInterface</code> is generated. For the incoming event &#8218;evA&#8217; a raise method with a boolean parameter is created because the event has a boolean type set. For the outgoing event &#8218;evB&#8217; the methods 
+			<code>isRaisedEvB()</code> and 
+			<code>getEvBValue()</code> are generated. The first one can be used to determine if the event is raised by the statemachine and the second method serves to query the boolean value of the event. For variables getters and setters are generated too. Additionally the parent interface decribes getter methods to acquire each nested interface.
+		</p>
+		<p>The statemachine implements the parent interface by iteself and each nested interface is implemented as internal class. It holds an instance of each nested interface implementation which is accessible through a getter method. Have a look at the code snipped of the &#8218;unnamed&#8217; default interface implementation:</p>
+		<pre><code>public class DefaultSMStatemachine implements IDefaultSMStatemachine {
+
+	private final class SCInterfaceImpl implements SCInterface {
+	
+			private boolean evA;
+	
+			private boolean evAValue;
+	
+			public void raiseEvA(boolean value) {
+				evA = true;
+				evAValue = value;
+			}
+	
+			private boolean getEvAValue() {
+				if (!evA)
+					throw new IllegalStateException(
+							"Illegal event value acces. Event EvA is not raised!");
+				return evAValue;
+			}
+	
+			private boolean evB;
+	
+			private int evBValue;
+	
+			public boolean isRaisedEvB() {
+				return evB;
+			}
+	
+			private void raiseEvB(int value) {
+				evB = true;
+				evBValue = value;
+			}
+	
+			public int getEvBValue() {
+				if (!evB)
+					throw new IllegalStateException(
+							"Illegal event value acces. Event EvB is not raised!");
+				return evBValue;
+			}
+	
+			private boolean a;
+	
+			public boolean getA() {
+				return a;
+			}
+	
+			public void setA(boolean value) {
+				this.a = value;
+			}
+	
+			public void clearEvents() {
+				evA = false;
+			}
+	
+			public void clearOutEvents() {
+				evB = false;
+			}
+		}
+		
+		private SCInterfaceImpl sCInterface;
+		
+		public DefaultSMStatemachine() {
+
+			sCInterface = new SCInterfaceImpl();
+		}
+		
+		public SCInterface getSCInterface() {
+			return sCInterface;
+	}
+}
+
+</code></pre>
+		<p>Now even a few notes on the naming of the generated interfaces and the value access of events. The default (unnamed) interface is named &#8218;SCInterface&#8217;. If an interface has a dedicated name then this name is used with the prefix &#8218;SCI&#8217; (e.g. &#8218;SCIInterfacename&#8217;). Additionally a value of an event can only be accessed if the event is occured during the run to completion step. Otherwise an 
+			<code>IllegalStateException</code> is thrown by the interface.
+		</p>
+		<h4 id="Interfaceobservers">Interface observers</h4>
+		<p>If the general feature &#8218;InterfaceObserverSupport&#8217; is enabled in the sgen model the generated interfaces get support to register observers:</p>
+		<pre><code>public interface IDefaultSMStatemachine extends IStatemachine {
+
+	public interface SCInterface {
+		public void raiseEvA(boolean value);
+		public boolean isRaisedEvB();
+		public int getEvBValue();
+		public boolean getA();
+		public void setA(boolean value);
+		public List&lt;SCInterfaceListener&gt; getListeners();
+	}
+
+	public interface SCInterfaceListener {
+		public void onEvBRaised(int value);
+	}
+
+	public SCInterface getSCInterface();
+}
+
+</code></pre>
+		<p>An additional interface 
+			<code>SCInterfaceListener</code> is generated. This interface has to be implemented by the user and contains callback methods for each outgoing event. So the listener get notified if a outgoing event is raised by the statemachine internally. To add or remove a listener from an interface use the 
+			<code>getListeners()</code> method of the associated interface. This method returns a 
+			<code>java.util.list</code> which is parameterized with the appropriate listener type. The operations within the callback should not take a long process time because the statemachine execution may hang too long which leads to a not expected runtime behavior.
+		</p>
+		<h4 id="Operationcallbacks">Operation callbacks</h4>
+		<p>The yakindu statecharts support the declaration of operations which can be used within a statechart as actions. These operations have to be implemented by the user before a statechart is executable. Here is an example statechart using an operation:</p>
+		<p>
+			<img border="0" src="images/OperationExample.png"/>
+		</p>
+		<p>Now have a look at the generated code:</p>
+		<pre><code>public interface IDefaultSMStatemachine extends IStatemachine {
+
+	public interface SCInterface {
+		public void raiseEvA(boolean value);
+		public boolean isRaisedEvB();
+		public int getEvBValue();
+		public boolean getA();
+		public void setA(boolean value);
+
+		public void setSCInterfaceOperationCallback(
+				SCInterfaceOperationCallback operationCallback);
+	}
+
+	public interface SCInterfaceOperationCallback {
+		public int myOperation(int param1, boolean param2);
+	}
+
+	public SCInterface getSCInterface();
+}
+
+</code></pre>
+		<p>An additional interface 
+			<code>SCInterfaceOperationCallback</code> with the method 
+			<code>myOperation(int param1, boolean param2)</code> is generated. This interface has to be implemented by the user and set with the 
+			<code>setSCInterfaceOperationCallback(SCInterfaceOperationCallback operationCallback)</code> method so that the statechart can use it:
+		</p>
+		<pre><code>public static void main(String[] args) {
+	DefaultSMStatemachine statemachine = new DefaultSMStatemachine();
+	
+	SCInterfaceOperationCallback callback = new SCInterfaceOperationCallback() {
+		
+		@Override
+		public int myOperation(int param1, boolean param2) {
+			// Your operation code should be placed here;
+			return 0;
+		}
+	};
+	
+	statemachine.getSCInterface().setSCInterfaceOperationCallback(callback);
+	
+	statemachine.init();
+	statemachine.enter();
+	statemachine.runCycle();
+}
+
+</code></pre>
 		<h4 id="Integrationofgeneratedcode">Integration of generated code</h4>
 		<p>To get a clue how to integrate the generated java statemachines into your existing projects have a look at the
 			<br/>

File diff suppressed because it is too large
+ 190 - 0
plugins/org.yakindu.sct.doc.user/help/04_Reference/reference.textile


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

@@ -1,3 +1,3 @@
-eclipse.preferences.version=1
-encoding//.settings/org.eclipse.xtend.shared.ui.prefs=Cp1252
-encoding/<project>=UTF-8
+eclipse.preferences.version=1
+encoding//.settings/org.eclipse.xtend.shared.ui.prefs=Cp1252
+encoding/<project>=UTF-8