Integrate timed execution engine with the execution queue manager.

Change-Id: I9eb42e7c144a445d42996cacfca5c7e132b8c015
Signed-off-by: jeremie.tatibouet <jeremie.tatibouet@cea.fr>
diff --git a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/META-INF/MANIFEST.MF b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/META-INF/MANIFEST.MF
index 33fb6e2..5c8fec2 100644
--- a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/META-INF/MANIFEST.MF
+++ b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/META-INF/MANIFEST.MF
@@ -18,6 +18,8 @@
  org.eclipse.papyrus.moka.fuml.Semantics.impl.Loci.LociL1,
  org.eclipse.papyrus.moka.fuml.Semantics.impl.Loci.LociL2,
  org.eclipse.papyrus.moka.fuml.Semantics.impl.Loci.LociL3,
+ org.eclipse.papyrus.moka.fuml.control.execution,
+ org.eclipse.papyrus.moka.fuml.control.queue,
  org.eclipse.papyrus.moka.fuml.debug,
  org.eclipse.papyrus.moka.fuml.profiling,
  org.eclipse.papyrus.moka.fuml.profiling.Semantics.Actions.BasicActions,
diff --git a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/impl/CommonBehaviors/BasicBehaviors/CallEventExecution.java b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/impl/CommonBehaviors/BasicBehaviors/CallEventExecution.java
index 36c02e6..bb3a725 100644
--- a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/impl/CommonBehaviors/BasicBehaviors/CallEventExecution.java
+++ b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/impl/CommonBehaviors/BasicBehaviors/CallEventExecution.java
@@ -24,7 +24,7 @@
 import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.Communications.IEventOccurrence;

 import org.eclipse.papyrus.moka.fuml.Semantics.impl.Classes.Kernel.Reference;

 import org.eclipse.papyrus.moka.fuml.Semantics.impl.CommonBehaviors.Communications.CallEventOccurrence;

-import org.eclipse.papyrus.moka.fuml.semantics.queue.ExecutionQueueManager;

+import org.eclipse.papyrus.moka.fuml.control.queue.ExecutionController;

 import org.eclipse.uml2.uml.Operation;

 import org.eclipse.uml2.uml.Parameter;

 import org.eclipse.uml2.uml.ParameterDirectionKind;

@@ -145,7 +145,7 @@
 		// Wait for an indeterminate amount of time to allow other concurrent 

 		// executions to proceed.

 		// [There is no further formal specification for this operation.]

-		ExecutionQueueManager.getInstance().step();

+		ExecutionController.getInstance().getExecutionLoop().step();

 	}

 

 }

diff --git a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/impl/CommonBehaviors/Communications/EventOccurrence.java b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/impl/CommonBehaviors/Communications/EventOccurrence.java
index 7a64e8e..15fb865 100644
--- a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/impl/CommonBehaviors/Communications/EventOccurrence.java
+++ b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/impl/CommonBehaviors/Communications/EventOccurrence.java
@@ -19,8 +19,8 @@
 import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.IReference;

 import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.IParameterValue;

 import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.Communications.IEventOccurrence;

-import org.eclipse.papyrus.moka.fuml.semantics.execution.EventOccurrenceSendingExecution;

-import org.eclipse.papyrus.moka.fuml.semantics.queue.ExecutionQueueManager;

+import org.eclipse.papyrus.moka.fuml.control.execution.EventOccurrenceSendingExecution;

