Browse Source

Updated Simulation Core and UI API

Andreas Mülder 13 years ago
parent
commit
ea85785ffd
30 changed files with 771 additions and 417 deletions
  1. 8 2
      plugins/org.yakindu.sct.simulation.core/META-INF/MANIFEST.MF
  2. 1 1
      plugins/org.yakindu.sct.simulation.core/plugin.xml
  3. 3 3
      plugins/org.yakindu.sct.simulation.core/schema/org.yakindu.sct.simulation.core.sgraph.executionbuilder.exsd
  4. 0 8
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/ISCTBuilder.java
  5. 0 80
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/ISGraphExecutionScope.java
  6. 0 56
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/ISimulationSessionListener.java
  7. 21 20
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugTarget.java
  8. 7 7
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugThread.java
  9. 6 6
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTStackFrame.java
  10. 68 0
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/extensions/ExecutionFactoryExtensions.java
  11. 0 63
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/extensions/Extensions.java
  12. 8 5
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/extensions/IExtensionPoints.java
  13. 107 0
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/IExecutionContext.java
  14. 41 0
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/IExecutionContextListener.java
  15. 16 12
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/ISGraphExecutionFacade.java
  16. 3 6
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/ISGraphExecutionBuilder.java
  17. 2 6
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/ISGraphExecutionListener.java
  18. 79 0
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/impl/AbstractExecutionContext.java
  19. 56 0
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/impl/AbstractSlot.java
  20. 152 0
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/impl/ExecutionContextImpl.java
  21. 41 0
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/impl/ExecutionEvent.java
  22. 31 0
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/impl/ExecutionVariable.java
  23. 27 0
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/session/ISimulationSessionListener.java
  24. 14 60
      plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/SGraphSimulationSession.java
  25. 18 14
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/SCTSourceDisplay.java
  26. 2 2
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/ActiveSessionProvider.java
  27. 40 48
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/DeclarationView.java
  28. 4 4
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/ScopeSlotLabelProvider.java
  29. 4 4
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/editing/BooleanEditingSupport.java
  30. 12 10
      plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/editing/ScopeSlotEditingSupport.java

+ 8 - 2
plugins/org.yakindu.sct.simulation.core/META-INF/MANIFEST.MF

@@ -9,11 +9,17 @@ Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.debug.core,
  org.eclipse.emf.ecore,
  org.yakindu.sct.model.sgraph,
- org.eclipse.jdt.debug
+ org.eclipse.jdt.debug,
+ org.yakindu.sct.model.sexec;bundle-version="1.0.0",
+ com.google.collect;bundle-version="1.0.0"
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Bundle-ActivationPolicy: lazy
 Export-Package: org.yakindu.sct.simulation.core,
  org.yakindu.sct.simulation.core.debugmodel,
  org.yakindu.sct.simulation.core.extensions,
  org.yakindu.sct.simulation.core.hmr,
- org.yakindu.sct.simulation.core.launch
+ org.yakindu.sct.simulation.core.launch,
+ org.yakindu.sct.simulation.core.runtime,
+ org.yakindu.sct.simulation.core.runtime.impl,
+ org.yakindu.sct.simulation.core.session,
+ org.yakindu.sct.simulation.core.util

+ 1 - 1
plugins/org.yakindu.sct.simulation.core/plugin.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?eclipse version="3.4"?>
 <plugin>
-   <extension-point id="org.yakindu.sct.simulation.core.sgraph.executionbuilder" name="SGraphExecutionBuilder" schema="schema/org.yakindu.sct.simulation.core.sgraph.executionbuilder.exsd"/>
+   <extension-point id="org.yakindu.sct.simulation.core.executionfactory" name="ExecutionFactory" schema="schema/executionfactory.exsd"/>
 
 <extension point="org.eclipse.debug.core.launchConfigurationTypes">
     <launchConfigurationType

+ 3 - 3
plugins/org.yakindu.sct.simulation.core/schema/org.yakindu.sct.simulation.core.sgraph.executionbuilder.exsd

@@ -18,7 +18,7 @@
       </annotation>
       <complexType>
          <sequence>
-            <element ref="SGraphExecutionBuilder"/>
+            <element ref="ExecutionFacadeFactory"/>
          </sequence>
          <attribute name="point" type="string" use="required">
             <annotation>
@@ -47,7 +47,7 @@
       </complexType>
    </element>
 
-   <element name="SGraphExecutionBuilder">
+   <element name="ExecutionFacadeFactory">
       <complexType>
          <attribute name="class" type="string">
             <annotation>
@@ -55,7 +55,7 @@
                   
                </documentation>
                <appinfo>
-                  <meta.attribute kind="java" basedOn=":org.yakindu.sct.core.simulation.builder.ISGraphExecutionBuilder"/>
+                  <meta.attribute kind="java" basedOn=":org.yakindu.sct.simulation.core.IExecutionFacadeFactory"/>
                </appinfo>
             </annotation>
          </attribute>

+ 0 - 8
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/ISCTBuilder.java

@@ -1,8 +0,0 @@
-package org.yakindu.sct.simulation.core;
-
-import org.eclipse.emf.ecore.EObject;
-//TODO 
-public interface ISCTBuilder {
-
-	public boolean isBuilderFor(EObject eObject);
-}

+ 0 - 80
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/ISGraphExecutionScope.java

@@ -1,80 +0,0 @@
-package org.yakindu.sct.simulation.core;
-
-import java.util.List;
-
-/**
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public interface ISGraphExecutionScope {
-
-	public ScopeSlot getVariable(String varName);
-
-	public List<ScopeVariable> getVariables();
-
-	public List<ScopeEvent> getEvents();
-
-	public void setSlotValue(ScopeSlot variable, Object object);
-
-	public void call(String procedureId);
-
-	public void raise(ScopeEvent event);
-
-	public static abstract class ScopeSlot {
-
-		protected String name;
-		protected Class<?> type;
-		protected Object value;
-
-		public ScopeSlot(String name, Class<?> type, Object value) {
-			super();
-			this.name = name;
-			this.type = type;
-			this.value = value;
-		}
-
-		public String getName() {
-			return name;
-		}
-
-		public Class<?> getType() {
-			return type;
-		}
-
-		public Object getValue() {
-			return value;
-		}
-
-	}
-
-	/**
-	 * Read only access to ScopeVariables. Value can only be changed via
-	 * {@link ISGraphExecutionScope}#setVariableValue
-	 * 
-	 */
-	public class ScopeVariable extends ScopeSlot {
-
-		public ScopeVariable(String name, Class<?> type, Object value) {
-			super(name, type, value);
-		}
-
-	}
-
-	/**
-	 * Read only access to ScopeEvents. Value can only be changed via
-	 * {@link ISGraphExecutionScope}#setVariableValue
-	 * 
-	 */
-	public class ScopeEvent extends ScopeSlot {
-
-		public ScopeEvent(String name) {
-			this(name, null, null);
-		}
-
-		public ScopeEvent(String name, Class<?> type, Object value) {
-			super(name, type, value);
-		}
-
-	}
-}

