浏览代码

refactored interpreter and trafo to enable derived trafos

terfloth@itemis.de 13 年之前
父节点
当前提交
f6eb50f8d6

+ 5 - 0
plugins/org.yakindu.sct.model.sexec.interpreter/src/org/yakindu/sct/model/sexec/interpreter/factory/SexecExecutionFacadeFactory.java

@@ -49,4 +49,9 @@ public class SexecExecutionFacadeFactory implements IExecutionFacadeFactory {
 
 	}
 
+	public boolean isApplicable(Statechart statechart) {
+		return statechart.eResource().getURI().toString().endsWith("sct");
+	}
+
+   
 }

+ 1 - 0
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/BehaviorMapping.xtend

@@ -133,6 +133,7 @@ class BehaviorMapping {
 	
 		switch (tes.unit) {
 			case TimeUnit::MILLISECOND : pve
+			case TimeUnit::MICROSECOND : pve.divide(1000)
 			case TimeUnit::NANOSECOND  : pve.divide(1000000)
 			case TimeUnit::SECOND      : pve.multiply(1000)
 			default : pve

+ 1 - 0
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/ModelSequencer.xtend

@@ -118,6 +118,7 @@ class ModelSequencer {
 		sc.mapEntryActions(ef)
 		sc.mapExitActions(ef)
 		
+		
 		ef.defineStateEnterSequences(sc)
 		ef.defineStateExitSequences(sc)
 		ef.defineDeepEnterSequences(sc)

+ 9 - 2
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/BehaviorMapping.java

@@ -328,12 +328,19 @@ public class BehaviorMapping {
         }
       }
       if (!matched) {
-        if (org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_equals(__valOfSwitchOver,TimeUnit.NANOSECOND)) {
+        if (org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_equals(__valOfSwitchOver,TimeUnit.MICROSECOND)) {
           matched=true;
-          Statement _divide = this.divide(pve, 1000000);
+          Statement _divide = this.divide(pve, 1000);
           _switchResult = _divide;
         }
       }
+      if (!matched) {
+        if (org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_equals(__valOfSwitchOver,TimeUnit.NANOSECOND)) {
+          matched=true;
+          Statement _divide_1 = this.divide(pve, 1000000);
+          _switchResult = _divide_1;
+        }
+      }
       if (!matched) {
         if (org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_equals(__valOfSwitchOver,TimeUnit.SECOND)) {
           matched=true;

+ 3 - 3
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SexecElementMapping.java

@@ -126,7 +126,7 @@ public class SexecElementMapping {
   
   private final HashMap<ArrayList<?>,InternalScope> _createCache_create_2 = new HashMap<ArrayList<?>,InternalScope>();
   
-  protected Scope _create(final InternalScope scope) {
+  protected Scope _create(final Scope scope) {
     final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(scope);
     final InternalScope r;
     synchronized (_createCache_create_2) {
@@ -627,8 +627,8 @@ public class SexecElementMapping {
   public Scope create(final Scope scope) {
     if ((scope instanceof InterfaceScope)) {
       return _create((InterfaceScope)scope);
-    } else if ((scope instanceof InternalScope)) {
-      return _create((InternalScope)scope);
+    } else if ((scope instanceof Scope)) {
+      return _create((Scope)scope);
     } else {
       throw new IllegalArgumentException("Unhandled parameter types: " +
         java.util.Arrays.<Object>asList(scope).toString());

+ 10 - 4
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/debugmodel/SCTDebugTarget.java

@@ -98,13 +98,19 @@ public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget,
 		controller.start();
 	}
 
-	protected IExecutionFacadeFactory getExecutionFacadeFactory(EObject context) {
+	protected IExecutionFacadeFactory getExecutionFacadeFactory(Statechart sc) {
 		Iterable<ExecutionFactoryDescriptor> executionFactoryDescriptor = ExecutionFactoryExtensions
 				.getExecutionFactoryDescriptor();
+		
+		for ( ExecutionFactoryDescriptor desc : executionFactoryDescriptor) {
+			IExecutionFacadeFactory f = desc.createExecutableExtensionFactory();
+			if ( f.isApplicable(sc) ) return f;
+		}
 		// TODO: Handle more than one registered factory
-		ExecutionFactoryDescriptor next = executionFactoryDescriptor.iterator()
-				.next();
-		return next.createExecutableExtensionFactory();
+//		ExecutionFactoryDescriptor next = executionFactoryDescriptor.iterator()
+//				.next();
+//		return next.createExecutableExtensionFactory();
+		return null;
 	}
 
 	public IProcess getProcess() {

+ 2 - 0
plugins/org.yakindu.sct.simulation.core/src/org/yakindu/sct/simulation/core/runtime/IExecutionFacadeFactory.java

@@ -20,5 +20,7 @@ import org.yakindu.sct.model.sgraph.Statechart;
 public interface IExecutionFacadeFactory {
 
 	public IExecutionFacade createExecutionFacade(Statechart statechart);
+	
+	public boolean isApplicable(Statechart statechart);
 
 }

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

@@ -129,7 +129,9 @@ public class ExecutionContextContentProvider implements ITreeContentProvider,
 	}
 
 	public void eventRaised(ExecutionEvent event) {
+		System.out.println("raised " + event.getName());
 	}
+	
 	public void timeScaleFactorChanged(double oldFactor, double newFactor) {
 	}