Ver código fonte

removed bug regarding exit and entry action handling

terfloth@itemis.de 14 anos atrás
pai
commit
b331dc77ea

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

@@ -23,7 +23,7 @@ class StatechartExtensions {
 			if (mo > s) mo else s }])
 	}
 
-	/** the maximum orthogonality of all pseudo states is 0 */
+	/** the maximum orthogonality of all  pseudo states is 0 */
 	def dispatch int maxOrthogonality(Vertex v) { 0 }
 	
 	/** calculates the maximum orthogonality (maximum number of possible active leaf states) of a state */

+ 232 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/FactoryExtension.java

@@ -0,0 +1,232 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import com.google.inject.Inject;
+import java.util.ArrayList;
+import java.util.HashMap;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.xtext.naming.IQualifiedNameProvider;
+import org.eclipse.xtext.naming.QualifiedName;
+import org.eclipse.xtext.xbase.lib.CollectionLiterals;
+import org.yakindu.sct.model.sexec.Call;
+import org.yakindu.sct.model.sexec.Check;
+import org.yakindu.sct.model.sexec.CheckRef;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sexec.ExecutionState;
+import org.yakindu.sct.model.sexec.SexecFactory;
+import org.yakindu.sct.model.sexec.Step;
+import org.yakindu.sct.model.sexec.transformation.StatechartExtensions;
+import org.yakindu.sct.model.sgraph.Reaction;
+import org.yakindu.sct.model.sgraph.Scope;
+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.stext.stext.EventDefinition;
+import org.yakindu.sct.model.stext.stext.InterfaceScope;
+import org.yakindu.sct.model.stext.stext.InternalScope;
+import org.yakindu.sct.model.stext.stext.ReactionTrigger;
+import org.yakindu.sct.model.stext.stext.StextFactory;
+import org.yakindu.sct.model.stext.stext.VariableDefinition;
+
+@SuppressWarnings("all")
+public class FactoryExtension {
+  
+  @Inject
+  private IQualifiedNameProvider qfnProvider;
+  
+  @Inject
+  private StatechartExtensions sce;
+  
+  private final HashMap<ArrayList<?>,ExecutionFlow> _createCache_create = new HashMap<ArrayList<?>,ExecutionFlow>();
+  
+  public ExecutionFlow create(final Statechart statechart) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(statechart);
+    ExecutionFlow r;
+    synchronized (_createCache_create) {
+      if (_createCache_create.containsKey(_cacheKey)) {
+        return _createCache_create.get(_cacheKey);
+      }
+      SexecFactory _sexecFactory = this.sexecFactory();
+      ExecutionFlow _createExecutionFlow = _sexecFactory.createExecutionFlow();
+      r = _createExecutionFlow;
+      _createCache_create.put(_cacheKey, r);
+    }
+    String _name = statechart.getName();
+    r.setName(_name);
+    return r;
+  }
+  
+  private final HashMap<ArrayList<?>,InterfaceScope> _createCache_create_1 = new HashMap<ArrayList<?>,InterfaceScope>();
+  
+  protected Scope _create(final InterfaceScope scope) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(scope);
+    InterfaceScope r;
+    synchronized (_createCache_create_1) {
+      if (_createCache_create_1.containsKey(_cacheKey)) {
+        return _createCache_create_1.get(_cacheKey);
+      }
+      StextFactory _stextFactory = this.stextFactory();
+      InterfaceScope _createInterfaceScope = _stextFactory.createInterfaceScope();
+      r = _createInterfaceScope;
+      _createCache_create_1.put(_cacheKey, r);
+    }
+    String _name = scope.getName();
+    r.setName(_name);
+    return r;
+  }
+  
+  private final HashMap<ArrayList<?>,InternalScope> _createCache_create_2 = new HashMap<ArrayList<?>,InternalScope>();
+  
+  protected Scope _create(final InternalScope scope) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(scope);
+    InternalScope r;
+    synchronized (_createCache_create_2) {
+      if (_createCache_create_2.containsKey(_cacheKey)) {
+        return _createCache_create_2.get(_cacheKey);
+      }
+      StextFactory _stextFactory = this.stextFactory();
+      InternalScope _createInternalScope = _stextFactory.createInternalScope();
+      r = _createInternalScope;
+      _createCache_create_2.put(_cacheKey, r);
+    }
+    return r;
+  }
+  
+  private final HashMap<ArrayList<?>,EventDefinition> _createCache_create_3 = new HashMap<ArrayList<?>,EventDefinition>();
+  
+  public EventDefinition create(final EventDefinition event) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(event);
+    EventDefinition r;
+    synchronized (_createCache_create_3) {
+      if (_createCache_create_3.containsKey(_cacheKey)) {
+        return _createCache_create_3.get(_cacheKey);
+      }
+      EventDefinition _copy = EcoreUtil.<EventDefinition>copy(event);
+      r = _copy;
+      _createCache_create_3.put(_cacheKey, r);
+    }
+    return r;
+  }
+  
+  private final HashMap<ArrayList<?>,VariableDefinition> _createCache_create_4 = new HashMap<ArrayList<?>,VariableDefinition>();
+  
+  public VariableDefinition create(final VariableDefinition v) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(v);
+    VariableDefinition r;
+    synchronized (_createCache_create_4) {
+      if (_createCache_create_4.containsKey(_cacheKey)) {
+        return _createCache_create_4.get(_cacheKey);
+      }
+      VariableDefinition _copy = EcoreUtil.<VariableDefinition>copy(v);
+      r = _copy;
+      _createCache_create_4.put(_cacheKey, r);
+    }
+    return r;
+  }
+  
+  private final HashMap<ArrayList<?>,ExecutionState> _createCache_create_5 = new HashMap<ArrayList<?>,ExecutionState>();
+  
+  public ExecutionState create(final State state) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(state);
+    ExecutionState r;
+    synchronized (_createCache_create_5) {
+      if (_createCache_create_5.containsKey(_cacheKey)) {
+        return _createCache_create_5.get(_cacheKey);
+      }
+      SexecFactory _sexecFactory = this.sexecFactory();
+      ExecutionState _createExecutionState = _sexecFactory.createExecutionState();
+      r = _createExecutionState;
+      _createCache_create_5.put(_cacheKey, r);
+    }
+    {
+      String _name = state.getName();
+      r.setSimpleName(_name);
+      QualifiedName _fullyQualifiedName = this.qfnProvider.getFullyQualifiedName(state);
+      String _string = _fullyQualifiedName.toString();
+      String _replaceAll = _string.replaceAll(" ", "");
+      r.setName(_replaceAll);
+    }
+    return r;
+  }
+  
+  private final HashMap<ArrayList<?>,Check> _createCache_createCheck = new HashMap<ArrayList<?>,Check>();
+  
+  public Check createCheck(final ReactionTrigger tr) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(tr);
+    Check r;
+    synchronized (_createCache_createCheck) {
+      if (_createCache_createCheck.containsKey(_cacheKey)) {
+        return _createCache_createCheck.get(_cacheKey);
+      }
+      SexecFactory _sexecFactory = this.sexecFactory();
+      Check _createCheck = _sexecFactory.createCheck();
+      r = _createCheck;
+      _createCache_createCheck.put(_cacheKey, r);
+    }
+    Reaction _reaction = this.sce.reaction(tr);
+    String _id = this.sce.id(_reaction);
+    r.setName(_id);
+    return r;
+  }
+  
+  private final HashMap<ArrayList<?>,org.yakindu.sct.model.sexec.Reaction> _createCache_create_6 = new HashMap<ArrayList<?>,org.yakindu.sct.model.sexec.Reaction>();
+  
+  public org.yakindu.sct.model.sexec.Reaction create(final Transition tr) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(tr);
+    org.yakindu.sct.model.sexec.Reaction r;
+    synchronized (_createCache_create_6) {
+      if (_createCache_create_6.containsKey(_cacheKey)) {
+        return _createCache_create_6.get(_cacheKey);
+      }
+      SexecFactory _sexecFactory = this.sexecFactory();
+      org.yakindu.sct.model.sexec.Reaction _createReaction = _sexecFactory.createReaction();
+      r = _createReaction;
+      _createCache_create_6.put(_cacheKey, r);
+    }
+    String _id = this.sce.id(tr);
+    r.setName(_id);
+    return r;
+  }
+  
+  public CheckRef newRef(final Check check) {
+    CheckRef _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      CheckRef _createCheckRef = _sexecFactory.createCheckRef();
+      final CheckRef r = _createCheckRef;
+      r.setCheck(check);
+      _xblockexpression = (r);
+    }
+    return _xblockexpression;
+  }
+  
+  public Call newCall(final Step step) {
+    Call _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      Call _createCall = _sexecFactory.createCall();
+      final Call r = _createCall;
+      r.setStep(step);
+      _xblockexpression = (r);
+    }
+    return _xblockexpression;
+  }
+  
+  public SexecFactory sexecFactory() {
+    return SexecFactory.eINSTANCE;
+  }
+  
+  public StextFactory stextFactory() {
+    return StextFactory.eINSTANCE;
+  }
+  
+  public Scope create(final Scope scope) {
+    if ((scope instanceof InterfaceScope)) {
+      return _create((InterfaceScope)scope);
+    } else if ((scope instanceof InternalScope)) {
+      return _create((InternalScope)scope);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        java.util.Arrays.<Object>asList(scope).toString());
+    }
+  }
+}