+ 0 - 56
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/ISimulationSessionListener.java

@@ -1,56 +0,0 @@
-/**
- * Copyright (c) 2011 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 org.yakindu.sct.simulation.core;
-
-import org.yakindu.sct.model.sgraph.Transition;
-import org.yakindu.sct.model.sgraph.Vertex;
-
-/**
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public interface ISimulationSessionListener extends ISGraphExecutionListener {
-
-	public static enum SimulationState {
-		STARTED, RUNNING, SINGLESTEP, PAUSED, TERMINATED
-	}
-
-	public void simulationStateChanged(SimulationState oldState,
-			SimulationState newState);
-
-	/**
-	 * Null implementation
-	 * 
-	 */
-	public static class SimulationSessionListenerAdapter implements
-			ISimulationSessionListener {
-
-		public void stateEntered(Vertex vertex) {
-		}
-
-		public void stateLeft(Vertex vertex) {
-		}
-
-		public void transitionFired(Transition transition) {
-		}
-
-		public void simulationStateChanged(SimulationState oldState,
-				SimulationState newState) {
-		}
-
-		public void variableValueChanged(String variableName, Object value) {
-		}
-
-		public void eventRaised(String eventName) {
-		}
-	}
-}

+ 21 - 20
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugTarget.java

@@ -33,12 +33,12 @@ import org.yakindu.sct.model.sgraph.State;
 import org.yakindu.sct.model.sgraph.Statechart;
 import org.yakindu.sct.model.sgraph.Transition;
 import org.yakindu.sct.model.sgraph.Vertex;
-import org.yakindu.sct.simulation.core.ISGraphExecutionBuilder;
-import org.yakindu.sct.simulation.core.ISGraphExecutionFacade;
-import org.yakindu.sct.simulation.core.ISGraphExecutionListener;
-import org.yakindu.sct.simulation.core.SGraphSimulationSession;
-import org.yakindu.sct.simulation.core.extensions.Extensions;
-import org.yakindu.sct.simulation.core.extensions.IExtensionPoints;
+import org.yakindu.sct.simulation.core.extensions.ExecutionFactoryExtensions;
+import org.yakindu.sct.simulation.core.extensions.ExecutionFactoryExtensions.ExecutionFactoryDescriptor;
+import org.yakindu.sct.simulation.core.runtime.IExecutionFacade;
+import org.yakindu.sct.simulation.core.runtime.IExecutionFacadeFactory;
+import org.yakindu.sct.simulation.core.runtime.IExecutionFacadeListener;
+import org.yakindu.sct.simulation.core.session.SimulationSession;
 
 /**
  * 
@@ -46,15 +46,15 @@ import org.yakindu.sct.simulation.core.extensions.IExtensionPoints;
  * 
  */
 public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget,
-		ISGraphExecutionListener {
+		IExecutionFacadeListener {
 
 	private IProcess process;
 
 	private ILaunch launch;
 
-	private ISGraphExecutionFacade facade;
+	private IExecutionFacade facade;
 
-	private SGraphSimulationSession session;
+	private SimulationSession session;
 
 	private boolean stepping = false;
 	private boolean terminated = false;
@@ -79,18 +79,20 @@ public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget,
 	}
 
 	private void createExecutionModel(Statechart statechart) {
-		ISGraphExecutionBuilder builder = getBuilder(statechart);
-		facade = builder.build(statechart);
+		IExecutionFacadeFactory factory = getExecutionFacadeFactory(statechart);
+		facade = factory.createExecutionFacade(statechart);
 		facade.addExecutionListener(this);
-		session = new SGraphSimulationSession(facade);
+		session = new SimulationSession(facade);
 		new Thread(session).start();
 		session.start();
 	}
 
-	protected ISGraphExecutionBuilder getBuilder(EObject context) {
-		Extensions<ISGraphExecutionBuilder> extensions = new Extensions<ISGraphExecutionBuilder>(
-				IExtensionPoints.EXECUTION_BUILDER);
-		return extensions.getRegisteredProvider(context);
+	protected IExecutionFacadeFactory getExecutionFacadeFactory(EObject context) {
+		Iterable<ExecutionFactoryDescriptor> executionFactoryDescriptor = ExecutionFactoryExtensions
+				.getExecutionFactoryDescriptor();
+		//7TODO: Handle more than one registered factory
+		ExecutionFactoryDescriptor next = executionFactoryDescriptor.iterator().next();
+		return next.createExecutableExtensionFactory();
 	}
 
 	public IProcess getProcess() {
@@ -117,7 +119,7 @@ public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget,
 	}
 
 	public String getName() throws DebugException {
-		return facade.getId();
+		return facade.getName();
 	}
 
 	public boolean supportsBreakpoint(IBreakpoint breakpoint) {
@@ -205,9 +207,9 @@ public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget,
 	}
 
 	public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
-		if (adapter == SGraphSimulationSession.class)
+		if (adapter == SimulationSession.class)
 			return session;
-		if (adapter == ISGraphExecutionFacade.class)
+		if (adapter == IExecutionFacade.class)
 			return facade;
 		return super.getAdapter(adapter);
 	}
@@ -287,5 +289,4 @@ public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget,
 	public Statechart getStatechart() {
 		return statechart;
 	}
-
 }

+ 7 - 7
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugThread.java

@@ -19,8 +19,8 @@ import org.eclipse.debug.core.model.IStackFrame;
 import org.eclipse.debug.core.model.IThread;
 import org.yakindu.sct.model.sgraph.Region;
 import org.yakindu.sct.model.sgraph.Vertex;