+import org.eclipse.papyrus.moka.fuml.control.queue.ExecutionController;

 import org.eclipse.uml2.uml.Trigger;

 

 /**

@@ -67,7 +67,7 @@
 		EventOccurrenceSendingExecution sendingExecution = new EventOccurrenceSendingExecution();

 		sendingExecution.self = this;

 		sendingExecution.context = this.target.getReferent();

-		ExecutionQueueManager.getInstance().enqueue(sendingExecution);

+		ExecutionController.getInstance().getExecutionLoop().enqueue(sendingExecution);

 	}

 	

 	public void setTarget(IReference target) {

diff --git a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/impl/CommonBehaviors/Communications/ObjectActivation.java b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/impl/CommonBehaviors/Communications/ObjectActivation.java
index 64b3f30..befb2a4 100644
--- a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/impl/CommonBehaviors/Communications/ObjectActivation.java
+++ b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/generated/org/eclipse/papyrus/moka/fuml/Semantics/impl/CommonBehaviors/Communications/ObjectActivation.java
@@ -26,8 +26,8 @@
 import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.Communications.IObjectActivation;
 import org.eclipse.papyrus.moka.fuml.Semantics.impl.Classes.Kernel.Object_;
 import org.eclipse.papyrus.moka.fuml.Semantics.impl.Loci.LociL1.ChoiceStrategy;
+import org.eclipse.papyrus.moka.fuml.control.execution.EventDispatchLoopExecution;
 import org.eclipse.papyrus.moka.fuml.debug.Debug;
-import org.eclipse.papyrus.moka.fuml.semantics.execution.EventDispatchLoopExecution;
 import org.eclipse.uml2.uml.Behavior;
 import org.eclipse.uml2.uml.Class;
 
diff --git a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/FUMLExecutionEngine.java b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/FUMLExecutionEngine.java
index 77b0bd5..3494acf 100644
--- a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/FUMLExecutionEngine.java
+++ b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/FUMLExecutionEngine.java
@@ -45,10 +45,11 @@
 import org.eclipse.papyrus.moka.fuml.Semantics.impl.Loci.LociL1.FirstChoiceStrategy;
 import org.eclipse.papyrus.moka.fuml.Semantics.impl.Loci.LociL1.Locus;
 import org.eclipse.papyrus.moka.fuml.Semantics.impl.Loci.LociL3.ExecutionFactoryL3;
+import org.eclipse.papyrus.moka.fuml.control.execution.RootExecution;
+import org.eclipse.papyrus.moka.fuml.control.queue.ExecutionController;
+import org.eclipse.papyrus.moka.fuml.control.queue.ExecutionLoop;
 import org.eclipse.papyrus.moka.fuml.registry.IOpaqueBehaviorExecutionRegistry;
 import org.eclipse.papyrus.moka.fuml.registry.ISystemServicesRegistry;
-import org.eclipse.papyrus.moka.fuml.semantics.execution.RootExecution;
-import org.eclipse.papyrus.moka.fuml.semantics.queue.ExecutionQueueManager;
 import org.eclipse.papyrus.moka.utils.constants.MokaConstants;
 import org.eclipse.uml2.uml.Behavior;
 import org.eclipse.uml2.uml.Parameter;
@@ -92,10 +93,16 @@
 			// Initializes arguments
 			this.initializeArguments(this.executionArgs);
 			// Start execution
-			RootExecution rootExecution = new RootExecution((Behavior) this.executionEntryPoint, this.executionArguments, locus);
-			ExecutionQueueManager.getInstance().start(rootExecution);
+			this.run_();
 		}
 	}
+	
+	protected void run_() {
+		// Starts the execution loop
+		RootExecution rootExecution = new RootExecution((Behavior) this.executionEntryPoint, this.executionArguments, locus);
+		ExecutionController.getInstance().setExecutionLoop(new ExecutionLoop());
+		ExecutionController.getInstance().start(rootExecution);
+	}
 
 	public void stop(IProgressMonitor monitor) {
 		super.stop(monitor);
diff --git a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/semantics/execution/EventDispatchLoopExecution.java b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/control/execution/EventDispatchLoopExecution.java
similarity index 88%
rename from bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/semantics/execution/EventDispatchLoopExecution.java
rename to bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/control/execution/EventDispatchLoopExecution.java
index 45a44ba..450a04f 100644
--- a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/semantics/execution/EventDispatchLoopExecution.java
+++ b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/control/execution/EventDispatchLoopExecution.java
@@ -11,12 +11,12 @@
  *   

  *****************************************************************************/

 

-package org.eclipse.papyrus.moka.fuml.semantics.execution;

