Skip to content

Commit

Permalink
Simplify concurrent API (#20)
Browse files Browse the repository at this point in the history
* Create ICCSLSolver + simplify concurrent API

* Adapt VCD addon to new API

* Fix warnings in VCD addon

* Remove addFutureAction from concurrent engine API

* Remove unused imports in GemocLanguageDesignerBuilder

* Split implem/api

* Fix few mistakes with MoccmlModelExecutionContext

* Re-remove getSolver and setSolver

* Add many @OverRide + new abstract concurrent solver-based engine

* Better manage types in concurrent tracing addon

* Fix missing code executor in platform

* Move code to abstract concurrent engine + simplify API + other

* Add missing new DeciderExecption class

* Add AbstractConcurrentLauncher to share concurrent Launcher code

* Add new abstract classes and remove extension point singleton

* Improve some import declarations

* Remove some bin folders from examples

* Remove need to have EP + add choice of run decider

* Align tfsm example with new Moccml EP

* Align SigPML example to new Moccml EP

* Simplify new default run decider API

* Fix wrong exception declaration in createExecutionPlatform

* Share among concurrent engines the init of the decider

Signed-off-by: Erwan Bousse <erwan.bousse@ls2n.fr>
  • Loading branch information
ebousse authored and dvojtise committed Nov 18, 2019
1 parent 3477250 commit 16033b0
Show file tree
Hide file tree
Showing 80 changed files with 1,790 additions and 1,700 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.reflect.Field;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -40,17 +39,15 @@
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.impl.InternalTransactionalEditingDomain;
import org.eclipse.gemoc.execution.concurrent.ccsljavaengine.commons.ConcurrentModelExecutionContext;
import org.eclipse.gemoc.execution.concurrent.ccsljavaengine.commons.MoccmlModelExecutionContext;
import org.eclipse.gemoc.execution.concurrent.ccsljavaengine.concurrentmse.FeedbackMSE;
import org.eclipse.gemoc.execution.concurrent.ccsljavaengine.extensions.timesquare.Activator;
import org.eclipse.gemoc.execution.concurrent.ccsljavaxdsml.api.core.IConcurrentExecutionContext;
import org.eclipse.gemoc.execution.concurrent.ccsljavaxdsml.api.core.AbstractConcurrentModelExecutionContext;
import org.eclipse.gemoc.execution.concurrent.ccsljavaxdsml.utils.ccsl.QvtoTransformationPerformer;
import org.eclipse.gemoc.moccml.mapping.feedback.feedback.ActionModel;
import org.eclipse.gemoc.moccml.mapping.feedback.feedback.ModelSpecificEvent;
import org.eclipse.gemoc.trace.commons.model.generictrace.GenericParallelStep;
import org.eclipse.gemoc.trace.commons.model.generictrace.GenericSmallStep;
import org.eclipse.gemoc.trace.commons.model.generictrace.GenericStep;
import org.eclipse.gemoc.trace.commons.model.generictrace.GenerictraceFactory;
import org.eclipse.gemoc.trace.commons.model.trace.MSE;
import org.eclipse.gemoc.trace.commons.model.trace.MSEModel;
Expand All @@ -68,7 +65,6 @@
import fr.inria.aoste.timesquare.ccslkernel.runtime.exceptions.SimulationException;
import fr.inria.aoste.timesquare.ccslkernel.solver.exception.SolverException;
import fr.inria.aoste.timesquare.ccslkernel.solver.launch.CCSLKernelSolverWrapper;
import fr.inria.aoste.timesquare.ccslkernel.solver.priorities.PrioritySolver;
import fr.inria.aoste.timesquare.instantrelation.CCSLRelationModel.OccurrenceRelation;
import fr.inria.aoste.timesquare.instantrelation.listener.RelationModelListener;
import fr.inria.aoste.timesquare.simulationpolicy.maxcardpolicy.MaxCardSimulationPolicy;
Expand All @@ -83,7 +79,7 @@
* Implementation of the ISolver dedicated to CCSL.
*
*/
public class CcslSolver implements org.eclipse.gemoc.execution.concurrent.ccsljavaxdsml.api.moc.ISolver {
public class CcslSolver implements org.eclipse.gemoc.execution.concurrent.ccsljavaxdsml.api.moc.ICCSLSolver {

protected CCSLKernelSolverWrapper solverWrapper = null;
protected URI solverInputURI = null;
Expand Down Expand Up @@ -357,20 +353,20 @@ public void revertForceClockEffect() {


@Override
public void initialize(IConcurrentExecutionContext context)
public void initialize(AbstractConcurrentModelExecutionContext context)
{
if (context instanceof ConcurrentModelExecutionContext){
_alternativeExecutionModelPath = ((ConcurrentModelExecutionContext)context).alternativeExecutionModelPath;
if (context instanceof MoccmlModelExecutionContext){
_alternativeExecutionModelPath = ((MoccmlModelExecutionContext)context).alternativeExecutionModelPath;
}
createSolver(context);
}

@Override
public void prepareBeforeModelLoading(IConcurrentExecutionContext context)
public void prepareBeforeModelLoading(AbstractConcurrentModelExecutionContext context)
{
generateMoC(context);
generateMoC((MoccmlModelExecutionContext)context);
}
private void generateMoC(IConcurrentExecutionContext context)
private void generateMoC(MoccmlModelExecutionContext context)
{
IExecutionWorkspace workspace = context.getWorkspace();
boolean mustGenerate = false;
Expand Down Expand Up @@ -446,7 +442,7 @@ private void generateMoC(IConcurrentExecutionContext context)
/**
* generates a MSEModel that wraps the FeedbackModel used by Timesquare
*/
private void generateMSEModel(final IConcurrentExecutionContext context){
private void generateMSEModel(final AbstractConcurrentModelExecutionContext context){
final URI feedbackURI = URI.createPlatformResourceURI(getFeedbackPathFromMSEModelPath(context.getWorkspace().getMSEModelPath()).toString(), true);
final URI mseModelURI = URI.createPlatformResourceURI(context.getWorkspace().getMSEModelPath().toString(), true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public GemocInstantRelationModelGenerator() {
ccslRelation = modelFactory.createOccurrenceRelationModel();
}

@Override
public void setIOutputTraceList(IOutputTraceList outputlist) {
irml.setIOutputTraceList(outputlist);
}
Expand All @@ -117,6 +118,7 @@ public GemocInstantRelationModelGenerator(IOutputTraceList outputlist) {
*
* @return A list of ClockConstraint
*/
@Override
public EList<CCSLConstraintRef> getClockConstraintList() {
return ccslRelation.getRefsToCCSLConstraints();
}
Expand All @@ -128,6 +130,7 @@ public EList<CCSLConstraintRef> getClockConstraintList() {
* @param eObject
* a model element
*/
@Override
public void getModelRoot(EObject eObject) {
// TODO ..
irml.clear();
Expand All @@ -145,6 +148,7 @@ public void getModelRoot(EObject eObject) {
* @param stepTrace
* a StepTrace of a trace model
*/
@Override
public void addClockConstraint(LogicalStep stepTrace) {

if (stepTrace.getEventOccurrences().isEmpty())
Expand All @@ -158,11 +162,13 @@ public void addClockConstraint(LogicalStep stepTrace) {
// disp();
}

@Override
public void extract(EObject eo1) {
LookForExtensions.getDefault().getICCSLModel(eo1, this);
// disp();
}

@Override
public ArrayList<IDescription> getDescription() {
ArrayList<IDescription> desc = new ArrayList<IDescription>(lab.size());
for (AbstractCreator a : lab) {
Expand All @@ -171,6 +177,7 @@ public ArrayList<IDescription> getDescription() {
return desc;
}

@Override
public void disp() {
for (AbstractCreator clockConstraint : lab) {
System.out.println(clockConstraint.getDescription().toString());
Expand All @@ -185,6 +192,7 @@ public void disp() {
* A list of trace model paths
* @return A list of StepTrace
*/
@Override
public ArrayList<LogicalStep> loadTrace(IPath path) {
ArrayList<LogicalStep> steps = new ArrayList<LogicalStep>();

Expand All @@ -208,10 +216,12 @@ public ArrayList<LogicalStep> loadTrace(IPath path) {
return steps;
}

@Override
public ModelElementReference searchClock(EObject eo) {
return searchClock(new EObject[] { eo });
}

@Override
public ModelElementReference searchClock(EObject[] eObjects) {

boucle1: for (ModelElementReference mer : listClock) {
Expand All @@ -227,10 +237,12 @@ public ModelElementReference searchClock(EObject[] eObjects) {
return null;
}

@Override
public ModelElementReference searchConstraint(EObject eo) {
return searchConstraint(new EObject[] { eo });
}

@Override
public ModelElementReference searchConstraint(EObject[] eObjects) {
boucle1: for (ModelElementReference mer : listRelation) {
if (mer.getElementRef().size() == eObjects.length) {
Expand All @@ -244,18 +256,22 @@ public ModelElementReference searchConstraint(EObject[] eObjects) {
return null;
}

@Override
public List<ModelElementReference> getListClock() {
return listClock;
}

@Override
public List<ModelElementReference> getListRelation() {
return listRelation;
}

@Override
public void setListClock(List<ModelElementReference> listClock) {
this.listClock = listClock;
}

@Override
public void setListRelation(List<ModelElementReference> listrelation) {
this.listRelation = listrelation;
}
Expand All @@ -274,6 +290,7 @@ public void setListRelation(List<ModelElementReference> listrelation) {
* @param stepTrace
* a StepTrace of a trace model
*/
@Override
public void resolve(LogicalStep stepTrace) {
List<ResolveClockConstraintException> list = new ArrayList<ResolveClockConstraintException>();
try {
Expand Down Expand Up @@ -355,6 +372,7 @@ private void saveRelationModel(ResourceSet rs) {
* @param namefilein
* the file name of the instants relation model
*/
@Override
public void saveRelationModel(IPath folderin, String namefilein) {
local = folderin;
namefile = namefilein;
Expand All @@ -365,6 +383,7 @@ public void saveRelationModel(IPath folderin, String namefilein) {

}

@Override
public void saveRelationModel(ResourceSet rs, IPath folderin, String namefilein) {
local = folderin;
namefile = namefilein;
Expand All @@ -375,6 +394,7 @@ public void saveRelationModel(ResourceSet rs, IPath folderin, String namefilein)

}

@Override
public void unload() {
// TODO
try {
Expand All @@ -385,11 +405,13 @@ public void unload() {
}
}

@Override
public void aNewClockConstraint(CCSLConstraintRef clockConstraint) {
getClockConstraintList().add(clockConstraint);
irml.aNewClockConstraint(clockConstraint);
}

@Override
public AbstractCreator add(AbstractCreator ab) {
if (ab != null) {
if (ab.addChecking()) {
Expand All @@ -407,6 +429,7 @@ public AbstractCreator add(AbstractCreator ab) {
return ab;
}

@Override
public AbstractCreator add(AbstractCreator ab, ActivationCreator activationCreator) {
if (ab != null) {
if (ab.addChecking()) {
Expand All @@ -426,6 +449,7 @@ public AbstractCreator add(AbstractCreator ab, ActivationCreator activationCreat
return ab;
}

@Override
public CCSLConstraintRef addAndCreateAlternates(ModelElementReference a, ModelElementReference b, int a1, int b1,
boolean left, boolean rigth) {
CCSLConstraintRef cref = CCSLRelationModelFactory.eINSTANCE.createCCSLConstraintRef();
Expand All @@ -445,6 +469,7 @@ public CCSLConstraintRef addAndCreateAlternates(ModelElementReference a, ModelEl
return cref;
}

@Override
public CCSLConstraintRef addAndCreatePrecedes(ModelElementReference a, ModelElementReference b, int a1, int b1,
boolean strict) {

Expand All @@ -460,6 +485,7 @@ public CCSLConstraintRef addAndCreatePrecedes(ModelElementReference a, ModelElem
return cref;
}

@Override
public CCSLConstraintRef addAndCreateSync(ModelElementReference a, ModelElementReference b, int a1, int b1,
boolean left, boolean rigth) {
CCSLConstraintRef cref = CCSLRelationModelFactory.eINSTANCE.createCCSLConstraintRef();
Expand All @@ -480,6 +506,7 @@ public CCSLConstraintRef addAndCreateSync(ModelElementReference a, ModelElementR
return cref;
}

@Override
public CCSLConstraintRef addAndCreateEqual(ModelElementReference a, ModelElementReference b) {
CCSLConstraintRef cref = CCSLRelationModelFactory.eINSTANCE.createCCSLConstraintRef();
cref.getCcslElements().add(a);
Expand All @@ -504,6 +531,7 @@ public CCSLConstraintRef addAndCreateEqual(ModelElementReference a, ModelElement
* (ModelElementReference)
* @return an element from the instantRelamtionModel named CCSLConstraintRef
*/
@Override
public CCSLConstraintRef addAndCreateConcatenation(ModelElementReference res, ModelElementReference c1,
ModelElementReference c2) {
CCSLConstraintRef cref = CCSLRelationModelFactory.eINSTANCE.createCCSLConstraintRef();
Expand Down Expand Up @@ -535,6 +563,7 @@ public CCSLConstraintRef addAndCreateConcatenation(ModelElementReference res, Mo
* (ModelElementReference)
* @return an element from the instantRelamtionModel named CCSLConstraintRef
*/
@Override
public CCSLConstraintRef addAndCreateUpTo(ModelElementReference res, ModelElementReference c1,
ModelElementReference c2) {
CCSLConstraintRef cref = CCSLRelationModelFactory.eINSTANCE.createCCSLConstraintRef();
Expand All @@ -557,6 +586,7 @@ public CCSLConstraintRef addAndCreateUpTo(ModelElementReference res, ModelElemen
return cref;
}

@Override
public CCSLConstraintRef addandCreateInf(ModelElementReference r, ModelElementReference lst[]) {
CCSLConstraintRef cref = CCSLRelationModelFactory.eINSTANCE.createCCSLConstraintRef();
cref.getCcslElements().add(r);
Expand All @@ -573,6 +603,7 @@ public CCSLConstraintRef addandCreateInf(ModelElementReference r, ModelElementRe
return cref;
}

@Override
public CCSLConstraintRef addandCreateSup(ModelElementReference r, ModelElementReference lst[]) {
CCSLConstraintRef cref = CCSLRelationModelFactory.eINSTANCE.createCCSLConstraintRef();
cref.getCcslElements().add(r);
Expand All @@ -590,6 +621,7 @@ public CCSLConstraintRef addandCreateSup(ModelElementReference r, ModelElementRe
return cref;
}

@Override
public CCSLConstraintRef addandCreateInterOrUnion(ModelElementReference r, ModelElementReference a,
ModelElementReference b) {
CCSLConstraintRef cref = CCSLRelationModelFactory.eINSTANCE.createCCSLConstraintRef();
Expand All @@ -605,6 +637,7 @@ public CCSLConstraintRef addandCreateInterOrUnion(ModelElementReference r, Model
return cref;
}

@Override
public CCSLConstraintRef addandCreateDelayedFor(ModelElementReference r, ModelElementReference a,
ModelElementReference b, int n) {
CCSLConstraintRef cref = CCSLRelationModelFactory.eINSTANCE.createCCSLConstraintRef();
Expand All @@ -625,6 +658,7 @@ public CCSLConstraintRef addandCreateDelayedFor(ModelElementReference r, ModelEl
return cref;
}

@Override
public CCSLConstraintRef addandCreateSampledOn(ModelElementReference sup, ModelElementReference superc,
ModelElementReference trigger, boolean strictly) {
CCSLConstraintRef cref = CCSLRelationModelFactory.eINSTANCE.createCCSLConstraintRef();
Expand All @@ -643,6 +677,7 @@ public CCSLConstraintRef addandCreateSampledOn(ModelElementReference sup, ModelE
return cref;
}

@Override
public CCSLConstraintRef addandCreateSustain(ModelElementReference res, ModelElementReference sustain,
ModelElementReference upto) {
CCSLConstraintRef cref = CCSLRelationModelFactory.eINSTANCE.createCCSLConstraintRef();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<extension
point="org.eclipse.debug.core.launchConfigurationTypes">
<launchConfigurationType
delegate="org.eclipse.gemoc.execution.concurrent.ccsljavaengine.ui.launcher.Launcher"
delegate="org.eclipse.gemoc.execution.concurrent.ccsljavaengine.ui.launcher.MoccmlLauncher"
id="org.eclipse.gemoc.execution.concurrent.ccsljavaengine.ui.launcher"
modes="run, debug"
name="Gemoc Concurrent eXecutable Model"
Expand Down Expand Up @@ -102,7 +102,7 @@
</extension>
<extension point="org.eclipse.debug.ui.launchConfigurationTabGroups">
<launchConfigurationTabGroup
class="org.eclipse.gemoc.execution.concurrent.ccsljavaengine.ui.launcher.LauncherTabGroup"
class="org.eclipse.gemoc.execution.concurrent.ccsljavaengine.ui.launcher.MoccmlLauncherTabGroup"
id="org.eclipse.gemoc.execution.concurrent.ccsljavaengine.ui.launcher.tabGroup"
type="org.eclipse.gemoc.execution.concurrent.ccsljavaengine.ui.launcher">
</launchConfigurationTabGroup>
Expand All @@ -120,7 +120,7 @@
<extension
point="org.eclipse.debug.ui.launchShortcuts">
<shortcut
class="org.eclipse.gemoc.execution.concurrent.ccsljavaengine.ui.launcher.Launcher"
class="org.eclipse.gemoc.execution.concurrent.ccsljavaengine.ui.launcher.MoccmlLauncher"
description="Create a configuration to launch an Eclipse application in debug mode."
icon="icons/IconeGemocModel-16.png"
id="org.eclipse.gemoc.execution.concurrent.ccsljavaengine.ui.GemocExecutableReflectiveModel"
Expand Down
Loading

0 comments on commit 16033b0

Please sign in to comment.