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

Merge branch 'master' into test_2.6

Rainer Klute 10 лет назад
Родитель
Сommit
2bd7369526
37 измененных файлов с 1419 добавлено и 3022 удалено
  1. 2 1
      examples/traffic_light/.classpath
  2. 1 12
      examples/traffic_light/.project
  3. 1 1
      examples/traffic_light/.settings/org.eclipse.core.resources.prefs
  4. 0 0
      examples/traffic_light/.settings/org.eclipse.jdt.core.prefs
  5. 17 0
      examples/traffic_light/README.TXT
  6. 0 2
      examples/traffic_light/build.properties
  7. 578 549
      examples/traffic_light/model/TrafficLightWaiting.sct
  8. 7 1
      examples/traffic_light/model/GenModelJava.sgen
  9. 4 5
      examples/traffic_light/src-gen/traffic/light/IStatemachine.java
  10. 2 3
      examples/traffic_light/src-gen/traffic/light/ITimer.java
  11. 2 3
      examples/traffic_light/src-gen/traffic/light/ITimerCallback.java
  12. 13 14
      examples/traffic_light/src-gen/traffic/light/RuntimeService.java
  13. 16 7
      examples/traffic_light/src-gen/traffic/light/TimerService.java
  14. 10 5
      examples/traffic_light/src-gen/traffic/light/trafficlightwaiting/ITrafficLightWaitingStatemachine.java
  15. 279 0
      examples/traffic_light/src-gen/traffic/light/trafficlightctrl/SynchronizedTrafficLightCtrlStatemachine.java
  16. 163 18
      examples/traffic_light/src-gen/traffic/light/trafficlightwaiting/TrafficLightWaitingStatemachine.java
  17. 1 1
      examples/trafficlight_example/src/trafficlight_example/ButtonPanel.java
  18. 96 0
      examples/traffic_light/src/traffic/light/CrossWalkPanel.java
  19. 125 0
      examples/traffic_light/src/traffic/light/CrossingPanel.java
  20. 4 4
      examples/trafficlight_example/src/trafficlight_example/PedestrianLight.java
  21. 1 1
      examples/trafficlight_example/src/trafficlight_example/TrafficLight.java
  22. 97 0
      examples/traffic_light/src/traffic/light/TrafficlightDemo.java
  23. 0 7
      examples/trafficlight_example/.classpath
  24. 0 23
      examples/trafficlight_example/.project
  25. 0 2
      examples/trafficlight_example/bin/.gitignore
  26. 0 549
      examples/trafficlight_example/model/TrafficLightWaiting.sct
  27. 0 19
      examples/trafficlight_example/model/default2.sgen
  28. 0 7
      examples/trafficlight_example/readme.txt
  29. 0 207
      examples/trafficlight_example/src-gen/org/yakindu/scr/RuntimeService.java
  30. 0 91
      examples/trafficlight_example/src-gen/org/yakindu/scr/TimerService.java
  31. 0 38
      examples/trafficlight_example/src-gen/org/yakindu/scr/trafficlightwaiting/ITrafficLightWaitingStatemachine.java
  32. 0 1111
      examples/trafficlight_example/src-gen/org/yakindu/scr/trafficlightwaiting/TrafficLightWaitingStatemachine.java
  33. 0 39
      examples/trafficlight_example/src/org/yakindu/scr/IStatemachine.java
  34. 0 38
      examples/trafficlight_example/src/org/yakindu/scr/ITimer.java
  35. 0 15
      examples/trafficlight_example/src/org/yakindu/scr/ITimerCallback.java
  36. 0 141
      examples/trafficlight_example/src/trafficlight_example/CrossingPanel.java
  37. 0 108
      examples/trafficlight_example/src/trafficlight_example/TrafficlightDemo.java

+ 2 - 1
examples/traffic_light/.classpath

@@ -1,7 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry kind="src" path="src-gen"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

+ 1 - 12
examples/traffic_light/.project

@@ -11,12 +11,7 @@
 			</arguments>
 		</buildCommand>
 		<buildCommand>
-			<name>org.eclipse.pde.ManifestBuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-		<buildCommand>
-			<name>org.eclipse.pde.SchemaBuilder</name>
+			<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
 			<arguments>
 			</arguments>
 		</buildCommand>
@@ -25,15 +20,9 @@
 			<arguments>
 			</arguments>
 		</buildCommand>
-		<buildCommand>
-			<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
 	</buildSpec>
 	<natures>
 		<nature>org.eclipse.jdt.core.javanature</nature>
-		<nature>org.eclipse.pde.PluginNature</nature>
 		<nature>org.yakindu.sct.builder.SCTNature</nature>
 		<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
 	</natures>

+ 1 - 1
examples/traffic_light/.settings/org.eclipse.core.resources.prefs

@@ -1,3 +1,3 @@
 eclipse.preferences.version=1
-encoding//model/TrafficLightWaiting.sct=UTF-8
+encoding//model/TrafficLightCtrl.sct=UTF-8
 encoding/<project>=UTF-8

examples/trafficlight_example/.settings/org.eclipse.jdt.core.prefs → examples/traffic_light/.settings/org.eclipse.jdt.core.prefs


+ 17 - 0
examples/traffic_light/README.TXT

@@ -0,0 +1,17 @@
+The traffic light example project is based on Java and contains a small GUI 
+that demonstrate the state machine behaviour in /model/TrafficLightWaiting.sct. 
+This example combines generated java code with manual Java implementations (the GUI). 
+To start the application run src/trafficlight_example/TrafficlightDemo.java. 
+In Eclipse select the project in the project explorer and right-click to open the 
+context menu. Select 'Run As > Java Application'. The application will start and 
+everything else should be self explaining
+
+ATTENTION:
+
+1! The example REQUIRES a JAVA 8 JDK. 
+
+2! When you installed the example then Eclipse may show errors on the project. This 
+is likely due to a missing configuration of the JDK. In this case select 'Properties'
+from the context menu on the project and set the correct JDK in 'Java Build Path'. You 
+will find further help in the 'Java development user guide' section of the Eclipse help.
+

+ 0 - 2
examples/traffic_light/build.properties

@@ -1,2 +0,0 @@
-source.. = src-gen/
-bin.includes = .

Разница между файлами не показана из-за своего большого размера
+ 578 - 549
examples/traffic_light/model/TrafficLightWaiting.sct


+ 7 - 1
examples/traffic_light/model/GenModelJava.sgen