+package org.eclipse.papyrus.moka.fuml.control.execution;

 

 import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.IValue;

 import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.Communications.IObjectActivation;

 import org.eclipse.papyrus.moka.fuml.Semantics.impl.CommonBehaviors.BasicBehaviors.Execution;

-import org.eclipse.papyrus.moka.fuml.semantics.queue.ExecutionQueueManager;

+import org.eclipse.papyrus.moka.fuml.control.queue.ExecutionController;

 

 public class EventDispatchLoopExecution extends Execution {

 

@@ -34,7 +34,7 @@
 		// the event dispatch loop execution to the execution queue manager.

 		this.signalCount = this.signalCount + 1;

 		if(this.signalCount == 1){

-			ExecutionQueueManager.getInstance().enqueue(this);

+			ExecutionController.getInstance().getExecutionLoop().enqueue(this);

 		}

 	}

 	

@@ -51,7 +51,7 @@
 		this.dispatchNextEvent();

 		this.signalCount = this.signalCount - 1;

 		if(this.signalCount > 0){

-			ExecutionQueueManager.getInstance().enqueue(this);

+			ExecutionController.getInstance().getExecutionLoop().enqueue(this);

 		}

 	}

 

diff --git a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/semantics/execution/EventOccurrenceSendingExecution.java b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/control/execution/EventOccurrenceSendingExecution.java
similarity index 95%
rename from bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/semantics/execution/EventOccurrenceSendingExecution.java
rename to bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/control/execution/EventOccurrenceSendingExecution.java
index 15ead12..6af9af7 100644
--- a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/semantics/execution/EventOccurrenceSendingExecution.java
+++ b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/control/execution/EventOccurrenceSendingExecution.java
@@ -11,7 +11,7 @@
  *   

  *****************************************************************************/

 

-package org.eclipse.papyrus.moka.fuml.semantics.execution;

+package org.eclipse.papyrus.moka.fuml.control.execution;

 

 import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.IValue;

 import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.Communications.IEventOccurrence;

diff --git a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/semantics/execution/RootExecution.java b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/control/execution/RootExecution.java
similarity index 77%
rename from bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/semantics/execution/RootExecution.java
rename to bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/control/execution/RootExecution.java
index 156e3db..659d7f8 100644
--- a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/semantics/execution/RootExecution.java
+++ b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/control/execution/RootExecution.java
@@ -1,4 +1,17 @@
-package org.eclipse.papyrus.moka.fuml.semantics.execution;

+/*****************************************************************************

+ * Copyright (c) 2017 CEA LIST 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:

+ *   CEA LIST - Initial API and implementation

+ *   

+ *****************************************************************************/

+

+package org.eclipse.papyrus.moka.fuml.control.execution;

 

 import java.util.ArrayList;

 import java.util.List;

diff --git a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/control/queue/ExecutionController.java b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/control/queue/ExecutionController.java
new file mode 100644
index 0000000..097701d
--- /dev/null
+++ b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/control/queue/ExecutionController.java
@@ -0,0 +1,38 @@
+package org.eclipse.papyrus.moka.fuml.control.queue;

+

+import org.eclipse.papyrus.moka.fuml.control.execution.RootExecution;

+

+public class ExecutionController {

+

+	// The manager is a singleton

+	private static ExecutionController INSTANCE;

+	

+	private ExecutionController(){}

+	

+	protected ExecutionLoop executionLoop;

+	

+	public static ExecutionController getInstance(){

+		// Instantiate the manager if required and return the

+		// singleton instance 

+		if(INSTANCE == null){

+			INSTANCE = new ExecutionController();

+		}

+		return INSTANCE;

+	}

+	

+	public void setExecutionLoop(ExecutionLoop loop) {

+		this.executionLoop = loop;

+	}

+	

+	public ExecutionLoop getExecutionLoop() {

+		return this.executionLoop;

+	}

+	

+	public void start(RootExecution rootExecution){

+		if(this.executionLoop != null){

+			this.executionLoop.start(rootExecution);

+		}else {

+			throw new RuntimeException("Execution loop cannot be null");

+		}

+	}

+}