-import org.yakindu.sct.simulation.core.ISGraphExecutionFacade;
-import org.yakindu.sct.simulation.core.SGraphSimulationSession;
+import org.yakindu.sct.simulation.core.runtime.IExecutionFacade;
+import org.yakindu.sct.simulation.core.session.SimulationSession;
 
 /**
  * 
@@ -31,7 +31,7 @@ public class SCTDebugThread extends SCTDebugElement implements IThread {
 
 	private final Region region;
 
-	public SCTDebugThread(SCTDebugTarget target, ISGraphExecutionFacade facade,
+	public SCTDebugThread(SCTDebugTarget target, IExecutionFacade facade,
 			String resourceString, Region region) {
 		super(target, resourceString);
 		this.region = region;
@@ -127,10 +127,10 @@ public class SCTDebugThread extends SCTDebugElement implements IThread {
 	}
 
 	public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
-		if (adapter == SGraphSimulationSession.class)
-			return getDebugTarget().getAdapter(SGraphSimulationSession.class);
-		if (adapter == ISGraphExecutionFacade.class)
-			return getDebugTarget().getAdapter(ISGraphExecutionFacade.class);
+		if (adapter == SimulationSession.class)
+			return getDebugTarget().getAdapter(SimulationSession.class);
+		if (adapter == IExecutionFacade.class)
+			return getDebugTarget().getAdapter(IExecutionFacade.class);
 		return super.getAdapter(adapter);
 	}
 

+ 6 - 6
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTStackFrame.java

@@ -17,8 +17,8 @@ import org.eclipse.debug.core.model.IRegisterGroup;
 import org.eclipse.debug.core.model.IStackFrame;
 import org.eclipse.debug.core.model.IVariable;
 import org.yakindu.sct.model.sgraph.Vertex;
-import org.yakindu.sct.simulation.core.ISGraphExecutionFacade;
-import org.yakindu.sct.simulation.core.SGraphSimulationSession;
+import org.yakindu.sct.simulation.core.runtime.IExecutionFacade;
+import org.yakindu.sct.simulation.core.session.SimulationSession;
 
 /**
  * 
@@ -160,10 +160,10 @@ public class SCTStackFrame extends SCTDebugElement implements IStackFrame {
 	}
 
 	public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
-		if (adapter == SGraphSimulationSession.class)
-			return thread.getAdapter(SGraphSimulationSession.class);
-		if (adapter == ISGraphExecutionFacade.class)
-			return getDebugTarget().getAdapter(ISGraphExecutionFacade.class);
+		if (adapter == SimulationSession.class)
+			return thread.getAdapter(SimulationSession.class);
+		if (adapter == IExecutionFacade.class)
+			return getDebugTarget().getAdapter(IExecutionFacade.class);
 		return super.getAdapter(adapter);
 	}
 

+ 68 - 0
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/extensions/ExecutionFactoryExtensions.java

@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2011 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 org.yakindu.sct.simulation.core.extensions;
+
+import static com.google.common.collect.Iterables.transform;
+import static com.google.common.collect.Lists.newArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.yakindu.sct.simulation.core.runtime.IExecutionFacadeFactory;
+
+import com.google.common.base.Function;
+
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class ExecutionFactoryExtensions {
+
+	private static final String EXTENSION_POINT_ID = "org.yakindu.sct.simulation.core.executionfactory";
+	private static final String ATTRIBUTE_CLASS = "class";
+
+	public static class ExecutionFactoryDescriptor {
+
+		private final IConfigurationElement configElement;
+
+		ExecutionFactoryDescriptor(IConfigurationElement configElement) {
+			this.configElement = configElement;
+		}
+
+		public IExecutionFacadeFactory createExecutableExtensionFactory() {
+			try {
+				return (IExecutionFacadeFactory) configElement
+						.createExecutableExtension(ATTRIBUTE_CLASS);
+			} catch (CoreException e) {
+				e.printStackTrace();
+			}
+			return null;
+		}
+	}
+
+	public static Iterable<ExecutionFactoryDescriptor> getExecutionFactoryDescriptor() {
+		IConfigurationElement[] configurationElements = Platform
+				.getExtensionRegistry().getConfigurationElementsFor(
+						EXTENSION_POINT_ID);
+		return transform(newArrayList(configurationElements),
+				new CreateLibraryDescriptor());
+	}
+
+	private static final class CreateLibraryDescriptor implements
+			Function<IConfigurationElement, ExecutionFactoryDescriptor> {
+
+		public ExecutionFactoryDescriptor apply(IConfigurationElement from) {
+			return new ExecutionFactoryDescriptor(from);
+		}
+	}
+
+}

+ 0 - 63
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/extensions/Extensions.java

@@ -1,63 +0,0 @@
-/**
- * Copyright (c) 2011 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 org.yakindu.sct.simulation.core.extensions;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.ecore.EObject;
-import org.yakindu.sct.simulation.core.ISCTBuilder;
-
-/**
- * 
- * @author andreas muelder
- * 
- */
-public class Extensions<T extends ISCTBuilder> {
-
-	private String extensionPointId;
-
-	public Extensions(String extensionPointId) {
-		this.extensionPointId = extensionPointId;
-	}
-
-	public T getRegisteredProvider(EObject object) {
-		List<T> loadRegisteredProvider = loadRegisteredProvider();
-		for (T t : loadRegisteredProvider) {
-			if (t.isBuilderFor(object)) {
-				return t;
-			}
-		}
-		throw new IllegalStateException("No provider found for type" + object);
-
-	}
-
-	public List<T> loadRegisteredProvider() {
-		List<T> providers = new ArrayList<T>();
-		IConfigurationElement[] configurationElements = Platform
-				.getExtensionRegistry().getConfigurationElementsFor(
-						extensionPointId);
-		for (IConfigurationElement configurationElement : configurationElements) {
-			try {
-				@SuppressWarnings("unchecked")
-				T provider = (T) configurationElement
-						.createExecutableExtension("class");
-				providers.add(provider);
-			} catch (CoreException e) {
-				e.printStackTrace();
-			}
-		}
-		return providers;
-	}
-}

+ 8 - 5
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/extensions/IExtensionPoints.java

@@ -4,19 +4,22 @@
  * 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
- * 
+ *     committers of YAKINDU - initial API and implementation
  */
-package org.yakindu.sct.simulation.core.extensions;
+package org.yakindu.sct.simulation.core.runtime;
 
 /**
  * 
  * @author andreas muelder - Initial contribution and API
  * 
  */
-public interface IExtensionPoints {
+public class ExecutionException extends RuntimeException {
 
-	public static final String EXECUTION_BUILDER = "org.yakindu.sct.simulation.core.sgraph.executionbuilder";
+	private static final long serialVersionUID = 1L;
 
+	public ExecutionException(String cause) {
+		super(cause);
+	}
 }

+ 107 - 0
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/IExecutionContext.java

@@ -0,0 +1,107 @@
+/**
+ * Copyright (c) 2011 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 org.yakindu.sct.simulation.core.runtime;
+
+import java.util.List;
+import java.util.Set;
+
+import org.yakindu.sct.model.sexec.ExecutionState;
+import org.yakindu.sct.model.sgraph.Vertex;
+import org.yakindu.sct.simulation.core.runtime.impl.ExecutionEvent;
+import org.yakindu.sct.simulation.core.runtime.impl.ExecutionVariable;
+
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public interface IExecutionContext {
+
+	/**
+	 * returns a readonly (!) List with all declared events
+	 */
+	public List<ExecutionEvent> getDeclaredEvents();
+
+	/**
+	 * Declares a new Event that can be raised
+	 */
+	public void declareEvent(ExecutionEvent event);
+
+	/**
+	 * Returns a readonly (!) List with all currently raised events
+	 */
+	public List<ExecutionEvent> getRaisedEvents();
+	
+	/**
+	 * Clears the collection of raised events
+	 */
+	public void resetRaisedEvents();
+
+	/**
+	 * Raises an event with an value, can be null
+	 * 
+	 * @throws ExecutionException
+	 *             if the value is incompatible with the declared event type or the Event can not be found
+	 */
+	public void raiseEvent(String name, Object value) throws ExecutionException;
+
+	/**
+	 * Returns true if the given event is currently raised, false otherwise
+	 */
+	public boolean isEventRaised(String eventName);
+
+	/**
+	 * Returns a readonly (!) List of all variables
+	 */
+	public List<ExecutionVariable> getVariables();
+	
+	/**
+	 * Declares a new Variable
+	 */
+	public void declareVariable(ExecutionVariable variable);
+
+	/**
+	 * Returns a {@link ExecutionVariable} by name, might be null
+	 */
+	public ExecutionVariable getVariable(String varName);
+
+	/**
+	 * Changes the value of a variable
+	 */
+	public void setVariableValue(String name, Object value)
+			throws ExecutionException;
+
+	/**
+	 * Returns a Set with all currently active states
+	 */
+	public Set<Vertex> getActiveStates();
+	/**
+	 * Returns the active state configuration
+	 */
+	public List<ExecutionState> getStateConfiguration();
+
+	/**
+	 * Calls a declared operation
+	 */
+	public void call(String procedureId);
+
+	/**
+	 * Registeres a new {@link IExecutionContextListener}
+	 */
+	public void addExecutionContextListener(IExecutionContextListener listener);
+
+	/**
+	 * removes a given {@link IExecutionContextListener}
+	 */
+	public void removeExecutionContextListener(
+			IExecutionContextListener listener);
+
+}