@@ -1,6 +1,6 @@
 GeneratorModel for yakindu::java {
 
-	statechart TrafficLightWaiting {
+	statechart TrafficLightCtrl {
 	 	
 		feature Outlet {
 			targetProject = "traffic_light"
@@ -9,6 +9,7 @@ GeneratorModel for yakindu::java {
 
 		feature Naming {
 			basePackage = "traffic.light"
+			implementationSuffix =""
 		}
 
 		feature GeneralFeatures {
@@ -16,6 +17,11 @@ GeneratorModel for yakindu::java {
 			TimerService = true
 		}
 		
+		feature RunnableWrapper {
+			namePrefix =  "" 
+			nameSuffix =  "Runnable" 
+		}
+		
 		feature LicenseHeader {
 			licenseText = "
 Copyright (c) 2012-2015 committers of YAKINDU and others.

+ 4 - 5
examples/traffic_light/src-gen/traffic/light/IStatemachine.java

@@ -1,5 +1,4 @@
-/**
-Copyright (c) 2012-2015 committers of YAKINDU and others.
+/** Copyright (c) 2012-2015 committers of YAKINDU and others.
 All rights reserved. This program and the accompanying materials
 are made available under the terms of the Eclipse Public License v1.0
 which accompanies this distribution, and is available at
@@ -7,7 +6,7 @@ http://www.eclipse.org/legal/epl-v10.html
 
 Contributors:
     committers of YAKINDU - initial API and implementation
-�*/
+� */
 package traffic.light;
 
 /**
@@ -16,7 +15,7 @@ package traffic.light;
 public interface IStatemachine {
 
 	/**
-	 * Initializes the state machine. Used to init internal variables etc.
+	 * Initializes the state machine. Used to initialize internal variables etc.
 	 */
 	public void init();
 
@@ -38,7 +37,7 @@ public interface IStatemachine {
 
 	/**
 	 * Checks whether all active states are final. 
-	 * If there are no active states then the state machine is considered to be incative and this method returns <code>false</code>.
+	 * If there are no active states then the state machine is considered being incative. In this case this method returns <code>false</code>.
 	 */
 	public boolean isFinal();
 

+ 2 - 3
examples/traffic_light/src-gen/traffic/light/ITimer.java

@@ -1,5 +1,4 @@
-/**
-Copyright (c) 2012-2015 committers of YAKINDU and others.
+/** Copyright (c) 2012-2015 committers of YAKINDU and others.
 All rights reserved. This program and the accompanying materials
 are made available under the terms of the Eclipse Public License v1.0
 which accompanies this distribution, and is available at
@@ -7,7 +6,7 @@ http://www.eclipse.org/legal/epl-v10.html
 
 Contributors:
     committers of YAKINDU - initial API and implementation
-�*/
+� */
 package traffic.light;
 
 /**

+ 2 - 3
examples/traffic_light/src-gen/traffic/light/ITimerCallback.java

@@ -1,5 +1,4 @@
-/**
-Copyright (c) 2012-2015 committers of YAKINDU and others.
+/** Copyright (c) 2012-2015 committers of YAKINDU and others.
 All rights reserved. This program and the accompanying materials
 are made available under the terms of the Eclipse Public License v1.0
 which accompanies this distribution, and is available at
@@ -7,7 +6,7 @@ http://www.eclipse.org/legal/epl-v10.html
 
 Contributors:
     committers of YAKINDU - initial API and implementation
-�*/
+� */
 package traffic.light;
 
 /**

+ 13 - 14
examples/traffic_light/src-gen/traffic/light/RuntimeService.java

@@ -1,5 +1,4 @@
-/**
-Copyright (c) 2012-2015 committers of YAKINDU and others.
+/** Copyright (c) 2012-2015 committers of YAKINDU and others.
 All rights reserved. This program and the accompanying materials
 are made available under the terms of the Eclipse Public License v1.0
 which accompanies this distribution, and is available at
@@ -7,7 +6,7 @@ http://www.eclipse.org/legal/epl-v10.html
 
 Contributors:
     committers of YAKINDU - initial API and implementation
-�*/
+� */
 package traffic.light;
 
 import java.util.HashMap;
@@ -52,7 +51,7 @@ public class RuntimeService {
 
 		/**
 		 * Adds the given state machine to the TimerTask.
-		 * 
+		 *
 		 * @param statemachine
 		 * @return {@code true} if state machine is added properly.
 		 */
@@ -65,7 +64,7 @@ public class RuntimeService {
 
 		/**
 		 * Removes the given state machine from the TimerTask.
-		 * 
+		 *
 		 * @param statemachine
 		 * @return {@code true} if state machine is removed properly.
 		 */
@@ -91,7 +90,7 @@ public class RuntimeService {
 
 	/**
 	 * Returns the {@code RuntimeService} instance as singleton.
-	 * 
+	 *
 	 * @return The singleton {@code RuntimeService} instance
 	 */
 	public static RuntimeService getInstance() {
@@ -103,7 +102,7 @@ public class RuntimeService {
 
 	/**
 	 * Registers an {@link IStatemachine} for scheduled fixed rate execution
-	 * 
+	 *
 	 * @param statemachine
 	 *            - The state machine to execute
 	 * @param cyclePeriod
@@ -133,9 +132,9 @@ public class RuntimeService {
 
 	/**
 	 * Removes the given state machine from runtime service.
-	 * 
+	 *
 	 * @param statemachine
-	 *            - the state machine which should be removed
+	 *            - the state machine to be removed
 	 * @param cyclePeriod
 	 *            - the scheduling cycle period of the state machine
 	 * @return {@code true} if state machine is removed properly.
@@ -155,7 +154,7 @@ public class RuntimeService {
 	 * Cancels the execution of state machines for the given cycle period. This
 	 * stops the execution of state machines 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) {
@@ -172,10 +171,10 @@ public class RuntimeService {
 	/**
 	 * Pauses the execution of all state machines which are registered for the
 	 * given cyclePeriod.
-	 * 
+	 *
 	 * @param cyclePeriod
 	 * @return {@code true} if properly paused
-	 * 
+	 *
 	 */
 	public boolean pauseAll(long cyclePeriod) {
 		if (timerTasks.containsKey(cyclePeriod)) {
@@ -188,10 +187,10 @@ public class RuntimeService {
 	/**
 	 * Resumes the execution of all state machines which are registered for the
 	 * given cyclePeriod.
-	 * 
+	 *
 	 * @param cyclePeriod
 	 * @return {@code true} if properly resumed
-	 * 
+	 *
 	 */
 	public boolean resumeAll(long cyclePeriod) {
 		if (timerTasks.containsKey(cyclePeriod)) {

+ 16 - 7
examples/traffic_light/src-gen/traffic/light/TimerService.java

@@ -1,5 +1,4 @@
-/**
-Copyright (c) 2012-2015 committers of YAKINDU and others.
+/** Copyright (c) 2012-2015 committers of YAKINDU and others.
 All rights reserved. This program and the accompanying materials
 are made available under the terms of the Eclipse Public License v1.0
 which accompanies this distribution, and is available at
@@ -7,17 +6,19 @@ http://www.eclipse.org/legal/epl-v10.html
 
 Contributors:
     committers of YAKINDU - initial API and implementation
-�*/
+� */
 package traffic.light;
 
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Timer;
 import java.util.TimerTask;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
 
 /**
  * Default timer service implementation.
- * 
+ *
  */
 public class TimerService implements ITimer {
 
@@ -25,10 +26,12 @@ public class TimerService implements ITimer {
 	
 	private final List<TimeEventTask> timerTaskList = new ArrayList<TimeEventTask>();
 	
+	private final Lock lock = new ReentrantLock();
+	
 	/**
 	 * Timer task that reflects a time event. It's internally used by
 	 * {@link TimerService}.
-	 * 
+	 *
 	 */
 	private class TimeEventTask extends TimerTask {
 	
@@ -38,11 +41,11 @@ public class TimerService implements ITimer {
 	
 		/**
 		 * Constructor for a time event.
-		 * 
+		 *
 		 * @param callback
 		 *            : Set to {@code true} if event should be repeated
 		 *            periodically.
-		 * 
+		 *
 		 * @param eventID
 		 *            : Index position within the state machine's timeEvent
 		 *            array.
@@ -70,6 +73,7 @@ public class TimerService implements ITimer {
 	
 		// Create a new TimerTask for given event and store it.
 		TimeEventTask timerTask = new TimeEventTask(callback, eventID);
+		lock.lock();
 		timerTaskList.add(timerTask);
 	
 		// start scheduling the timer
@@ -78,15 +82,18 @@ public class TimerService implements ITimer {
 		} else {
 			timer.schedule(timerTask, time);
 		}
+		lock.unlock();
 	}
 	
 	public void unsetTimer(ITimerCallback callback, int eventID) {
+		lock.lock();
 		int index = timerTaskList.indexOf(new TimeEventTask(callback, eventID));
 		if (index != -1) {
 			timerTaskList.get(index).cancel();
 			timer.purge();
 			timerTaskList.remove(index);
 		}
+		lock.unlock();
 	}
 	
 	/**
@@ -94,8 +101,10 @@ public class TimerService implements ITimer {
 	 * memory resources.
 	 */
 	public void cancel() {
+		lock.lock();
 		timer.cancel();
 		timer.purge();
+		lock.unlock();
 	}
 }
 

+ 10 - 5
examples/traffic_light/src-gen/traffic/light/trafficlightwaiting/ITrafficLightWaitingStatemachine.java

@@ -1,5 +1,4 @@
-/**
-Copyright (c) 2012-2015 committers of YAKINDU and others.
+/** Copyright (c) 2012-2015 committers of YAKINDU and others.
 All rights reserved. This program and the accompanying materials
 are made available under the terms of the Eclipse Public License v1.0
 which accompanies this distribution, and is available at
@@ -7,12 +6,13 @@ http://www.eclipse.org/legal/epl-v10.html
 
 Contributors:
     committers of YAKINDU - initial API and implementation
-�*/
-package traffic.light.trafficlightwaiting;
+� */
+package traffic.light.trafficlightctrl;
 import traffic.light.IStatemachine;
 import traffic.light.ITimerCallback;
 
-public interface ITrafficLightWaitingStatemachine extends ITimerCallback, IStatemachine {
+public interface ITrafficLightCtrlStatemachine extends ITimerCallback, IStatemachine {
+
 	public interface SCITrafficLight {
 		public boolean getRed();
 		public void setRed(boolean value);
@@ -41,6 +41,11 @@ public interface ITrafficLightWaitingStatemachine extends ITimerCallback, IState
 		public void raisePedestrianRequest();
 		public void raiseOnOff();
 
+		public void setSCInterfaceOperationCallback(SCInterfaceOperationCallback operationCallback);
+	}
+
+	public interface SCInterfaceOperationCallback {
+		public void synchronize();
 	}
 
 	public SCInterface getSCInterface();

+ 279 - 0
examples/traffic_light/src-gen/traffic/light/trafficlightctrl/SynchronizedTrafficLightCtrlStatemachine.java

@@ -0,0 +1,279 @@
+/** Copyright (c) 2012-2015 committers of YAKINDU and others.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+
+Contributors:
+    committers of YAKINDU - initial API and implementation
+� */
+package traffic.light.trafficlightctrl;
+import traffic.light.ITimer;
+import traffic.light.ITimerCallback;
+import traffic.light.trafficlightctrl.TrafficLightCtrlStatemachine.State;
+
+/**
+ * Runnable wrapper of TrafficLightCtrlStatemachine. This wrapper provides a thread-safe
+ * instance of the state machine.
+ * 
+ * Please report bugs and issues...
+ */
+
+public class SynchronizedTrafficLightCtrlStatemachine implements ITrafficLightCtrlStatemachine {
+	
+	/**
+	 * The core state machine is simply wrapped and the event processing will be
+	 * delegated to that state machine instance. This instance will be created
+	 * implicitly.
+	 */
+	protected TrafficLightCtrlStatemachine statemachine = new TrafficLightCtrlStatemachine();
+	
+	/**
+	 * Interface object for SCITrafficLight
+	 */		
+	protected class SynchronizedSCITrafficLight implements SCITrafficLight {
+		
+		public boolean getRed() {
+			synchronized(statemachine) {
+				return statemachine.getSCITrafficLight().getRed();
+			}
+		}
+		
+		public void setRed(final boolean value) {
+			synchronized(statemachine) {
+				statemachine.getSCITrafficLight().setRed(value);
+			}
+		}
+		
+		public boolean getYellow() {
+			synchronized(statemachine) {
+				return statemachine.getSCITrafficLight().getYellow();
+			}
+		}
+		
+		public void setYellow(final boolean value) {
+			synchronized(statemachine) {
+				statemachine.getSCITrafficLight().setYellow(value);
+			}
+		}
+		
+		public boolean getGreen() {
+			synchronized(statemachine) {
+				return statemachine.getSCITrafficLight().getGreen();
+			}
+		}
+		
+		public void setGreen(final boolean value) {
+			synchronized(statemachine) {
+				statemachine.getSCITrafficLight().setGreen(value);
+			}
+		}
+		
+	};
+	
+	protected SCITrafficLight sCITrafficLight;
+	
+	/**
+	 * Interface object for SCIPedestrian
+	 */		
+	protected class SynchronizedSCIPedestrian implements SCIPedestrian {
+		
+		public boolean getRequest() {
+			synchronized(statemachine) {
+				return statemachine.getSCIPedestrian().getRequest();
+			}
+		}
+		
+		public void setRequest(final boolean value) {
+			synchronized(statemachine) {
+				statemachine.getSCIPedestrian().setRequest(value);
+			}
+		}
+		
+		public boolean getRed() {
+			synchronized(statemachine) {
+				return statemachine.getSCIPedestrian().getRed();
+			}
+		}
+		
+		public void setRed(final boolean value) {
+			synchronized(statemachine) {
+				statemachine.getSCIPedestrian().setRed(value);
+			}
+		}
+		
+		public boolean getGreen() {
+			synchronized(statemachine) {
+				return statemachine.getSCIPedestrian().getGreen();
+			}
+		}
+		
+		public void setGreen(final boolean value) {
+			synchronized(statemachine) {
+				statemachine.getSCIPedestrian().setGreen(value);
+			}
+		}
+		
+	};
+	
+	protected SCIPedestrian sCIPedestrian;
+	
+	/**
+	 * Interface object for SCInterface
+	 */		
+	protected class SynchronizedSCInterface implements SCInterface {
+		
+		public void setSCInterfaceOperationCallback(SCInterfaceOperationCallback operationCallback) {
+			synchronized(statemachine) {
+				statemachine.getSCInterface().setSCInterfaceOperationCallback(operationCallback);
+			}
+		}
+		
+		public void raisePedestrianRequest() {
+			
+			synchronized (statemachine) {
+				statemachine.getSCInterface().raisePedestrianRequest();
+				statemachine.runCycle();
+			}
+		}
+		
+		public void raiseOnOff() {
+			
+			synchronized (statemachine) {
+				statemachine.getSCInterface().raiseOnOff();
+				statemachine.runCycle();
+			}
+		}
+		
+	};
+	
+	protected SCInterface sCInterface;
+	
+	public SynchronizedTrafficLightCtrlStatemachine() {
+		sCITrafficLight = new SynchronizedSCITrafficLight();
+		sCIPedestrian = new SynchronizedSCIPedestrian();
+		sCInterface = new SynchronizedSCInterface();
+	}
+	
+	public synchronized SCITrafficLight getSCITrafficLight() {
+		return sCITrafficLight;
+	}
+	public synchronized SCIPedestrian getSCIPedestrian() {
+		return sCIPedestrian;
+	}
+	public synchronized SCInterface getSCInterface() {
+		return sCInterface;
+	}
+	/*================ TIME EVENT HANDLING ================
+	
+	/** An external timer instance is required. */
+	protected ITimer externalTimer;
+	
+	/** Internally we use a timer proxy that queues time events together with other input events. */
+	protected ITimer timerProxy = new ITimer() {
+		/** Simply delegate to external timer with a modified callback. */
+		@Override
+		public void setTimer(ITimerCallback callback, int eventID, long time,
+				boolean isPeriodic) {
+			externalTimer.setTimer(SynchronizedTrafficLightCtrlStatemachine.this, eventID, time, isPeriodic);
+		}
+		
+		@Override
+		public void unsetTimer(ITimerCallback callback, int eventID) {
+			externalTimer.unsetTimer(SynchronizedTrafficLightCtrlStatemachine.this, eventID);
+		}
+	};
+	
+	/**
+	 * Set the {@link ITimer} for the state machine. It must be set externally
+	 * on a timed state machine before a run cycle can be correct executed.
+	 * 
+	 * @param timer
+	 */
+	public void setTimer(ITimer timer) {
+		synchronized(statemachine) {
+			this.externalTimer = timer;
+			/* the wrapped state machine uses timer proxy as timer */
+			statemachine.setTimer(timerProxy);
+		}
+	}
+	
+	/**
+	* Returns the currently used timer.
+	* 
+	* @return {@link ITimer}
+	*/
+	public ITimer getTimer() {
+		return externalTimer;
+	}
+	
+	public void timeElapsed(int eventID) {
+		synchronized (statemachine) {
+			statemachine.timeElapsed(eventID);
+		}
+	}
+	
+	/**
+	 * init() will be delegated thread-safely to the wrapped state machine.
+	 */
+	public void init() {
+		synchronized(statemachine) {
+			statemachine.init();
+		}
+	}
+	
+	/**
+	 * enter() will be delegated thread-safely to the wrapped state machine.
+	 */
+	public void enter() {
+		synchronized(statemachine) {
+			statemachine.enter();
+		}
+	}
+	
+	/**
+	 * exit() will be delegated thread-safely to the wrapped state machine.
+	 */
+	public void exit() {
+		synchronized(statemachine) {
+			statemachine.exit();
+		}
+	}
+	
+	/**
+	 * isActive() will be delegated thread-safely to the wrapped state machine.
+	 */
+	public boolean isActive() {
+		synchronized(statemachine) {
+			return statemachine.isActive();
+		}
+	}
+	
+	/**
+	 * isFinal() will be delegated thread-safely to the wrapped state machine.
+	 */
+	public boolean isFinal() {
+		synchronized(statemachine) {
+			return statemachine.isFinal();
+		}
+	}
+	
+	/**
+	 * 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.
+	 */ 
+	@Override
+	public void runCycle() {
+		synchronized (statemachine) {
+			statemachine.runCycle();
+		}
+	}
+}

+ 163 - 18
examples/traffic_light/src-gen/traffic/light/trafficlightwaiting/TrafficLightWaitingStatemachine.java

@@ -1,5 +1,4 @@
-/**
-Copyright (c) 2012-2015 committers of YAKINDU and others.
+/** Copyright (c) 2012-2015 committers of YAKINDU and others.
 All rights reserved. This program and the accompanying materials
 are made available under the terms of the Eclipse Public License v1.0
 which accompanies this distribution, and is available at
@@ -7,11 +6,11 @@ http://www.eclipse.org/legal/epl-v10.html
 
 Contributors:
     committers of YAKINDU - initial API and implementation
-�*/
-package traffic.light.trafficlightwaiting;
+� */
+package traffic.light.trafficlightctrl;
 import traffic.light.ITimer;
 
-public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStatemachine {
+public class TrafficLightCtrlStatemachine implements ITrafficLightCtrlStatemachine {
 
 	protected class SCITrafficLightImpl implements SCITrafficLight {
 
@@ -87,6 +86,12 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 
 	protected class SCInterfaceImpl implements SCInterface {
 
+		private SCInterfaceOperationCallback operationCallback;
+
+		public void setSCInterfaceOperationCallback(SCInterfaceOperationCallback operationCallback) {
+			this.operationCallback = operationCallback;
+		}
+
 		private boolean pedestrianRequest;
 
 		public void raisePedestrianRequest() {
@@ -111,7 +116,7 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 	private boolean initialized = false;
 
 	public enum State {
-		main_region_on, main_region_on_r1_StreetGreen, main_region_on_r1_PedWaiting, main_region_on_r1_PedWaiting_r1_waitOn, main_region_on_r1_PedWaiting_r1_waitOff, main_region_on_r1_StreetAttention, main_region_on_r1_StreetRed, main_region_on_r1_PedestrianGreen, main_region_on_r1_PedestrianRed, main_region_on_r1_StreetPrepare, main_region_off, main_region_off_r1_YellowOn, main_region_off_r1_YellowOff, $NullState$
+		main_region_on, main_region_on_r1_StreetGreen, main_region_on_r1_PedWaiting, main_region_on_r1_PedWaiting_r1_waitOn, main_region_on_r1_PedWaiting_r1_waitOff, main_region_on_r1_StreetAttention, main_region_on_r1_StreetRed, main_region_on_r1_PedestrianGreen, main_region_on_r1_PedestrianRed, main_region_on_r1_StreetPrepare, main_region_on_r1_Safe, main_region_off, main_region_off_r1_YellowOn, main_region_off_r1_YellowOff, $NullState$
 	};
 
 	private final State[] stateVector = new State[1];
@@ -120,9 +125,9 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 
 	private ITimer timer;
 
-	private final boolean[] timeEvents = new boolean[10];
+	private final boolean[] timeEvents = new boolean[12];
 
-	public TrafficLightWaitingStatemachine() {
+	public TrafficLightCtrlStatemachine() {
 
 		sCITrafficLight = new SCITrafficLightImpl();
 		sCIPedestrian = new SCIPedestrianImpl();
@@ -162,11 +167,15 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 		if (timer == null) {
 			throw new IllegalStateException("timer not set.");
 		}
+		entryAction();
+
 		enterSequence_main_region_default();
 	}
 
 	public void exit() {
 		exitSequence_main_region();
+
+		exitAction();
 	}
 
 	/**
@@ -180,7 +189,7 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 	/** 
 	* Always returns 'false' since this state machine can never become final.
 	*
-	 * @see IStatemachine#isFinal() 
+	 * @see IStatemachine#isFinal()
 	 */
 	public boolean isFinal() {
 		return false;
@@ -210,7 +219,7 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 		switch (state) {
 			case main_region_on :
 				return stateVector[0].ordinal() >= State.main_region_on.ordinal()
-						&& stateVector[0].ordinal() <= State.main_region_on_r1_StreetPrepare.ordinal();
+						&& stateVector[0].ordinal() <= State.main_region_on_r1_Safe.ordinal();
 			case main_region_on_r1_StreetGreen :
 				return stateVector[0] == State.main_region_on_r1_StreetGreen;
 			case main_region_on_r1_PedWaiting :
@@ -230,6 +239,8 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 				return stateVector[0] == State.main_region_on_r1_PedestrianRed;
 			case main_region_on_r1_StreetPrepare :
 				return stateVector[0] == State.main_region_on_r1_StreetPrepare;
+			case main_region_on_r1_Safe :
+				return stateVector[0] == State.main_region_on_r1_Safe;
 			case main_region_off :
 				return stateVector[0].ordinal() >= State.main_region_off.ordinal()
 						&& stateVector[0].ordinal() <= State.main_region_off_r1_YellowOff.ordinal();
@@ -283,6 +294,10 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 		sCInterface.raiseOnOff();
 	}
 
+	private boolean check__lr0() {
+		return timeEvents[11];
+	}
+
 	private boolean check_main_region_on_tr0_tr0() {
 		return sCInterface.onOff;
 	}
@@ -323,16 +338,24 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 		return timeEvents[7];
 	}
 
+	private boolean check_main_region_on_r1_Safe_tr0_tr0() {
+		return timeEvents[8];
+	}
+
 	private boolean check_main_region_off_tr0_tr0() {
 		return sCInterface.onOff;
 	}
 
 	private boolean check_main_region_off_r1_YellowOn_tr0_tr0() {
-		return timeEvents[8];
+		return timeEvents[9];
 	}
 
 	private boolean check_main_region_off_r1_YellowOff_tr0_tr0() {
-		return timeEvents[9];
+		return timeEvents[10];
+	}
+
+	private void effect__lr0() {
+		sCInterface.operationCallback.synchronize();
 	}
 
 	private void effect_main_region_on_tr0() {
@@ -395,6 +418,12 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 		enterSequence_main_region_on_r1_StreetGreen_default();
 	}
 
+	private void effect_main_region_on_r1_Safe_tr0() {
+		exitSequence_main_region_on_r1_Safe();
+
+		enterSequence_main_region_on_r1_StreetPrepare_default();
+	}
+
 	private void effect_main_region_off_tr0() {
 		exitSequence_main_region_off();
 
@@ -413,6 +442,12 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 		enterSequence_main_region_off_r1_YellowOn_default();
 	}
 
+	/* Entry action for statechart 'TrafficLightCtrl'. */
+	private void entryAction() {
+
+		timer.setTimer(this, 11, 200, true);
+	}
+
 	/* Entry action for state 'StreetGreen'. */
 	private void entryAction_main_region_on_r1_StreetGreen() {
 		sCITrafficLight.setRed(false);
@@ -506,6 +541,24 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 		sCITrafficLight.setGreen(false);
 	}
 
+	/* Entry action for state 'Safe'. */
+	private void entryAction_main_region_on_r1_Safe() {
+
+		timer.setTimer(this, 8, 10 * 1000, false);
+
+		sCITrafficLight.setRed(true);
+
+		sCITrafficLight.setYellow(false);
+
+		sCITrafficLight.setGreen(false);
+
+		sCIPedestrian.setRed(true);
+
+		sCIPedestrian.setGreen(false);
+
+		sCIPedestrian.setRequest(false);
+	}
+
 	/* Entry action for state 'off'. */
 	private void entryAction_main_region_off() {
 		sCITrafficLight.setRed(false);
@@ -522,7 +575,7 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 	/* Entry action for state 'YellowOn'. */
 	private void entryAction_main_region_off_r1_YellowOn() {
 
-		timer.setTimer(this, 8, 500, false);
+		timer.setTimer(this, 9, 500, false);
 
 		sCITrafficLight.setYellow(true);
 
@@ -532,13 +585,18 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 	/* Entry action for state 'YellowOff'. */
 	private void entryAction_main_region_off_r1_YellowOff() {
 
-		timer.setTimer(this, 9, 500, false);
+		timer.setTimer(this, 10, 500, false);
 
 		sCITrafficLight.setYellow(false);
 
 		sCIPedestrian.setRequest(false);
 	}
 
+	/* Exit action for state 'TrafficLightCtrl'. */
+	private void exitAction() {
+		timer.unsetTimer(this, 11);
+	}
+
 	/* Exit action for state 'PedWaiting'. */
 	private void exitAction_main_region_on_r1_PedWaiting() {
 		timer.unsetTimer(this, 0);
@@ -581,14 +639,19 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 		timer.unsetTimer(this, 7);
 	}
 
+	/* Exit action for state 'Safe'. */
+	private void exitAction_main_region_on_r1_Safe() {
+		timer.unsetTimer(this, 8);
+	}
+
 	/* Exit action for state 'YellowOn'. */
 	private void exitAction_main_region_off_r1_YellowOn() {
-		timer.unsetTimer(this, 8);
+		timer.unsetTimer(this, 9);
 	}
 
 	/* Exit action for state 'YellowOff'. */
 	private void exitAction_main_region_off_r1_YellowOff() {
-		timer.unsetTimer(this, 9);
+		timer.unsetTimer(this, 10);
 	}
 
 	/* 'default' enter sequence for state on */
@@ -667,6 +730,14 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 		stateVector[0] = State.main_region_on_r1_StreetPrepare;
 	}
 
+	/* 'default' enter sequence for state Safe */
+	private void enterSequence_main_region_on_r1_Safe_default() {
+		entryAction_main_region_on_r1_Safe();
+
+		nextStateIndex = 0;
+		stateVector[0] = State.main_region_on_r1_Safe;
+	}
+
 	/* 'default' enter sequence for state off */
 	private void enterSequence_main_region_off_default() {
 		entryAction_main_region_off();
@@ -784,6 +855,14 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 		exitAction_main_region_on_r1_StreetPrepare();
 	}
 
+	/* Default exit sequence for state Safe */
+	private void exitSequence_main_region_on_r1_Safe() {
+		nextStateIndex = 0;
+		stateVector[0] = State.$NullState$;
+
+		exitAction_main_region_on_r1_Safe();
+	}
+
 	/* Default exit sequence for state off */
 	private void exitSequence_main_region_off() {
 		exitSequence_main_region_off_r1();
@@ -844,6 +923,10 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 				exitSequence_main_region_on_r1_StreetPrepare();
 				break;
 
+			case main_region_on_r1_Safe :
+				exitSequence_main_region_on_r1_Safe();
+				break;
+
 			case main_region_off_r1_YellowOn :
 				exitSequence_main_region_off_r1_YellowOn();
 				break;
@@ -896,6 +979,10 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 				exitSequence_main_region_on_r1_StreetPrepare();
 				break;
 
+			case main_region_on_r1_Safe :
+				exitSequence_main_region_on_r1_Safe();
+				break;
+
 			default :
 				break;
 		}
@@ -935,6 +1022,10 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 
 	/* The reactions of state StreetGreen. */
 	private void react_main_region_on_r1_StreetGreen() {
+		if (check__lr0()) {
+			effect__lr0();
+		}
+
 		if (check_main_region_on_tr0_tr0()) {
 			effect_main_region_on_tr0();
 		} else {
@@ -946,6 +1037,10 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 
 	/* The reactions of state waitOn. */
 	private void react_main_region_on_r1_PedWaiting_r1_waitOn() {
+		if (check__lr0()) {
+			effect__lr0();
+		}
+
 		if (check_main_region_on_tr0_tr0()) {
 			effect_main_region_on_tr0();
 		} else {
@@ -961,6 +1056,10 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 
 	/* The reactions of state waitOff. */
 	private void react_main_region_on_r1_PedWaiting_r1_waitOff() {
+		if (check__lr0()) {
+			effect__lr0();
+		}
+
 		if (check_main_region_on_tr0_tr0()) {
 			effect_main_region_on_tr0();
 		} else {
@@ -976,6 +1075,10 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 
 	/* The reactions of state StreetAttention. */
 	private void react_main_region_on_r1_StreetAttention() {
+		if (check__lr0()) {
+			effect__lr0();
+		}
+
 		if (check_main_region_on_tr0_tr0()) {
 			effect_main_region_on_tr0();
 		} else {
@@ -987,6 +1090,10 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 
 	/* The reactions of state StreetRed. */
 	private void react_main_region_on_r1_StreetRed() {
+		if (check__lr0()) {
+			effect__lr0();
+		}
+
 		if (check_main_region_on_tr0_tr0()) {
 			effect_main_region_on_tr0();
 		} else {
@@ -998,6 +1105,10 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 
 	/* The reactions of state PedestrianGreen. */
 	private void react_main_region_on_r1_PedestrianGreen() {
+		if (check__lr0()) {
+			effect__lr0();
+		}
+
 		if (check_main_region_on_tr0_tr0()) {
 			effect_main_region_on_tr0();
 		} else {
@@ -1009,6 +1120,10 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 
 	/* The reactions of state PedestrianRed. */
 	private void react_main_region_on_r1_PedestrianRed() {
+		if (check__lr0()) {
+			effect__lr0();
+		}
+
 		if (check_main_region_on_tr0_tr0()) {
 			effect_main_region_on_tr0();
 		} else {
@@ -1020,6 +1135,10 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 
 	/* The reactions of state StreetPrepare. */
 	private void react_main_region_on_r1_StreetPrepare() {
+		if (check__lr0()) {
+			effect__lr0();
+		}
+
 		if (check_main_region_on_tr0_tr0()) {
 			effect_main_region_on_tr0();
 		} else {
@@ -1029,8 +1148,27 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 		}
 	}
 
+	/* The reactions of state Safe. */
+	private void react_main_region_on_r1_Safe() {
+		if (check__lr0()) {
+			effect__lr0();
+		}
+
+		if (check_main_region_on_tr0_tr0()) {
+			effect_main_region_on_tr0();
+		} else {
+			if (check_main_region_on_r1_Safe_tr0_tr0()) {
+				effect_main_region_on_r1_Safe_tr0();
+			}
+		}
+	}
+
 	/* The reactions of state YellowOn. */
 	private void react_main_region_off_r1_YellowOn() {
+		if (check__lr0()) {
+			effect__lr0();
+		}
+
 		if (check_main_region_off_tr0_tr0()) {
 			effect_main_region_off_tr0();
 		} else {
@@ -1042,6 +1180,10 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 
 	/* The reactions of state YellowOff. */
 	private void react_main_region_off_r1_YellowOff() {
+		if (check__lr0()) {
+			effect__lr0();
+		}
+
 		if (check_main_region_off_tr0_tr0()) {
 			effect_main_region_off_tr0();
 		} else {
@@ -1053,7 +1195,7 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 
 	/* Default react sequence for initial entry  */
 	private void react_main_region__entry_Default() {
-		enterSequence_main_region_on_default();
+		enterSequence_main_region_off_default();
 	}
 
 	/* Default react sequence for initial entry  */
@@ -1063,7 +1205,7 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 
 	/* Default react sequence for initial entry  */
 	private void react_main_region_on_r1__entry_Default() {
-		enterSequence_main_region_on_r1_StreetGreen_default();
+		enterSequence_main_region_on_r1_Safe_default();
 	}
 
 	/* Default react sequence for initial entry  */
@@ -1105,6 +1247,9 @@ public class TrafficLightWaitingStatemachine implements ITrafficLightWaitingStat
 				case main_region_on_r1_StreetPrepare :
 					react_main_region_on_r1_StreetPrepare();
 					break;
+				case main_region_on_r1_Safe :
+					react_main_region_on_r1_Safe();
+					break;
 				case main_region_off_r1_YellowOn :
 					react_main_region_off_r1_YellowOn();
 					break;

+ 1 - 1
examples/trafficlight_example/src/trafficlight_example/ButtonPanel.java

@@ -8,7 +8,7 @@
  * 	committers of YAKINDU - initial API and implementation
  * 
  */
-package trafficlight_example;
+package traffic.light;
 
 import java.awt.BorderLayout;
 

+ 96 - 0
examples/traffic_light/src/traffic/light/CrossWalkPanel.java

@@ -0,0 +1,96 @@
+package traffic.light;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Point;
+
+import javax.swing.JPanel;
+
+import traffic.light.TrafficLight.Alignment;
+
+public class CrossWalkPanel extends JPanel {
+
+	private static final long serialVersionUID = -7137708533029709629L;
+	protected TrafficLight trafficLight;
+	protected PedestrianLight pedLight;
+
+	
+	public CrossWalkPanel() {
+		super();
+		trafficLight = new TrafficLight(Alignment.HORIZONTAL);
+		pedLight = new PedestrianLight(PedestrianLight.Alignment.VERTICAL);
+	}
+	
+	public TrafficLight getTrafficLight() {
+		return trafficLight;
+	}
+
+	public PedestrianLight getPedLight() {
+		return pedLight;
+	}
+
+	public void paint(Graphics g) {
+		paintCrossing(g);
+		paintTrafficLights(g);
+		paintPedestrainLights(g);
+		g.dispose();
+	}
+
+	protected void paintPedestrainLights(Graphics g) {
+		pedLight.updatePosition(new Point(210, 80));
+		pedLight.paint(g);
+	}
+
+	protected void paintTrafficLights(Graphics g) {
+		trafficLight.updatePosition(new Point(170, 280));
+		trafficLight.paint(g);
+	}
+
+	protected void paintCrossing(Graphics g) {
+	
+		int width = getSize().width;
+
+		int streetYOffset = 150;
+		int streetWidth = 100;
+		
+		Dimension streetEastWest = new Dimension(width, streetWidth);
+		g.setColor(Color.darkGray);
+		paint(streetEastWest, 0, streetYOffset, true, g);
+
+		
+		g.setColor(Color.white);
+
+		Dimension laneSeparator = new Dimension(20, 4);
+		for (int i=0; i<4; i++) {
+			paint(laneSeparator, i * 2 * laneSeparator.width , streetYOffset -2 + streetWidth / 2, true, g);			
+		}
+
+		Dimension stopLine = new Dimension(10, streetWidth/2 +2);
+		paint(stopLine, 7 * laneSeparator.width , streetYOffset -2 + streetWidth / 2, true, g);			
+		
+		Dimension zebraStripe = new Dimension(80, 10);
+		
+		paint(zebraStripe, 9 * laneSeparator.width , streetYOffset + 5, true, g);			
+		paint(zebraStripe, 9 * laneSeparator.width , streetYOffset + 25 , true, g);			
+		paint(zebraStripe, 9 * laneSeparator.width , streetYOffset + 45 , true, g);			
+		paint(zebraStripe, 9 * laneSeparator.width , streetYOffset + 65 , true, g);			
+		paint(zebraStripe, 9 * laneSeparator.width , streetYOffset + 85 , true, g);		
+		
+		
+		paint(stopLine, 11 * laneSeparator.width + zebraStripe.width - stopLine.width, streetYOffset, true, g);			
+
+		for (int i=0; i<4; i++) {
+			paint(laneSeparator, (i * 2 + 11) * laneSeparator.width + zebraStripe.width, streetYOffset -2 + streetWidth / 2, true, g);			
+		}	
+	
+	}
+
+	
+	protected void paint(Dimension area, int x, int y, boolean horizontally, Graphics g) {
+		g.fillRect(x, y, 
+				horizontally ? area.width : area.height, 
+				horizontally ? area.height : area.width);
+
+	}
+}

+ 125 - 0
examples/traffic_light/src/traffic/light/CrossingPanel.java

@@ -0,0 +1,125 @@
+/**
+ * Copyright (c) 2016 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package traffic.light;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Point;
+
+import traffic.light.TrafficLight.Alignment;
+
+/**
+ * 
+ * @author Tesch
+ *
+ */
+
+public class CrossingPanel extends CrossWalkPanel {
+
+	private static final long serialVersionUID = 2709756259645789247L;
+	
+	protected TrafficLight trafficLightWest;
+	protected TrafficLight trafficLightNorth;
+	protected TrafficLight trafficLightSouth;
+	protected PedestrianLight pedlightNorth;
+	
+	public CrossingPanel() {
+		super();
+		
+		trafficLightWest = new TrafficLight(Alignment.HORIZONTAL);
+		trafficLightNorth = new TrafficLight(Alignment.VERTICAL);
+		trafficLightSouth = new TrafficLight(Alignment.VERTICAL);
+		pedlightNorth = new PedestrianLight(PedestrianLight.Alignment.HORIZONTAL);
+	}
+
+	@Override
+	protected void paintTrafficLights(Graphics g) {
+		super.paintTrafficLights(g);
+		
+		trafficLightWest.updatePosition(new Point(25, 150));
+		trafficLightWest.paint(g);
+
+		trafficLightNorth.updatePosition(new Point(350, 25));
+		trafficLightNorth.paint(g);
+
+		trafficLightSouth.updatePosition(new Point(150, 425));
+		trafficLightSouth.paint(g);
+	}
+
+	@Override
+	protected void paintPedestrainLights(Graphics g) {
+		super.paintPedestrainLights(g);
+		
+		pedlightNorth.updatePosition(new Point(175, 25));
+		pedlightNorth.paint(g);
+	}
+	
+	@Override
+	protected void paintCrossing(Graphics g) {
+		
+		int breite = getSize().width;
+		int hoehe = getSize().height;
+	
+		g.setColor(Color.darkGray);
+		g.fillRect(225, 0, 100, hoehe);
+	
+		g.setColor(Color.darkGray);
+		g.fillRect(0, 225, breite, 100);
+	
+		g.setColor(Color.white);
+		g.fillRect(270, 0, 10, hoehe);
+	
+		g.setColor(Color.white);
+		g.fillRect(0, 270, breite, 10);
+	
+		g.setColor(Color.darkGray);
+		g.fillRect(225, 225, 100, 100);
+	
+		g.setColor(Color.white);
+		g.fillRect(225, 225, 100, 100);
+	
+		g.setColor(Color.darkGray);
+		g.fillRect(235, 235, 80, 80);
+	
+		g.setColor(Color.white);
+	
+		g.fillRect(230, 30, 10, 50);
+		g.fillRect(230 + 20, 30, 10, 50);
+		g.fillRect(230 + 40, 30, 10, 50);
+		g.fillRect(230 + 60, 30, 10, 50);
+		g.fillRect(230 + 80, 30, 10, 50);
+	
+		g.setColor(Color.white);
+		g.fillRect(475, 230, 50, 10);
+		g.fillRect(475, 230 + 20, 50, 10);
+		g.fillRect(475, 230 + 40, 50, 10);
+		g.fillRect(475, 230 + 60, 50, 10);
+		g.fillRect(475, 230 + 80, 50, 10);
+	
+	}
+
+
+	public TrafficLight getTrafficLightWest() {
+		return trafficLightWest;
+	}
+
+	public TrafficLight getTrafficLightNorth() {
+		return trafficLightNorth;
+	}
+
+	public TrafficLight getTrafficLightSouth() {
+		return trafficLightSouth;
+	}
+
+	public PedestrianLight getPedLightNorth() {
+		return pedlightNorth;
+	}
+}

+ 4 - 4
examples/trafficlight_example/src/trafficlight_example/PedestrianLight.java

@@ -8,7 +8,7 @@
  * 	committers of YAKINDU - initial API and implementation
  * 
  */
-package trafficlight_example;
+package traffic.light;
 
 import java.awt.Color;
 import java.awt.Graphics;
@@ -33,7 +33,7 @@ public class PedestrianLight extends JPanel {
 	private Alignment alignment;
 
 	public enum Alignment {
-		HORIZONTAL(25, 50), VERTICAL(50, 25);
+		HORIZONTAL(50, 25), VERTICAL(25, 50);
 
 		private int width;
 		private int height;
@@ -91,7 +91,7 @@ public class PedestrianLight extends JPanel {
 		graphics.setColor(Color.black);
 		graphics.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
 
-		if (alignment == Alignment.VERTICAL) {
+		if (alignment == Alignment.HORIZONTAL) {
 
 			graphics.setColor(white ? Color.white : Color.black);
 			graphics.fillRect(bounds.x + ((bounds.width - (3 * (bounds.height / 3))) / 4),
@@ -106,7 +106,7 @@ public class PedestrianLight extends JPanel {
 					bounds.x + (3 * ((bounds.width - (3 * (bounds.height / 3))) / 4)) + (2 * (bounds.height / 3)),
 					bounds.y + ((bounds.width - (3 * (bounds.height / 3))) / 4), bounds.width / 4, bounds.width / 4);
 
-		} else if (alignment == Alignment.HORIZONTAL) {
+		} else if (alignment == Alignment.VERTICAL) {
 
 			graphics.setColor(white ? Color.white : Color.black);
 			graphics.fillRect(bounds.x + 7, bounds.y + 2, bounds.height / 4, bounds.height / 4);

+ 1 - 1
examples/trafficlight_example/src/trafficlight_example/TrafficLight.java

@@ -8,7 +8,7 @@
  * 	committers of YAKINDU - initial API and implementation
  * 
  */
-package trafficlight_example;
+package traffic.light;
 
 import java.awt.Color;
 import java.awt.Graphics;

+ 97 - 0
examples/traffic_light/src/traffic/light/TrafficlightDemo.java

@@ -0,0 +1,97 @@
+/**
+ * Copyright (c) 2016 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package traffic.light;
+
+import java.awt.BorderLayout;
+import java.awt.Graphics;
+
+import javax.swing.JFrame;
+
+import traffic.light.trafficlightctrl.ITrafficLightCtrlStatemachine;
+import traffic.light.trafficlightctrl.SynchronizedTrafficLightCtrlStatemachine;
+
+/**
+ * 
+ * @author Tesch
+ *
+ */
+
+public class TrafficlightDemo extends JFrame {
+
+	private static final long serialVersionUID = -8909693541678814631L;
+
+	protected SynchronizedTrafficLightCtrlStatemachine statemachine;
+
+	protected TimerService timer;
+
+	private CrossWalkPanel crossing;
+
+	private ButtonPanel buttonPanel;
+
+	public static void main(String[] args) {
+		TrafficlightDemo application = new TrafficlightDemo();
+		application.createContents();
+		application.setupStatemachine();
+		application.run();
+	}
+
+	protected void run() {
+		statemachine.enter();
+		RuntimeService.getInstance().registerStatemachine(statemachine, 100);
+	}
+
+	protected void createContents() {
+		setLayout(new BorderLayout());
+		setTitle("Crosswalk traffic light");
+		crossing = new CrossWalkPanel();
+		add(BorderLayout.CENTER, crossing);
+		buttonPanel = new ButtonPanel();
+		add(BorderLayout.SOUTH, buttonPanel);
+		setSize(440, 440);
+		setVisible(true);
+	}
+
+	@Override
+	public void paint(Graphics g) {
+		super.paint(g);
+	}
+
+	protected void setupStatemachine() {
+		statemachine = new SynchronizedTrafficLightCtrlStatemachine();
+		timer = new TimerService();
+		statemachine.setTimer(timer);
+		statemachine.getSCInterface().setSCInterfaceOperationCallback(new ITrafficLightCtrlStatemachine.SCInterfaceOperationCallback() {
+			@Override
+			public void synchronize() {
+				checkTrafficLightStates();
+				repaint();
+			}
+		});
+		
+		statemachine.init();
+
+		buttonPanel.getPedestrianRequest()
+				.addActionListener(e -> statemachine.getSCInterface().raisePedestrianRequest());
+		buttonPanel.getOnOff().addActionListener(e -> statemachine.getSCInterface().raiseOnOff());
+	}
+
+	
+	protected void checkTrafficLightStates() {
+
+		crossing.getTrafficLight().setRed(statemachine.getSCITrafficLight().getRed());
+		crossing.getTrafficLight().setYellow(statemachine.getSCITrafficLight().getYellow());
+		crossing.getTrafficLight().setGreen(statemachine.getSCITrafficLight().getGreen());
+
+		crossing.getPedLight().setRed(statemachine.getSCIPedestrian().getRed());
+		crossing.getPedLight().setGreen(statemachine.getSCIPedestrian().getGreen());
+		crossing.getPedLight().setWhite(statemachine.getSCIPedestrian().getRequest());
+	}
+}

+ 0 - 7
examples/trafficlight_example/.classpath

@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
-	<classpathentry kind="src" path="src-gen"/>
-	<classpathentry kind="output" path="bin"/>
-</classpath>

+ 0 - 23
examples/trafficlight_example/.project

@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-	<name>trafficlight_example</name>
-	<comment></comment>
-	<projects>
-	</projects>
-	<buildSpec>
-		<buildCommand>
-			<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-		<buildCommand>
-			<name>org.eclipse.jdt.core.javabuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-	</buildSpec>
-	<natures>
-		<nature>org.eclipse.jdt.core.javanature</nature>
-		<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
-	</natures>
-</projectDescription>

+ 0 - 2
examples/trafficlight_example/bin/.gitignore

@@ -1,2 +0,0 @@
-/org/
-/trafficlight_example/

Разница между файлами не показана из-за своего большого размера
+ 0 - 549
examples/trafficlight_example/model/TrafficLightWaiting.sct


+ 0 - 19
examples/trafficlight_example/model/default2.sgen

@@ -1,19 +0,0 @@
-GeneratorModel for yakindu::java {
-
-	statechart TrafficLightWaiting {
-
-		feature Outlet {
-			targetProject = "trafficlight_example"
-			targetFolder = "src-gen"
-			libraryTargetFolder = "src"
-		}
-		
-		feature GeneralFeatures {
-			InterfaceObserverSupport = false
-			RuntimeService = true
-			TimerService = true
-			UseJavaIntForInteger = false
-		}
-		
-	}
-}

+ 0 - 7
examples/trafficlight_example/readme.txt

@@ -1,7 +0,0 @@
-The Trafficlight example contains a simple Swing based Java GUI to
-demonstrate the state machine behaviour in /model/TrafficLightWaiting.sct
-
-To start the application run src/trafficlight_example/TrafficlightDemo.java
-
-The example requires Java 8.
-

+ 0 - 207
examples/trafficlight_example/src-gen/org/yakindu/scr/RuntimeService.java

@@ -1,207 +0,0 @@
-package org.yakindu.scr;
-
-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;
-		}
-	}
-}

+ 0 - 91
examples/trafficlight_example/src-gen/org/yakindu/scr/TimerService.java

@@ -1,91 +0,0 @@
-package org.yakindu.scr;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Timer;
-import java.util.TimerTask;
-
-/**
- * Default timer service implementation.
- * 
- */
-public class TimerService implements ITimer {
-
-	private final Timer timer = new Timer();
-	
-	private final List<TimeEventTask> timerTaskList = new ArrayList<TimeEventTask>();
-	
-	/**
-	 * Timer task that reflects a time event. It's internally used by
-	 * {@link TimerService}.
-	 * 
-	 */
-	private class TimeEventTask extends TimerTask {
-	
-		private ITimerCallback callback;
-	
-		int eventID;
-	
-		/**
-		 * Constructor for a time event.
-		 * 
-		 * @param callback
-		 *            : Set to {@code true} if event should be repeated
-		 *            periodically.
-		 * 
-		 * @param eventID
-		 *            : Index position within the state machine's timeEvent
-		 *            array.
-		 */
-		public TimeEventTask(ITimerCallback callback, int eventID) {
-			this.callback = callback;
-			this.eventID = eventID;
-		}
-	
-		public void run() {
-			callback.timeElapsed(eventID);
-		}
-	
-		public boolean equals(Object obj) {
-			if (obj instanceof TimeEventTask) {
-				return ((TimeEventTask) obj).callback.equals(callback)
-						&& ((TimeEventTask) obj).eventID == eventID;
-			}
-			return super.equals(obj);
-		}
-	}
-	
-	public void setTimer(final ITimerCallback callback, final int eventID,
-			long time, boolean isPeriodic) {
-	
-		// Create a new TimerTask for given event and store it.
-		TimeEventTask timerTask = new TimeEventTask(callback, eventID);
-		timerTaskList.add(timerTask);
-	
-		// start scheduling the timer
-		if (isPeriodic) {
-			timer.scheduleAtFixedRate(timerTask, time, time);
-		} else {
-			timer.schedule(timerTask, time);
-		}
-	}
-	
-	public void unsetTimer(ITimerCallback callback, int eventID) {
-		int index = timerTaskList.indexOf(new TimeEventTask(callback, eventID));
-		if (index != -1) {
-			timerTaskList.get(index).cancel();
-			timer.purge();
-			timerTaskList.remove(index);
-		}
-	}
-	
-	/**
-	 * Cancel timer service. Use this to end possible timing threads and free
-	 * memory resources.
-	 */
-	public void cancel() {
-		timer.cancel();
-		timer.purge();
-	}
-}
-

+ 0 - 38
examples/trafficlight_example/src-gen/org/yakindu/scr/trafficlightwaiting/ITrafficLightWaitingStatemachine.java

@@ -1,38 +0,0 @@
-package org.yakindu.scr.trafficlightwaiting;
-import org.yakindu.scr.IStatemachine;
-import org.yakindu.scr.ITimerCallback;
-
-public interface ITrafficLightWaitingStatemachine extends ITimerCallback, 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();
-
-}

Разница между файлами не показана из-за своего большого размера
+ 0 - 1111
examples/trafficlight_example/src-gen/org/yakindu/scr/trafficlightwaiting/TrafficLightWaitingStatemachine.java


+ 0 - 39
examples/trafficlight_example/src/org/yakindu/scr/IStatemachine.java

@@ -1,39 +0,0 @@
-package org.yakindu.scr;
-
-/**
- * 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();
-
-	/**
-	 * Checks if the statemachine is active. 
-	 * A statemachine is active if it was entered. It is inactive if it has not been entered at all or if it was exited.
-	 */
-	public boolean isActive();
-
-	/**
-	 * Checks if all active states are final. 
-	 * If there are no active states then the statemachine is considered as incative and this method returns false.
-	 */
-	public boolean isFinal();
-
-	/**
-	* Start a run-to-completion cycle.
-	*/
-	public void runCycle();
-}

+ 0 - 38
examples/trafficlight_example/src/org/yakindu/scr/ITimer.java

@@ -1,38 +0,0 @@
-package org.yakindu.scr;
-
-/**
- * Interface a timer has to implement. Use to implement your own timer
- * service.
- * 
- */
-public interface ITimer {
-
-	/**
-	 * Starts the timing for a given time event id.
-	 * 
-	 * @param callback
-	 * 			  : The target callback where the time event has to be raised.
-	 * 
-	 * @param eventID
-	 *            : The eventID the timer should use if timed out.
-	 *            
-	 * @param time
-	 *            : Time in milliseconds after the given time event should be
-	 *            triggered
-	 *            
-	 * @param isPeriodic
-	 * 			  : Set to true if the time event should be triggered periodically
-	 */
-	public void setTimer(ITimerCallback callback, int eventID, long time, boolean isPeriodic);
-
-	/**
-	 * Unset a time event.
-	 * 
-	 * @param callback
-	 * 			: The target callback for which the time event has to be unset.
-	 * 
-	 * @param eventID
-	 * 			: The time event id.
-	 */
-	public void unsetTimer(ITimerCallback callback, int eventID);
-}

+ 0 - 15
examples/trafficlight_example/src/org/yakindu/scr/ITimerCallback.java

@@ -1,15 +0,0 @@
-package org.yakindu.scr;
-
-/**
-* Interface for state machines which use timed event triggers.
-*/
-public interface ITimerCallback {
-	
-	/**
-	* Callback method if a time event occurred.
-	* 
-	* @param eventID
-	* 			:The id of the occurred event.
-	*/
-	public void timeElapsed(int eventID);
-}

+ 0 - 141
examples/trafficlight_example/src/trafficlight_example/CrossingPanel.java

@@ -1,141 +0,0 @@
-/**
- * Copyright (c) 2016 committers of YAKINDU and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * Contributors:
- * 	committers of YAKINDU - initial API and implementation
- * 
- */
-package trafficlight_example;
-
-import java.awt.Color;
-import java.awt.Graphics;
-import java.awt.Point;
-
-import javax.swing.JPanel;
-
-import trafficlight_example.TrafficLight.Alignment;
-
-/**
- * 
- * @author Tesch
- *
- */
-
-public class CrossingPanel extends JPanel {
-
-	private static final long serialVersionUID = 2709756259645789247L;
-	private TrafficLight light1;
-	private TrafficLight light2;
-	private TrafficLight light3;
-	private TrafficLight light4;
-	private PedestrianLight light5;
-	private PedestrianLight light6;
-
-	public CrossingPanel() {
-		light1 = new TrafficLight(Alignment.HORIZONTAL);
-		light2 = new TrafficLight(Alignment.VERTICAL);
-		light3 = new TrafficLight(Alignment.HORIZONTAL);
-		light4 = new TrafficLight(Alignment.VERTICAL);
-		light5 = new PedestrianLight(trafficlight_example.PedestrianLight.Alignment.HORIZONTAL);
-		light6 = new PedestrianLight(trafficlight_example.PedestrianLight.Alignment.VERTICAL);
-	}
-
-	public void paint(Graphics g) {
-		paintCrossing(g);
-		paintTrafficLights(g);
-		paintPedestrainLights(g);
-		g.dispose();
-	}
-
-	private void paintTrafficLights(Graphics g) {
-		light1.updatePosition(new Point(25, 150));
-		light1.paint(g);
-
-		light2.updatePosition(new Point(350, 25));
-		light2.paint(g);
-
-		light3.updatePosition(new Point(425, 350));
-		light3.paint(g);
-
-		light4.updatePosition(new Point(150, 425));
-		light4.paint(g);
-	}
-
-	private void paintPedestrainLights(Graphics g) {
-		light5.updatePosition(new Point(175, 25));
-		light5.paint(g);
-
-		light6.updatePosition(new Point(475, 175));
-		light6.paint(g);
-	}
-
-	private void paintCrossing(Graphics g) {
-
-		int breite = getSize().width;
-		int hoehe = getSize().height;
-
-		g.setColor(Color.darkGray);
-		g.fillRect(225, 0, 100, hoehe);
-
-		g.setColor(Color.darkGray);
-		g.fillRect(0, 225, breite, 100);
-
-		g.setColor(Color.white);
-		g.fillRect(270, 0, 10, hoehe);
-
-		g.setColor(Color.white);
-		g.fillRect(0, 270, breite, 10);
-
-		g.setColor(Color.darkGray);
-		g.fillRect(225, 225, 100, 100);
-
-		g.setColor(Color.white);
-		g.fillRect(225, 225, 100, 100);
-
-		g.setColor(Color.darkGray);
-		g.fillRect(235, 235, 80, 80);
-
-		g.setColor(Color.white);
-
-		g.fillRect(230, 30, 10, 50);
-		g.fillRect(230 + 20, 30, 10, 50);
-		g.fillRect(230 + 40, 30, 10, 50);
-		g.fillRect(230 + 60, 30, 10, 50);
-		g.fillRect(230 + 80, 30, 10, 50);
-
-		g.setColor(Color.white);
-		g.fillRect(475, 230, 50, 10);
-		g.fillRect(475, 230 + 20, 50, 10);
-		g.fillRect(475, 230 + 40, 50, 10);
-		g.fillRect(475, 230 + 60, 50, 10);
-		g.fillRect(475, 230 + 80, 50, 10);
-
-	}
-
-	public TrafficLight getLight1() {
-		return light1;
-	}
-
-	public TrafficLight getLight2() {
-		return light2;
-	}
-
-	public TrafficLight getLight3() {
-		return light3;
-	}
-
-	public TrafficLight getLight4() {
-		return light4;
-	}
-
-	public PedestrianLight getLight5() {
-		return light5;
-	}
-
-	public PedestrianLight getLight6() {
-		return light6;
-	}
-}

+ 0 - 108
examples/trafficlight_example/src/trafficlight_example/TrafficlightDemo.java

@@ -1,108 +0,0 @@
-/**
- * Copyright (c) 2016 committers of YAKINDU and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * Contributors:
- * 	committers of YAKINDU - initial API and implementation
- * 
- */
-package trafficlight_example;
-
-import java.awt.BorderLayout;
-import java.awt.Graphics;
-
-import javax.swing.JFrame;
-
-import org.yakindu.scr.RuntimeService;
-import org.yakindu.scr.TimerService;
-import org.yakindu.scr.trafficlightwaiting.TrafficLightWaitingStatemachine;
-
-/**
- * 
- * @author Tesch
- *
- */
-
-public class TrafficlightDemo extends JFrame {
-
-	private static final long serialVersionUID = -8909693541678814631L;
-
-	protected TrafficLightWaitingStatemachine statemachine;
-
-	protected TimerService timer;
-
-	private CrossingPanel crossing;
-
-	private ButtonPanel buttonPanel;
-
-	public static void main(String[] args) {
-		TrafficlightDemo application = new TrafficlightDemo();
-		application.createContents();
-		application.setupStatemachine();
-		application.run();
-	}
-
-	protected void run() {
-		statemachine.enter();
-		RuntimeService.getInstance().registerStatemachine(statemachine, 100);
-		while (isVisible()) {
-			checkTrafficLightStates();
-			repaint();
-		}
-	}
-
-	protected void createContents() {
-		setLayout(new BorderLayout());
-		setTitle("CycleBasedDemo");
-		crossing = new CrossingPanel();
-		add(BorderLayout.CENTER, crossing);
-		buttonPanel = new ButtonPanel();
-		add(BorderLayout.SOUTH, buttonPanel);
-		setSize(600, 600);
-		setVisible(true);
-	}
-
-	@Override
-	public void paint(Graphics g) {
-		super.paint(g);
-	}
-
-	protected void setupStatemachine() {
-		statemachine = new TrafficLightWaitingStatemachine();
-		timer = new TimerService();
-		statemachine.setTimer(timer);
-		statemachine.init();
-
-		buttonPanel.getPedestrianRequest()
-				.addActionListener(e -> statemachine.getSCInterface().raisePedestrianRequest());
-		buttonPanel.getOnOff().addActionListener(e -> statemachine.getSCInterface().raiseOnOff());
-	}
-
-	protected void checkTrafficLightStates() {
-		crossing.getLight1().setRed(statemachine.getSCITrafficLight().getRed());
-		crossing.getLight1().setYellow(statemachine.getSCITrafficLight().getYellow());
-		crossing.getLight1().setGreen(statemachine.getSCITrafficLight().getGreen());
-
-		crossing.getLight3().setRed(statemachine.getSCITrafficLight().getRed());
-		crossing.getLight3().setYellow(statemachine.getSCITrafficLight().getYellow());
-		crossing.getLight3().setGreen(statemachine.getSCITrafficLight().getGreen());
-
-		crossing.getLight2().setGreen(statemachine.getSCITrafficLight().getRed());
-		crossing.getLight2().setYellow(statemachine.getSCITrafficLight().getYellow());
-		crossing.getLight2().setRed(statemachine.getSCITrafficLight().getGreen());
-
-		crossing.getLight4().setGreen(statemachine.getSCITrafficLight().getRed());
-		crossing.getLight4().setYellow(statemachine.getSCITrafficLight().getYellow());
-		crossing.getLight4().setRed(statemachine.getSCITrafficLight().getGreen());
-
-		crossing.getLight5().setGreen(statemachine.getSCIPedestrian().getRed());
-		crossing.getLight5().setRed(statemachine.getSCIPedestrian().getGreen());
-		crossing.getLight5().setWhite(statemachine.getSCIPedestrian().getRequest());
-
-		crossing.getLight6().setRed(statemachine.getSCIPedestrian().getRed());
-		crossing.getLight6().setGreen(statemachine.getSCIPedestrian().getGreen());
-		crossing.getLight6().setWhite(statemachine.getSCIPedestrian().getRequest());
-	}
-}