diff --git a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/control/queue/ExecutionLoop.java b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/control/queue/ExecutionLoop.java
new file mode 100644
index 0000000..86cdec6
--- /dev/null
+++ b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/control/queue/ExecutionLoop.java
@@ -0,0 +1,66 @@
+/*****************************************************************************

+ * Copyright (c) 2017 CEA LIST 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:

+ *   CEA LIST - Initial API and implementation

+ *   

+ *****************************************************************************/

+

+package org.eclipse.papyrus.moka.fuml.control.queue;

+

+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.IExecution;

+import org.eclipse.papyrus.moka.fuml.control.execution.RootExecution;

+

+public class ExecutionLoop {

+	

+	// The queue handled by the execution manager

+	protected ExecutionQueue queue;

+	

+	public ExecutionLoop(){

+		this.queue = new ExecutionQueue();

+	}

+	

+	public void enqueue(IExecution execution){

+		// Add an execution to the queue

+		this.queue.offer(execution);

+	}

+	

+	public void start(RootExecution execution){

+		// Add an execution to the queue and start the execution

+		// loop.

+		this.queue.clear();

+		this.enqueue(execution);

+		this.run();

+	}

+	

+	public void run(){

+		// Execute all execution in the queue until

+		// the queue is empty

+		while(!this.queue.isEmpty()){

+			this.runNext();

+		}

+	}

+	

+	public boolean step(){

+		// Run the execution at the head of the queue

+		return this.runNext();

+	}

+	

+	private boolean runNext(){

+		// If the queue is not empty, then the head execution is removed

+		// and executed. True is returned. False is only returned if the

+		// queue was empty.

+		if(!this.queue.isEmpty()){

+			IExecution nextExecution = this.queue.poll();

+			nextExecution.execute();

+			return true;

+		}

+		return false;

+	}

+	

+}
\ No newline at end of file
diff --git a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/semantics/queue/ExecutionQueue.java b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/control/queue/ExecutionQueue.java
similarity index 71%
rename from bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/semantics/queue/ExecutionQueue.java
rename to bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/control/queue/ExecutionQueue.java
index 8d3c76b..ba7b17c 100644
--- a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/semantics/queue/ExecutionQueue.java
+++ b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/control/queue/ExecutionQueue.java
@@ -1,4 +1,17 @@
-package org.eclipse.papyrus.moka.fuml.semantics.queue;

+/*****************************************************************************

+ * Copyright (c) 2017 CEA LIST 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:

+ *   CEA LIST - Initial API and implementation

+ *   

+ *****************************************************************************/

+

+package org.eclipse.papyrus.moka.fuml.control.queue;

 

 import java.util.AbstractQueue;

 import java.util.ArrayList;

diff --git a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/semantics/queue/ExecutionQueueManager.java b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/semantics/queue/ExecutionQueueManager.java
deleted file mode 100644
index 7875829..0000000
--- a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/semantics/queue/ExecutionQueueManager.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.eclipse.papyrus.moka.fuml.semantics.queue;

-

-import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.IExecution;

-import org.eclipse.papyrus.moka.fuml.semantics.execution.RootExecution;

-