+ 131 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StatechartExtensions.java

@@ -0,0 +1,131 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.xbase.lib.ComparableExtensions;
+import org.eclipse.xtext.xbase.lib.Functions.Function2;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.yakindu.sct.model.sgraph.Reaction;
+import org.yakindu.sct.model.sgraph.Region;
+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.Trigger;
+import org.yakindu.sct.model.sgraph.Vertex;
+
+@SuppressWarnings("all")
+public class StatechartExtensions {
+  
+  public int maxOrthogonality(final Statechart sc) {
+    EList<Region> _regions = sc.getRegions();
+    final Function2<Integer,Region,Integer> _function = new Function2<Integer,Region,Integer>() {
+        public Integer apply(final Integer o , final Region r) {
+          int _maxOrthogonality = StatechartExtensions.this.maxOrthogonality(r);
+          int _operator_plus = IntegerExtensions.operator_plus(((Integer)_maxOrthogonality), o);
+          return ((Integer)_operator_plus);
+        }
+      };
+    Integer _fold = IterableExtensions.<Region, Integer>fold(_regions, ((Integer)0), _function);
+    return _fold;
+  }
+  
+  public int maxOrthogonality(final Region r) {
+    EList<Vertex> _vertices = r.getVertices();
+    final Function2<Integer,Vertex,Integer> _function = new Function2<Integer,Vertex,Integer>() {
+        public Integer apply(final Integer s , final Vertex v) {
+          int _xblockexpression = (int) 0;
+          {
+            int _maxOrthogonality = StatechartExtensions.this.maxOrthogonality(v);
+            final int mo = _maxOrthogonality;
+            int _xifexpression = (int) 0;
+            boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)mo), s);
+            if (_operator_greaterThan) {
+              _xifexpression = mo;
+            } else {
+              _xifexpression = s;
+            }
+            _xblockexpression = (_xifexpression);
+          }
+          return ((Integer)_xblockexpression);
+        }
+      };
+    Integer _fold = IterableExtensions.<Vertex, Integer>fold(_vertices, ((Integer)0), _function);
+    return _fold;
+  }
+  
+  protected int _maxOrthogonality(final Vertex v) {
+    return 0;
+  }
+  
+  protected int _maxOrthogonality(final State s) {
+    Integer _xifexpression = null;
+    EList<Region> _subRegions = s.getSubRegions();
+    int _size = _subRegions.size();
+    boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)0));
+    if (_operator_greaterThan) {
+      EList<Region> _subRegions_1 = s.getSubRegions();
+      final Function2<Integer,Region,Integer> _function = new Function2<Integer,Region,Integer>() {
+          public Integer apply(final Integer o , final Region r) {
+            int _maxOrthogonality = StatechartExtensions.this.maxOrthogonality(r);
+            int _operator_plus = IntegerExtensions.operator_plus(((Integer)_maxOrthogonality), o);
+            return ((Integer)_operator_plus);
+          }
+        };
+      Integer _fold = IterableExtensions.<Region, Integer>fold(_subRegions_1, ((Integer)0), _function);
+      _xifexpression = _fold;
+    } else {
+      _xifexpression = 1;
+    }
+    return _xifexpression;
+  }
+  
+  public Reaction reaction(final Trigger tr) {
+    EObject _eContainer = tr.eContainer();
+    return ((Reaction) _eContainer);
+  }
+  
+  protected String _id(final Object obj) {
+    return null;
+  }
+  
+  protected String _id(final Transition t) {
+    Comparable<? extends Object> _xifexpression = null;
+    Vertex _source = t.getSource();
+    boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_source, null);
+    if (_operator_notEquals) {
+      Vertex _source_1 = t.getSource();
+      EList<Transition> _outgoingTransitions = _source_1.getOutgoingTransitions();
+      int _indexOf = _outgoingTransitions.indexOf(t);
+      _xifexpression = _indexOf;
+    } else {
+      _xifexpression = "";
+    }
+    String _operator_plus = StringExtensions.operator_plus("tr", _xifexpression);
+    return _operator_plus;
+  }
+  
+  public int maxOrthogonality(final Vertex s) {
+    if ((s instanceof State)) {
+      return _maxOrthogonality((State)s);
+    } else if ((s instanceof Vertex)) {
+      return _maxOrthogonality((Vertex)s);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        java.util.Arrays.<Object>asList(s).toString());
+    }
+  }
+  
+  public String id(final Object t) {
+    if ((t instanceof Transition)) {
+      return _id((Transition)t);
+    } else if ((t instanceof Object)) {
+      return _id((Object)t);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        java.util.Arrays.<Object>asList(t).toString());
+    }
+  }
+}