+ 41 - 0
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/IExecutionContextListener.java

@@ -0,0 +1,41 @@
+/**
+ * Copyright (c) 2011 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 org.yakindu.sct.simulation.core.runtime;
+
+import org.yakindu.sct.simulation.core.runtime.impl.ExecutionEvent;
+import org.yakindu.sct.simulation.core.runtime.impl.ExecutionVariable;
+
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public interface IExecutionContextListener {
+	/**
+	 * called when a new variable is declared
+	 */
+	public void variableDeclared(ExecutionVariable variable);
+
+	/**
+	 * called when e new event is declared
+	 */
+	public void eventDeclared(ExecutionEvent event);
+
+	/**
+	 * called when an event is raised
+	 */
+	public void eventRaised(ExecutionEvent event);
+
+	/**
+	 * called when a variable value changed
+	 */
+	public void variableValueChanged(ExecutionVariable variable);
+}

+ 16 - 12
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/ISGraphExecutionFacade.java

@@ -8,11 +8,9 @@
  * Contributors:
  *     committers of YAKINDU - initial API and implementation
  */
-package org.yakindu.sct.simulation.core;
+package org.yakindu.sct.simulation.core.runtime;
 
-import java.util.Set;
 
-import org.yakindu.sct.model.sgraph.Vertex;
 
 /**
  * Facade for executable statechart implementation.
@@ -20,20 +18,26 @@ import org.yakindu.sct.model.sgraph.Vertex;
  * @author andreas muelder - Initial contribution and API
  * 
  */