-public class ExecutionQueueManager {

-	

-	// The queue handled by the execution manager

-	protected ExecutionQueue queue;

-	

-	// The manager is a singleton

-	private static ExecutionQueueManager INSTANCE;

-	

-	public static ExecutionQueueManager getInstance(){

-		// Instantiate the manager if required and return the

-		// singleton instance 

-		if(INSTANCE == null){

-			INSTANCE = new ExecutionQueueManager();

-		}

-		return INSTANCE;

-	}

-	

-	private ExecutionQueueManager(){

-		this.queue = new ExecutionQueue();

-	}

-	

-	public void enqueue(IExecution execution){

-		// Add an execution to the queue

-		this.queue.offer(execution);

-	}

-	

-	public void start(RootExecution execution){

-		// Add an execution to the queue and start the execution

-		// loop.

-		this.queue.clear();

-		this.enqueue(execution);

-		this.run();

-	}

-	

-	public void run(){

-		// Execute all execution in the queue until

-		// the queue is empty

-		while(!this.queue.isEmpty()){

-			this.runNext();

-		}

-	}

-	

-	public void step(){

-		// Run the execution at the head of the queue

-		this.runNext();

-	}

-	

-	private boolean runNext(){

-		// If the queue is not empty, then the head execution is removed

-		// and executed. True is returned. False is only returned if the

-		// queue was empty.

-		if(!this.queue.isEmpty()){

-			IExecution nextExecution = this.queue.poll();

-			//System.err.println(nextExecution);

-			nextExecution.execute();

-			return true;

-		}

-		return false;

-	}

-	

-}
\ No newline at end of file
diff --git a/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/META-INF/MANIFEST.MF b/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/META-INF/MANIFEST.MF
index 8ed063a..7b1b864 100644
--- a/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/META-INF/MANIFEST.MF
+++ b/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/META-INF/MANIFEST.MF
@@ -7,7 +7,8 @@
 Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.13.0,4.0.0)",
  org.eclipse.papyrus.moka.discreteevent;bundle-version="2.0.100";visibility:=reexport,
  org.eclipse.papyrus.moka;bundle-version="2.0.100",
- org.eclipse.papyrus.moka.fuml.statemachines;bundle-version="1.0.100";visibility:=reexport
+ org.eclipse.papyrus.moka.fuml.statemachines;bundle-version="1.0.100";visibility:=reexport,
+ org.eclipse.papyrus.moka.fuml
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Bundle-ActivationPolicy: lazy
 Export-Package: org.eclipse.papyrus.moka.timedfuml,
diff --git a/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/src/org/eclipse/papyrus/moka/timedfuml/TimedUmlExecutionEngine.java b/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/src/org/eclipse/papyrus/moka/timedfuml/TimedUmlExecutionEngine.java
index bfaff8a..2f562b6 100644
--- a/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/src/org/eclipse/papyrus/moka/timedfuml/TimedUmlExecutionEngine.java
+++ b/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/src/org/eclipse/papyrus/moka/timedfuml/TimedUmlExecutionEngine.java
@@ -11,37 +11,32 @@
  *****************************************************************************/

 package org.eclipse.papyrus.moka.timedfuml;

 

-import org.eclipse.core.runtime.IProgressMonitor;

-

 import org.eclipse.papyrus.moka.composites.Semantics.impl.Loci.LociL3.CS_Executor;

-import org.eclipse.papyrus.moka.discreteevent.DEScheduler;

 import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.ILocus;

+import org.eclipse.papyrus.moka.fuml.control.execution.RootExecution;

+import org.eclipse.papyrus.moka.fuml.control.queue.ExecutionController;

 import org.eclipse.papyrus.moka.fuml.statemachines.StateMachineExecutionEngine;

-import org.eclipse.papyrus.moka.timedfuml.actions._displayCurrentTimeAction;

+import org.eclipse.papyrus.moka.fuml.statemachines.Semantics.Loci.SM_Locus;

+import org.eclipse.papyrus.moka.timedfuml.control.queue.TimedExecutionLoop;

 import org.eclipse.papyrus.moka.timedfuml.semantics.Timed_ExecutionFactory;

-import org.eclipse.papyrus.moka.timedfuml.semantics.Timed_Locus;

+import org.eclipse.uml2.uml.Behavior;

 

 public class TimedUmlExecutionEngine extends StateMachineExecutionEngine {

 

-

 	@Override

 	public ILocus initializeLocus() {

-		this.locus = new Timed_Locus();

+		this.locus = new SM_Locus();

 		locus.setExecutor(new CS_Executor());

 		locus.setFactory(new Timed_ExecutionFactory());

-

 		return this.locus;

-

 	}

-

-	public void start(IProgressMonitor monitor) {

-		_displayCurrentTimeAction displayAction = new _displayCurrentTimeAction();

-		DEScheduler.init(-1.0);

-		DEScheduler.getInstance().pushPreStepAction(displayAction);

-		super.start(monitor);

-		DEScheduler.getInstance().run();

+	

+	@Override

+	protected void run_() {

+		// Starts the execution loop

+		RootExecution rootExecution = new RootExecution((Behavior) this.executionEntryPoint, this.executionArguments, locus);

+		ExecutionController.getInstance().setExecutionLoop(new TimedExecutionLoop());

+		ExecutionController.getInstance().start(rootExecution);

 	}

 

-

-

 }

diff --git a/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/src/org/eclipse/papyrus/moka/timedfuml/control/queue/TimedExecutionLoop.java b/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/src/org/eclipse/papyrus/moka/timedfuml/control/queue/TimedExecutionLoop.java
new file mode 100644
index 0000000..09d34b2
--- /dev/null
+++ b/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/src/org/eclipse/papyrus/moka/timedfuml/control/queue/TimedExecutionLoop.java
@@ -0,0 +1,67 @@
+/*****************************************************************************

+ * Copyright (c) 2017 CEA LIST 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:

+ *   CEA LIST - Initial API and implementation

+ *   

+ *****************************************************************************/

+

+package org.eclipse.papyrus.moka.timedfuml.control.queue;

+

+import org.eclipse.papyrus.moka.discreteevent.DEScheduler;

+import org.eclipse.papyrus.moka.fuml.control.execution.RootExecution;

+import org.eclipse.papyrus.moka.fuml.control.queue.ExecutionLoop;

+import org.eclipse.papyrus.moka.timedfuml.actions._displayCurrentTimeAction;

+

+public class TimedExecutionLoop extends ExecutionLoop{

+	

+	// Discrete event time scheduler

+	protected DEScheduler scheduler;

+	

+	public TimedExecutionLoop() {

+		super();

+	}

+	

+	@Override

+	public void start(RootExecution execution) {

+		// Initialize the scheduler and starts the execution loop

+		DEScheduler.init(-1.0);

+		DEScheduler.getInstance().pushPreStepAction(new _displayCurrentTimeAction());

+		this.scheduler = DEScheduler.getInstance();

+		super.start(execution);

+	}

+	

+	@Override

+	public void run() {

+		// While the DEScheduler has the opportunity to move

+		// forward in the simulation then the execution propagates

+		// as specified in the executable UML semantics. If the

+		// execution reached a wait point (i.e., not any behavior can

+		// be executed so far) then the simulation time moves forward

+		// (if possible - i.e., events are available).

+		while(!this.scheduler.isFinished()) {

+			super.run();

+			this.scheduler.step();

+		}

+	}

+	

+	@Override

+	public boolean step() {

+		// If the model is in a state that enables the execution to move

+		// forward according to executable UML semantics. Conversely, if

+		// the model is in a state that does not enable the execution to

+		// move forward according to the executable UML semantics then enable

+		// scheduler to step forward.

+		boolean stepIn = super.step();

+		if(!stepIn && !scheduler.isFinished()){

+			scheduler.step();

+		}

+		return stepIn;

+	}

+	

+}

diff --git a/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/src/org/eclipse/papyrus/moka/timedfuml/semantics/Timed_AcceptEventActionActivation.java b/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/src/org/eclipse/papyrus/moka/timedfuml/semantics/Timed_AcceptEventActionActivation.java
index ba951eb..84dcbcc 100644
--- a/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/src/org/eclipse/papyrus/moka/timedfuml/semantics/Timed_AcceptEventActionActivation.java
+++ b/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/src/org/eclipse/papyrus/moka/timedfuml/semantics/Timed_AcceptEventActionActivation.java
@@ -17,8 +17,7 @@
 import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.IRealValue;

 import org.eclipse.papyrus.moka.fuml.Semantics.impl.Actions.BasicActions.ActionActivation;

 import org.eclipse.papyrus.moka.timedfuml.actions._sendAcceptEventOfferAction;

-import org.eclipse.uml2.uml.Action;

-import org.eclipse.uml2.uml.Element;

+import org.eclipse.uml2.uml.AcceptEventAction;

 import org.eclipse.uml2.uml.OpaqueExpression;

 import org.eclipse.uml2.uml.TimeEvent;

 import org.eclipse.uml2.uml.TimeExpression;

@@ -39,10 +38,9 @@
 		double relativeDate = 0;

 		double absoluteDate = 0;

 		double currentTime = 0;

-		for (Element elt : ((Action) node).getOwnedElements()) {

+		for (Trigger trigger : ((AcceptEventAction) node).getTriggers()) {

 			boolean isMissed = false;

-			Trigger t = (Trigger) elt;

-			TimeEvent e = (TimeEvent) t.getEvent();

+			TimeEvent e = (TimeEvent) trigger.getEvent();

 			TimeExpression texp = ((TimeEvent) e).getWhen();

 			IEvaluation evaluation = null;

 			// FIXME Hack. Changes would be required in fUML

diff --git a/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/src/org/eclipse/papyrus/moka/timedfuml/semantics/Timed_ClassifierBehaviorExecution.java b/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/src/org/eclipse/papyrus/moka/timedfuml/semantics/Timed_ClassifierBehaviorExecution.java
deleted file mode 100644
index 918d1bb..0000000
--- a/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/src/org/eclipse/papyrus/moka/timedfuml/semantics/Timed_ClassifierBehaviorExecution.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*****************************************************************************

- * Copyright (c) 2016 CEA LIST.

- * 

- * 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:

- *  CEA LIST Initial API and implementation

- *****************************************************************************/

-package org.eclipse.papyrus.moka.timedfuml.semantics;

-

-import org.eclipse.papyrus.moka.discreteevent.DEScheduler;

-import org.eclipse.papyrus.moka.discreteevent.Event;

-import org.eclipse.papyrus.moka.fuml.Semantics.impl.CommonBehaviors.Communications.ClassifierBehaviorExecution;

-import org.eclipse.papyrus.moka.timedfuml.actions._startObjectBehavior_Action;

-

-/**

- * @author ac221913

- *

- */

-public class Timed_ClassifierBehaviorExecution extends ClassifierBehaviorExecution {

-

-	@Override

-	public void _startObjectBehavior() {

-		// FIXME delegate control here: this.execution.execute();

-		_startObjectBehavior_Action deAction = new _startObjectBehavior_Action(this);

-		DEScheduler.getInstance().pushEvent(new Event(0.0, deAction));

-	}

-}

diff --git a/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/src/org/eclipse/papyrus/moka/timedfuml/semantics/Timed_Locus.java b/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/src/org/eclipse/papyrus/moka/timedfuml/semantics/Timed_Locus.java
deleted file mode 100644
index c9c4da2..0000000
--- a/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/src/org/eclipse/papyrus/moka/timedfuml/semantics/Timed_Locus.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*****************************************************************************

- * Copyright (c) 2016 CEA LIST.

- * 

- * 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:

- *  CEA LIST Initial API and implementation

- *****************************************************************************/

-package org.eclipse.papyrus.moka.timedfuml.semantics;

-

-import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.IObject_;

-import org.eclipse.papyrus.moka.fuml.statemachines.Semantics.Loci.SM_Locus;

-import org.eclipse.uml2.uml.Behavior;

-import org.eclipse.uml2.uml.Class;

-

-/**

- * @author ac221913

- *

- */

-public class Timed_Locus extends SM_Locus {

-

-	@Override

-	public IObject_ instantiate(Class type) {

-		// Overrides PSCS by instantiating a DE_Object

-		// instead of a CS_Object

-

-		IObject_ object = null;

-

-		if (type instanceof Behavior) {

-			object = super.instantiate(type);

-		} else {

-			object = new Timed_Object();

-			object.addType(type);

-			object.createFeatureValues();

-			this.add(object);

-		}

-

-		return object;

-	}

-

-}

diff --git a/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/src/org/eclipse/papyrus/moka/timedfuml/semantics/Timed_Object.java b/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/src/org/eclipse/papyrus/moka/timedfuml/semantics/Timed_Object.java
deleted file mode 100644
index 7a84071..0000000
--- a/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/src/org/eclipse/papyrus/moka/timedfuml/semantics/Timed_Object.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*****************************************************************************

- * Copyright (c) 2016 CEA LIST.

- * 

- * 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:

- *  CEA LIST Initial API and implementation

- *****************************************************************************/

-package org.eclipse.papyrus.moka.timedfuml.semantics;

-

-import java.util.List;

-

-import org.eclipse.uml2.uml.Class;

-import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.IParameterValue;

-import org.eclipse.papyrus.moka.fuml.statemachines.Semantics.StructuredClassifiers.SM_Object;

-

-/**

- * @author ac221913

- *

- */

-public class Timed_Object extends SM_Object {

-

-	@Override

-	public void startBehavior(Class classifier, List<IParameterValue> inputs) {

-		// Overrides default startBehavior by instantiating a DE_ObjectActivation

-		// Create an object activation for this object (if one does not already

-		// exist) and start its behavior(s).

-		// Debug.println("[startBehavior] On object...");

-		if (this.objectActivation == null) {

-			this.objectActivation = new Timed_ObjectActivation();

-			this.objectActivation.setObject(this);

-		}

-		// Debug.println("[startBehavior] objectActivation = " +

-		// objectActivation);

-		this.objectActivation.startBehavior(classifier, inputs);

-	}

-

-}

diff --git a/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/src/org/eclipse/papyrus/moka/timedfuml/semantics/Timed_ObjectActivation.java b/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/src/org/eclipse/papyrus/moka/timedfuml/semantics/Timed_ObjectActivation.java
deleted file mode 100644
index 5ca269c..0000000
--- a/bundles/core/engines/org.eclipse.papyrus.moka.timedfuml/src/org/eclipse/papyrus/moka/timedfuml/semantics/Timed_ObjectActivation.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*****************************************************************************

- * Copyright (c) 2016 CEA LIST.

- * 

- * 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:

- *  CEA LIST Initial API and implementation

- *****************************************************************************/

-package org.eclipse.papyrus.moka.timedfuml.semantics;

-

-import org.eclipse.papyrus.moka.discreteevent.DEScheduler;

-import org.eclipse.papyrus.moka.discreteevent.Event;

-import org.eclipse.papyrus.moka.fuml.Semantics.impl.CommonBehaviors.Communications.ArrivalSignal;

-import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.Communications.IEventAccepter;

-import org.eclipse.papyrus.moka.fuml.statemachines.Semantics.CommonBehavior.SM_ObjectActivation;

-import org.eclipse.papyrus.moka.timedfuml.actions._acceptAction;

-import org.eclipse.papyrus.moka.timedfuml.actions._send_Action;

-

-/**

- * @author ac221913

- *

- */

-public class Timed_ObjectActivation extends SM_ObjectActivation {

-

-	@Override

-	public void register(IEventAccepter accepter) {

-		// Register the given event accepter to wait for a dispatched signal

-		// event.

-		this.waitingEventAccepters.add(accepter);

-		if (!this.eventPool.isEmpty()) {

-			_acceptAction acceptAction = new _acceptAction(this);

-			DEScheduler.getInstance().pushEvent(new Event(0.0, acceptAction));

-		}

-	}

-

-	@Override

-	public void _send(ArrivalSignal signal) {

-		// Signal the arrival of a new signal instance in the event pool.

-		// *** This should send an ArrivalSignal to the EventDispatchLoop. ***

-		_send_Action sendAction = new _send_Action(this);

-		DEScheduler.getInstance().pushEvent(new Event(0.0, sendAction));

-	} // _send

-

-	@Override

-	public void _startObjectBehavior() {

-		// The integration with the DE engine makes the usage of

-		// signalCount useless

-		// while (this.signalCount > 0) {

-		this.dispatchNextEvent();

-		// }

-	}

-

-}