-public interface ISGraphExecutionFacade {
-
-	public String getId();
+public interface IExecutionFacade {
+	/**
+	 * Returns a name for the Execution Facade implementation
+	 */
+	public String getName();
 	
+	public void tearDown();
+	/**
+	 * Startes the execution
+	 */
 	public void enter();
-
+	/**
+	 * Executes one cycle
+	 */
 	public void runCycle();
 
-	public void addExecutionListener(ISGraphExecutionListener listener);
+	public void addExecutionListener(IExecutionFacadeListener listener);
 
-	public void removeExecutionListener(ISGraphExecutionListener listener);
+	public void removeExecutionListener(IExecutionFacadeListener listener);
 
-	public ISGraphExecutionScope getExecutionScope();
-	
-	public Set<Vertex> getStateConfiguration(); 
+	public IExecutionContext getExecutionContext();
 	
 }

+ 3 - 6
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/ISGraphExecutionBuilder.java

@@ -8,7 +8,7 @@
  * Contributors:
  *     committers of YAKINDU - initial API and implementation
  */
-package org.yakindu.sct.simulation.core;
+package org.yakindu.sct.simulation.core.runtime;
 
 import org.yakindu.sct.model.sgraph.Statechart;
 
@@ -17,15 +17,12 @@ import org.yakindu.sct.model.sgraph.Statechart;
  * @author andreas muelder - Initial contribution and API
  * 
  */
-public interface ISGraphExecutionBuilder extends ISCTBuilder{
+public interface IExecutionFacadeFactory {
 	/**
-	 * Returns an execution facade for a statechart model. Execution Builder can
-	 * be registered via extension point
-	 * "org.yakindu.sct.simulation.core.sgraph.executionbuilder"
 	 * 
 	 * @param statechart
 	 * @return
 	 */
-	public ISGraphExecutionFacade build(Statechart statechart);
+	public IExecutionFacade createExecutionFacade(Statechart statechart);
 
 }

+ 2 - 6
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/ISGraphExecutionListener.java

@@ -8,7 +8,7 @@
  * Contributors:
  *     committers of YAKINDU - initial API and implementation
  */
-package org.yakindu.sct.simulation.core;
+package org.yakindu.sct.simulation.core.runtime;
 
 import org.yakindu.sct.model.sgraph.Transition;
 import org.yakindu.sct.model.sgraph.Vertex;
@@ -18,7 +18,7 @@ import org.yakindu.sct.model.sgraph.Vertex;
  * @author andreas muelder - Initial contribution and API
  * 
  */
-public interface ISGraphExecutionListener {
+public interface IExecutionFacadeListener {
 
 	void stateEntered(Vertex vertex);
 
@@ -26,8 +26,4 @@ public interface ISGraphExecutionListener {
 
 	void transitionFired(Transition transition);
 
-	void variableValueChanged(String variableName, Object value);
-
-	void eventRaised(String eventName);
-
 }

+ 79 - 0
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/impl/AbstractExecutionContext.java

@@ -0,0 +1,79 @@
+/**
+ * Copyright (c) 2011 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 org.yakindu.sct.simulation.core.runtime.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.yakindu.sct.simulation.core.runtime.IExecutionContext;
+import org.yakindu.sct.simulation.core.runtime.IExecutionContextListener;
+
+/**
+ * Abstract implementation of {@link IExecutionContext}. Adds some convenience
+ * for handling the {@link IExecutionContextListener}s
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public abstract class AbstractExecutionContext implements IExecutionContext {
+
+	private List<IExecutionContextListener> _listeners;
+
+	public AbstractExecutionContext() {
+		_listeners = new ArrayList<IExecutionContextListener>();
+	}
+	
+	public void addExecutionContextListener(IExecutionContextListener listener) {
+		synchronized (_listeners) {
+			_listeners.add(listener);
+		}
+	}
+
+	public void removeExecutionContextListener(
+			IExecutionContextListener listener) {
+		synchronized (_listeners) {
+			_listeners.remove(listener);
+		}
+	}
+
+	public void notifyVariableDeclared(ExecutionVariable variable) {
+		synchronized (_listeners) {
+			for (IExecutionContextListener listener : _listeners) {
+				listener.variableDeclared(variable);
+			}
+		}
+	}
+
+	public void notifyEventDeclared(ExecutionEvent event) {
+		synchronized (_listeners) {
+			for (IExecutionContextListener listener : _listeners) {
+				listener.eventDeclared(event);
+			}
+		}
+	}
+
+	public void notifyEventRaised(ExecutionEvent event) {
+		synchronized (_listeners) {
+			for (IExecutionContextListener listener : _listeners) {
+				listener.eventRaised(event);
+			}
+		}
+	}
+
+	public void notifyVariableValueChanged(ExecutionVariable variable) {
+		synchronized (_listeners) {
+			for (IExecutionContextListener listener : _listeners) {
+				listener.variableValueChanged(variable);
+			}
+		}
+	}
+
+}

+ 56 - 0
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/impl/AbstractSlot.java

@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) 2011 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 org.yakindu.sct.simulation.core.runtime.impl;
+
+import org.eclipse.core.runtime.Assert;
+import org.yakindu.sct.simulation.core.runtime.ExecutionException;
+
+/**
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public abstract class AbstractSlot {
+
+	protected String name;
+	protected Class<?> type;
+	protected Object value;
+
+	public AbstractSlot(String name, Class<?> type, Object value) {
+		super();
+		Assert.isNotNull(name);
+		this.name = name;
+		this.type = type;
+		if (value != null)
+			setValue(value);
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public Class<?> getType() {
+		return type;
+	}
+
+	public Object getValue() {
+		return value;
+	}
+
+	/* package */void setValue(Object value) {
+		Assert.isNotNull(value, "Value must not be null ");
+		if (!value.getClass().isAssignableFrom(type)) {
+			throw new ExecutionException("Error assigning value to \' "+name +"\' Can not assign value " + value
+					+ " of type" + value.getClass() + " to type " + type);
+		}
+		this.value = value;
+	}
+
+}

+ 152 - 0
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/impl/ExecutionContextImpl.java

@@ -0,0 +1,152 @@
+/**
+ * Copyright (c) 2011 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 org.yakindu.sct.simulation.core.runtime.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.yakindu.sct.model.sexec.ExecutionState;
+import org.yakindu.sct.model.sgraph.Vertex;
+import org.yakindu.sct.simulation.core.runtime.ExecutionException;
+import org.yakindu.sct.simulation.core.runtime.IExecutionContext;
+
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class ExecutionContextImpl extends AbstractExecutionContext implements
+		IExecutionContext {
+
+	private List<ExecutionVariable> variables;
+	private List<ExecutionEvent> declaredEvents;
+	private List<ExecutionEvent> raisedEvents;
+	private List<ExecutionState> activeStateConfig;
+
+	public ExecutionContextImpl() {
+		variables = new ArrayList<ExecutionVariable>();
+		declaredEvents = new ArrayList<ExecutionEvent>();
+		raisedEvents = new ArrayList<ExecutionEvent>();
+		activeStateConfig = new ArrayList<ExecutionState>();
+	}
+
+	public List<ExecutionEvent> getDeclaredEvents() {
+		synchronized (declaredEvents) {
+			return Collections.unmodifiableList(declaredEvents);
+		}
+	}
+
+	public void declareEvent(ExecutionEvent event) {
+		System.out.println("Declaring event " + event.getName());
+		synchronized (declaredEvents) {
+			declaredEvents.add(event);
+		}
+		notifyEventDeclared(event);
+	}
+
+	public List<ExecutionEvent> getRaisedEvents() {
+		return Collections.unmodifiableList(raisedEvents);
+	}
+
+	public void resetRaisedEvents() {
+		synchronized (raisedEvents) {
+			raisedEvents.clear();
+		}
+	}
+
+	public void raiseEvent(String eventName, Object value) {
+		ExecutionEvent event = getDeclaredEvent(eventName);
+		if (event == null)
+			throw new ExecutionException("Event with name " + eventName
+					+ "is undefined!");
+		ExecutionEvent eventCopy = event.getCopy();
+		if (value != null) {
+			eventCopy.setValue(value);
+		}
+		raisedEvents.add(eventCopy);
+		notifyEventRaised(eventCopy);
+	}
+
+	private ExecutionEvent getDeclaredEvent(String eventName) {
+		synchronized (declaredEvents) {
+			for (ExecutionEvent event : declaredEvents) {
+				if (event.getName().equals(eventName))
+					return event;
+			}
+		}
+		return null;
+	}
+
+	public boolean isEventRaised(String eventName) {
+		synchronized (raisedEvents) {
+			for (ExecutionEvent event : raisedEvents) {
+				if (eventName.equals(event.getName())) {
+					return true;
+				}
+			}
+		}
+		return false;
+	}
+
+	public List<ExecutionVariable> getVariables() {
+		return Collections.unmodifiableList(variables);
+	}
+
+	public ExecutionVariable getVariable(String varName) {
+		synchronized (variables) {
+			for (ExecutionVariable variable : variables) {
+				if (varName.equals(variable.getName())) {
+					return variable;
+				}
+			}
+		}
+		return null;
+	}
+
+	public void declareVariable(ExecutionVariable variable) {
+		System.out.println("Declaring variable " + variable.getName());
+		synchronized (variables) {
+			variables.add(variable);
+		}
+		notifyVariableDeclared(variable);
+	}
+
+	public void setVariableValue(String name, Object value)
+			throws ExecutionException {
+		ExecutionVariable variable = getVariable(name);
+		if (variable == null)
+			throw new ExecutionException("Variable with name " + name
+					+ " is undefined!");
+		variable.setValue(value);
+		notifyVariableValueChanged(variable);
+
+	}
+
+	public List<ExecutionState> getStateConfiguration() {
+		return activeStateConfig;
+	}
+
+	public void call(String procedureId) {
+		// TODO: Implement me
+	}
+
+	public Set<Vertex> getActiveStates() {
+		Set<Vertex> vertices = new HashSet<Vertex>();
+		for (ExecutionState state : activeStateConfig) {
+			vertices.add((Vertex) state.getSourceElement());
+		}
+		return vertices;
+	}
+
+}

+ 41 - 0
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/impl/ExecutionEvent.java

@@ -0,0 +1,41 @@
+/**
+ * Copyright (c) 2011 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 org.yakindu.sct.simulation.core.runtime.impl;
+
+import org.yakindu.sct.simulation.core.runtime.IExecutionContext;
+
+/**
+ * Read only access to ScopeEvents. Value can only be changed via
+ * {@link IExecutionContext}#setVariableValue
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ * 
+ */
+public class ExecutionEvent extends AbstractSlot {
+
+	public ExecutionEvent(String name) {
+		this(name, null, null);
+	}
+
+	public ExecutionEvent(String name, Class<?> type) {
+		super(name, type, null);
+	}
+
+	public ExecutionEvent(String name, Class<?> type, Object value) {
+		super(name, type, value);
+	}
+
+	public ExecutionEvent getCopy() {
+		return new ExecutionEvent(getName(), getType(), getValue());
+	}
+
+}

+ 31 - 0
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/impl/ExecutionVariable.java

@@ -0,0 +1,31 @@
+/**
+ * Copyright (c) 2011 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 org.yakindu.sct.simulation.core.runtime.impl;
+
+import org.yakindu.sct.simulation.core.runtime.IExecutionContext;
+
+
+/**
+ * Read only access to ScopeVariables. Value can only be changed via
+ * {@link IExecutionContext}#setVariableValue
+ * 
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ * 
+ */
+public class ExecutionVariable extends AbstractSlot {
+
+	public ExecutionVariable(String name, Class<?> type, Object value) {
+		super(name, type, value);
+	}
+
+}

+ 27 - 0
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/session/ISimulationSessionListener.java

@@ -0,0 +1,27 @@
+/**
+ * Copyright (c) 2011 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 org.yakindu.sct.simulation.core.session;
+
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public interface ISimulationSessionListener {
+
+	public static enum SimulationState {
+		STARTED, RUNNING, SINGLESTEP, PAUSED, TERMINATED
+	}
+
+	public void simulationStateChanged(SimulationState oldState,
+			SimulationState newState);
+
+}

+ 14 - 60
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/SGraphSimulationSession.java

@@ -8,7 +8,7 @@
  * Contributors:
  *     committers of YAKINDU - initial API and implementation
  */
-package org.yakindu.sct.simulation.core;
+package org.yakindu.sct.simulation.core.session;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -17,18 +17,17 @@ import java.util.TimerTask;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 
-import org.yakindu.sct.model.sgraph.Transition;
-import org.yakindu.sct.model.sgraph.Vertex;
-import org.yakindu.sct.simulation.core.ISGraphExecutionScope.ScopeEvent;
-import org.yakindu.sct.simulation.core.ISimulationSessionListener.SimulationState;
+import org.yakindu.sct.simulation.core.runtime.IExecutionContext;
+import org.yakindu.sct.simulation.core.runtime.IExecutionFacade;
+import org.yakindu.sct.simulation.core.runtime.impl.ExecutionEvent;
+import org.yakindu.sct.simulation.core.session.ISimulationSessionListener.SimulationState;
 
 /**
  * 
  * @author andreas muelder - Initial contribution and API
  * 
  */
-public class SGraphSimulationSession implements Runnable,
-		ISGraphExecutionListener {
+public class SimulationSession implements Runnable {
 
 	// TODO: Add to launch tab config
 	private static final int CYCLE_SLEEP_TIME = 100;
@@ -39,13 +38,12 @@ public class SGraphSimulationSession implements Runnable,
 
 	private SimulationState currentState;
 
-	private final ISGraphExecutionFacade facade;
+	private final IExecutionFacade facade;
 
 	private Timer timer;
 
-	public SGraphSimulationSession(ISGraphExecutionFacade facade) {
+	public SimulationSession(IExecutionFacade facade) {
 		this.facade = facade;
-		facade.addExecutionListener(this);
 		listeners = new ArrayList<ISimulationSessionListener>();
 		taskQueue = new LinkedBlockingQueue<Runnable>();
 		timer = new Timer();
@@ -93,20 +91,18 @@ public class SGraphSimulationSession implements Runnable,
 				changeSimulationState(SimulationState.TERMINATED);
 			}
 		});
+		facade.tearDown();
 	}
 
-	public void raiseEvent(final ScopeEvent event) {
+	public void raiseEvent(final ExecutionEvent event) {
 		taskQueue.add(new Runnable() {
 			public void run() {
-				facade.getExecutionScope().raise(event);
+				facade.getExecutionContext().raiseEvent(event.getName(),
+						event.getValue());
 			}
 		});
 	}
 
-	public void setVariableValue(String variableName, Object value) {
-
-	}
-
 	protected void scheduleCycle() {
 		if (currentState == SimulationState.RUNNING) {
 			timer.schedule(new TimerTask() {
@@ -143,30 +139,6 @@ public class SGraphSimulationSession implements Runnable,
 		}
 	}
 
-	public void stateEntered(Vertex vertex) {
-		synchronized (listeners) {
-			for (ISimulationSessionListener listener : listeners) {
-				listener.stateEntered(vertex);
-			}
-		}
-	}
-
-	public void stateLeft(Vertex vertex) {
-		synchronized (listeners) {
-			for (ISimulationSessionListener listener : listeners) {
-				listener.stateLeft(vertex);
-			}
-		}
-	}
-
-	public void transitionFired(Transition transition) {
-		synchronized (listeners) {
-			for (ISimulationSessionListener listener : listeners) {
-				listener.transitionFired(transition);
-			}
-		}
-	}
-
 	public void addSimulationListener(ISimulationSessionListener listener) {
 		synchronized (listeners) {
 			listeners.add(listener);
@@ -179,26 +151,8 @@ public class SGraphSimulationSession implements Runnable,
 		}
 	}
 
-	public void variableValueChanged(String variableName, Object value) {
-		synchronized (listeners) {
-			for (ISimulationSessionListener listener : listeners) {
-				listener.variableValueChanged(variableName, value);
-			}
-		}
-
-	}
-
-	public void eventRaised(String eventName) {
-synchronized (listeners) {
-	for (ISimulationSessionListener listener : listeners) {
-		listener.eventRaised(eventName);
-	}
-	
-}
-	}
-
-	public ISGraphExecutionScope getExecutionScope() {
-		return facade.getExecutionScope();
+	public IExecutionContext getExecutionScope() {
+		return facade.getExecutionContext();
 	}
 
 	public SimulationState getCurrentState() {

+ 18 - 14
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/model/presenter/SCTSourceDisplay.java

@@ -23,12 +23,13 @@ import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.part.FileEditorInput;
 import org.yakindu.sct.model.sgraph.Transition;
 import org.yakindu.sct.model.sgraph.Vertex;
-import org.yakindu.sct.simulation.core.ISGraphExecutionFacade;
-import org.yakindu.sct.simulation.core.ISimulationSessionListener;
-import org.yakindu.sct.simulation.core.ISimulationSessionListener.SimulationSessionListenerAdapter;
-import org.yakindu.sct.simulation.core.SGraphSimulationSession;
 import org.yakindu.sct.simulation.core.debugmodel.SCTDebugElement;
 import org.yakindu.sct.simulation.core.debugmodel.SCTStackFrame;
+import org.yakindu.sct.simulation.core.runtime.IExecutionContextListener;
+import org.yakindu.sct.simulation.core.runtime.IExecutionFacade;
+import org.yakindu.sct.simulation.core.runtime.IExecutionFacadeListener;
+import org.yakindu.sct.simulation.core.session.ISimulationSessionListener;
+import org.yakindu.sct.simulation.core.session.SimulationSession;
 import org.yakindu.sct.ui.editor.editor.StatechartDiagramEditor;
 
 import de.itemis.gmf.runtime.commons.highlighting.HighlightingParameters;
@@ -47,26 +48,29 @@ import de.itemis.gmf.runtime.commons.util.EditPartUtils;
  * @author andreas muelder - Initial contribution and API
  * 
  */
-public class SCTSourceDisplay extends SimulationSessionListenerAdapter
-		implements ISimulationSessionListener, ISourceDisplay {
+public class SCTSourceDisplay implements ISimulationSessionListener,
+		IExecutionFacadeListener, ISourceDisplay {
 
 	private IHighlightingSupport support = new IHighlightingSupport.HighlightingSupportNullImpl();
 
-	private SGraphSimulationSession lastActiveSession;
+	private SimulationSession lastActiveSession;
 
 	private HighlightingParameters parameters = new HighlightingParameters();
 
 	public SCTSourceDisplay() {
 	}
-	
+
 	public void displaySource(Object element, IWorkbenchPage page,
 			boolean forceSourceLookup) {
 
 		SCTDebugElement debugElement = (SCTDebugElement) element;
-		SGraphSimulationSession session = (SGraphSimulationSession) debugElement
-				.getAdapter(SGraphSimulationSession.class);
-		ISGraphExecutionFacade facade = (ISGraphExecutionFacade) debugElement
-				.getAdapter(ISGraphExecutionFacade.class);
+		SimulationSession session = (SimulationSession) debugElement
+				.getAdapter(SimulationSession.class);
+		IExecutionFacade facade = (IExecutionFacade) debugElement
+				.getAdapter(IExecutionFacade.class);
+		
+		//TODO CHECK FOR MULTI EDITOR SIM
+		facade.addExecutionListener(this);
 
 		StatechartDiagramEditor editor = openEditorAndSelectElements(
 				debugElement, page);
@@ -85,7 +89,8 @@ public class SCTSourceDisplay extends SimulationSessionListenerAdapter
 		// Paint the active states if the session is not terminated
 		if (session.getCurrentState() != SimulationState.TERMINATED) {
 			support.lockEditor();
-			Set<Vertex> stateConfiguration = facade.getStateConfiguration();
+			Set<Vertex> stateConfiguration = facade.getExecutionContext()
+					.getActiveStates();
 			for (Vertex vertex : stateConfiguration) {
 				support.highlight(vertex, new HighlightingParameters());
 			}
@@ -124,7 +129,6 @@ public class SCTSourceDisplay extends SimulationSessionListenerAdapter
 		});
 	}
 
-	@Override
 	public void simulationStateChanged(SimulationState oldState,
 			SimulationState newState) {
 		if (newState == SimulationState.TERMINATED) {

+ 2 - 2
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/ActiveSessionProvider.java

@@ -10,7 +10,7 @@
  */
 package org.yakindu.sct.simulation.ui.view;
 
-import org.yakindu.sct.simulation.core.SGraphSimulationSession;
+import org.yakindu.sct.simulation.core.session.SimulationSession;
 
 /**
  * 
@@ -19,6 +19,6 @@ import org.yakindu.sct.simulation.core.SGraphSimulationSession;
  */
 public interface ActiveSessionProvider {
 
-	SGraphSimulationSession getActiveSession();
+	SimulationSession getActiveSession();
 
 }

+ 40 - 48
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/DeclarationView.java

@@ -35,12 +35,11 @@ import org.eclipse.swt.widgets.TableItem;
 import org.eclipse.ui.IViewSite;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.part.ViewPart;
-import org.yakindu.sct.model.sgraph.Transition;
-import org.yakindu.sct.model.sgraph.Vertex;
-import org.yakindu.sct.simulation.core.ISGraphExecutionScope.ScopeEvent;
-import org.yakindu.sct.simulation.core.ISGraphExecutionScope.ScopeVariable;
-import org.yakindu.sct.simulation.core.ISimulationSessionListener;
-import org.yakindu.sct.simulation.core.SGraphSimulationSession;
+import org.yakindu.sct.simulation.core.runtime.IExecutionContextListener;
+import org.yakindu.sct.simulation.core.runtime.impl.ExecutionEvent;
+import org.yakindu.sct.simulation.core.runtime.impl.ExecutionVariable;
+import org.yakindu.sct.simulation.core.session.ISimulationSessionListener;
+import org.yakindu.sct.simulation.core.session.SimulationSession;
 import org.yakindu.sct.simulation.ui.view.editing.BooleanEditingSupport;
 import org.yakindu.sct.simulation.ui.view.editing.IntegerEditingSupport;
 import org.yakindu.sct.simulation.ui.view.editing.MultiEditingSupport;
@@ -52,7 +51,7 @@ import org.yakindu.sct.simulation.ui.view.editing.RealEditingSupport;
  * 
  */
 public class DeclarationView extends ViewPart implements IDebugContextListener,
-		ISimulationSessionListener, ActiveSessionProvider {
+		ISimulationSessionListener, IExecutionContextListener, ActiveSessionProvider {
 
 	private TableViewer eventViewer;
 
@@ -60,7 +59,7 @@ public class DeclarationView extends ViewPart implements IDebugContextListener,
 
 	private List<Control> controls;
 
-	private SGraphSimulationSession activeSession;
+	private SimulationSession activeSession;
 
 	public DeclarationView() {
 		controls = new ArrayList<Control>();
@@ -133,8 +132,8 @@ public class DeclarationView extends ViewPart implements IDebugContextListener,
 
 	public void setEventViewerInput() {
 		if (activeSession != null) {
-			List<ScopeEvent> events = activeSession.getExecutionScope()
-					.getEvents();
+			List<ExecutionEvent> events = activeSession.getExecutionScope()
+					.getDeclaredEvents();
 			eventViewer.setInput(events);
 			TableItem[] items = eventViewer.getTable().getItems();
 			for (TableItem tableItem : items) {
@@ -155,7 +154,7 @@ public class DeclarationView extends ViewPart implements IDebugContextListener,
 
 	private void setVariableViewerInput() {
 		if (activeSession != null) {
-			List<ScopeVariable> variables = activeSession.getExecutionScope()
+			List<ExecutionVariable> variables = activeSession.getExecutionScope()
 					.getVariables();
 			variableViewer.setInput(variables);
 		}
@@ -169,39 +168,6 @@ public class DeclarationView extends ViewPart implements IDebugContextListener,
 		variableViewer.setInput(null);
 	}
 
-	public void variableValueChanged(String variableName, Object value) {
-		Display.getDefault().asyncExec(new Runnable() {
-			public void run() {
-				setVariableViewerInput();
-			}
-		});
-	}
-
-	@Override
-	public void dispose() {
-		super.dispose();
-	}
-
-	public void stateEntered(Vertex vertex) {
-		// Nothing to do
-	}
-
-	public void stateLeft(Vertex vertex) {
-		// Nothing to do
-	}
-
-	public void transitionFired(Transition transition) {
-		// Nothing to do
-	}
-
-	public void eventRaised(String eventName) {
-		Display.getDefault().asyncExec(new Runnable() {
-			public void run() {
-				setEventViewerInput();
-			}
-		});
-	}
-
 	private final class ButtonListener implements SelectionListener {
 
 		private final String eventName;
@@ -212,7 +178,7 @@ public class DeclarationView extends ViewPart implements IDebugContextListener,
 
 		public void widgetSelected(SelectionEvent e) {
 			if (activeSession != null) {
-				activeSession.raiseEvent(new ScopeEvent(eventName));
+				activeSession.raiseEvent(new ExecutionEvent(eventName));
 			}
 		}
 
@@ -227,8 +193,8 @@ public class DeclarationView extends ViewPart implements IDebugContextListener,
 		if (firstElement == null) {
 			return;
 		}
-		SGraphSimulationSession selectedSession = (SGraphSimulationSession) firstElement
-				.getAdapter(SGraphSimulationSession.class);
+		SimulationSession selectedSession = (SimulationSession) firstElement
+				.getAdapter(SimulationSession.class);
 		if (selectedSession == null
 				|| selectedSession.getCurrentState() == SimulationState.TERMINATED) {
 			activeSession = selectedSession;
@@ -237,16 +203,18 @@ public class DeclarationView extends ViewPart implements IDebugContextListener,
 		if (!(selectedSession == activeSession) && selectedSession != null) {
 			if (activeSession != null) {
 				activeSession.removeSimulationListener(this);
+				activeSession.getExecutionScope().removeExecutionContextListener(this);
 			}
 			activeSession = selectedSession;
 			selectedSession.addSimulationListener(this);
+			selectedSession.getExecutionScope().addExecutionContextListener(this);
 			clearViewerInput();
 			setEventViewerInput();
 			setVariableViewerInput();
 		}
 	}
 
-	public SGraphSimulationSession getActiveSession() {
+	public SimulationSession getActiveSession() {
 		return activeSession;
 	}
 
@@ -271,4 +239,28 @@ public class DeclarationView extends ViewPart implements IDebugContextListener,
 			break;
 		}
 	}
+
+	public void variableDeclared(ExecutionVariable variable) {
+		//Nothing to do
+	}
+
+	public void eventDeclared(ExecutionEvent event) {
+		//Nothing to do
+	}
+
+	public void eventRaised(ExecutionEvent event) {
+		Display.getDefault().asyncExec(new Runnable() {
+			public void run() {
+				setEventViewerInput();
+			}
+		});
+	}
+
+	public void variableValueChanged(ExecutionVariable variable) {
+		Display.getDefault().asyncExec(new Runnable() {
+			public void run() {
+				setVariableViewerInput();
+			}
+		});
+	}
 }

+ 4 - 4
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/ScopeSlotLabelProvider.java

@@ -11,7 +11,7 @@
 package org.yakindu.sct.simulation.ui.view;
 
 import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.yakindu.sct.simulation.core.ISGraphExecutionScope.ScopeSlot;
+import org.yakindu.sct.simulation.core.runtime.impl.AbstractSlot;
 
 /**
  * 
@@ -31,14 +31,14 @@ public class ScopeSlotLabelProvider extends ColumnLabelProvider {
 		switch (index) {
 		case 0:
 			// NAME
-			return ((ScopeSlot) element).getName();
+			return ((AbstractSlot) element).getName();
 		case 1:
 			// TYPE
-			Class<?> type = ((ScopeSlot) element).getType();
+			Class<?> type = ((AbstractSlot) element).getType();
 			return type != null ? type.getSimpleName() : null;
 		case 2:
 			// VALUE:
-			Object value = ((ScopeSlot) element).getValue();
+			Object value = ((AbstractSlot) element).getValue();
 			return value != null ? value.toString() : null;
 		default:
 			return "";

+ 4 - 4
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/editing/BooleanEditingSupport.java

@@ -15,8 +15,8 @@ import org.eclipse.jface.viewers.ColumnViewer;
 import org.eclipse.jface.viewers.ComboBoxCellEditor;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Composite;
-import org.yakindu.sct.simulation.core.ISGraphExecutionScope.ScopeSlot;
-import org.yakindu.sct.simulation.core.ISGraphExecutionScope.ScopeVariable;
+import org.yakindu.sct.simulation.core.runtime.impl.AbstractSlot;
+import org.yakindu.sct.simulation.core.runtime.impl.ExecutionVariable;
 import org.yakindu.sct.simulation.ui.view.ActiveSessionProvider;
 
 /**
@@ -43,8 +43,8 @@ public class BooleanEditingSupport extends ScopeSlotEditingSupport {
 	}
 
 	public Object getValue(Object element) {
-		if (element instanceof ScopeVariable) {
-			Boolean value = (Boolean) ((ScopeSlot) element).getValue();
+		if (element instanceof ExecutionVariable) {
+			Boolean value = (Boolean) ((AbstractSlot) element).getValue();
 			return value ? 0 : 1;
 		}
 		return null;

+ 12 - 10
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/editing/ScopeSlotEditingSupport.java

@@ -11,8 +11,8 @@
 package org.yakindu.sct.simulation.ui.view.editing;
 
 import org.eclipse.jface.viewers.ColumnViewer;
-import org.yakindu.sct.simulation.core.ISGraphExecutionScope;
-import org.yakindu.sct.simulation.core.ISGraphExecutionScope.ScopeSlot;
+import org.yakindu.sct.simulation.core.runtime.impl.AbstractSlot;
+import org.yakindu.sct.simulation.core.runtime.impl.ExecutionVariable;
 import org.yakindu.sct.simulation.ui.view.ActiveSessionProvider;
 
 /**
@@ -36,16 +36,17 @@ public abstract class ScopeSlotEditingSupport extends PublicEditingSupport {
 
 	@Override
 	public boolean canEdit(Object element) {
-		if (element instanceof ScopeSlot) {
-			return getSupportedType().equals(((ScopeSlot) element).getType());
+		if (element instanceof AbstractSlot) {
+			return getSupportedType()
+					.equals(((AbstractSlot) element).getType());
 		}
 		return false;
 	}
 
 	@Override
 	public Object getValue(Object element) {
-		if (element instanceof ScopeSlot) {
-			return String.valueOf(((ScopeSlot) element).getValue());
+		if (element instanceof AbstractSlot) {
+			return String.valueOf(((AbstractSlot) element).getValue());
 		}
 		return null;
 	}
@@ -55,10 +56,11 @@ public abstract class ScopeSlotEditingSupport extends PublicEditingSupport {
 		value = convertValue(value);
 		if (value == null)
 			return;
-		if (element instanceof ScopeSlot) {
-			ISGraphExecutionScope scope = provider.getActiveSession()
-					.getExecutionScope();
-			scope.setSlotValue((ScopeSlot) element, value);
+		if (element instanceof ExecutionVariable) {
+			provider.getActiveSession()
+					.getExecutionScope()
+					.setVariableValue(((ExecutionVariable) element).getName(),
+							value);
 		}
 	}
 }