Forráskód Böngészése

added xtend-gen files again and disabled comilation

benjamin.schwertfeger@gmail.com 13 éve
szülő
commit
90fef965a7
14 módosított fájl, 6063 hozzáadás és 28 törlés
  1. 28 28
      plugins/org.yakindu.sct.model.sexec/pom.xml
  2. 1115 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/BehaviorMapping.java
  3. 809 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/FlowOptimizer.java
  4. 263 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/ModelSequencer.java
  5. 582 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/ReactionBuilder.java
  6. 878 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SequenceBuilder.java
  7. 829 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SexecElementMapping.java
  8. 147 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SexecExtensions.java
  9. 238 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SgraphExtensions.java
  10. 239 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StateVectorBuilder.java
  11. 461 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StatechartExtensions.java
  12. 53 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StextExtensions.java
  13. 319 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StructureMapping.java
  14. 102 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/TraceExtensions.java

+ 28 - 28
plugins/org.yakindu.sct.model.sexec/pom.xml

@@ -62,35 +62,35 @@
 					</execution>
 				</executions>
 			</plugin>
-			<plugin>
-				<artifactId>maven-clean-plugin</artifactId>
-				<configuration>
-					<filesets>
-						<fileset>
-							<directory>xtend-gen</directory>
-							<includes>
-								<include>**</include>
-							</includes>
-							<excludes>
-								<exclude>.gitignore</exclude>
-								<exclude>.svn/</exclude>
-							</excludes>
-						</fileset>
-					</filesets>
-				</configuration>
-			</plugin>
+<!-- 			<plugin> -->
+<!-- 				<artifactId>maven-clean-plugin</artifactId> -->
+<!-- 				<configuration> -->
+<!-- 					<filesets> -->
+<!-- 						<fileset> -->
+<!-- 							<directory>xtend-gen</directory> -->
+<!-- 							<includes> -->
+<!-- 								<include>**</include> -->
+<!-- 							</includes> -->
+<!-- 							<excludes> -->
+<!-- 								<exclude>.gitignore</exclude> -->
+<!-- 								<exclude>.svn/</exclude> -->
+<!-- 							</excludes> -->
+<!-- 						</fileset> -->
+<!-- 					</filesets> -->
+<!-- 				</configuration> -->
+<!-- 			</plugin> -->
 			
-			<plugin>
-				<groupId>org.eclipse.xtend</groupId>
-				<artifactId>xtend-maven-plugin</artifactId>
-				<executions>
-					<execution>
-						<goals>
-							<goal>compile</goal>
-						</goals>
-					</execution>
-				</executions>
-			</plugin>
+<!-- 			<plugin> -->
+<!-- 				<groupId>org.eclipse.xtend</groupId> -->
+<!-- 				<artifactId>xtend-maven-plugin</artifactId> -->
+<!-- 				<executions> -->
+<!-- 					<execution> -->
+<!-- 						<goals> -->
+<!-- 							<goal>compile</goal> -->
+<!-- 						</goals> -->
+<!-- 					</execution> -->
+<!-- 				</executions> -->
+<!-- 			</plugin> -->
 		</plugins>
 	</build>
 </project>

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 1115 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/BehaviorMapping.java


+ 809 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/FlowOptimizer.java

@@ -0,0 +1,809 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.IteratorExtensions;
+import org.eclipse.xtext.xbase.lib.ListExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+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.ExecutionChoice;
+import org.yakindu.sct.model.sexec.ExecutionEntry;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sexec.ExecutionNode;
+import org.yakindu.sct.model.sexec.ExecutionRegion;
+import org.yakindu.sct.model.sexec.ExecutionState;
+import org.yakindu.sct.model.sexec.HistoryEntry;
+import org.yakindu.sct.model.sexec.If;
+import org.yakindu.sct.model.sexec.Reaction;
+import org.yakindu.sct.model.sexec.Sequence;
+import org.yakindu.sct.model.sexec.SexecFactory;
+import org.yakindu.sct.model.sexec.StateCase;
+import org.yakindu.sct.model.sexec.StateSwitch;
+import org.yakindu.sct.model.sexec.Step;
+import org.yakindu.sct.model.sgraph.SGraphFactory;
+import org.yakindu.sct.model.sgraph.Statement;
+import org.yakindu.sct.model.stext.stext.BoolLiteral;
+import org.yakindu.sct.model.stext.stext.Literal;
+import org.yakindu.sct.model.stext.stext.PrimitiveValueExpression;
+import org.yakindu.sct.model.stext.stext.StextFactory;
+
+@SuppressWarnings("all")
+public class FlowOptimizer {
+  private boolean _inlineReactions;
+  
+  public boolean inlineReactions(final boolean b) {
+    boolean __inlineReactions = this._inlineReactions = b;
+    return __inlineReactions;
+  }
+  
+  private boolean _inlineEntryActions;
+  
+  public boolean inlineEntryActions(final boolean b) {
+    boolean __inlineEntryActions = this._inlineEntryActions = b;
+    return __inlineEntryActions;
+  }
+  
+  private boolean _inlineExitActions;
+  
+  public boolean inlineExitActions(final boolean b) {
+    boolean __inlineExitActions = this._inlineExitActions = b;
+    return __inlineExitActions;
+  }
+  
+  private boolean _inlineEnterSequences;
+  
+  public boolean inlineEnterSequences(final boolean b) {
+    boolean __inlineEnterSequences = this._inlineEnterSequences = b;
+    return __inlineEnterSequences;
+  }
+  
+  private boolean _inlineEnterRegion;
+  
+  public boolean inlineEnterRegion(final boolean b) {
+    boolean __inlineEnterRegion = this._inlineEnterRegion = b;
+    return __inlineEnterRegion;
+  }
+  
+  private boolean _inlineExitRegion;
+  
+  public boolean inlineExitRegion(final boolean b) {
+    boolean __inlineExitRegion = this._inlineExitRegion = b;
+    return __inlineExitRegion;
+  }
+  
+  private boolean _inlineExitSequences;
+  
+  public boolean inlineExitSequences(final boolean b) {
+    boolean __inlineExitSequences = this._inlineExitSequences = b;
+    return __inlineExitSequences;
+  }
+  
+  private boolean _inlineChoices;
+  
+  public boolean inlineChoices(final boolean b) {
+    boolean __inlineChoices = this._inlineChoices = b;
+    return __inlineChoices;
+  }
+  
+  private boolean _inlineEntries;
+  
+  public boolean inlineEntries(final boolean b) {
+    boolean __inlineEntries = this._inlineEntries = b;
+    return __inlineEntries;
+  }
+  
+  public ExecutionFlow transform(final ExecutionFlow flow) {
+    ExecutionFlow _xblockexpression = null;
+    {
+      this.replaceTrueIfs(flow);
+      if (this._inlineReactions) {
+        this.inlineReactionChecks(flow);
+        this.inlineReactionEffects(flow);
+      }
+      if (this._inlineEntryActions) {
+        EList<ExecutionState> _states = flow.getStates();
+        final Procedure1<ExecutionState> _function = new Procedure1<ExecutionState>() {
+            public void apply(final ExecutionState state) {
+              Step _entryAction = state.getEntryAction();
+              FlowOptimizer.this.inline(_entryAction);
+            }
+          };
+        IterableExtensions.<ExecutionState>forEach(_states, _function);
+      }
+      if (this._inlineExitActions) {
+        EList<ExecutionState> _states_1 = flow.getStates();
+        final Procedure1<ExecutionState> _function_1 = new Procedure1<ExecutionState>() {
+            public void apply(final ExecutionState state) {
+              Step _exitAction = state.getExitAction();
+              FlowOptimizer.this.inline(_exitAction);
+            }
+          };
+        IterableExtensions.<ExecutionState>forEach(_states_1, _function_1);
+      }
+      if (this._inlineEnterSequences) {
+        EList<ExecutionState> _states_2 = flow.getStates();
+        final Procedure1<ExecutionState> _function_2 = new Procedure1<ExecutionState>() {
+            public void apply(final ExecutionState state) {
+              Sequence _enterSequence = state.getEnterSequence();
+              FlowOptimizer.this.inline(_enterSequence);
+            }
+          };
+        IterableExtensions.<ExecutionState>forEach(_states_2, _function_2);
+      }
+      if (this._inlineExitSequences) {
+        EList<ExecutionState> _states_3 = flow.getStates();
+        final Procedure1<ExecutionState> _function_3 = new Procedure1<ExecutionState>() {
+            public void apply(final ExecutionState state) {
+              Sequence _exitSequence = state.getExitSequence();
+              FlowOptimizer.this.inline(_exitSequence);
+            }
+          };
+        IterableExtensions.<ExecutionState>forEach(_states_3, _function_3);
+      }
+      if (this._inlineExitRegion) {
+        TreeIterator<EObject> _eAllContents = flow.eAllContents();
+        Iterator<ExecutionRegion> _filter = IteratorExtensions.<ExecutionRegion>filter(_eAllContents, ExecutionRegion.class);
+        final Procedure1<ExecutionRegion> _function_4 = new Procedure1<ExecutionRegion>() {
+            public void apply(final ExecutionRegion region) {
+              Sequence _exitSequence = region.getExitSequence();
+              FlowOptimizer.this.inline(_exitSequence);
+            }
+          };
+        IteratorExtensions.<ExecutionRegion>forEach(_filter, _function_4);
+      }
+      if (this._inlineEnterRegion) {
+        TreeIterator<EObject> _eAllContents_1 = flow.eAllContents();
+        Iterator<ExecutionRegion> _filter_1 = IteratorExtensions.<ExecutionRegion>filter(_eAllContents_1, ExecutionRegion.class);
+        final Procedure1<ExecutionRegion> _function_5 = new Procedure1<ExecutionRegion>() {
+            public void apply(final ExecutionRegion region) {
+              Sequence _enterSequence = region.getEnterSequence();
+              FlowOptimizer.this.inline(_enterSequence);
+            }
+          };
+        IteratorExtensions.<ExecutionRegion>forEach(_filter_1, _function_5);
+      }
+      if (this._inlineChoices) {
+        EList<ExecutionNode> _nodes = flow.getNodes();
+        Iterable<ExecutionChoice> _filter_2 = IterableExtensions.<ExecutionChoice>filter(_nodes, ExecutionChoice.class);
+        final Procedure1<ExecutionChoice> _function_6 = new Procedure1<ExecutionChoice>() {
+            public void apply(final ExecutionChoice node) {
+              EList<Reaction> _reactions = node.getReactions();
+              final Procedure1<Reaction> _function = new Procedure1<Reaction>() {
+                  public void apply(final Reaction r) {
+                    Check _check = r.getCheck();
+                    FlowOptimizer.this.inline(_check);
+                    Step _effect = r.getEffect();
+                    FlowOptimizer.this.inline(_effect);
+                  }
+                };
+              IterableExtensions.<Reaction>forEach(_reactions, _function);
+            }
+          };
+        IterableExtensions.<ExecutionChoice>forEach(_filter_2, _function_6);
+        EList<ExecutionNode> _nodes_1 = flow.getNodes();
+        Iterable<ExecutionChoice> _filter_3 = IterableExtensions.<ExecutionChoice>filter(_nodes_1, ExecutionChoice.class);
+        final Procedure1<ExecutionChoice> _function_7 = new Procedure1<ExecutionChoice>() {
+            public void apply(final ExecutionChoice node) {
+              Sequence _reactSequence = node.getReactSequence();
+              FlowOptimizer.this.inline(_reactSequence);
+            }
+          };
+        IterableExtensions.<ExecutionChoice>forEach(_filter_3, _function_7);
+      }
+      if (this._inlineEntries) {
+        EList<ExecutionNode> _nodes_2 = flow.getNodes();
+        Iterable<ExecutionEntry> _filter_4 = IterableExtensions.<ExecutionEntry>filter(_nodes_2, ExecutionEntry.class);
+        final Procedure1<ExecutionEntry> _function_8 = new Procedure1<ExecutionEntry>() {
+            public void apply(final ExecutionEntry node) {
+              EList<Reaction> _reactions = node.getReactions();
+              final Procedure1<Reaction> _function = new Procedure1<Reaction>() {
+                  public void apply(final Reaction r) {
+                    Check _check = r.getCheck();
+                    FlowOptimizer.this.inline(_check);
+                    Step _effect = r.getEffect();
+                    FlowOptimizer.this.inline(_effect);
+                  }
+                };
+              IterableExtensions.<Reaction>forEach(_reactions, _function);
+            }
+          };
+        IterableExtensions.<ExecutionEntry>forEach(_filter_4, _function_8);
+        EList<ExecutionNode> _nodes_3 = flow.getNodes();
+        Iterable<ExecutionEntry> _filter_5 = IterableExtensions.<ExecutionEntry>filter(_nodes_3, ExecutionEntry.class);
+        final Procedure1<ExecutionEntry> _function_9 = new Procedure1<ExecutionEntry>() {
+            public void apply(final ExecutionEntry node) {
+              Sequence _reactSequence = node.getReactSequence();
+              FlowOptimizer.this.inline(_reactSequence);
+            }
+          };
+        IterableExtensions.<ExecutionEntry>forEach(_filter_5, _function_9);
+      }
+      _xblockexpression = (flow);
+    }
+    return _xblockexpression;
+  }
+  
+  public void replaceTrueIfs(final ExecutionFlow flow) {
+    TreeIterator<EObject> _eAllContents = flow.eAllContents();
+    Iterator<If> _filter = IteratorExtensions.<If>filter(_eAllContents, If.class);
+    final Function1<If,Boolean> _function = new Function1<If,Boolean>() {
+        public Boolean apply(final If i) {
+          Check _check = i.getCheck();
+          boolean _alwaysTrue = FlowOptimizer.this.alwaysTrue(_check);
+          return Boolean.valueOf(_alwaysTrue);
+        }
+      };
+    Iterator<If> _filter_1 = IteratorExtensions.<If>filter(_filter, _function);
+    final Procedure1<If> _function_1 = new Procedure1<If>() {
+        public void apply(final If i) {
+          Step _thenStep = i.getThenStep();
+          FlowOptimizer.this.substituteBy(i, _thenStep);
+        }
+      };
+    IteratorExtensions.<If>forEach(_filter_1, _function_1);
+  }
+  
+  public Step substituteBy(final Step orig, final Step substitute) {
+    EObject _eContainer = orig.eContainer();
+    Step _substitute = this.substitute(_eContainer, orig, substitute);
+    return _substitute;
+  }
+  
+  protected Step _substitute(final Object parent, final Step orig, final Step subst) {
+    return null;
+  }
+  
+  protected Step _substitute(final Sequence parent, final Step orig, final Step subst) {
+    Step _xifexpression = null;
+    EList<Step> _steps = parent.getSteps();
+    boolean _contains = _steps.contains(orig);
+    if (_contains) {
+      EList<Step> _steps_1 = parent.getSteps();
+      EList<Step> _steps_2 = parent.getSteps();
+      int _indexOf = _steps_2.indexOf(orig);
+      Step _set = _steps_1.set(_indexOf, subst);
+      _xifexpression = _set;
+    }
+    return _xifexpression;
+  }
+  
+  protected Step _substitute(final If parent, final Step orig, final Step subst) {
+    Step _xblockexpression = null;
+    {
+      Step _thenStep = parent.getThenStep();
+      boolean _equals = ObjectExtensions.operator_equals(_thenStep, orig);
+      if (_equals) {
+        parent.setThenStep(subst);
+      } else {
+        Step _elseStep = parent.getElseStep();
+        boolean _equals_1 = ObjectExtensions.operator_equals(_elseStep, orig);
+        if (_equals_1) {
+          parent.setElseStep(subst);
+        }
+      }
+      _xblockexpression = (subst);
+    }
+    return _xblockexpression;
+  }
+  
+  public boolean alwaysTrue(final Check check) {
+    boolean _and = false;
+    boolean _notEquals = ObjectExtensions.operator_notEquals(check, null);
+    if (!_notEquals) {
+      _and = false;
+    } else {
+      Statement _condition = check.getCondition();
+      _and = BooleanExtensions.operator_and(_notEquals, (_condition instanceof PrimitiveValueExpression));
+    }
+    if (_and) {
+      Statement _condition_1 = check.getCondition();
+      final PrimitiveValueExpression pve = ((PrimitiveValueExpression) _condition_1);
+      boolean _and_1 = false;
+      Literal _value = pve.getValue();
+      if (!(_value instanceof BoolLiteral)) {
+        _and_1 = false;
+      } else {
+        Literal _value_1 = pve.getValue();
+        boolean _isValue = ((BoolLiteral) _value_1).isValue();
+        _and_1 = BooleanExtensions.operator_and((_value instanceof BoolLiteral), _isValue);
+      }
+      return _and_1;
+    }
+    return false;
+  }
+  
+  protected boolean _empty(final Step step) {
+    return false;
+  }
+  
+  protected boolean _empty(final Sequence seq) {
+    EList<Step> _steps = seq.getSteps();
+    int _size = _steps.size();
+    boolean _equals = IntegerExtensions.operator_equals(_size, 0);
+    return _equals;
+  }
+  
+  public void inlineReactionChecks(final ExecutionFlow flow) {
+    EList<ExecutionState> _states = flow.getStates();
+    final Procedure1<ExecutionState> _function = new Procedure1<ExecutionState>() {
+        public void apply(final ExecutionState state) {
+          FlowOptimizer.this.inlineReactionChecks(state);
+        }
+      };
+    IterableExtensions.<ExecutionState>forEach(_states, _function);
+  }
+  
+  public ExecutionState inlineReactionChecks(final ExecutionState state) {
+    ExecutionState _xblockexpression = null;
+    {
+      EList<Reaction> _reactions = state.getReactions();
+      final Function1<Reaction,Check> _function = new Function1<Reaction,Check>() {
+          public Check apply(final Reaction r) {
+            Check _check = r.getCheck();
+            return _check;
+          }
+        };
+      List<Check> _map = ListExtensions.<Reaction, Check>map(_reactions, _function);
+      final List<Check> checks = IterableExtensions.<Check>toList(_map);
+      final Procedure1<Check> _function_1 = new Procedure1<Check>() {
+          public void apply(final Check c) {
+            FlowOptimizer.this.inline(c);
+          }
+        };
+      IterableExtensions.<Check>forEach(checks, _function_1);
+      _xblockexpression = (state);
+    }
+    return _xblockexpression;
+  }
+  
+  public Check inline(final Check c) {
+    Check _xblockexpression = null;
+    {
+      boolean _notEquals = ObjectExtensions.operator_notEquals(c, null);
+      if (_notEquals) {
+        ArrayList<CheckRef> _arrayList = new ArrayList<CheckRef>();
+        final List<CheckRef> cRefs = _arrayList;
+        EList<CheckRef> _refs = c.getRefs();
+        cRefs.addAll(_refs);
+        for (final CheckRef ref : cRefs) {
+          {
+            final Check clone = EcoreUtil.<Check>copy(c);
+            EObject _eContainer = ref.eContainer();
+            this.substitute(_eContainer, ref, clone);
+            ref.setCheck(null);
+          }
+        }
+      }
+      _xblockexpression = (c);
+    }
+    return _xblockexpression;
+  }
+  
+  protected Step _substitute(final EObject owner, final Check pre, final Check post) {
+    return null;
+  }
+  
+  protected Step _substitute(final If owner, final Check pre, final Check post) {
+    Check _xblockexpression = null;
+    {
+      Check _check = owner.getCheck();
+      boolean _equals = ObjectExtensions.operator_equals(_check, pre);
+      if (_equals) {
+        owner.setCheck(post);
+      }
+      _xblockexpression = (post);
+    }
+    return _xblockexpression;
+  }
+  
+  public void inlineReactionEffects(final ExecutionFlow flow) {
+    EList<ExecutionState> _states = flow.getStates();
+    final Procedure1<ExecutionState> _function = new Procedure1<ExecutionState>() {
+        public void apply(final ExecutionState state) {
+          FlowOptimizer.this.inlineReactionEffects(state);
+        }
+      };
+    IterableExtensions.<ExecutionState>forEach(_states, _function);
+  }
+  
+  public ExecutionState inlineReactionEffects(final ExecutionState state) {
+    ExecutionState _xblockexpression = null;
+    {
+      EList<Reaction> _reactions = state.getReactions();
+      final Function1<Reaction,Step> _function = new Function1<Reaction,Step>() {
+          public Step apply(final Reaction r) {
+            Step _effect = r.getEffect();
+            return _effect;
+          }
+        };
+      List<Step> _map = ListExtensions.<Reaction, Step>map(_reactions, _function);
+      final List<Step> effects = IterableExtensions.<Step>toList(_map);
+      final Procedure1<Step> _function_1 = new Procedure1<Step>() {
+          public void apply(final Step e) {
+            FlowOptimizer.this.inline(e);
+          }
+        };
+      IterableExtensions.<Step>forEach(effects, _function_1);
+      _xblockexpression = (state);
+    }
+    return _xblockexpression;
+  }
+  
+  public void inlineEntryAndExitActions(final ExecutionFlow flow) {
+    EList<ExecutionState> _states = flow.getStates();
+    final Procedure1<ExecutionState> _function = new Procedure1<ExecutionState>() {
+        public void apply(final ExecutionState state) {
+          Step _entryAction = state.getEntryAction();
+          FlowOptimizer.this.inline(_entryAction);
+        }
+      };
+    IterableExtensions.<ExecutionState>forEach(_states, _function);
+    EList<ExecutionState> _states_1 = flow.getStates();
+    final Procedure1<ExecutionState> _function_1 = new Procedure1<ExecutionState>() {
+        public void apply(final ExecutionState state) {
+          Step _exitAction = state.getExitAction();
+          FlowOptimizer.this.inline(_exitAction);
+        }
+      };
+    IterableExtensions.<ExecutionState>forEach(_states_1, _function_1);
+  }
+  
+  public Step inline(final Step step) {
+    Step _xblockexpression = null;
+    {
+      boolean _notEquals = ObjectExtensions.operator_notEquals(step, null);
+      if (_notEquals) {
+        ArrayList<Call> _arrayList = new ArrayList<Call>();
+        final List<Call> calls = _arrayList;
+        EList<Call> _caller = step.getCaller();
+        calls.addAll(_caller);
+        for (final Call caller : calls) {
+          {
+            final Step clone = this.stepCopy(step);
+            EObject _eContainer = caller.eContainer();
+            boolean _substituteCall = this.substituteCall(_eContainer, caller, clone);
+            if (_substituteCall) {
+              caller.setStep(null);
+            } else {
+              String _plus = StringExtensions.operator_plus("Did not substitute \'", step);
+              String _plus_1 = ObjectExtensions.operator_plus(_plus, "\' call from \'");
+              EObject _eContainer_1 = caller.eContainer();
+              String _plus_2 = StringExtensions.operator_plus(_plus_1, _eContainer_1);
+              String _plus_3 = ObjectExtensions.operator_plus(_plus_2, "\'.");
+              System.out.println(_plus_3);
+            }
+          }
+        }
+      }
+      _xblockexpression = (step);
+    }
+    return _xblockexpression;
+  }
+  
+  protected boolean _substituteCall(final EObject owner, final Call pre, final Step post) {
+    return false;
+  }
+  
+  protected boolean _substituteCall(final StateCase owner, final Call pre, final Step post) {
+    Step _step = owner.getStep();
+    boolean _equals = ObjectExtensions.operator_equals(_step, pre);
+    if (_equals) {
+      owner.setStep(post);
+      return true;
+    }
+    return false;
+  }
+  
+  protected boolean _substituteCall(final HistoryEntry owner, final Call pre, final Step post) {
+    Step _initialStep = owner.getInitialStep();
+    boolean _equals = ObjectExtensions.operator_equals(_initialStep, pre);
+    if (_equals) {
+      owner.setInitialStep(post);
+      return true;
+    }
+    Step _historyStep = owner.getHistoryStep();
+    boolean _equals_1 = ObjectExtensions.operator_equals(_historyStep, pre);
+    if (_equals_1) {
+      owner.setHistoryStep(post);
+      return true;
+    }
+    return false;
+  }
+  
+  protected boolean _substituteCall(final Sequence owner, final Call call, final Step step) {
+    EList<Step> _steps = owner.getSteps();
+    boolean _contains = _steps.contains(call);
+    if (_contains) {
+      EList<Step> _steps_1 = owner.getSteps();
+      EList<Step> _steps_2 = owner.getSteps();
+      int _indexOf = _steps_2.indexOf(call);
+      _steps_1.set(_indexOf, step);
+      return true;
+    }
+    return false;
+  }
+  
+  protected boolean _substituteCall(final If owner, final Call call, final Step step) {
+    Step _thenStep = owner.getThenStep();
+    boolean _equals = ObjectExtensions.operator_equals(_thenStep, call);
+    if (_equals) {
+      owner.setThenStep(step);
+      return true;
+    } else {
+      Step _elseStep = owner.getElseStep();
+      boolean _equals_1 = ObjectExtensions.operator_equals(_elseStep, call);
+      if (_equals_1) {
+        owner.setElseStep(step);
+        return true;
+      }
+    }
+    return false;
+  }
+  
+  protected Step _stepCopy(final Step step) {
+    Step _copy = EcoreUtil.<Step>copy(step);
+    return _copy;
+  }
+  
+  protected Step _stepCopy(final Sequence seq) {
+    Sequence _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      final Sequence _copy = _sexecFactory.createSequence();
+      String _name = seq.getName();
+      _copy.setName(_name);
+      String _comment = seq.getComment();
+      _copy.setComment(_comment);
+      EList<Step> _steps = _copy.getSteps();
+      EList<Step> _steps_1 = seq.getSteps();
+      final Function1<Step,Step> _function = new Function1<Step,Step>() {
+          public Step apply(final Step s) {
+            Step _stepCopy = FlowOptimizer.this.stepCopy(s);
+            return _stepCopy;
+          }
+        };
+      List<Step> _map = ListExtensions.<Step, Step>map(_steps_1, _function);
+      _steps.addAll(_map);
+      _xblockexpression = (_copy);
+    }
+    return _xblockexpression;
+  }
+  
+  protected Step _stepCopy(final If _if) {
+    If _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      final If _copy = _sexecFactory.createIf();
+      String _name = _if.getName();
+      _copy.setName(_name);
+      String _comment = _if.getComment();
+      _copy.setComment(_comment);
+      Check _check = _if.getCheck();
+      Step _stepCopy = this.stepCopy(_check);
+      _copy.setCheck(((Check) _stepCopy));
+      Step _xifexpression = null;
+      Step _thenStep = _if.getThenStep();
+      boolean _notEquals = ObjectExtensions.operator_notEquals(_thenStep, null);
+      if (_notEquals) {
+        Step _thenStep_1 = _if.getThenStep();
+        Step _stepCopy_1 = this.stepCopy(_thenStep_1);
+        _xifexpression = _stepCopy_1;
+      } else {
+        _xifexpression = null;
+      }
+      _copy.setThenStep(_xifexpression);
+      Step _xifexpression_1 = null;
+      Step _elseStep = _if.getElseStep();
+      boolean _notEquals_1 = ObjectExtensions.operator_notEquals(_elseStep, null);
+      if (_notEquals_1) {
+        Step _elseStep_1 = _if.getElseStep();
+        Step _stepCopy_2 = this.stepCopy(_elseStep_1);
+        _xifexpression_1 = _stepCopy_2;
+      } else {
+        _xifexpression_1 = null;
+      }
+      _copy.setElseStep(_xifexpression_1);
+      _xblockexpression = (_copy);
+    }
+    return _xblockexpression;
+  }
+  
+  protected Step _stepCopy(final Call call) {
+    Call _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      final Call _copy = _sexecFactory.createCall();
+      String _name = call.getName();
+      _copy.setName(_name);
+      String _comment = call.getComment();
+      _copy.setComment(_comment);
+      Step _step = call.getStep();
+      _copy.setStep(_step);
+      _xblockexpression = (_copy);
+    }
+    return _xblockexpression;
+  }
+  
+  protected Step _stepCopy(final CheckRef cref) {
+    CheckRef _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      final CheckRef _copy = _sexecFactory.createCheckRef();
+      String _name = cref.getName();
+      _copy.setName(_name);
+      String _comment = cref.getComment();
+      _copy.setComment(_comment);
+      Check _check = cref.getCheck();
+      _copy.setCheck(_check);
+      _xblockexpression = (_copy);
+    }
+    return _xblockexpression;
+  }
+  
+  protected Step _stepCopy(final HistoryEntry cref) {
+    HistoryEntry _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      final HistoryEntry _copy = _sexecFactory.createHistoryEntry();
+      String _name = cref.getName();
+      _copy.setName(_name);
+      String _comment = cref.getComment();
+      _copy.setComment(_comment);
+      boolean _isDeep = cref.isDeep();
+      _copy.setDeep(_isDeep);
+      ExecutionRegion _region = cref.getRegion();
+      _copy.setRegion(_region);
+      Step _initialStep = cref.getInitialStep();
+      Step _stepCopy = this.stepCopy(_initialStep);
+      _copy.setInitialStep(_stepCopy);
+      Step _historyStep = cref.getHistoryStep();
+      Step _stepCopy_1 = this.stepCopy(_historyStep);
+      _copy.setHistoryStep(_stepCopy_1);
+      _xblockexpression = (_copy);
+    }
+    return _xblockexpression;
+  }
+  
+  protected Step _stepCopy(final StateSwitch _switch) {
+    StateSwitch _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      final StateSwitch _copy = _sexecFactory.createStateSwitch();
+      String _name = _switch.getName();
+      _copy.setName(_name);
+      String _comment = _switch.getComment();
+      _copy.setComment(_comment);
+      int _stateConfigurationIdx = _switch.getStateConfigurationIdx();
+      _copy.setStateConfigurationIdx(_stateConfigurationIdx);
+      EList<StateCase> _cases = _copy.getCases();
+      EList<StateCase> _cases_1 = _switch.getCases();
+      final Function1<StateCase,StateCase> _function = new Function1<StateCase,StateCase>() {
+          public StateCase apply(final StateCase c) {
+            StateCase _stepCopy = FlowOptimizer.this.stepCopy(c);
+            return _stepCopy;
+          }
+        };
+      List<StateCase> _map = ListExtensions.<StateCase, StateCase>map(_cases_1, _function);
+      _cases.addAll(_map);
+      _xblockexpression = (_copy);
+    }
+    return _xblockexpression;
+  }
+  
+  public StateCase stepCopy(final StateCase _case) {
+    StateCase _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      final StateCase _copy = _sexecFactory.createStateCase();
+      ExecutionState _state = _case.getState();
+      _copy.setState(_state);
+      Step _step = _case.getStep();
+      Step _stepCopy = this.stepCopy(_step);
+      _copy.setStep(_stepCopy);
+      _xblockexpression = (_copy);
+    }
+    return _xblockexpression;
+  }
+  
+  public SexecFactory sexecFactory() {
+    return SexecFactory.eINSTANCE;
+  }
+  
+  public SGraphFactory sgraphFactory() {
+    return SGraphFactory.eINSTANCE;
+  }
+  
+  public StextFactory stextFactory() {
+    return StextFactory.eINSTANCE;
+  }
+  
+  public Step substitute(final Object owner, final Step pre, final Step post) {
+    if (owner instanceof If
+         && pre instanceof Check
+         && post instanceof Check) {
+      return _substitute((If)owner, (Check)pre, (Check)post);
+    } else if (owner instanceof If
+         && pre != null
+         && post != null) {
+      return _substitute((If)owner, pre, post);
+    } else if (owner instanceof Sequence
+         && pre != null
+         && post != null) {
+      return _substitute((Sequence)owner, pre, post);
+    } else if (owner instanceof EObject
+         && pre instanceof Check
+         && post instanceof Check) {
+      return _substitute((EObject)owner, (Check)pre, (Check)post);
+    } else if (owner != null
+         && pre != null
+         && post != null) {
+      return _substitute(owner, pre, post);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(owner, pre, post).toString());
+    }
+  }
+  
+  public boolean empty(final Step seq) {
+    if (seq instanceof Sequence) {
+      return _empty((Sequence)seq);
+    } else if (seq != null) {
+      return _empty(seq);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(seq).toString());
+    }
+  }
+  
+  public boolean substituteCall(final EObject owner, final Call pre, final Step post) {
+    if (owner instanceof HistoryEntry) {
+      return _substituteCall((HistoryEntry)owner, pre, post);
+    } else if (owner instanceof If) {
+      return _substituteCall((If)owner, pre, post);
+    } else if (owner instanceof Sequence) {
+      return _substituteCall((Sequence)owner, pre, post);
+    } else if (owner instanceof StateCase) {
+      return _substituteCall((StateCase)owner, pre, post);
+    } else if (owner != null) {
+      return _substituteCall(owner, pre, post);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(owner, pre, post).toString());
+    }
+  }
+  
+  public Step stepCopy(final Step cref) {
+    if (cref instanceof CheckRef) {
+      return _stepCopy((CheckRef)cref);
+    } else if (cref instanceof Call) {
+      return _stepCopy((Call)cref);
+    } else if (cref instanceof HistoryEntry) {
+      return _stepCopy((HistoryEntry)cref);
+    } else if (cref instanceof If) {
+      return _stepCopy((If)cref);
+    } else if (cref instanceof Sequence) {
+      return _stepCopy((Sequence)cref);
+    } else if (cref instanceof StateSwitch) {
+      return _stepCopy((StateSwitch)cref);
+    } else if (cref != null) {
+      return _stepCopy(cref);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(cref).toString());
+    }
+  }
+}

+ 263 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/ModelSequencer.java

@@ -0,0 +1,263 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import com.google.inject.Inject;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogConfigurationException;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.EcoreUtil2;
+import org.eclipse.xtext.naming.IQualifiedNameProvider;
+import org.eclipse.xtext.naming.QualifiedName;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.Exceptions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.InputOutput;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.yakindu.base.types.Feature;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sexec.TimeEvent;
+import org.yakindu.sct.model.sexec.transformation.BehaviorMapping;
+import org.yakindu.sct.model.sexec.transformation.ReactionBuilder;
+import org.yakindu.sct.model.sexec.transformation.SequenceBuilder;
+import org.yakindu.sct.model.sexec.transformation.SexecElementMapping;
+import org.yakindu.sct.model.sexec.transformation.StateVectorBuilder;
+import org.yakindu.sct.model.sexec.transformation.StructureMapping;
+import org.yakindu.sct.model.sgraph.Declaration;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.stext.stext.ElementReferenceExpression;
+import org.yakindu.sct.model.stext.stext.EventDefinition;
+import org.yakindu.sct.model.stext.stext.FeatureCall;
+import org.yakindu.sct.model.stext.stext.OperationDefinition;
+import org.yakindu.sct.model.stext.stext.VariableDefinition;
+
+@SuppressWarnings("all")
+public class ModelSequencer {
+  @Inject
+  private IQualifiedNameProvider qfnProvider;
+  
+  @Inject
+  private SexecElementMapping mapping;
+  
+  @Inject
+  private StructureMapping structureMapping;
+  
+  @Inject
+  private BehaviorMapping behaviorMapping;
+  
+  @Inject
+  private ReactionBuilder reactBuilder;
+  
+  @Inject
+  private SequenceBuilder seqBuilder;
+  
+  @Inject
+  private StateVectorBuilder svBuilder;
+  
+  /**
+   * ==========================================================================
+   * TRANSFORMATION ROOT
+   */
+  public ExecutionFlow transform(final Statechart sc) {
+    final ExecutionFlow ef = this.mapping.create(sc);
+    this.structureMapping.mapScopes(sc, ef);
+    this.structureMapping.mapRegularStates(sc, ef);
+    this.structureMapping.mapRegions(sc, ef);
+    this.structureMapping.mapPseudoStates(sc, ef);
+    this.structureMapping.mapTimeEvents(sc, ef);
+    this.svBuilder.defineStateVector(ef, sc);
+    this.svBuilder.defineHistoryVector(ef, sc);
+    this.behaviorMapping.mapEntryActions(sc, ef);
+    this.behaviorMapping.mapExitActions(sc, ef);
+    this.seqBuilder.defineStateEnterSequences(ef, sc);
+    this.seqBuilder.defineStateExitSequences(ef, sc);
+    this.seqBuilder.defineDeepEnterSequences(ef, sc);
+    this.seqBuilder.defineShallowEnterSequences(ef, sc);
+    this.seqBuilder.defineStatechartEnterSequence(ef, sc);
+    this.seqBuilder.defineStatechartExitSequence(ef, sc);
+    this.behaviorMapping.mapTransitions(sc, ef);
+    this.behaviorMapping.mapLocalReactions(sc, ef);
+    this.behaviorMapping.mapChoiceTransitions(sc, ef);
+    this.behaviorMapping.mapSyncTransitions(sc, ef);
+    this.reactBuilder.defineEntryReactions(sc, ef);
+    this.reactBuilder.defineRegularStateReactions(ef, sc);
+    this.reactBuilder.definePseudoStateReactions(ef, sc);
+    this.reactBuilder.defineStatechartReaction(ef, sc);
+    this.retargetDeclRefs(ef);
+    return ef;
+  }
+  
+  /**
+   * retarget declaration refs
+   */
+  public void retargetDeclRefs(final ExecutionFlow flow) {
+    final List<EObject> allContent = EcoreUtil2.eAllContentsAsList(flow);
+    final Function1<EObject,Boolean> _function = new Function1<EObject,Boolean>() {
+        public Boolean apply(final EObject e) {
+          boolean _or = false;
+          boolean _or_1 = false;
+          if ((e instanceof EventDefinition)) {
+            _or_1 = true;
+          } else {
+            _or_1 = BooleanExtensions.operator_or((e instanceof EventDefinition), (e instanceof VariableDefinition));
+          }
+          if (_or_1) {
+            _or = true;
+          } else {
+            _or = BooleanExtensions.operator_or(_or_1, (e instanceof OperationDefinition));
+          }
+          return Boolean.valueOf(_or);
+        }
+      };
+    Iterable<EObject> _filter = IterableExtensions.<EObject>filter(allContent, _function);
+    final Set<EObject> declared = IterableExtensions.<EObject>toSet(_filter);
+    Iterable<ElementReferenceExpression> _filter_1 = IterableExtensions.<ElementReferenceExpression>filter(allContent, ElementReferenceExpression.class);
+    final Procedure1<ElementReferenceExpression> _function_1 = new Procedure1<ElementReferenceExpression>() {
+        public void apply(final ElementReferenceExpression ere) {
+          ModelSequencer.this.retarget(ere, declared);
+        }
+      };
+    IterableExtensions.<ElementReferenceExpression>forEach(_filter_1, _function_1);
+    Iterable<FeatureCall> _filter_2 = IterableExtensions.<FeatureCall>filter(allContent, FeatureCall.class);
+    final Procedure1<FeatureCall> _function_2 = new Procedure1<FeatureCall>() {
+        public void apply(final FeatureCall call) {
+          ModelSequencer.this.retarget(call, declared);
+        }
+      };
+    IterableExtensions.<FeatureCall>forEach(_filter_2, _function_2);
+  }
+  
+  public void retarget(final ElementReferenceExpression ere, final Collection<EObject> declared) {
+    boolean _and = false;
+    EObject _reference = ere.getReference();
+    boolean _notEquals = ObjectExtensions.operator_notEquals(_reference, null);
+    if (!_notEquals) {
+      _and = false;
+    } else {
+      EObject _reference_1 = ere.getReference();
+      boolean _contains = declared.contains(_reference_1);
+      boolean _not = BooleanExtensions.operator_not(_contains);
+      _and = BooleanExtensions.operator_and(_notEquals, _not);
+    }
+    if (_and) {
+      EObject _reference_2 = ere.getReference();
+      final Declaration r = this.replaced(_reference_2);
+      boolean _notEquals_1 = ObjectExtensions.operator_notEquals(r, null);
+      if (_notEquals_1) {
+        ere.setReference(r);
+      }
+    }
+  }
+  
+  public void retarget(final FeatureCall call, final Collection<EObject> declared) {
+    boolean _and = false;
+    EObject _feature = call.getFeature();
+    boolean _notEquals = ObjectExtensions.operator_notEquals(_feature, null);
+    if (!_notEquals) {
+      _and = false;
+    } else {
+      EObject _feature_1 = call.getFeature();
+      boolean _contains = declared.contains(_feature_1);
+      boolean _not = BooleanExtensions.operator_not(_contains);
+      _and = BooleanExtensions.operator_and(_notEquals, _not);
+    }
+    if (_and) {
+      EObject _feature_2 = call.getFeature();
+      final Declaration r = this.replaced(_feature_2);
+      boolean _notEquals_1 = ObjectExtensions.operator_notEquals(r, null);
+      if (_notEquals_1) {
+        call.setFeature(((Feature) r));
+      }
+    }
+  }
+  
+  protected Declaration _replaced(final EObject ne) {
+    Declaration _xblockexpression = null;
+    {
+      try {
+        Comparable<? extends Object> _xifexpression = null;
+        boolean _equals = ObjectExtensions.operator_equals(ne, null);
+        if (_equals) {
+          _xifexpression = "null";
+        } else {
+          QualifiedName _fullyQualifiedName = this.qfnProvider.getFullyQualifiedName(ne);
+          _xifexpression = _fullyQualifiedName;
+        }
+        String _plus = StringExtensions.operator_plus("Replace with unknown eObject called: ", _xifexpression);
+        InputOutput.<String>println(_plus);
+        Log _log = LogFactory.getLog(ModelSequencer.class);
+        Comparable<? extends Object> _xifexpression_1 = null;
+        boolean _equals_1 = ObjectExtensions.operator_equals(ne, null);
+        if (_equals_1) {
+          _xifexpression_1 = "null";
+        } else {
+          QualifiedName _fullyQualifiedName_1 = this.qfnProvider.getFullyQualifiedName(ne);
+          _xifexpression_1 = _fullyQualifiedName_1;
+        }
+        String _plus_1 = StringExtensions.operator_plus("Replace with unknown NamedElement called: ", _xifexpression_1);
+        _log.error(_plus_1);
+      } catch (final Throwable _t) {
+        if (_t instanceof LogConfigurationException) {
+          final LogConfigurationException e = (LogConfigurationException)_t;
+          e.printStackTrace();
+          Comparable<? extends Object> _xifexpression_2 = null;
+          boolean _equals_2 = ObjectExtensions.operator_equals(ne, null);
+          if (_equals_2) {
+            _xifexpression_2 = "null";
+          } else {
+            QualifiedName _fullyQualifiedName_2 = this.qfnProvider.getFullyQualifiedName(ne);
+            _xifexpression_2 = _fullyQualifiedName_2;
+          }
+          String _plus_2 = StringExtensions.operator_plus("Replace with unknown NamedElement called: ", _xifexpression_2);
+          InputOutput.<String>println(_plus_2);
+        } else {
+          throw Exceptions.sneakyThrow(_t);
+        }
+      }
+      _xblockexpression = (null);
+    }
+    return _xblockexpression;
+  }
+  
+  protected Declaration _replaced(final VariableDefinition vd) {
+    VariableDefinition _create = this.mapping.create(vd);
+    return _create;
+  }
+  
+  protected Declaration _replaced(final OperationDefinition vd) {
+    OperationDefinition _create = this.mapping.create(vd);
+    return _create;
+  }
+  
+  protected Declaration _replaced(final EventDefinition ed) {
+    EventDefinition _create = this.mapping.create(ed);
+    return _create;
+  }
+  
+  protected Declaration _replaced(final TimeEvent ed) {
+    return ed;
+  }
+  
+  public Declaration replaced(final EObject ed) {
+    if (ed instanceof TimeEvent) {
+      return _replaced((TimeEvent)ed);
+    } else if (ed instanceof EventDefinition) {
+      return _replaced((EventDefinition)ed);
+    } else if (ed instanceof OperationDefinition) {
+      return _replaced((OperationDefinition)ed);
+    } else if (ed instanceof VariableDefinition) {
+      return _replaced((VariableDefinition)ed);
+    } else if (ed != null) {
+      return _replaced(ed);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(ed).toString());
+    }
+  }
+}

+ 582 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/ReactionBuilder.java

@@ -0,0 +1,582 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
+import java.util.HashSet;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.EcoreUtil2;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.CollectionExtensions;
+import org.eclipse.xtext.xbase.lib.CollectionLiterals;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+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.ListExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
+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.ExecutionChoice;
+import org.yakindu.sct.model.sexec.ExecutionEntry;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sexec.ExecutionNode;
+import org.yakindu.sct.model.sexec.ExecutionRegion;
+import org.yakindu.sct.model.sexec.ExecutionState;
+import org.yakindu.sct.model.sexec.ExecutionSynchronization;
+import org.yakindu.sct.model.sexec.HistoryEntry;
+import org.yakindu.sct.model.sexec.If;
+import org.yakindu.sct.model.sexec.Reaction;
+import org.yakindu.sct.model.sexec.ReactionFired;
+import org.yakindu.sct.model.sexec.Sequence;
+import org.yakindu.sct.model.sexec.SexecFactory;
+import org.yakindu.sct.model.sexec.StateCase;
+import org.yakindu.sct.model.sexec.StateSwitch;
+import org.yakindu.sct.model.sexec.StateVector;
+import org.yakindu.sct.model.sexec.Step;
+import org.yakindu.sct.model.sexec.TraceNodeExecuted;
+import org.yakindu.sct.model.sexec.transformation.SexecElementMapping;
+import org.yakindu.sct.model.sexec.transformation.SexecExtensions;
+import org.yakindu.sct.model.sexec.transformation.SgraphExtensions;
+import org.yakindu.sct.model.sexec.transformation.StatechartExtensions;
+import org.yakindu.sct.model.sexec.transformation.TraceExtensions;
+import org.yakindu.sct.model.sgraph.Choice;
+import org.yakindu.sct.model.sgraph.Entry;
+import org.yakindu.sct.model.sgraph.EntryKind;
+import org.yakindu.sct.model.sgraph.FinalState;
+import org.yakindu.sct.model.sgraph.Region;
+import org.yakindu.sct.model.sgraph.RegularState;
+import org.yakindu.sct.model.sgraph.State;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.sgraph.Statement;
+import org.yakindu.sct.model.sgraph.Synchronization;
+import org.yakindu.sct.model.sgraph.Transition;
+import org.yakindu.sct.model.stext.stext.BoolLiteral;
+import org.yakindu.sct.model.stext.stext.Literal;
+import org.yakindu.sct.model.stext.stext.PrimitiveValueExpression;
+
+@SuppressWarnings("all")
+public class ReactionBuilder {
+  @Inject
+  private SexecElementMapping mapping;
+  
+  @Inject
+  private SexecExtensions sexec;
+  
+  @Inject
+  private SgraphExtensions sgraph;
+  
+  @Inject
+  private StatechartExtensions sct;
+  
+  @Inject
+  private TraceExtensions trace;
+  
+  public ExecutionFlow defineStatechartReaction(final ExecutionFlow flow, final Statechart sc) {
+    SexecFactory _factory = this.sexec.factory();
+    final Sequence sequence = _factory.createSequence();
+    sequence.setName("react");
+    String _name = sc.getName();
+    String _plus = ObjectExtensions.operator_plus("The reactions of statechart ", _name);
+    sequence.setComment(_plus);
+    List<RegularState> _allRegularStates = this.sct.allRegularStates(sc);
+    final Function1<RegularState,Boolean> _function = new Function1<RegularState,Boolean>() {
+        public Boolean apply(final RegularState s) {
+          boolean _isLeaf = ReactionBuilder.this.sgraph.isLeaf(s);
+          return Boolean.valueOf(_isLeaf);
+        }
+      };
+    final Iterable<RegularState> leafStates = IterableExtensions.<RegularState>filter(_allRegularStates, _function);
+    SexecFactory _factory_1 = this.sexec.factory();
+    final StateSwitch sSwitch = _factory_1.createStateSwitch();
+    EList<Step> _steps = sequence.getSteps();
+    CollectionExtensions.<StateSwitch>operator_add(_steps, sSwitch);
+    final Function1<RegularState,ExecutionState> _function_1 = new Function1<RegularState,ExecutionState>() {
+        public ExecutionState apply(final RegularState s) {
+          ExecutionState _create = ReactionBuilder.this.mapping.create(s);
+          return _create;
+        }
+      };
+    Iterable<ExecutionState> _map = IterableExtensions.<RegularState, ExecutionState>map(leafStates, _function_1);
+    for (final ExecutionState leaf : _map) {
+      {
+        SexecFactory _factory_2 = this.sexec.factory();
+        final StateCase sCase = _factory_2.createStateCase();
+        sCase.setState(leaf);
+        Sequence _reactSequence = leaf.getReactSequence();
+        Call _newCall = this.mapping.newCall(_reactSequence);
+        sCase.setStep(_newCall);
+        EList<StateCase> _cases = sSwitch.getCases();
+        CollectionExtensions.<StateCase>operator_add(_cases, sCase);
+      }
+    }
+    flow.setReactSequence(sequence);
+    return flow;
+  }
+  
+  public ExecutionFlow defineRegularStateReactions(final ExecutionFlow flow, final Statechart sc) {
+    final List<RegularState> states = this.sct.allRegularStates(sc);
+    Iterable<State> _filter = IterableExtensions.<State>filter(states, State.class);
+    final Function1<State,Boolean> _function = new Function1<State,Boolean>() {
+        public Boolean apply(final State s) {
+          boolean _isSimple = s.isSimple();
+          return Boolean.valueOf(_isSimple);
+        }
+      };
+    Iterable<State> _filter_1 = IterableExtensions.<State>filter(_filter, _function);
+    final Procedure1<State> _function_1 = new Procedure1<State>() {
+        public void apply(final State s) {
+          ReactionBuilder.this.defineCycle(s);
+        }
+      };
+    IterableExtensions.<State>forEach(_filter_1, _function_1);
+    Iterable<FinalState> _filter_2 = IterableExtensions.<FinalState>filter(states, FinalState.class);
+    final Procedure1<FinalState> _function_2 = new Procedure1<FinalState>() {
+        public void apply(final FinalState s) {
+          ReactionBuilder.this.defineCycle(s);
+        }
+      };
+    IterableExtensions.<FinalState>forEach(_filter_2, _function_2);
+    return flow;
+  }
+  
+  public void definePseudoStateReactions(final ExecutionFlow flow, final Statechart sc) {
+    Iterable<Choice> _allChoices = this.sct.allChoices(sc);
+    final Procedure1<Choice> _function = new Procedure1<Choice>() {
+        public void apply(final Choice choice) {
+          ReactionBuilder.this.defineReaction(choice);
+        }
+      };
+    IterableExtensions.<Choice>forEach(_allChoices, _function);
+    Iterable<Synchronization> _allSynchronizations = this.sct.allSynchronizations(sc);
+    final Procedure1<Synchronization> _function_1 = new Procedure1<Synchronization>() {
+        public void apply(final Synchronization sync) {
+          ReactionBuilder.this.defineReaction(sync);
+        }
+      };
+    IterableExtensions.<Synchronization>forEach(_allSynchronizations, _function_1);
+  }
+  
+  public Sequence defineReaction(final Choice choice) {
+    final ExecutionChoice execChoice = this.mapping.create(choice);
+    EList<Reaction> _reactions = execChoice.getReactions();
+    final Function1<Reaction,Boolean> _function = new Function1<Reaction,Boolean>() {
+        public Boolean apply(final Reaction r) {
+          Check _check = r.getCheck();
+          boolean _alwaysTrue = ReactionBuilder.this.alwaysTrue(_check);
+          return Boolean.valueOf(_alwaysTrue);
+        }
+      };
+    Iterable<Reaction> _filter = IterableExtensions.<Reaction>filter(_reactions, _function);
+    List<Reaction> _list = IterableExtensions.<Reaction>toList(_filter);
+    final Reaction _default_ = IterableExtensions.<Reaction>head(_list);
+    boolean _notEquals = ObjectExtensions.operator_notEquals(_default_, null);
+    if (_notEquals) {
+      EList<Reaction> _reactions_1 = execChoice.getReactions();
+      EList<Reaction> _reactions_2 = execChoice.getReactions();
+      int _size = _reactions_2.size();
+      int _minus = IntegerExtensions.operator_minus(_size, 1);
+      _reactions_1.move(_minus, _default_);
+    }
+    final Sequence stateReaction = this.createReactionSequence(execChoice, null);
+    Sequence _reactSequence = execChoice.getReactSequence();
+    EList<Step> _steps = _reactSequence.getSteps();
+    EList<Step> _steps_1 = stateReaction.getSteps();
+    _steps.addAll(_steps_1);
+    Sequence _reactSequence_1 = execChoice.getReactSequence();
+    _reactSequence_1.setName("react");
+    Sequence _reactSequence_2 = execChoice.getReactSequence();
+    String _name = choice.getName();
+    String _plus = ObjectExtensions.operator_plus("The reactions of state ", _name);
+    String _plus_1 = ObjectExtensions.operator_plus(_plus, ".");
+    _reactSequence_2.setComment(_plus_1);
+    boolean _isAddTraceSteps = this.trace.isAddTraceSteps();
+    if (_isAddTraceSteps) {
+      Sequence _reactSequence_3 = execChoice.getReactSequence();
+      EList<Step> _steps_2 = _reactSequence_3.getSteps();
+      ExecutionChoice _create = this.mapping.create(choice);
+      TraceNodeExecuted _newTraceNodeExecuted = this.trace.newTraceNodeExecuted(_create);
+      _steps_2.add(0, _newTraceNodeExecuted);
+    }
+    return execChoice.getReactSequence();
+  }
+  
+  /**
+   * TODO : support fork...
+   */
+  public Sequence defineReaction(final Synchronization sync) {
+    final ExecutionSynchronization execSync = this.mapping.create(sync);
+    EList<Reaction> _reactions = execSync.getReactions();
+    final Reaction _default_ = IterableExtensions.<Reaction>head(_reactions);
+    Sequence _reactSequence = execSync.getReactSequence();
+    EList<Step> _steps = _reactSequence.getSteps();
+    Step _effect = _default_.getEffect();
+    CollectionExtensions.<Step>addAll(_steps, _effect);
+    Sequence _reactSequence_1 = execSync.getReactSequence();
+    _reactSequence_1.setName("react");
+    Sequence _reactSequence_2 = execSync.getReactSequence();
+    String _name = sync.getName();
+    String _plus = ObjectExtensions.operator_plus("The reactions of state ", _name);
+    String _plus_1 = ObjectExtensions.operator_plus(_plus, ".");
+    _reactSequence_2.setComment(_plus_1);
+    boolean _isAddTraceSteps = this.trace.isAddTraceSteps();
+    if (_isAddTraceSteps) {
+      Sequence _reactSequence_3 = execSync.getReactSequence();
+      EList<Step> _steps_1 = _reactSequence_3.getSteps();
+      ExecutionSynchronization _create = this.mapping.create(sync);
+      TraceNodeExecuted _newTraceNodeExecuted = this.trace.newTraceNodeExecuted(_create);
+      _steps_1.add(0, _newTraceNodeExecuted);
+    }
+    return execSync.getReactSequence();
+  }
+  
+  public boolean alwaysTrue(final Check check) {
+    boolean _and = false;
+    boolean _notEquals = ObjectExtensions.operator_notEquals(check, null);
+    if (!_notEquals) {
+      _and = false;
+    } else {
+      Statement _condition = check.getCondition();
+      _and = BooleanExtensions.operator_and(_notEquals, (_condition instanceof PrimitiveValueExpression));
+    }
+    if (_and) {
+      Statement _condition_1 = check.getCondition();
+      final PrimitiveValueExpression pve = ((PrimitiveValueExpression) _condition_1);
+      boolean _and_1 = false;
+      Literal _value = pve.getValue();
+      if (!(_value instanceof BoolLiteral)) {
+        _and_1 = false;
+      } else {
+        Literal _value_1 = pve.getValue();
+        boolean _isValue = ((BoolLiteral) _value_1).isValue();
+        _and_1 = BooleanExtensions.operator_and((_value instanceof BoolLiteral), _isValue);
+      }
+      return _and_1;
+    }
+    return false;
+  }
+  
+  public Sequence defineCycle(final RegularState state) {
+    final ExecutionState execState = this.mapping.create(state);
+    List<RegularState> _parentStates = this.sgraph.parentStates(state);
+    final Function1<RegularState,ExecutionState> _function = new Function1<RegularState,ExecutionState>() {
+        public ExecutionState apply(final RegularState p) {
+          ExecutionState _create = ReactionBuilder.this.mapping.create(p);
+          return ((ExecutionState) _create);
+        }
+      };
+    List<ExecutionState> _map = ListExtensions.<RegularState, ExecutionState>map(_parentStates, _function);
+    final Function1<ExecutionState,Boolean> _function_1 = new Function1<ExecutionState,Boolean>() {
+        public Boolean apply(final ExecutionState p) {
+          StateVector _stateVector = p.getStateVector();
+          int _offset = _stateVector.getOffset();
+          StateVector _stateVector_1 = execState.getStateVector();
+          int _offset_1 = _stateVector_1.getOffset();
+          boolean _equals = IntegerExtensions.operator_equals(_offset, _offset_1);
+          return Boolean.valueOf(_equals);
+        }
+      };
+    final Iterable<ExecutionState> parents = IterableExtensions.<ExecutionState>filter(_map, _function_1);
+    Iterable<ExecutionNode> _xifexpression = null;
+    EObject _rootContainer = EcoreUtil2.getRootContainer(execState);
+    StateVector _stateVector = ((ExecutionFlow) _rootContainer).getStateVector();
+    int _offset = _stateVector.getOffset();
+    StateVector _stateVector_1 = execState.getStateVector();
+    int _offset_1 = _stateVector_1.getOffset();
+    boolean _equals = IntegerExtensions.operator_equals(_offset, _offset_1);
+    if (_equals) {
+      final Function1<ExecutionState,ExecutionNode> _function_2 = new Function1<ExecutionState,ExecutionNode>() {
+          public ExecutionNode apply(final ExecutionState p) {
+            return ((ExecutionNode) p);
+          }
+        };
+      Iterable<ExecutionNode> _map_1 = IterableExtensions.<ExecutionState, ExecutionNode>map(parents, _function_2);
+      EObject _rootContainer_1 = EcoreUtil2.getRootContainer(execState);
+      HashSet<ExecutionNode> _newHashSet = CollectionLiterals.<ExecutionNode>newHashSet(((ExecutionNode) _rootContainer_1));
+      Iterable<ExecutionNode> _concat = Iterables.<ExecutionNode>concat(_map_1, _newHashSet);
+      _xifexpression = _concat;
+    } else {
+      final Function1<ExecutionState,ExecutionNode> _function_3 = new Function1<ExecutionState,ExecutionNode>() {
+          public ExecutionNode apply(final ExecutionState p) {
+            return ((ExecutionNode) p);
+          }
+        };
+      Iterable<ExecutionNode> _map_2 = IterableExtensions.<ExecutionState, ExecutionNode>map(parents, _function_3);
+      _xifexpression = _map_2;
+    }
+    final Iterable<ExecutionNode> parentNodes = _xifexpression;
+    final Function2<Sequence,ExecutionNode,Sequence> _function_4 = new Function2<Sequence,ExecutionNode,Sequence>() {
+        public Sequence apply(final Sequence r, final ExecutionNode s) {
+          Sequence _createReactionSequence = ReactionBuilder.this.createReactionSequence(s, r);
+          return _createReactionSequence;
+        }
+      };
+    Sequence _fold = IterableExtensions.<ExecutionNode, Sequence>fold(parentNodes, null, _function_4);
+    execState.setReactSequence(_fold);
+    Sequence _reactSequence = execState.getReactSequence();
+    _reactSequence.setName("react");
+    Sequence _reactSequence_1 = execState.getReactSequence();
+    String _name = state.getName();
+    String _plus = ObjectExtensions.operator_plus("The reactions of state ", _name);
+    String _plus_1 = ObjectExtensions.operator_plus(_plus, ".");
+    _reactSequence_1.setComment(_plus_1);
+    return execState.getReactSequence();
+  }
+  
+  public Sequence createReactionSequence(final ExecutionNode state, final Step localStep) {
+    SexecFactory _factory = this.sexec.factory();
+    final Sequence cycle = _factory.createSequence();
+    cycle.setName("react");
+    EList<Reaction> _reactions = state.getReactions();
+    final Function1<Reaction,Boolean> _function = new Function1<Reaction,Boolean>() {
+        public Boolean apply(final Reaction r) {
+          boolean _isTransition = r.isTransition();
+          boolean _not = BooleanExtensions.operator_not(_isTransition);
+          return Boolean.valueOf(_not);
+        }
+      };
+    Iterable<Reaction> _filter = IterableExtensions.<Reaction>filter(_reactions, _function);
+    final List<Reaction> localReactions = IterableExtensions.<Reaction>toList(_filter);
+    SexecFactory _factory_1 = this.sexec.factory();
+    Sequence localSteps = _factory_1.createSequence();
+    EList<Step> _steps = localSteps.getSteps();
+    final Function1<Reaction,If> _function_1 = new Function1<Reaction,If>() {
+        public If apply(final Reaction lr) {
+          If _xblockexpression = null;
+          {
+            SexecFactory _factory = ReactionBuilder.this.sexec.factory();
+            If ifStep = _factory.createIf();
+            Check _check = lr.getCheck();
+            CheckRef _newRef = ReactionBuilder.this.mapping.newRef(_check);
+            ifStep.setCheck(_newRef);
+            Step _effect = lr.getEffect();
+            Call _newCall = ReactionBuilder.this.mapping.newCall(_effect);
+            ifStep.setThenStep(_newCall);
+            _xblockexpression = (ifStep);
+          }
+          return _xblockexpression;
+        }
+      };
+    List<If> _map = ListExtensions.<Reaction, If>map(localReactions, _function_1);
+    _steps.addAll(_map);
+    boolean _notEquals = ObjectExtensions.operator_notEquals(localStep, null);
+    if (_notEquals) {
+      EList<Step> _steps_1 = localSteps.getSteps();
+      CollectionExtensions.<Step>operator_add(_steps_1, localStep);
+    }
+    EList<Step> _steps_2 = localSteps.getSteps();
+    boolean _isEmpty = _steps_2.isEmpty();
+    if (_isEmpty) {
+      localSteps = null;
+    }
+    EList<Reaction> _reactions_1 = state.getReactions();
+    final Function1<Reaction,Boolean> _function_2 = new Function1<Reaction,Boolean>() {
+        public Boolean apply(final Reaction r) {
+          boolean _isTransition = r.isTransition();
+          return Boolean.valueOf(_isTransition);
+        }
+      };
+    Iterable<Reaction> _filter_1 = IterableExtensions.<Reaction>filter(_reactions_1, _function_2);
+    final List<Reaction> transitionReactions = IterableExtensions.<Reaction>toList(_filter_1);
+    List<Reaction> _reverseView = ListExtensions.<Reaction>reverseView(transitionReactions);
+    final Function2<Step,Reaction,Step> _function_3 = new Function2<Step,Reaction,Step>() {
+        public Step apply(final Step s, final Reaction reaction) {
+          Step _xblockexpression = null;
+          {
+            SexecFactory _factory = ReactionBuilder.this.sexec.factory();
+            If ifStep = _factory.createIf();
+            Check _check = reaction.getCheck();
+            CheckRef _newRef = ReactionBuilder.this.mapping.newRef(_check);
+            ifStep.setCheck(_newRef);
+            Step _effect = reaction.getEffect();
+            Call _newCall = ReactionBuilder.this.mapping.newCall(_effect);
+            ifStep.setThenStep(_newCall);
+            ifStep.setElseStep(s);
+            _xblockexpression = (((Step) ifStep));
+          }
+          return _xblockexpression;
+        }
+      };
+    final Step transitionStep = IterableExtensions.<Reaction, Step>fold(_reverseView, ((Step) localSteps), _function_3);
+    boolean _notEquals_1 = ObjectExtensions.operator_notEquals(transitionStep, null);
+    if (_notEquals_1) {
+      EList<Step> _steps_3 = cycle.getSteps();
+      _steps_3.add(transitionStep);
+    } else {
+      boolean _notEquals_2 = ObjectExtensions.operator_notEquals(localSteps, null);
+      if (_notEquals_2) {
+        EList<Step> _steps_4 = cycle.getSteps();
+        _steps_4.add(localSteps);
+      }
+    }
+    return cycle;
+  }
+  
+  public ExecutionFlow defineEntryReactions(final Statechart statechart, final ExecutionFlow r) {
+    Iterable<Entry> _allEntries = this.sct.allEntries(statechart);
+    final Procedure1<Entry> _function = new Procedure1<Entry>() {
+        public void apply(final Entry e) {
+          ReactionBuilder.this.defineReaction(e);
+        }
+      };
+    IterableExtensions.<Entry>forEach(_allEntries, _function);
+    return r;
+  }
+  
+  public boolean defineReaction(final Entry e) {
+    boolean _xblockexpression = false;
+    {
+      final ExecutionEntry execEntry = this.mapping.create(e);
+      final Sequence seq = execEntry.getReactSequence();
+      State _target = this.sgraph.target(e);
+      final ExecutionState target = this.mapping.create(_target);
+      boolean _isAddTraceSteps = this.trace.isAddTraceSteps();
+      if (_isAddTraceSteps) {
+        EList<Step> _steps = seq.getSteps();
+        TraceNodeExecuted _newTraceNodeExecuted = this.trace.newTraceNodeExecuted(execEntry);
+        _steps.add(0, _newTraceNodeExecuted);
+      }
+      boolean _xifexpression = false;
+      EntryKind _kind = e.getKind();
+      boolean _equals = ObjectExtensions.operator_equals(_kind, EntryKind.INITIAL);
+      if (_equals) {
+        boolean _xifexpression_1 = false;
+        boolean _and = false;
+        boolean _notEquals = ObjectExtensions.operator_notEquals(target, null);
+        if (!_notEquals) {
+          _and = false;
+        } else {
+          Sequence _enterSequence = target.getEnterSequence();
+          boolean _notEquals_1 = ObjectExtensions.operator_notEquals(_enterSequence, null);
+          _and = BooleanExtensions.operator_and(_notEquals, _notEquals_1);
+        }
+        if (_and) {
+          boolean _xblockexpression_1 = false;
+          {
+            boolean _isAddTraceSteps_1 = this.trace.isAddTraceSteps();
+            if (_isAddTraceSteps_1) {
+              EList<Step> _steps_1 = seq.getSteps();
+              EList<Transition> _outgoingTransitions = e.getOutgoingTransitions();
+              Transition _get = _outgoingTransitions.get(0);
+              Reaction _create = this.mapping.create(_get);
+              ReactionFired _newTraceReactionFired = this.trace.newTraceReactionFired(_create);
+              CollectionExtensions.<ReactionFired>operator_add(_steps_1, _newTraceReactionFired);
+            }
+            EList<Step> _steps_2 = seq.getSteps();
+            Sequence _enterSequence_1 = target.getEnterSequence();
+            Call _newCall = this.mapping.newCall(_enterSequence_1);
+            boolean _add = CollectionExtensions.<Call>operator_add(_steps_2, _newCall);
+            _xblockexpression_1 = (_add);
+          }
+          _xifexpression_1 = _xblockexpression_1;
+        }
+        _xifexpression = _xifexpression_1;
+      } else {
+        boolean _xifexpression_2 = false;
+        EntryKind _kind_1 = e.getKind();
+        boolean _equals_1 = ObjectExtensions.operator_equals(_kind_1, EntryKind.SHALLOW_HISTORY);
+        if (_equals_1) {
+          boolean _xblockexpression_2 = false;
+          {
+            SexecFactory _factory = this.sexec.factory();
+            final HistoryEntry entryStep = _factory.createHistoryEntry();
+            entryStep.setName("HistoryEntry");
+            entryStep.setComment("Enter the region with shallow history");
+            entryStep.setDeep(false);
+            EObject _eContainer = e.eContainer();
+            ExecutionRegion _create = this.mapping.create(((Region) _eContainer));
+            entryStep.setRegion(_create);
+            boolean _and_1 = false;
+            boolean _notEquals_2 = ObjectExtensions.operator_notEquals(target, null);
+            if (!_notEquals_2) {
+              _and_1 = false;
+            } else {
+              Sequence _enterSequence_1 = target.getEnterSequence();
+              boolean _notEquals_3 = ObjectExtensions.operator_notEquals(_enterSequence_1, null);
+              _and_1 = BooleanExtensions.operator_and(_notEquals_2, _notEquals_3);
+            }
+            if (_and_1) {
+              boolean _isAddTraceSteps_1 = this.trace.isAddTraceSteps();
+              if (_isAddTraceSteps_1) {
+                EList<Step> _steps_1 = seq.getSteps();
+                EList<Transition> _outgoingTransitions = e.getOutgoingTransitions();
+                Transition _get = _outgoingTransitions.get(0);
+                Reaction _create_1 = this.mapping.create(_get);
+                ReactionFired _newTraceReactionFired = this.trace.newTraceReactionFired(_create_1);
+                CollectionExtensions.<ReactionFired>operator_add(_steps_1, _newTraceReactionFired);
+              }
+              Sequence _enterSequence_2 = target.getEnterSequence();
+              Call _newCall = this.mapping.newCall(_enterSequence_2);
+              entryStep.setInitialStep(_newCall);
+            }
+            EObject _eContainer_1 = e.eContainer();
+            ExecutionRegion _create_2 = this.mapping.create(((Region) _eContainer_1));
+            Sequence _shallowEnterSequence = _create_2.getShallowEnterSequence();
+            Call _newCall_1 = this.mapping.newCall(_shallowEnterSequence);
+            entryStep.setHistoryStep(_newCall_1);
+            EList<Step> _steps_2 = seq.getSteps();
+            boolean _add = CollectionExtensions.<HistoryEntry>operator_add(_steps_2, entryStep);
+            _xblockexpression_2 = (_add);
+          }
+          _xifexpression_2 = _xblockexpression_2;
+        } else {
+          boolean _xifexpression_3 = false;
+          EntryKind _kind_2 = e.getKind();
+          boolean _equals_2 = ObjectExtensions.operator_equals(_kind_2, EntryKind.DEEP_HISTORY);
+          if (_equals_2) {
+            boolean _xblockexpression_3 = false;
+            {
+              SexecFactory _factory = this.sexec.factory();
+              final HistoryEntry entryStep = _factory.createHistoryEntry();
+              entryStep.setName("HistoryEntry");
+              entryStep.setComment("Enter the region with deep history");
+              EObject _eContainer = e.eContainer();
+              ExecutionRegion _create = this.mapping.create(((Region) _eContainer));
+              entryStep.setRegion(_create);
+              entryStep.setDeep(true);
+              boolean _and_1 = false;
+              boolean _notEquals_2 = ObjectExtensions.operator_notEquals(target, null);
+              if (!_notEquals_2) {
+                _and_1 = false;
+              } else {
+                Sequence _enterSequence_1 = target.getEnterSequence();
+                boolean _notEquals_3 = ObjectExtensions.operator_notEquals(_enterSequence_1, null);
+                _and_1 = BooleanExtensions.operator_and(_notEquals_2, _notEquals_3);
+              }
+              if (_and_1) {
+                boolean _isAddTraceSteps_1 = this.trace.isAddTraceSteps();
+                if (_isAddTraceSteps_1) {
+                  EList<Step> _steps_1 = seq.getSteps();
+                  EList<Transition> _outgoingTransitions = e.getOutgoingTransitions();
+                  Transition _get = _outgoingTransitions.get(0);
+                  Reaction _create_1 = this.mapping.create(_get);
+                  ReactionFired _newTraceReactionFired = this.trace.newTraceReactionFired(_create_1);
+                  CollectionExtensions.<ReactionFired>operator_add(_steps_1, _newTraceReactionFired);
+                }
+                Sequence _enterSequence_2 = target.getEnterSequence();
+                Call _newCall = this.mapping.newCall(_enterSequence_2);
+                entryStep.setInitialStep(_newCall);
+              }
+              EObject _eContainer_1 = e.eContainer();
+              ExecutionRegion _create_2 = this.mapping.create(((Region) _eContainer_1));
+              Sequence _deepEnterSequence = _create_2.getDeepEnterSequence();
+              Call _newCall_1 = this.mapping.newCall(_deepEnterSequence);
+              entryStep.setHistoryStep(_newCall_1);
+              EList<Step> _steps_2 = seq.getSteps();
+              boolean _add = CollectionExtensions.<HistoryEntry>operator_add(_steps_2, entryStep);
+              _xblockexpression_3 = (_add);
+            }
+            _xifexpression_3 = _xblockexpression_3;
+          }
+          _xifexpression_2 = _xifexpression_3;
+        }
+        _xifexpression = _xifexpression_2;
+      }
+      _xblockexpression = (_xifexpression);
+    }
+    return _xblockexpression;
+  }
+}

+ 878 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SequenceBuilder.java

@@ -0,0 +1,878 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import com.google.inject.name.Named;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.CollectionExtensions;
+import org.eclipse.xtext.xbase.lib.CollectionLiterals;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.Functions.Function2;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xbase.lib.IntegerRange;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.IteratorExtensions;
+import org.eclipse.xtext.xbase.lib.ListExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.yakindu.base.base.NamedElement;
+import org.yakindu.sct.model.sexec.Call;
+import org.yakindu.sct.model.sexec.EnterState;
+import org.yakindu.sct.model.sexec.Execution;
+import org.yakindu.sct.model.sexec.ExecutionEntry;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sexec.ExecutionRegion;
+import org.yakindu.sct.model.sexec.ExecutionScope;
+import org.yakindu.sct.model.sexec.ExecutionState;
+import org.yakindu.sct.model.sexec.ExitState;
+import org.yakindu.sct.model.sexec.SaveHistory;
+import org.yakindu.sct.model.sexec.ScheduleTimeEvent;
+import org.yakindu.sct.model.sexec.Sequence;
+import org.yakindu.sct.model.sexec.SexecFactory;
+import org.yakindu.sct.model.sexec.StateCase;
+import org.yakindu.sct.model.sexec.StateSwitch;
+import org.yakindu.sct.model.sexec.StateVector;
+import org.yakindu.sct.model.sexec.Step;
+import org.yakindu.sct.model.sexec.TimeEvent;
+import org.yakindu.sct.model.sexec.TraceStateEntered;
+import org.yakindu.sct.model.sexec.TraceStateExited;
+import org.yakindu.sct.model.sexec.transformation.SexecElementMapping;
+import org.yakindu.sct.model.sexec.transformation.SexecExtensions;
+import org.yakindu.sct.model.sexec.transformation.SgraphExtensions;
+import org.yakindu.sct.model.sexec.transformation.StatechartExtensions;
+import org.yakindu.sct.model.sexec.transformation.StextExtensions;
+import org.yakindu.sct.model.sexec.transformation.TraceExtensions;
+import org.yakindu.sct.model.sgraph.Entry;
+import org.yakindu.sct.model.sgraph.FinalState;
+import org.yakindu.sct.model.sgraph.Region;
+import org.yakindu.sct.model.sgraph.RegularState;
+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.Statement;
+import org.yakindu.sct.model.sgraph.Variable;
+import org.yakindu.sct.model.sgraph.Vertex;
+import org.yakindu.sct.model.stext.stext.AssignmentExpression;
+import org.yakindu.sct.model.stext.stext.AssignmentOperator;
+import org.yakindu.sct.model.stext.stext.ElementReferenceExpression;
+import org.yakindu.sct.model.stext.stext.Expression;
+import org.yakindu.sct.model.stext.stext.IntLiteral;
+import org.yakindu.sct.model.stext.stext.MultiplicativeOperator;
+import org.yakindu.sct.model.stext.stext.NumericalMultiplyDivideExpression;
+import org.yakindu.sct.model.stext.stext.PrimitiveValueExpression;
+import org.yakindu.sct.model.stext.stext.StextFactory;
+import org.yakindu.sct.model.stext.stext.TimeEventSpec;
+import org.yakindu.sct.model.stext.stext.TimeUnit;
+import org.yakindu.sct.model.stext.stext.VariableDefinition;
+
+@SuppressWarnings("all")
+public class SequenceBuilder {
+  @Inject
+  private StatechartExtensions sc;
+  
+  @Inject
+  private SgraphExtensions sgraph;
+  
+  @Inject
+  private StextExtensions stext;
+  
+  @Inject
+  private SexecExtensions sexec;
+  
+  @Inject
+  private SexecElementMapping mapping;
+  
+  @Inject
+  private TraceExtensions trace;
+  
+  @Inject
+  @Named(value = "ADD_TRACES")
+  private boolean _addTraceSteps;
+  
+  public void defineDeepEnterSequences(final ExecutionFlow flow, final Statechart sc) {
+    EList<Region> _regions = sc.getRegions();
+    for (final Region r : _regions) {
+      this.defineDeepEnterSequence(r);
+    }
+  }
+  
+  public void defineDeepEnterSequence(final State s) {
+    EList<Region> _regions = s.getRegions();
+    for (final Region r : _regions) {
+      this.defineDeepEnterSequence(r);
+    }
+  }
+  
+  public void defineDeepEnterSequence(final Region r) {
+    EList<Vertex> _vertices = r.getVertices();
+    Iterable<State> _filter = IterableExtensions.<State>filter(_vertices, State.class);
+    for (final State s : _filter) {
+      this.defineDeepEnterSequence(s);
+    }
+    boolean _requireDeepHistory = this.sgraph.requireDeepHistory(r);
+    boolean _not = BooleanExtensions.operator_not(_requireDeepHistory);
+    if (_not) {
+      return;
+    }
+    final ExecutionRegion execRegion = this.mapping.create(r);
+    SexecFactory _factory = this.sexec.factory();
+    final Sequence seq = _factory.createSequence();
+    seq.setName("deepEnterSequence");
+    String _name = r.getName();
+    String _plus = ObjectExtensions.operator_plus("deep enterSequence with history in child ", _name);
+    seq.setComment(_plus);
+    EList<Step> _steps = seq.getSteps();
+    StateSwitch _defineDeepHistorySwitch = this.defineDeepHistorySwitch(r);
+    CollectionExtensions.<StateSwitch>operator_add(_steps, _defineDeepHistorySwitch);
+    execRegion.setDeepEnterSequence(seq);
+  }
+  
+  public StateSwitch defineDeepHistorySwitch(final Region r) {
+    final ExecutionRegion execRegion = this.mapping.create(r);
+    SexecFactory _factory = this.sexec.factory();
+    final StateSwitch sSwitch = _factory.createStateSwitch();
+    StateVector _stateVector = execRegion.getStateVector();
+    int _offset = _stateVector.getOffset();
+    sSwitch.setStateConfigurationIdx(_offset);
+    String _name = r.getName();
+    String _plus = ObjectExtensions.operator_plus("Handle deep history entry of ", _name);
+    sSwitch.setComment(_plus);
+    sSwitch.setHistoryRegion(execRegion);
+    EList<Vertex> _vertices = r.getVertices();
+    Iterable<State> _filter = IterableExtensions.<State>filter(_vertices, State.class);
+    for (final State child : _filter) {
+      ArrayList<RegularState> _newArrayList = CollectionLiterals.<RegularState>newArrayList();
+      List<RegularState> _collectLeafStates = this.sgraph.collectLeafStates(child, _newArrayList);
+      final Function1<RegularState,Boolean> _function = new Function1<RegularState,Boolean>() {
+          public Boolean apply(final RegularState c) {
+            ExecutionState _create = SequenceBuilder.this.mapping.create(c);
+            StateVector _stateVector = _create.getStateVector();
+            int _offset = _stateVector.getOffset();
+            int _stateConfigurationIdx = sSwitch.getStateConfigurationIdx();
+            boolean _equals = IntegerExtensions.operator_equals(_offset, _stateConfigurationIdx);
+            return Boolean.valueOf(_equals);
+          }
+        };
+      Iterable<RegularState> _filter_1 = IterableExtensions.<RegularState>filter(_collectLeafStates, _function);
+      for (final RegularState childLeaf : _filter_1) {
+        {
+          final ExecutionState execChild = this.mapping.create(child);
+          SexecFactory _factory_1 = this.sexec.factory();
+          final Sequence seq = _factory_1.createSequence();
+          seq.setName("enterSequence");
+          String _name_1 = child.getName();
+          String _plus_1 = ObjectExtensions.operator_plus("enterSequence with history in child ", _name_1);
+          String _plus_2 = ObjectExtensions.operator_plus(_plus_1, " for leaf ");
+          String _name_2 = childLeaf.getName();
+          String _plus_3 = ObjectExtensions.operator_plus(_plus_2, _name_2);
+          seq.setComment(_plus_3);
+          boolean _isLeaf = execChild.isLeaf();
+          if (_isLeaf) {
+            EList<Step> _steps = seq.getSteps();
+            Sequence _enterSequence = execChild.getEnterSequence();
+            Call _newCall = this.mapping.newCall(_enterSequence);
+            CollectionExtensions.<Call>operator_add(_steps, _newCall);
+          } else {
+            Step _entryAction = execChild.getEntryAction();
+            boolean _notEquals = ObjectExtensions.operator_notEquals(_entryAction, null);
+            if (_notEquals) {
+              EList<Step> _steps_1 = seq.getSteps();
+              Step _entryAction_1 = execChild.getEntryAction();
+              Call _newCall_1 = this.mapping.newCall(_entryAction_1);
+              CollectionExtensions.<Call>operator_add(_steps_1, _newCall_1);
+            }
+            boolean _isAddTraceSteps = this.trace.isAddTraceSteps();
+            if (_isAddTraceSteps) {
+              EList<Step> _steps_2 = seq.getSteps();
+              TraceStateEntered _newTraceStateEntered = this.trace.newTraceStateEntered(execChild);
+              CollectionExtensions.<TraceStateEntered>operator_add(_steps_2, _newTraceStateEntered);
+            }
+            EList<Region> _regions = child.getRegions();
+            for (final Region childRegion : _regions) {
+              EList<Step> _steps_3 = seq.getSteps();
+              ExecutionRegion _create = this.mapping.create(childRegion);
+              Sequence _deepEnterSequence = _create.getDeepEnterSequence();
+              Call _newCall_2 = this.mapping.newCall(_deepEnterSequence);
+              CollectionExtensions.<Call>operator_add(_steps_3, _newCall_2);
+            }
+          }
+          EList<StateCase> _cases = sSwitch.getCases();
+          ExecutionState _create_1 = this.mapping.create(childLeaf);
+          StateCase _newCase = this.sexec.newCase(_create_1, seq);
+          CollectionExtensions.<StateCase>operator_add(_cases, _newCase);
+        }
+      }
+    }
+    return sSwitch;
+  }
+  
+  public void defineShallowEnterSequences(final ExecutionFlow flow, final Statechart sc) {
+    final TreeIterator<EObject> contents = sc.eAllContents();
+    Iterator<Region> _filter = IteratorExtensions.<Region>filter(contents, Region.class);
+    Iterable<Region> _iterable = IteratorExtensions.<Region>toIterable(_filter);
+    for (final Region r : _iterable) {
+      boolean _requireShallowHistory = this.sgraph.requireShallowHistory(r);
+      if (_requireShallowHistory) {
+        final ExecutionRegion execRegion = this.mapping.create(r);
+        SexecFactory _factory = this.sexec.factory();
+        final Sequence seq = _factory.createSequence();
+        seq.setName("shallowEnterSequence");
+        String _name = r.getName();
+        String _plus = ObjectExtensions.operator_plus("shallow enterSequence with history in child ", _name);
+        seq.setComment(_plus);
+        EList<Step> _steps = seq.getSteps();
+        StateSwitch _defineShallowHistorySwitch = this.defineShallowHistorySwitch(r);
+        CollectionExtensions.<StateSwitch>operator_add(_steps, _defineShallowHistorySwitch);
+        execRegion.setShallowEnterSequence(seq);
+      }
+    }
+  }
+  
+  public StateSwitch defineShallowHistorySwitch(final Region r) {
+    final ExecutionRegion execRegion = this.mapping.create(r);
+    SexecFactory _factory = this.sexec.factory();
+    final StateSwitch sSwitch = _factory.createStateSwitch();
+    StateVector _stateVector = execRegion.getStateVector();
+    int _offset = _stateVector.getOffset();
+    sSwitch.setStateConfigurationIdx(_offset);
+    String _name = r.getName();
+    String _plus = ObjectExtensions.operator_plus("Handle shallow history entry of ", _name);
+    sSwitch.setComment(_plus);
+    ExecutionRegion _create = this.mapping.create(r);
+    sSwitch.setHistoryRegion(_create);
+    EList<Vertex> _vertices = r.getVertices();
+    Iterable<State> _filter = IterableExtensions.<State>filter(_vertices, State.class);
+    for (final State child : _filter) {
+      {
+        final ExecutionState execChild = this.mapping.create(child);
+        ArrayList<RegularState> _newArrayList = CollectionLiterals.<RegularState>newArrayList();
+        List<RegularState> _collectLeafStates = this.sgraph.collectLeafStates(child, _newArrayList);
+        final Function1<RegularState,Boolean> _function = new Function1<RegularState,Boolean>() {
+            public Boolean apply(final RegularState c) {
+              ExecutionState _create = SequenceBuilder.this.mapping.create(c);
+              StateVector _stateVector = _create.getStateVector();
+              int _offset = _stateVector.getOffset();
+              int _stateConfigurationIdx = sSwitch.getStateConfigurationIdx();
+              boolean _equals = IntegerExtensions.operator_equals(_offset, _stateConfigurationIdx);
+              return Boolean.valueOf(_equals);
+            }
+          };
+        Iterable<RegularState> _filter_1 = IterableExtensions.<RegularState>filter(_collectLeafStates, _function);
+        for (final RegularState childLeaf : _filter_1) {
+          EList<StateCase> _cases = sSwitch.getCases();
+          ExecutionState _create_1 = this.mapping.create(childLeaf);
+          Sequence _enterSequence = execChild.getEnterSequence();
+          Call _newCall = this.mapping.newCall(_enterSequence);
+          StateCase _newCase = this.sexec.newCase(_create_1, _newCall);
+          CollectionExtensions.<StateCase>operator_add(_cases, _newCase);
+        }
+      }
+    }
+    return sSwitch;
+  }
+  
+  /**
+   * Defines the enter sequences of all states
+   */
+  public void defineStateEnterSequences(final ExecutionFlow flow, final Statechart sc) {
+    EList<Region> _regions = sc.getRegions();
+    for (final Region r : _regions) {
+      this.defineStateEnterSequence(r);
+    }
+  }
+  
+  protected void _defineStateEnterSequence(final Region r) {
+    final ExecutionRegion execState = this.mapping.create(r);
+    SexecFactory _factory = this.sexec.factory();
+    final Sequence seq = _factory.createSequence();
+    seq.setName("enterSequence");
+    String _name = r.getName();
+    String _plus = ObjectExtensions.operator_plus("Default enter sequence for region ", _name);
+    seq.setComment(_plus);
+    EList<Vertex> _vertices = r.getVertices();
+    for (final Vertex s : _vertices) {
+      this.defineStateEnterSequence(s);
+    }
+    Entry _entry = this.sgraph.entry(r);
+    final ExecutionEntry entryNode = _entry==null?(ExecutionEntry)null:this.mapping.create(_entry);
+    boolean _and = false;
+    boolean _notEquals = ObjectExtensions.operator_notEquals(entryNode, null);
+    if (!_notEquals) {
+      _and = false;
+    } else {
+      Sequence _reactSequence = entryNode.getReactSequence();
+      boolean _notEquals_1 = ObjectExtensions.operator_notEquals(_reactSequence, null);
+      _and = BooleanExtensions.operator_and(_notEquals, _notEquals_1);
+    }
+    if (_and) {
+      EList<Step> _steps = seq.getSteps();
+      Sequence _reactSequence_1 = entryNode.getReactSequence();
+      Call _newCall = this.mapping.newCall(_reactSequence_1);
+      _steps.add(_newCall);
+    }
+    execState.setEnterSequence(seq);
+  }
+  
+  protected void _defineStateEnterSequence(final Vertex v) {
+  }
+  
+  protected void _defineStateEnterSequence(final FinalState state) {
+    final ExecutionState execState = this.mapping.create(state);
+    SexecFactory _factory = this.sexec.factory();
+    final Sequence seq = _factory.createSequence();
+    seq.setName("enterSequence");
+    String _name = state.getName();
+    String _plus = ObjectExtensions.operator_plus("Default enter sequence for state ", _name);
+    seq.setComment(_plus);
+    Step _entryAction = execState.getEntryAction();
+    boolean _notEquals = ObjectExtensions.operator_notEquals(_entryAction, null);
+    if (_notEquals) {
+      EList<Step> _steps = seq.getSteps();
+      Step _entryAction_1 = execState.getEntryAction();
+      Call _newCall = this.mapping.newCall(_entryAction_1);
+      _steps.add(_newCall);
+    }
+    if (this._addTraceSteps) {
+      EList<Step> _steps_1 = seq.getSteps();
+      TraceStateEntered _newTraceStateEntered = this.trace.newTraceStateEntered(execState);
+      CollectionExtensions.<TraceStateEntered>operator_add(_steps_1, _newTraceStateEntered);
+    }
+    EList<Step> _steps_2 = seq.getSteps();
+    EnterState _newEnterStateStep = this.sexec.newEnterStateStep(execState);
+    CollectionExtensions.<EnterState>operator_add(_steps_2, _newEnterStateStep);
+    execState.setEnterSequence(seq);
+  }
+  
+  protected void _defineStateEnterSequence(final State state) {
+    final ExecutionState execState = this.mapping.create(state);
+    SexecFactory _factory = this.sexec.factory();
+    final Sequence seq = _factory.createSequence();
+    seq.setName("enterSequence");
+    String _name = state.getName();
+    String _plus = ObjectExtensions.operator_plus("Default enter sequence for state ", _name);
+    seq.setComment(_plus);
+    Step _entryAction = execState.getEntryAction();
+    boolean _notEquals = ObjectExtensions.operator_notEquals(_entryAction, null);
+    if (_notEquals) {
+      EList<Step> _steps = seq.getSteps();
+      Step _entryAction_1 = execState.getEntryAction();
+      Call _newCall = this.mapping.newCall(_entryAction_1);
+      _steps.add(_newCall);
+    }
+    if (this._addTraceSteps) {
+      EList<Step> _steps_1 = seq.getSteps();
+      TraceStateEntered _newTraceStateEntered = this.trace.newTraceStateEntered(execState);
+      CollectionExtensions.<TraceStateEntered>operator_add(_steps_1, _newTraceStateEntered);
+    }
+    boolean _isLeaf = execState.isLeaf();
+    if (_isLeaf) {
+      EList<Step> _steps_2 = seq.getSteps();
+      EnterState _newEnterStateStep = this.sexec.newEnterStateStep(execState);
+      CollectionExtensions.<EnterState>operator_add(_steps_2, _newEnterStateStep);
+    } else {
+      EList<Region> _regions = state.getRegions();
+      for (final Region r : _regions) {
+        {
+          this.defineStateEnterSequence(r);
+          final ExecutionRegion execRegion = this.mapping.create(r);
+          Sequence _enterSequence = execRegion.getEnterSequence();
+          boolean _notEquals_1 = ObjectExtensions.operator_notEquals(_enterSequence, null);
+          if (_notEquals_1) {
+            EList<Step> _steps_3 = seq.getSteps();
+            Sequence _enterSequence_1 = execRegion.getEnterSequence();
+            Call _newCall_1 = this.mapping.newCall(_enterSequence_1);
+            _steps_3.add(_newCall_1);
+          }
+        }
+      }
+    }
+    execState.setEnterSequence(seq);
+  }
+  
+  /**
+   * Defines the exit sequences of all states
+   */
+  public void defineStateExitSequences(final ExecutionFlow flow, final Statechart sc) {
+    EList<Region> _regions = sc.getRegions();
+    for (final Region r : _regions) {
+      this.defineStateExitSequence(r);
+    }
+  }
+  
+  protected void _defineStateExitSequence(final Region r) {
+    final ExecutionRegion execRegion = this.mapping.create(r);
+    SexecFactory _factory = this.sexec.factory();
+    final Sequence seq = _factory.createSequence();
+    seq.setName("exitSequence");
+    String _name = r.getName();
+    String _plus = ObjectExtensions.operator_plus("Default exit sequence for region ", _name);
+    seq.setComment(_plus);
+    EList<Vertex> _vertices = r.getVertices();
+    for (final Vertex s : _vertices) {
+      this.defineStateExitSequence(s);
+    }
+    StateVector _historyVector = execRegion.getHistoryVector();
+    boolean _notEquals = ObjectExtensions.operator_notEquals(_historyVector, null);
+    if (_notEquals) {
+      EList<Step> _steps = seq.getSteps();
+      SaveHistory _newSaveHistory = this.sexec.newSaveHistory(execRegion);
+      CollectionExtensions.<SaveHistory>operator_add(_steps, _newSaveHistory);
+    }
+    ArrayList<RegularState> _arrayList = new ArrayList<RegularState>();
+    List<RegularState> _collectLeafStates = this.sgraph.collectLeafStates(r, _arrayList);
+    final Function1<RegularState,ExecutionState> _function = new Function1<RegularState,ExecutionState>() {
+        public ExecutionState apply(final RegularState rs) {
+          ExecutionState _create = SequenceBuilder.this.mapping.create(rs);
+          return _create;
+        }
+      };
+    final Iterable<ExecutionState> leafStates = ListExtensions.<RegularState, ExecutionState>map(_collectLeafStates, _function);
+    final StateVector sVector = execRegion.getStateVector();
+    int _offset = sVector.getOffset();
+    int _offset_1 = sVector.getOffset();
+    int _size = sVector.getSize();
+    int _plus_1 = IntegerExtensions.operator_plus(_offset_1, _size);
+    int _minus = IntegerExtensions.operator_minus(_plus_1, 1);
+    IntegerRange _upTo = IntegerExtensions.operator_upTo(_offset, _minus);
+    for (final Integer i : _upTo) {
+      {
+        final StateSwitch sSwitch = this.defineExitSwitch(execRegion, leafStates, (i).intValue());
+        EList<Step> _steps_1 = seq.getSteps();
+        _steps_1.add(sSwitch);
+      }
+    }
+    execRegion.setExitSequence(seq);
+  }
+  
+  protected void _defineStateExitSequence(final Vertex v) {
+  }
+  
+  protected void _defineStateExitSequence(final FinalState s) {
+    final ExecutionState execState = this.mapping.create(s);
+    SexecFactory _factory = this.sexec.factory();
+    final Sequence seq = _factory.createSequence();
+    seq.setName("exitSequence");
+    seq.setComment("Default exit sequence for final state.");
+    EList<Step> _steps = seq.getSteps();
+    ExitState _newExitStateStep = this.sexec.newExitStateStep(execState);
+    CollectionExtensions.<ExitState>operator_add(_steps, _newExitStateStep);
+    if (this._addTraceSteps) {
+      EList<Step> _steps_1 = seq.getSteps();
+      TraceStateExited _newTraceStateExited = this.trace.newTraceStateExited(execState);
+      CollectionExtensions.<TraceStateExited>operator_add(_steps_1, _newTraceStateExited);
+    }
+    execState.setExitSequence(seq);
+  }
+  
+  protected void _defineStateExitSequence(final State state) {
+    final ExecutionState execState = this.mapping.create(state);
+    SexecFactory _factory = this.sexec.factory();
+    final Sequence seq = _factory.createSequence();
+    seq.setName("exitSequence");
+    String _name = state.getName();
+    String _plus = ObjectExtensions.operator_plus("Default exit sequence for state ", _name);
+    seq.setComment(_plus);
+    boolean _isLeaf = execState.isLeaf();
+    if (_isLeaf) {
+      EList<Step> _steps = seq.getSteps();
+      ExitState _newExitStateStep = this.sexec.newExitStateStep(execState);
+      CollectionExtensions.<ExitState>operator_add(_steps, _newExitStateStep);
+    } else {
+      EList<Region> _regions = state.getRegions();
+      for (final Region r : _regions) {
+        {
+          this.defineStateExitSequence(r);
+          final ExecutionRegion execRegion = this.mapping.create(r);
+          Sequence _exitSequence = execRegion.getExitSequence();
+          boolean _notEquals = ObjectExtensions.operator_notEquals(_exitSequence, null);
+          if (_notEquals) {
+            EList<Step> _steps_1 = seq.getSteps();
+            Sequence _exitSequence_1 = execRegion.getExitSequence();
+            Call _newCall = this.mapping.newCall(_exitSequence_1);
+            _steps_1.add(_newCall);
+          }
+        }
+      }
+    }
+    Step _exitAction = execState.getExitAction();
+    boolean _notEquals = ObjectExtensions.operator_notEquals(_exitAction, null);
+    if (_notEquals) {
+      EList<Step> _steps_1 = seq.getSteps();
+      Step _exitAction_1 = execState.getExitAction();
+      Call _newCall = this.mapping.newCall(_exitAction_1);
+      _steps_1.add(_newCall);
+    }
+    if (this._addTraceSteps) {
+      EList<Step> _steps_2 = seq.getSteps();
+      TraceStateExited _newTraceStateExited = this.trace.newTraceStateExited(execState);
+      CollectionExtensions.<TraceStateExited>operator_add(_steps_2, _newTraceStateExited);
+    }
+    execState.setExitSequence(seq);
+  }
+  
+  public StateSwitch defineExitSwitch(final ExecutionRegion region, final Iterable<ExecutionState> leafStates, final int pos) {
+    SexecFactory _factory = this.sexec.factory();
+    StateSwitch sSwitch = _factory.createStateSwitch();
+    sSwitch.setStateConfigurationIdx(pos);
+    String _name = region.getName();
+    String _plus = ObjectExtensions.operator_plus("Handle exit of all possible states (of ", _name);
+    String _plus_1 = ObjectExtensions.operator_plus(_plus, ") at position ");
+    int _stateConfigurationIdx = sSwitch.getStateConfigurationIdx();
+    String _plus_2 = StringExtensions.operator_plus(_plus_1, Integer.valueOf(_stateConfigurationIdx));
+    String _plus_3 = ObjectExtensions.operator_plus(_plus_2, "...");
+    sSwitch.setComment(_plus_3);
+    final Function1<ExecutionState,Boolean> _function = new Function1<ExecutionState,Boolean>() {
+        public Boolean apply(final ExecutionState rs) {
+          boolean _and = false;
+          StateVector _stateVector = rs.getStateVector();
+          int _size = _stateVector.getSize();
+          boolean _equals = IntegerExtensions.operator_equals(_size, 1);
+          if (!_equals) {
+            _and = false;
+          } else {
+            StateVector _stateVector_1 = rs.getStateVector();
+            int _offset = _stateVector_1.getOffset();
+            boolean _equals_1 = IntegerExtensions.operator_equals(_offset, pos);
+            _and = BooleanExtensions.operator_and(_equals, _equals_1);
+          }
+          return Boolean.valueOf(_and);
+        }
+      };
+    final Iterable<ExecutionState> posStates = IterableExtensions.<ExecutionState>filter(leafStates, _function);
+    for (final ExecutionState s : posStates) {
+      {
+        SexecFactory _factory_1 = this.sexec.factory();
+        final Sequence caseSeq = _factory_1.createSequence();
+        final ArrayList<ExecutionScope> exitScopes = this.sexec.parentScopes(s);
+        ArrayList<ExecutionScope> _parentScopes = this.sexec.parentScopes(region);
+        exitScopes.removeAll(_parentScopes);
+        exitScopes.remove(s);
+        final Function2<Sequence,ExecutionScope,Sequence> _function_1 = new Function2<Sequence,ExecutionScope,Sequence>() {
+            public Sequence apply(final Sequence cs, final ExecutionScope exitScope) {
+              Sequence _xblockexpression = null;
+              {
+                boolean _and = false;
+                if (!(exitScope instanceof ExecutionRegion)) {
+                  _and = false;
+                } else {
+                  StateVector _historyVector = ((ExecutionRegion) exitScope).getHistoryVector();
+                  boolean _notEquals = ObjectExtensions.operator_notEquals(_historyVector, null);
+                  _and = BooleanExtensions.operator_and((exitScope instanceof ExecutionRegion), _notEquals);
+                }
+                if (_and) {
+                  final ExecutionRegion execRegion = ((ExecutionRegion) exitScope);
+                  EList<Step> _steps = cs.getSteps();
+                  SaveHistory _newSaveHistory = SequenceBuilder.this.sexec.newSaveHistory(execRegion);
+                  CollectionExtensions.<SaveHistory>operator_add(_steps, _newSaveHistory);
+                }
+                _xblockexpression = (cs);
+              }
+              return _xblockexpression;
+            }
+          };
+        IterableExtensions.<ExecutionScope, Sequence>fold(exitScopes, caseSeq, _function_1);
+        Sequence _exitSequence = s.getExitSequence();
+        boolean _notEquals = ObjectExtensions.operator_notEquals(_exitSequence, null);
+        if (_notEquals) {
+          EList<Step> _steps = caseSeq.getSteps();
+          Sequence _exitSequence_1 = s.getExitSequence();
+          Call _newCall = this.mapping.newCall(_exitSequence_1);
+          CollectionExtensions.<Call>operator_add(_steps, _newCall);
+        }
+        final Function2<Sequence,ExecutionScope,Sequence> _function_2 = new Function2<Sequence,ExecutionScope,Sequence>() {
+            public Sequence apply(final Sequence cs, final ExecutionScope exitScope) {
+              Sequence _xblockexpression = null;
+              {
+                boolean _and = false;
+                if (!(exitScope instanceof ExecutionState)) {
+                  _and = false;
+                } else {
+                  StateVector _stateVector = s.getStateVector();
+                  int _last = SequenceBuilder.this.sexec.last(_stateVector);
+                  StateVector _stateVector_1 = exitScope.getStateVector();
+                  int _last_1 = SequenceBuilder.this.sexec.last(_stateVector_1);
+                  boolean _equals = IntegerExtensions.operator_equals(_last, _last_1);
+                  _and = BooleanExtensions.operator_and((exitScope instanceof ExecutionState), _equals);
+                }
+                if (_and) {
+                  final ExecutionState execState = ((ExecutionState) exitScope);
+                  Step _exitAction = execState.getExitAction();
+                  boolean _notEquals = ObjectExtensions.operator_notEquals(_exitAction, null);
+                  if (_notEquals) {
+                    EList<Step> _steps = cs.getSteps();
+                    Step _exitAction_1 = execState.getExitAction();
+                    Call _newCall = SequenceBuilder.this.mapping.newCall(_exitAction_1);
+                    _steps.add(_newCall);
+                  }
+                  if (SequenceBuilder.this._addTraceSteps) {
+                    EList<Step> _steps_1 = cs.getSteps();
+                    TraceStateExited _newTraceStateExited = SequenceBuilder.this.trace.newTraceStateExited(execState);
+                    _steps_1.add(_newTraceStateExited);
+                  }
+                }
+                _xblockexpression = (cs);
+              }
+              return _xblockexpression;
+            }
+          };
+        IterableExtensions.<ExecutionScope, Sequence>fold(exitScopes, caseSeq, _function_2);
+        EList<Step> _steps_1 = caseSeq.getSteps();
+        boolean _isEmpty = _steps_1.isEmpty();
+        boolean _not = BooleanExtensions.operator_not(_isEmpty);
+        if (_not) {
+          EList<StateCase> _cases = sSwitch.getCases();
+          StateCase _newCase = this.sexec.newCase(s, caseSeq);
+          _cases.add(_newCase);
+        }
+      }
+    }
+    return sSwitch;
+  }
+  
+  public Sequence defineStatechartExitSequence(final ExecutionFlow flow, final Statechart sc) {
+    SexecFactory _factory = this.sexec.factory();
+    final Sequence exitSequence = _factory.createSequence();
+    exitSequence.setName("exit");
+    String _name = sc.getName();
+    String _plus = ObjectExtensions.operator_plus("Default exit sequence for statechart ", _name);
+    exitSequence.setComment(_plus);
+    EList<Region> _regions = sc.getRegions();
+    for (final Region r : _regions) {
+      {
+        final ExecutionRegion execRegion = this.mapping.create(r);
+        Sequence _exitSequence = execRegion.getExitSequence();
+        boolean _notEquals = ObjectExtensions.operator_notEquals(_exitSequence, null);
+        if (_notEquals) {
+          EList<Step> _steps = exitSequence.getSteps();
+          Sequence _exitSequence_1 = execRegion.getExitSequence();
+          Call _newCall = this.mapping.newCall(_exitSequence_1);
+          _steps.add(_newCall);
+        }
+      }
+    }
+    Step _exitAction = flow.getExitAction();
+    boolean _notEquals = ObjectExtensions.operator_notEquals(_exitAction, null);
+    if (_notEquals) {
+      EList<Step> _steps = exitSequence.getSteps();
+      Step _exitAction_1 = flow.getExitAction();
+      Call _newCall = this.mapping.newCall(_exitAction_1);
+      _steps.add(_newCall);
+    }
+    flow.setExitSequence(exitSequence);
+    return exitSequence;
+  }
+  
+  public Sequence defineStatechartEnterSequence(final ExecutionFlow flow, final Statechart sc) {
+    SexecFactory _factory = this.sexec.factory();
+    final Sequence enterSequence = _factory.createSequence();
+    enterSequence.setName("enter");
+    String _name = sc.getName();
+    String _plus = ObjectExtensions.operator_plus("Default enter sequence for statechart ", _name);
+    enterSequence.setComment(_plus);
+    EList<Scope> _scopes = sc.getScopes();
+    final Function1<Scope,EList<Variable>> _function = new Function1<Scope,EList<Variable>>() {
+        public EList<Variable> apply(final Scope s) {
+          EList<Variable> _variables = s.getVariables();
+          return _variables;
+        }
+      };
+    List<EList<Variable>> _map = ListExtensions.<Scope, EList<Variable>>map(_scopes, _function);
+    Iterable<Variable> _flatten = IterableExtensions.<Variable>flatten(_map);
+    Iterable<VariableDefinition> _filter = IterableExtensions.<VariableDefinition>filter(_flatten, VariableDefinition.class);
+    for (final VariableDefinition vd : _filter) {
+      Expression _initialValue = vd.getInitialValue();
+      boolean _notEquals = ObjectExtensions.operator_notEquals(_initialValue, null);
+      if (_notEquals) {
+        EList<Step> _steps = enterSequence.getSteps();
+        Execution _createInitialization = this.createInitialization(vd);
+        _steps.add(_createInitialization);
+      }
+    }
+    List<TimeEventSpec> _timeEventSpecs = this.sc.timeEventSpecs(sc);
+    for (final TimeEventSpec tes : _timeEventSpecs) {
+      {
+        final TimeEvent timeEvent = this.mapping.createDerivedEvent(tes);
+        Statement _buildValueExpression = this.buildValueExpression(tes);
+        final ScheduleTimeEvent scheduleStep = this.mapping.newScheduleTimeEvent(timeEvent, _buildValueExpression);
+        EList<Step> _steps_1 = enterSequence.getSteps();
+        _steps_1.add(scheduleStep);
+      }
+    }
+    Step _entryAction = flow.getEntryAction();
+    boolean _notEquals_1 = ObjectExtensions.operator_notEquals(_entryAction, null);
+    if (_notEquals_1) {
+      EList<Step> _steps_1 = enterSequence.getSteps();
+      Step _entryAction_1 = flow.getEntryAction();
+      Call _newCall = this.mapping.newCall(_entryAction_1);
+      _steps_1.add(_newCall);
+    }
+    EList<Region> _regions = sc.getRegions();
+    for (final Region r : _regions) {
+      {
+        final ExecutionRegion execRegion = this.mapping.create(r);
+        Sequence _enterSequence = execRegion.getEnterSequence();
+        boolean _notEquals_2 = ObjectExtensions.operator_notEquals(_enterSequence, null);
+        if (_notEquals_2) {
+          EList<Step> _steps_2 = enterSequence.getSteps();
+          Sequence _enterSequence_1 = execRegion.getEnterSequence();
+          Call _newCall_1 = this.mapping.newCall(_enterSequence_1);
+          _steps_2.add(_newCall_1);
+        }
+      }
+    }
+    flow.setEnterSequence(enterSequence);
+    return enterSequence;
+  }
+  
+  public Execution createInitialization(final VariableDefinition vd) {
+    SexecFactory _factory = this.sexec.factory();
+    final Execution execution = _factory.createExecution();
+    StextFactory _factory_1 = this.stext.factory();
+    final AssignmentExpression assignment = _factory_1.createAssignmentExpression();
+    StextFactory _factory_2 = this.stext.factory();
+    final ElementReferenceExpression reference = _factory_2.createElementReferenceExpression();
+    reference.setReference(vd);
+    assignment.setVarRef(reference);
+    assignment.setOperator(AssignmentOperator.ASSIGN);
+    Expression _initialValue = vd.getInitialValue();
+    Expression _copy = EcoreUtil.<Expression>copy(_initialValue);
+    assignment.setExpression(_copy);
+    execution.setStatement(assignment);
+    return execution;
+  }
+  
+  public Statement buildValueExpression(final TimeEventSpec tes) {
+    Statement _xblockexpression = null;
+    {
+      StextFactory _factory = this.stext.factory();
+      final PrimitiveValueExpression pve = _factory.createPrimitiveValueExpression();
+      StextFactory _factory_1 = this.stext.factory();
+      final IntLiteral intLit = _factory_1.createIntLiteral();
+      int _value = tes.getValue();
+      intLit.setValue(_value);
+      pve.setValue(intLit);
+      Statement _switchResult = null;
+      TimeUnit _unit = tes.getUnit();
+      final TimeUnit _switchValue = _unit;
+      boolean _matched = false;
+      if (!_matched) {
+        if (Objects.equal(_switchValue,TimeUnit.MILLISECOND)) {
+          _matched=true;
+          _switchResult = pve;
+        }
+      }
+      if (!_matched) {
+        if (Objects.equal(_switchValue,TimeUnit.MICROSECOND)) {
+          _matched=true;
+          Statement _divide = this.divide(pve, 1000);
+          _switchResult = _divide;
+        }
+      }
+      if (!_matched) {
+        if (Objects.equal(_switchValue,TimeUnit.NANOSECOND)) {
+          _matched=true;
+          Statement _divide_1 = this.divide(pve, 1000000);
+          _switchResult = _divide_1;
+        }
+      }
+      if (!_matched) {
+        if (Objects.equal(_switchValue,TimeUnit.SECOND)) {
+          _matched=true;
+          Statement _multiply = this.multiply(pve, 1000);
+          _switchResult = _multiply;
+        }
+      }
+      if (!_matched) {
+        _switchResult = pve;
+      }
+      _xblockexpression = (_switchResult);
+    }
+    return _xblockexpression;
+  }
+  
+  public Statement divide(final Expression stmnt, final long divisor) {
+    NumericalMultiplyDivideExpression _xblockexpression = null;
+    {
+      StextFactory _factory = this.stext.factory();
+      final NumericalMultiplyDivideExpression div = _factory.createNumericalMultiplyDivideExpression();
+      StextFactory _factory_1 = this.stext.factory();
+      final PrimitiveValueExpression pve = _factory_1.createPrimitiveValueExpression();
+      StextFactory _factory_2 = this.stext.factory();
+      final IntLiteral intLit = _factory_2.createIntLiteral();
+      int _intValue = Long.valueOf(divisor).intValue();
+      intLit.setValue(_intValue);
+      pve.setValue(intLit);
+      div.setOperator(MultiplicativeOperator.DIV);
+      div.setLeftOperand(stmnt);
+      div.setRightOperand(pve);
+      _xblockexpression = (div);
+    }
+    return _xblockexpression;
+  }
+  
+  public Statement multiply(final Expression stmnt, final long factor) {
+    NumericalMultiplyDivideExpression _xblockexpression = null;
+    {
+      StextFactory _factory = this.stext.factory();
+      final NumericalMultiplyDivideExpression div = _factory.createNumericalMultiplyDivideExpression();
+      StextFactory _factory_1 = this.stext.factory();
+      final PrimitiveValueExpression pve = _factory_1.createPrimitiveValueExpression();
+      StextFactory _factory_2 = this.stext.factory();
+      final IntLiteral intLit = _factory_2.createIntLiteral();
+      int _intValue = Long.valueOf(factor).intValue();
+      intLit.setValue(_intValue);
+      pve.setValue(intLit);
+      div.setOperator(MultiplicativeOperator.MUL);
+      div.setLeftOperand(stmnt);
+      div.setRightOperand(pve);
+      _xblockexpression = (div);
+    }
+    return _xblockexpression;
+  }
+  
+  public void defineStateEnterSequence(final NamedElement state) {
+    if (state instanceof FinalState) {
+      _defineStateEnterSequence((FinalState)state);
+      return;
+    } else if (state instanceof State) {
+      _defineStateEnterSequence((State)state);
+      return;
+    } else if (state instanceof Region) {
+      _defineStateEnterSequence((Region)state);
+      return;
+    } else if (state instanceof Vertex) {
+      _defineStateEnterSequence((Vertex)state);
+      return;
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(state).toString());
+    }
+  }
+  
+  public void defineStateExitSequence(final NamedElement s) {
+    if (s instanceof FinalState) {
+      _defineStateExitSequence((FinalState)s);
+      return;
+    } else if (s instanceof State) {
+      _defineStateExitSequence((State)s);
+      return;
+    } else if (s instanceof Region) {
+      _defineStateExitSequence((Region)s);
+      return;
+    } else if (s instanceof Vertex) {
+      _defineStateExitSequence((Vertex)s);
+      return;
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(s).toString());
+    }
+  }
+}

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

@@ -0,0 +1,829 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.xtext.naming.IQualifiedNameProvider;
+import org.eclipse.xtext.naming.QualifiedName;
+import org.eclipse.xtext.util.Strings;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.CollectionLiterals;
+import org.eclipse.xtext.xbase.lib.Functions.Function0;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.yakindu.base.base.NamedElement;
+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.ExecutionChoice;
+import org.yakindu.sct.model.sexec.ExecutionEntry;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sexec.ExecutionRegion;
+import org.yakindu.sct.model.sexec.ExecutionState;
+import org.yakindu.sct.model.sexec.ExecutionSynchronization;
+import org.yakindu.sct.model.sexec.ScheduleTimeEvent;
+import org.yakindu.sct.model.sexec.Sequence;
+import org.yakindu.sct.model.sexec.SexecFactory;
+import org.yakindu.sct.model.sexec.Step;
+import org.yakindu.sct.model.sexec.TimeEvent;
+import org.yakindu.sct.model.sexec.UnscheduleTimeEvent;
+import org.yakindu.sct.model.sexec.transformation.SexecExtensions;
+import org.yakindu.sct.model.sexec.transformation.SgraphExtensions;
+import org.yakindu.sct.model.sexec.transformation.StatechartExtensions;
+import org.yakindu.sct.model.sexec.transformation.StextExtensions;
+import org.yakindu.sct.model.sgraph.Choice;
+import org.yakindu.sct.model.sgraph.CompositeElement;
+import org.yakindu.sct.model.sgraph.Entry;
+import org.yakindu.sct.model.sgraph.EntryKind;
+import org.yakindu.sct.model.sgraph.FinalState;
+import org.yakindu.sct.model.sgraph.Reaction;
+import org.yakindu.sct.model.sgraph.Region;
+import org.yakindu.sct.model.sgraph.RegularState;
+import org.yakindu.sct.model.sgraph.SGraphFactory;
+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.Statement;
+import org.yakindu.sct.model.sgraph.Synchronization;
+import org.yakindu.sct.model.sgraph.Transition;
+import org.yakindu.sct.model.sgraph.Vertex;
+import org.yakindu.sct.model.stext.stext.AlwaysEvent;
+import org.yakindu.sct.model.stext.stext.BoolLiteral;
+import org.yakindu.sct.model.stext.stext.DefaultEvent;
+import org.yakindu.sct.model.stext.stext.ElementReferenceExpression;
+import org.yakindu.sct.model.stext.stext.EventDefinition;
+import org.yakindu.sct.model.stext.stext.EventSpec;
+import org.yakindu.sct.model.stext.stext.Expression;
+import org.yakindu.sct.model.stext.stext.FeatureCall;
+import org.yakindu.sct.model.stext.stext.InterfaceScope;
+import org.yakindu.sct.model.stext.stext.InternalScope;
+import org.yakindu.sct.model.stext.stext.LocalReaction;
+import org.yakindu.sct.model.stext.stext.OnCycleEvent;
+import org.yakindu.sct.model.stext.stext.OperationDefinition;
+import org.yakindu.sct.model.stext.stext.PrimitiveValueExpression;
+import org.yakindu.sct.model.stext.stext.ReactionTrigger;
+import org.yakindu.sct.model.stext.stext.RegularEventSpec;
+import org.yakindu.sct.model.stext.stext.StextFactory;
+import org.yakindu.sct.model.stext.stext.TimeEventSpec;
+import org.yakindu.sct.model.stext.stext.TimeEventType;
+import org.yakindu.sct.model.stext.stext.VariableDefinition;
+
+@Singleton
+@SuppressWarnings("all")
+public class SexecElementMapping {
+  @Inject
+  private IQualifiedNameProvider qfnProvider;
+  
+  @Inject
+  private StatechartExtensions sce;
+  
+  @Inject
+  private SgraphExtensions sgraph;
+  
+  @Inject
+  private StextExtensions stext;
+  
+  @Inject
+  private SexecExtensions sexec;
+  
+  public ExecutionFlow create(final Statechart statechart) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(statechart);
+    final ExecutionFlow _result;
+    synchronized (_createCache_create) {
+      if (_createCache_create.containsKey(_cacheKey)) {
+        return _createCache_create.get(_cacheKey);
+      }
+      SexecFactory _sexecFactory = this.sexecFactory();
+      ExecutionFlow _createExecutionFlow = _sexecFactory.createExecutionFlow();
+      _result = _createExecutionFlow;
+      _createCache_create.put(_cacheKey, _result);
+    }
+    _init_create(_result, statechart);
+    return _result;
+  }
+  
+  private final HashMap<ArrayList<? extends Object>,ExecutionFlow> _createCache_create = CollectionLiterals.newHashMap();
+  
+  private void _init_create(final ExecutionFlow r, final Statechart statechart) {
+    String _name = statechart.getName();
+    r.setName(_name);
+    r.setSourceElement(statechart);
+  }
+  
+  protected Scope _create(final InterfaceScope scope) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(scope);
+    final InterfaceScope _result;
+    synchronized (_createCache_create_1) {
+      if (_createCache_create_1.containsKey(_cacheKey)) {
+        return _createCache_create_1.get(_cacheKey);
+      }
+      StextFactory _stextFactory = this.stextFactory();
+      InterfaceScope _createInterfaceScope = _stextFactory.createInterfaceScope();
+      _result = _createInterfaceScope;
+      _createCache_create_1.put(_cacheKey, _result);
+    }
+    _init_create_1(_result, scope);
+    return _result;
+  }
+  
+  private final HashMap<ArrayList<? extends Object>,Scope> _createCache_create_1 = CollectionLiterals.newHashMap();
+  
+  private void _init_create_1(final InterfaceScope r, final InterfaceScope scope) {
+    String _name = scope.getName();
+    r.setName(_name);
+  }
+  
+  protected Scope _create(final Scope scope) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(scope);
+    final InternalScope _result;
+    synchronized (_createCache_create_2) {
+      if (_createCache_create_2.containsKey(_cacheKey)) {
+        return _createCache_create_2.get(_cacheKey);
+      }
+      StextFactory _stextFactory = this.stextFactory();
+      InternalScope _createInternalScope = _stextFactory.createInternalScope();
+      _result = _createInternalScope;
+      _createCache_create_2.put(_cacheKey, _result);
+    }
+    _init_create_2(_result, scope);
+    return _result;
+  }
+  
+  private final HashMap<ArrayList<? extends Object>,Scope> _createCache_create_2 = CollectionLiterals.newHashMap();
+  
+  private void _init_create_2(final InternalScope r, final Scope scope) {
+  }
+  
+  public Scope timeEventScope(final ExecutionFlow flow) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(flow);
+    final Scope _result;
+    synchronized (_createCache_timeEventScope) {
+      if (_createCache_timeEventScope.containsKey(_cacheKey)) {
+        return _createCache_timeEventScope.get(_cacheKey);
+      }
+      SGraphFactory _factory = this.sgraph.factory();
+      Scope _createScope = _factory.createScope();
+      _result = _createScope;
+      _createCache_timeEventScope.put(_cacheKey, _result);
+    }
+    _init_timeEventScope(_result, flow);
+    return _result;
+  }
+  
+  private final HashMap<ArrayList<? extends Object>,Scope> _createCache_timeEventScope = CollectionLiterals.newHashMap();
+  
+  private void _init_timeEventScope(final Scope r, final ExecutionFlow flow) {
+    EList<Scope> _scopes = flow.getScopes();
+    _scopes.add(r);
+  }
+  
+  public EventDefinition create(final EventDefinition event) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(event);
+    final EventDefinition _result;
+    synchronized (_createCache_create_3) {
+      if (_createCache_create_3.containsKey(_cacheKey)) {
+        return _createCache_create_3.get(_cacheKey);
+      }
+      EventDefinition _copy = EcoreUtil.<EventDefinition>copy(event);
+      _result = _copy;
+      _createCache_create_3.put(_cacheKey, _result);
+    }
+    _init_create_3(_result, event);
+    return _result;
+  }
+  
+  private final HashMap<ArrayList<? extends Object>,EventDefinition> _createCache_create_3 = CollectionLiterals.newHashMap();
+  
+  private void _init_create_3(final EventDefinition r, final EventDefinition event) {
+  }
+  
+  public VariableDefinition create(final VariableDefinition v) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(v);
+    final VariableDefinition _result;
+    synchronized (_createCache_create_4) {
+      if (_createCache_create_4.containsKey(_cacheKey)) {
+        return _createCache_create_4.get(_cacheKey);
+      }
+      VariableDefinition _copy = EcoreUtil.<VariableDefinition>copy(v);
+      _result = _copy;
+      _createCache_create_4.put(_cacheKey, _result);
+    }
+    _init_create_4(_result, v);
+    return _result;
+  }
+  
+  private final HashMap<ArrayList<? extends Object>,VariableDefinition> _createCache_create_4 = CollectionLiterals.newHashMap();
+  
+  private void _init_create_4(final VariableDefinition r, final VariableDefinition v) {
+  }
+  
+  public OperationDefinition create(final OperationDefinition v) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(v);
+    final OperationDefinition _result;
+    synchronized (_createCache_create_5) {
+      if (_createCache_create_5.containsKey(_cacheKey)) {
+        return _createCache_create_5.get(_cacheKey);
+      }
+      OperationDefinition _copy = EcoreUtil.<OperationDefinition>copy(v);
+      _result = _copy;
+      _createCache_create_5.put(_cacheKey, _result);
+    }
+    _init_create_5(_result, v);
+    return _result;
+  }
+  
+  private final HashMap<ArrayList<? extends Object>,OperationDefinition> _createCache_create_5 = CollectionLiterals.newHashMap();
+  
+  private void _init_create_5(final OperationDefinition r, final OperationDefinition v) {
+  }
+  
+  public ExecutionState create(final RegularState state) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(state);
+    final ExecutionState _result;
+    synchronized (_createCache_create_6) {
+      if (_createCache_create_6.containsKey(_cacheKey)) {
+        return _createCache_create_6.get(_cacheKey);
+      }
+      SexecFactory _sexecFactory = this.sexecFactory();
+      ExecutionState _createExecutionState = _sexecFactory.createExecutionState();
+      _result = _createExecutionState;
+      _createCache_create_6.put(_cacheKey, _result);
+    }
+    _init_create_6(_result, state);
+    return _result;
+  }
+  
+  private final HashMap<ArrayList<? extends Object>,ExecutionState> _createCache_create_6 = CollectionLiterals.newHashMap();
+  
+  private void _init_create_6(final ExecutionState r, final RegularState state) {
+    boolean _notEquals = ObjectExtensions.operator_notEquals(state, null);
+    if (_notEquals) {
+      Region _parentRegion = state.getParentRegion();
+      EList<Vertex> _vertices = _parentRegion.getVertices();
+      Iterable<FinalState> _filter = IterableExtensions.<FinalState>filter(_vertices, FinalState.class);
+      List<FinalState> _list = IterableExtensions.<FinalState>toList(_filter);
+      final int n = _list.indexOf(state);
+      String _xifexpression = null;
+      if ((state instanceof FinalState)) {
+        String _plus = StringExtensions.operator_plus("_final_", Integer.valueOf(n));
+        _xifexpression = _plus;
+      } else {
+        String _name = state.getName();
+        _xifexpression = _name;
+      }
+      r.setSimpleName(_xifexpression);
+      QualifiedName _fullyQualifiedName = this.qfnProvider.getFullyQualifiedName(state);
+      String _string = _fullyQualifiedName.toString();
+      String _replaceAll = _string.replaceAll(" ", "");
+      r.setName(_replaceAll);
+      r.setSourceElement(state);
+    }
+  }
+  
+  public ExecutionChoice create(final Choice choice) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(choice);
+    final ExecutionChoice _result;
+    synchronized (_createCache_create_7) {
+      if (_createCache_create_7.containsKey(_cacheKey)) {
+        return _createCache_create_7.get(_cacheKey);
+      }
+      SexecFactory _sexecFactory = this.sexecFactory();
+      ExecutionChoice _createExecutionChoice = _sexecFactory.createExecutionChoice();
+      _result = _createExecutionChoice;
+      _createCache_create_7.put(_cacheKey, _result);
+    }
+    _init_create_7(_result, choice);
+    return _result;
+  }
+  
+  private final HashMap<ArrayList<? extends Object>,ExecutionChoice> _createCache_create_7 = CollectionLiterals.newHashMap();
+  
+  private void _init_create_7(final ExecutionChoice r, final Choice choice) {
+    boolean _notEquals = ObjectExtensions.operator_notEquals(choice, null);
+    if (_notEquals) {
+      Region _parentRegion = choice.getParentRegion();
+      EList<Vertex> _vertices = _parentRegion.getVertices();
+      Iterable<Choice> _filter = IterableExtensions.<Choice>filter(_vertices, Choice.class);
+      List<Choice> _list = IterableExtensions.<Choice>toList(_filter);
+      final int n = _list.indexOf(choice);
+      String _plus = StringExtensions.operator_plus("_choice", Integer.valueOf(n));
+      String _plus_1 = ObjectExtensions.operator_plus(_plus, "_");
+      r.setSimpleName(_plus_1);
+      QualifiedName _fullyQualifiedName = this.qfnProvider.getFullyQualifiedName(choice);
+      String _string = _fullyQualifiedName.toString();
+      String _replaceAll = _string.replaceAll(" ", "");
+      r.setName(_replaceAll);
+      r.setSourceElement(choice);
+      SexecFactory _sexecFactory = this.sexecFactory();
+      Sequence _createSequence = _sexecFactory.createSequence();
+      r.setReactSequence(_createSequence);
+    }
+  }
+  
+  public ExecutionEntry create(final Entry entry) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(entry);
+    final ExecutionEntry _result;
+    synchronized (_createCache_create_8) {
+      if (_createCache_create_8.containsKey(_cacheKey)) {
+        return _createCache_create_8.get(_cacheKey);
+      }
+      SexecFactory _sexecFactory = this.sexecFactory();
+      ExecutionEntry _createExecutionEntry = _sexecFactory.createExecutionEntry();
+      _result = _createExecutionEntry;
+      _createCache_create_8.put(_cacheKey, _result);
+    }
+    _init_create_8(_result, entry);
+    return _result;
+  }
+  
+  private final HashMap<ArrayList<? extends Object>,ExecutionEntry> _createCache_create_8 = CollectionLiterals.newHashMap();
+  
+  private void _init_create_8(final ExecutionEntry r, final Entry entry) {
+    boolean _notEquals = ObjectExtensions.operator_notEquals(entry, null);
+    if (_notEquals) {
+      EObject _eContainer = entry.eContainer();
+      final Region region = ((Region) _eContainer);
+      String _name = region.getName();
+      final String regionName = StringExtensions.toFirstUpper(_name);
+      String _xifexpression = null;
+      EObject _eContainer_1 = region.eContainer();
+      if ((_eContainer_1 instanceof State)) {
+        EObject _eContainer_2 = region.eContainer();
+        String _name_1 = ((State) _eContainer_2).getName();
+        String _firstUpper = StringExtensions.toFirstUpper(_name_1);
+        _xifexpression = _firstUpper;
+      }
+      final String stateName = _xifexpression;
+      String _xifexpression_1 = null;
+      String _name_2 = entry.getName();
+      boolean _isEmpty = _name_2==null?false:_name_2.isEmpty();
+      boolean _not = BooleanExtensions.operator_not(_isEmpty);
+      if (_not) {
+        String _name_3 = entry.getName();
+        _xifexpression_1 = _name_3;
+      } else {
+        _xifexpression_1 = "_entry_Default";
+      }
+      final String entryName = _xifexpression_1;
+      String _xifexpression_2 = null;
+      boolean _notEquals_1 = ObjectExtensions.operator_notEquals(regionName, null);
+      if (_notEquals_1) {
+        _xifexpression_2 = regionName;
+      } else {
+        _xifexpression_2 = "";
+      }
+      String _plus = ObjectExtensions.operator_plus(new Function0<Object>() {
+        public Object apply() {
+          String _xifexpression = null;
+          boolean _notEquals = ObjectExtensions.operator_notEquals(regionName, null);
+          if (_notEquals) {
+            _xifexpression = regionName;
+          } else {
+            _xifexpression = "";
+          }
+          return _xifexpression;
+        }
+      }.apply(), "_");
+      String _xifexpression_3 = null;
+      boolean _notEquals_2 = ObjectExtensions.operator_notEquals(stateName, null);
+      if (_notEquals_2) {
+        _xifexpression_3 = stateName;
+      } else {
+        _xifexpression_3 = "";
+      }
+      String _plus_1 = ObjectExtensions.operator_plus(_plus, new Function0<String>() {
+        public String apply() {
+          String _xifexpression = null;
+          boolean _notEquals = ObjectExtensions.operator_notEquals(stateName, null);
+          if (_notEquals) {
+            _xifexpression = stateName;
+          } else {
+            _xifexpression = "";
+          }
+          return _xifexpression;
+        }
+      }.apply());
+      String _plus_2 = ObjectExtensions.operator_plus(_plus_1, "_");
+      String _plus_3 = ObjectExtensions.operator_plus(_plus_2, entryName);
+      r.setSimpleName(_plus_3);
+      QualifiedName _fullyQualifiedName = this.qfnProvider.getFullyQualifiedName(entry);
+      String _string = _fullyQualifiedName.toString();
+      String _replaceAll = _string.replaceAll(" ", "");
+      r.setName(_replaceAll);
+      r.setSourceElement(entry);
+      SexecFactory _factory = this.sexec.factory();
+      final Sequence seq = _factory.createSequence();
+      seq.setName("react");
+      String _switchResult = null;
+      EntryKind _kind = entry.getKind();
+      final EntryKind _switchValue = _kind;
+      boolean _matched = false;
+      if (!_matched) {
+        if (Objects.equal(_switchValue,EntryKind.INITIAL)) {
+          _matched=true;
+          _switchResult = "initial ";
+        }
+      }
+      if (!_matched) {
+        if (Objects.equal(_switchValue,EntryKind.DEEP_HISTORY)) {
+          _matched=true;
+          _switchResult = "deep history ";
+        }
+      }
+      if (!_matched) {
+        if (Objects.equal(_switchValue,EntryKind.SHALLOW_HISTORY)) {
+          _matched=true;
+          _switchResult = "shallow history ";
+        }
+      }
+      if (!_matched) {
+        _switchResult = "";
+      }
+      String _plus_4 = ObjectExtensions.operator_plus("Default react sequence for ", _switchResult);
+      String _plus_5 = ObjectExtensions.operator_plus(_plus_4, "entry ");
+      String _name_4 = entry.getName();
+      String _plus_6 = ObjectExtensions.operator_plus(_plus_5, _name_4);
+      seq.setComment(_plus_6);
+      r.setReactSequence(seq);
+    }
+  }
+  
+  public ExecutionSynchronization create(final Synchronization sync) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(sync);
+    final ExecutionSynchronization _result;
+    synchronized (_createCache_create_9) {
+      if (_createCache_create_9.containsKey(_cacheKey)) {
+        return _createCache_create_9.get(_cacheKey);
+      }
+      SexecFactory _sexecFactory = this.sexecFactory();
+      ExecutionSynchronization _createExecutionSynchronization = _sexecFactory.createExecutionSynchronization();
+      _result = _createExecutionSynchronization;
+      _createCache_create_9.put(_cacheKey, _result);
+    }
+    _init_create_9(_result, sync);
+    return _result;
+  }
+  
+  private final HashMap<ArrayList<? extends Object>,ExecutionSynchronization> _createCache_create_9 = CollectionLiterals.newHashMap();
+  
+  private void _init_create_9(final ExecutionSynchronization r, final Synchronization sync) {
+    boolean _notEquals = ObjectExtensions.operator_notEquals(sync, null);
+    if (_notEquals) {
+      Region _parentRegion = sync.getParentRegion();
+      EList<Vertex> _vertices = _parentRegion.getVertices();
+      Iterable<Synchronization> _filter = IterableExtensions.<Synchronization>filter(_vertices, Synchronization.class);
+      List<Synchronization> _list = IterableExtensions.<Synchronization>toList(_filter);
+      final int n = _list.indexOf(sync);
+      String _plus = StringExtensions.operator_plus("_sync", Integer.valueOf(n));
+      String _plus_1 = ObjectExtensions.operator_plus(_plus, "_");
+      r.setSimpleName(_plus_1);
+      QualifiedName _fullyQualifiedName = this.qfnProvider.getFullyQualifiedName(sync);
+      String _string = _fullyQualifiedName.toString();
+      String _replaceAll = _string.replaceAll(" ", "");
+      r.setName(_replaceAll);
+      r.setSourceElement(sync);
+      SexecFactory _sexecFactory = this.sexecFactory();
+      Sequence _createSequence = _sexecFactory.createSequence();
+      r.setReactSequence(_createSequence);
+    }
+  }
+  
+  public ExecutionRegion create(final Region region) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(region);
+    final ExecutionRegion _result;
+    synchronized (_createCache_create_10) {
+      if (_createCache_create_10.containsKey(_cacheKey)) {
+        return _createCache_create_10.get(_cacheKey);
+      }
+      SexecFactory _sexecFactory = this.sexecFactory();
+      ExecutionRegion _createExecutionRegion = _sexecFactory.createExecutionRegion();
+      _result = _createExecutionRegion;
+      _createCache_create_10.put(_cacheKey, _result);
+    }
+    _init_create_10(_result, region);
+    return _result;
+  }
+  
+  private final HashMap<ArrayList<? extends Object>,ExecutionRegion> _createCache_create_10 = CollectionLiterals.newHashMap();
+  
+  private void _init_create_10(final ExecutionRegion r, final Region region) {
+    boolean _notEquals = ObjectExtensions.operator_notEquals(region, null);
+    if (_notEquals) {
+      String _name = region.getName();
+      boolean _isEmpty = Strings.isEmpty(_name);
+      if (_isEmpty) {
+        EObject _eContainer = region.eContainer();
+        final CompositeElement container = ((CompositeElement) _eContainer);
+        EList<Region> _regions = container.getRegions();
+        final int index = _regions.indexOf(region);
+        String _plus = StringExtensions.operator_plus("region", Integer.valueOf(index));
+        r.setName(_plus);
+      } else {
+        String _name_1 = region.getName();
+        r.setName(_name_1);
+      }
+      r.setSourceElement(region);
+    }
+  }
+  
+  public Check createCheck(final ReactionTrigger tr) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(tr);
+    final Check _result;
+    synchronized (_createCache_createCheck) {
+      if (_createCache_createCheck.containsKey(_cacheKey)) {
+        return _createCache_createCheck.get(_cacheKey);
+      }
+      SexecFactory _sexecFactory = this.sexecFactory();
+      Check _createCheck = _sexecFactory.createCheck();
+      _result = _createCheck;
+      _createCache_createCheck.put(_cacheKey, _result);
+    }
+    _init_createCheck(_result, tr);
+    return _result;
+  }
+  
+  private final HashMap<ArrayList<? extends Object>,Check> _createCache_createCheck = CollectionLiterals.newHashMap();
+  
+  private void _init_createCheck(final Check r, final ReactionTrigger tr) {
+    Reaction _reaction = this.sce.reaction(tr);
+    String _id = this.sce.id(_reaction);
+    r.setName(_id);
+  }
+  
+  public org.yakindu.sct.model.sexec.Reaction create(final Transition tr) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(tr);
+    final org.yakindu.sct.model.sexec.Reaction _result;
+    synchronized (_createCache_create_11) {
+      if (_createCache_create_11.containsKey(_cacheKey)) {
+        return _createCache_create_11.get(_cacheKey);
+      }
+      SexecFactory _sexecFactory = this.sexecFactory();
+      org.yakindu.sct.model.sexec.Reaction _createReaction = _sexecFactory.createReaction();
+      _result = _createReaction;
+      _createCache_create_11.put(_cacheKey, _result);
+    }
+    _init_create_11(_result, tr);
+    return _result;
+  }
+  
+  private final HashMap<ArrayList<? extends Object>,org.yakindu.sct.model.sexec.Reaction> _createCache_create_11 = CollectionLiterals.newHashMap();
+  
+  private void _init_create_11(final org.yakindu.sct.model.sexec.Reaction r, final Transition tr) {
+    String _id = this.sce.id(tr);
+    r.setName(_id);
+    r.setTransition(true);
+    r.setSourceElement(tr);
+  }
+  
+  public org.yakindu.sct.model.sexec.Reaction create(final LocalReaction lr) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(lr);
+    final org.yakindu.sct.model.sexec.Reaction _result;
+    synchronized (_createCache_create_12) {
+      if (_createCache_create_12.containsKey(_cacheKey)) {
+        return _createCache_create_12.get(_cacheKey);
+      }
+      SexecFactory _sexecFactory = this.sexecFactory();
+      org.yakindu.sct.model.sexec.Reaction _createReaction = _sexecFactory.createReaction();
+      _result = _createReaction;
+      _createCache_create_12.put(_cacheKey, _result);
+    }
+    _init_create_12(_result, lr);
+    return _result;
+  }
+  
+  private final HashMap<ArrayList<? extends Object>,org.yakindu.sct.model.sexec.Reaction> _createCache_create_12 = CollectionLiterals.newHashMap();
+  
+  private void _init_create_12(final org.yakindu.sct.model.sexec.Reaction r, final LocalReaction lr) {
+    String _id = this.sce.id(lr);
+    r.setName(_id);
+    r.setTransition(false);
+  }
+  
+  public CheckRef newRef(final Check check) {
+    CheckRef _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      final CheckRef r = _sexecFactory.createCheckRef();
+      r.setCheck(check);
+      _xblockexpression = (r);
+    }
+    return _xblockexpression;
+  }
+  
+  public Call newCall(final Step step) {
+    Call _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      final Call r = _sexecFactory.createCall();
+      r.setStep(step);
+      _xblockexpression = (r);
+    }
+    return _xblockexpression;
+  }
+  
+  public ScheduleTimeEvent newScheduleTimeEvent(final TimeEvent te, final Statement timeValue) {
+    ScheduleTimeEvent _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      final ScheduleTimeEvent r = _sexecFactory.createScheduleTimeEvent();
+      r.setTimeEvent(te);
+      r.setTimeValue(timeValue);
+      _xblockexpression = (r);
+    }
+    return _xblockexpression;
+  }
+  
+  public UnscheduleTimeEvent newUnscheduleTimeEvent(final TimeEvent te) {
+    UnscheduleTimeEvent _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      final UnscheduleTimeEvent r = _sexecFactory.createUnscheduleTimeEvent();
+      r.setTimeEvent(te);
+      _xblockexpression = (r);
+    }
+    return _xblockexpression;
+  }
+  
+  public TimeEvent createDerivedEvent(final TimeEventSpec tes) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(tes);
+    final TimeEvent _result;
+    synchronized (_createCache_createDerivedEvent) {
+      if (_createCache_createDerivedEvent.containsKey(_cacheKey)) {
+        return _createCache_createDerivedEvent.get(_cacheKey);
+      }
+      SexecFactory _sexecFactory = this.sexecFactory();
+      TimeEvent _createTimeEvent = _sexecFactory.createTimeEvent();
+      _result = _createTimeEvent;
+      _createCache_createDerivedEvent.put(_cacheKey, _result);
+    }
+    _init_createDerivedEvent(_result, tes);
+    return _result;
+  }
+  
+  private final HashMap<ArrayList<? extends Object>,TimeEvent> _createCache_createDerivedEvent = CollectionLiterals.newHashMap();
+  
+  private void _init_createDerivedEvent(final TimeEvent r, final TimeEventSpec tes) {
+    TimeEventType _type = tes.getType();
+    boolean _equals = ObjectExtensions.operator_equals(_type, TimeEventType.EVERY);
+    r.setPeriodic(_equals);
+  }
+  
+  protected Expression _raised(final EventSpec e) {
+    return null;
+  }
+  
+  protected Expression _raised(final RegularEventSpec e) {
+    StextFactory _factory = this.stext.factory();
+    final ElementReferenceExpression r = _factory.createElementReferenceExpression();
+    EObject _eContainer = e.eContainer();
+    NamedElement _resolveRegularEventSpec = this.resolveRegularEventSpec(e, _eContainer);
+    r.setReference(_resolveRegularEventSpec);
+    return r;
+  }
+  
+  protected NamedElement _resolveRegularEventSpec(final Object o, final Object context) {
+    return null;
+  }
+  
+  protected NamedElement _resolveRegularEventSpec(final RegularEventSpec re, final Object context) {
+    NamedElement _xifexpression = null;
+    Expression _event = re.getEvent();
+    boolean _notEquals = ObjectExtensions.operator_notEquals(_event, null);
+    if (_notEquals) {
+      Expression _event_1 = re.getEvent();
+      NamedElement _resolveRegularEventSpec = this.resolveRegularEventSpec(_event_1, re);
+      _xifexpression = _resolveRegularEventSpec;
+    }
+    return _xifexpression;
+  }
+  
+  protected NamedElement _resolveRegularEventSpec(final FeatureCall fc, final Object context) {
+    NamedElement _xifexpression = null;
+    EObject _feature = fc.getFeature();
+    boolean _notEquals = ObjectExtensions.operator_notEquals(_feature, null);
+    if (_notEquals) {
+      EObject _feature_1 = fc.getFeature();
+      NamedElement _resolveRegularEventSpec = this.resolveRegularEventSpec(_feature_1, fc);
+      _xifexpression = _resolveRegularEventSpec;
+    }
+    return _xifexpression;
+  }
+  
+  protected NamedElement _resolveRegularEventSpec(final ElementReferenceExpression ter, final Object context) {
+    NamedElement _xifexpression = null;
+    EObject _reference = ter.getReference();
+    boolean _notEquals = ObjectExtensions.operator_notEquals(_reference, null);
+    if (_notEquals) {
+      EObject _reference_1 = ter.getReference();
+      NamedElement _resolveRegularEventSpec = this.resolveRegularEventSpec(_reference_1, ter);
+      _xifexpression = _resolveRegularEventSpec;
+    }
+    return _xifexpression;
+  }
+  
+  protected NamedElement _resolveRegularEventSpec(final EventDefinition ed, final Object context) {
+    EventDefinition _create = this.create(ed);
+    return _create;
+  }
+  
+  protected Expression _raised(final TimeEventSpec e) {
+    StextFactory _factory = this.stext.factory();
+    final ElementReferenceExpression r = _factory.createElementReferenceExpression();
+    TimeEvent _createDerivedEvent = this.createDerivedEvent(e);
+    r.setReference(_createDerivedEvent);
+    return r;
+  }
+  
+  protected Expression _raised(final OnCycleEvent e) {
+    StextFactory _factory = this.stext.factory();
+    final PrimitiveValueExpression r = _factory.createPrimitiveValueExpression();
+    StextFactory _factory_1 = this.stext.factory();
+    final BoolLiteral boolLit = _factory_1.createBoolLiteral();
+    boolLit.setValue(true);
+    r.setValue(boolLit);
+    return r;
+  }
+  
+  protected Expression _raised(final AlwaysEvent e) {
+    StextFactory _factory = this.stext.factory();
+    final PrimitiveValueExpression r = _factory.createPrimitiveValueExpression();
+    StextFactory _factory_1 = this.stext.factory();
+    final BoolLiteral boolLit = _factory_1.createBoolLiteral();
+    boolLit.setValue(true);
+    r.setValue(boolLit);
+    return r;
+  }
+  
+  protected Expression _raised(final DefaultEvent e) {
+    StextFactory _factory = this.stext.factory();
+    final PrimitiveValueExpression r = _factory.createPrimitiveValueExpression();
+    StextFactory _factory_1 = this.stext.factory();
+    final BoolLiteral boolLit = _factory_1.createBoolLiteral();
+    boolLit.setValue(true);
+    r.setValue(boolLit);
+    return r;
+  }
+  
+  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 != null) {
+      return _create(scope);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(scope).toString());
+    }
+  }
+  
+  public Expression raised(final EventSpec e) {
+    if (e instanceof AlwaysEvent) {
+      return _raised((AlwaysEvent)e);
+    } else if (e instanceof DefaultEvent) {
+      return _raised((DefaultEvent)e);
+    } else if (e instanceof OnCycleEvent) {
+      return _raised((OnCycleEvent)e);
+    } else if (e instanceof RegularEventSpec) {
+      return _raised((RegularEventSpec)e);
+    } else if (e instanceof TimeEventSpec) {
+      return _raised((TimeEventSpec)e);
+    } else if (e != null) {
+      return _raised(e);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(e).toString());
+    }
+  }
+  
+  public NamedElement resolveRegularEventSpec(final Object ed, final Object context) {
+    if (ed instanceof EventDefinition) {
+      return _resolveRegularEventSpec((EventDefinition)ed, context);
+    } else if (ed instanceof ElementReferenceExpression) {
+      return _resolveRegularEventSpec((ElementReferenceExpression)ed, context);
+    } else if (ed instanceof FeatureCall) {
+      return _resolveRegularEventSpec((FeatureCall)ed, context);
+    } else if (ed instanceof RegularEventSpec) {
+      return _resolveRegularEventSpec((RegularEventSpec)ed, context);
+    } else if (ed != null) {
+      return _resolveRegularEventSpec(ed, context);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(ed, context).toString());
+    }
+  }
+}

+ 147 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SexecExtensions.java

@@ -0,0 +1,147 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.xtext.xbase.lib.CollectionExtensions;
+import org.eclipse.xtext.xbase.lib.CollectionLiterals;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.yakindu.sct.model.sexec.EnterState;
+import org.yakindu.sct.model.sexec.ExecutionRegion;
+import org.yakindu.sct.model.sexec.ExecutionScope;
+import org.yakindu.sct.model.sexec.ExecutionState;
+import org.yakindu.sct.model.sexec.ExitState;
+import org.yakindu.sct.model.sexec.SaveHistory;
+import org.yakindu.sct.model.sexec.SexecFactory;
+import org.yakindu.sct.model.sexec.StateCase;
+import org.yakindu.sct.model.sexec.StateVector;
+import org.yakindu.sct.model.sexec.Step;
+
+@SuppressWarnings("all")
+public class SexecExtensions {
+  public SexecFactory factory() {
+    return SexecFactory.eINSTANCE;
+  }
+  
+  public EnterState newEnterStateStep(final ExecutionState s) {
+    EnterState ess = null;
+    boolean _notEquals = ObjectExtensions.operator_notEquals(s, null);
+    if (_notEquals) {
+      SexecFactory _factory = this.factory();
+      EnterState _createEnterState = _factory.createEnterState();
+      ess = _createEnterState;
+      ess.setState(s);
+    }
+    return ess;
+  }
+  
+  public ExitState newExitStateStep(final ExecutionState s) {
+    ExitState ess = null;
+    boolean _notEquals = ObjectExtensions.operator_notEquals(s, null);
+    if (_notEquals) {
+      SexecFactory _factory = this.factory();
+      ExitState _createExitState = _factory.createExitState();
+      ess = _createExitState;
+      ess.setState(s);
+    }
+    return ess;
+  }
+  
+  public StateCase newCase(final ExecutionState it, final Step step) {
+    SexecFactory _factory = this.factory();
+    final StateCase sCase = _factory.createStateCase();
+    sCase.setState(it);
+    sCase.setStep(step);
+    return sCase;
+  }
+  
+  public SaveHistory newSaveHistory(final ExecutionRegion r) {
+    SexecFactory _factory = this.factory();
+    final SaveHistory save = _factory.createSaveHistory();
+    save.setRegion(r);
+    return save;
+  }
+  
+  protected List<ExecutionState> _collectLeafStates(final ExecutionState state, final List<ExecutionState> leafStates) {
+    boolean _isLeaf = state.isLeaf();
+    if (_isLeaf) {
+      CollectionExtensions.<ExecutionState>operator_add(leafStates, state);
+    } else {
+      EList<ExecutionScope> _subScopes = state.getSubScopes();
+      for (final ExecutionScope r : _subScopes) {
+        this.collectLeafStates(r, leafStates);
+      }
+    }
+    return leafStates;
+  }
+  
+  protected List<ExecutionState> _collectLeafStates(final ExecutionRegion region, final List<ExecutionState> leafStates) {
+    EList<ExecutionScope> _subScopes = region.getSubScopes();
+    for (final ExecutionScope r : _subScopes) {
+      this.collectLeafStates(r, leafStates);
+    }
+    return leafStates;
+  }
+  
+  public int last(final StateVector sv) {
+    int _offset = sv.getOffset();
+    int _size = sv.getSize();
+    int _plus = IntegerExtensions.operator_plus(_offset, _size);
+    int _minus = IntegerExtensions.operator_minus(_plus, 1);
+    return _minus;
+  }
+  
+  public int first(final StateVector sv) {
+    int _offset = sv.getOffset();
+    return _offset;
+  }
+  
+  public ArrayList<ExecutionScope> parentScopes(final ExecutionScope scope) {
+    final ArrayList<ExecutionScope> parents = CollectionLiterals.<ExecutionScope>newArrayList();
+    ExecutionScope s = scope;
+    boolean _notEquals = ObjectExtensions.operator_notEquals(s, null);
+    boolean _while = _notEquals;
+    while (_while) {
+      {
+        parents.add(s);
+        ExecutionScope _superScope = s.getSuperScope();
+        s = _superScope;
+      }
+      boolean _notEquals_1 = ObjectExtensions.operator_notEquals(s, null);
+      _while = _notEquals_1;
+    }
+    return parents;
+  }
+  
+  /**
+   * Collect all scopes beneath this scope which does not contain subscopes and are instances of ExecutionState.
+   */
+  public List<ExecutionState> collectLeafScopes(final ExecutionScope scope, final List<ExecutionState> leafs) {
+    EList<ExecutionScope> _subScopes = scope.getSubScopes();
+    boolean _isEmpty = _subScopes.isEmpty();
+    if (_isEmpty) {
+      if ((scope instanceof ExecutionState)) {
+        leafs.add(((ExecutionState) scope));
+      }
+    } else {
+      EList<ExecutionScope> _subScopes_1 = scope.getSubScopes();
+      for (final ExecutionScope s : _subScopes_1) {
+        this.collectLeafScopes(s, leafs);
+      }
+    }
+    return leafs;
+  }
+  
+  public List<ExecutionState> collectLeafStates(final ExecutionScope region, final List<ExecutionState> leafStates) {
+    if (region instanceof ExecutionRegion) {
+      return _collectLeafStates((ExecutionRegion)region, leafStates);
+    } else if (region instanceof ExecutionState) {
+      return _collectLeafStates((ExecutionState)region, leafStates);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(region, leafStates).toString());
+    }
+  }
+}

+ 238 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SgraphExtensions.java

@@ -0,0 +1,238 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.CollectionExtensions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.yakindu.sct.model.sgraph.Entry;
+import org.yakindu.sct.model.sgraph.EntryKind;
+import org.yakindu.sct.model.sgraph.FinalState;
+import org.yakindu.sct.model.sgraph.Region;
+import org.yakindu.sct.model.sgraph.RegularState;
+import org.yakindu.sct.model.sgraph.SGraphFactory;
+import org.yakindu.sct.model.sgraph.State;
+import org.yakindu.sct.model.sgraph.Transition;
+import org.yakindu.sct.model.sgraph.Vertex;
+
+@SuppressWarnings("all")
+public class SgraphExtensions {
+  public SGraphFactory factory() {
+    return SGraphFactory.eINSTANCE;
+  }
+  
+  protected boolean _isLeaf(final RegularState s) {
+    return false;
+  }
+  
+  protected boolean _isLeaf(final FinalState s) {
+    return true;
+  }
+  
+  protected boolean _isLeaf(final State s) {
+    boolean _isSimple = s.isSimple();
+    return _isSimple;
+  }
+  
+  public List<RegularState> parentStates(final RegularState s) {
+    List<EObject> _containers = this.containers(s);
+    Iterable<RegularState> _filter = IterableExtensions.<RegularState>filter(_containers, RegularState.class);
+    List<RegularState> _list = IterableExtensions.<RegularState>toList(_filter);
+    return _list;
+  }
+  
+  public List<RegularState> parentStates(final Region s) {
+    List<EObject> _containers = this.containers(s);
+    Iterable<RegularState> _filter = IterableExtensions.<RegularState>filter(_containers, RegularState.class);
+    List<RegularState> _list = IterableExtensions.<RegularState>toList(_filter);
+    return _list;
+  }
+  
+  public List<EObject> containers(final EObject obj) {
+    ArrayList<EObject> _arrayList = new ArrayList<EObject>();
+    final ArrayList<EObject> containerList = _arrayList;
+    this.collectContainers(obj, containerList);
+    return containerList;
+  }
+  
+  public void collectContainers(final EObject obj, final List<EObject> containerList) {
+    CollectionExtensions.<EObject>operator_add(containerList, obj);
+    EObject _eContainer = obj==null?(EObject)null:obj.eContainer();
+    boolean _notEquals = ObjectExtensions.operator_notEquals(_eContainer, null);
+    if (_notEquals) {
+      EObject _eContainer_1 = obj.eContainer();
+      this.collectContainers(_eContainer_1, containerList);
+    }
+  }
+  
+  public Iterable<Entry> collectEntries(final Region r) {
+    EList<Vertex> _vertices = r.getVertices();
+    Iterable<Entry> _filter = IterableExtensions.<Entry>filter(_vertices, Entry.class);
+    return _filter;
+  }
+  
+  public Entry entry(final Region r) {
+    EList<Vertex> _vertices = r.getVertices();
+    final Function1<Vertex,Boolean> _function = new Function1<Vertex,Boolean>() {
+        public Boolean apply(final Vertex v) {
+          boolean _and = false;
+          if (!(v instanceof Entry)) {
+            _and = false;
+          } else {
+            boolean _or = false;
+            boolean _or_1 = false;
+            String _name = v.getName();
+            boolean _equals = ObjectExtensions.operator_equals(_name, null);
+            if (_equals) {
+              _or_1 = true;
+            } else {
+              String _name_1 = v.getName();
+              boolean _equals_1 = "".equals(_name_1);
+              _or_1 = BooleanExtensions.operator_or(_equals, _equals_1);
+            }
+            if (_or_1) {
+              _or = true;
+            } else {
+              String _name_2 = v.getName();
+              boolean _equals_2 = ObjectExtensions.operator_equals(_name_2, "default");
+              _or = BooleanExtensions.operator_or(_or_1, _equals_2);
+            }
+            _and = BooleanExtensions.operator_and((v instanceof Entry), _or);
+          }
+          return Boolean.valueOf(_and);
+        }
+      };
+    Vertex _findFirst = IterableExtensions.<Vertex>findFirst(_vertices, _function);
+    return ((Entry) _findFirst);
+  }
+  
+  /**
+   * Retrieves the target from an entry.
+   * TODO: validation of preconditions for entry targets e.g every region needs an entry with appropriate target
+   */
+  public State target(final Entry entry) {
+    State _xifexpression = null;
+    EList<Transition> _outgoingTransitions = entry==null?(EList<Transition>)null:entry.getOutgoingTransitions();
+    boolean _notEquals = ObjectExtensions.operator_notEquals(_outgoingTransitions, null);
+    if (_notEquals) {
+      State _xifexpression_1 = null;
+      EList<Transition> _outgoingTransitions_1 = entry.getOutgoingTransitions();
+      int _size = _outgoingTransitions_1.size();
+      boolean _greaterThan = IntegerExtensions.operator_greaterThan(_size, 0);
+      if (_greaterThan) {
+        State _xblockexpression = null;
+        {
+          EList<Transition> _outgoingTransitions_2 = entry.getOutgoingTransitions();
+          Transition _get = _outgoingTransitions_2.get(0);
+          final Vertex target = _get.getTarget();
+          State _xifexpression_2 = null;
+          if ((target instanceof State)) {
+            _xifexpression_2 = ((State) target);
+          }
+          _xblockexpression = (_xifexpression_2);
+        }
+        _xifexpression_1 = _xblockexpression;
+      }
+      _xifexpression = _xifexpression_1;
+    }
+    return _xifexpression;
+  }
+  
+  public List<RegularState> collectLeafStates(final RegularState state, final List<RegularState> leafStates) {
+    boolean _isLeaf = this.isLeaf(state);
+    if (_isLeaf) {
+      CollectionExtensions.<RegularState>operator_add(leafStates, state);
+    } else {
+      if ((state instanceof State)) {
+        final State s = ((State) state);
+        EList<Region> _regions = s.getRegions();
+        for (final Region r : _regions) {
+          EList<Vertex> _vertices = r.getVertices();
+          for (final Vertex v : _vertices) {
+            if ((v instanceof RegularState)) {
+              this.collectLeafStates(((RegularState) v), leafStates);
+            }
+          }
+        }
+      }
+    }
+    return leafStates;
+  }
+  
+  public List<RegularState> collectLeafStates(final Region region, final List<RegularState> leafStates) {
+    EList<Vertex> _vertices = region.getVertices();
+    for (final Vertex v : _vertices) {
+      if ((v instanceof RegularState)) {
+        this.collectLeafStates(((RegularState) v), leafStates);
+      }
+    }
+    return leafStates;
+  }
+  
+  public boolean requireDeepHistory(final Region r) {
+    List<EObject> _containers = this.containers(r);
+    Iterable<Region> _filter = IterableExtensions.<Region>filter(_containers, Region.class);
+    final Function1<Region,Boolean> _function = new Function1<Region,Boolean>() {
+        public Boolean apply(final Region p) {
+          EList<Vertex> _vertices = p.getVertices();
+          Iterable<Entry> _filter = IterableExtensions.<Entry>filter(_vertices, Entry.class);
+          final Function1<Entry,Boolean> _function = new Function1<Entry,Boolean>() {
+              public Boolean apply(final Entry v) {
+                EntryKind _kind = v.getKind();
+                boolean _equals = ObjectExtensions.operator_equals(_kind, EntryKind.DEEP_HISTORY);
+                return Boolean.valueOf(_equals);
+              }
+            };
+          boolean _exists = IterableExtensions.<Entry>exists(_filter, _function);
+          return Boolean.valueOf(_exists);
+        }
+      };
+    boolean _exists = IterableExtensions.<Region>exists(_filter, _function);
+    return _exists;
+  }
+  
+  public boolean requireShallowHistory(final Region r) {
+    EList<Vertex> _vertices = r.getVertices();
+    Iterable<Entry> _filter = IterableExtensions.<Entry>filter(_vertices, Entry.class);
+    final Function1<Entry,Boolean> _function = new Function1<Entry,Boolean>() {
+        public Boolean apply(final Entry v) {
+          EntryKind _kind = v.getKind();
+          boolean _equals = ObjectExtensions.operator_equals(_kind, EntryKind.SHALLOW_HISTORY);
+          return Boolean.valueOf(_equals);
+        }
+      };
+    boolean _exists = IterableExtensions.<Entry>exists(_filter, _function);
+    return _exists;
+  }
+  
+  public boolean requireHistory(final Region r) {
+    boolean _or = false;
+    boolean _requireDeepHistory = this.requireDeepHistory(r);
+    if (_requireDeepHistory) {
+      _or = true;
+    } else {
+      boolean _requireShallowHistory = this.requireShallowHistory(r);
+      _or = BooleanExtensions.operator_or(_requireDeepHistory, _requireShallowHistory);
+    }
+    return _or;
+  }
+  
+  public boolean isLeaf(final RegularState s) {
+    if (s instanceof FinalState) {
+      return _isLeaf((FinalState)s);
+    } else if (s instanceof State) {
+      return _isLeaf((State)s);
+    } else if (s != null) {
+      return _isLeaf(s);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(s).toString());
+    }
+  }
+}

+ 239 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StateVectorBuilder.java

@@ -0,0 +1,239 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import com.google.inject.Inject;
+import java.util.Arrays;
+import java.util.Iterator;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EObject;
+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.IteratorExtensions;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sexec.ExecutionRegion;
+import org.yakindu.sct.model.sexec.ExecutionState;
+import org.yakindu.sct.model.sexec.SexecFactory;
+import org.yakindu.sct.model.sexec.StateVector;
+import org.yakindu.sct.model.sexec.transformation.SexecElementMapping;
+import org.yakindu.sct.model.sexec.transformation.SexecExtensions;
+import org.yakindu.sct.model.sexec.transformation.SgraphExtensions;
+import org.yakindu.sct.model.sexec.transformation.StatechartExtensions;
+import org.yakindu.sct.model.sgraph.Choice;
+import org.yakindu.sct.model.sgraph.FinalState;
+import org.yakindu.sct.model.sgraph.Region;
+import org.yakindu.sct.model.sgraph.RegularState;
+import org.yakindu.sct.model.sgraph.State;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.sgraph.Vertex;
+
+@SuppressWarnings("all")
+public class StateVectorBuilder {
+  @Inject
+  private SexecExtensions sexec;
+  
+  @Inject
+  private SexecElementMapping mapping;
+  
+  @Inject
+  private StatechartExtensions sc;
+  
+  @Inject
+  private SgraphExtensions sgraph;
+  
+  public void defineHistoryVector(final ExecutionFlow flow, final Statechart sc) {
+    int offset = IntegerExtensions.operator_minus(1);
+    TreeIterator<EObject> _eAllContents = sc.eAllContents();
+    Iterator<Region> _filter = IteratorExtensions.<Region>filter(_eAllContents, Region.class);
+    Iterable<Region> _iterable = IteratorExtensions.<Region>toIterable(_filter);
+    for (final Region r : _iterable) {
+      boolean _requireHistory = this.sgraph.requireHistory(r);
+      if (_requireHistory) {
+        int _plus = IntegerExtensions.operator_plus(offset, 1);
+        offset = _plus;
+        final ExecutionRegion er = this.mapping.create(r);
+        SexecFactory _factory = this.sexec.factory();
+        StateVector _createStateVector = _factory.createStateVector();
+        er.setHistoryVector(_createStateVector);
+        StateVector _historyVector = er.getHistoryVector();
+        _historyVector.setOffset(offset);
+        StateVector _historyVector_1 = er.getHistoryVector();
+        _historyVector_1.setSize(1);
+      }
+    }
+    int _minus = IntegerExtensions.operator_minus(1);
+    boolean _notEquals = IntegerExtensions.operator_notEquals(offset, _minus);
+    if (_notEquals) {
+      SexecFactory _factory_1 = this.sexec.factory();
+      StateVector _createStateVector_1 = _factory_1.createStateVector();
+      flow.setHistoryVector(_createStateVector_1);
+      StateVector _historyVector_2 = flow.getHistoryVector();
+      _historyVector_2.setOffset(0);
+      StateVector _historyVector_3 = flow.getHistoryVector();
+      int _plus_1 = IntegerExtensions.operator_plus(offset, 1);
+      _historyVector_3.setSize(_plus_1);
+    }
+  }
+  
+  public void defineStateVector(final ExecutionFlow flow, final Statechart sc) {
+    int offset = 0;
+    EList<Region> _regions = sc.getRegions();
+    for (final Region r : _regions) {
+      int _defineStateVectors = this.defineStateVectors(r, offset);
+      int _plus = IntegerExtensions.operator_plus(offset, _defineStateVectors);
+      offset = _plus;
+    }
+    SexecFactory _factory = this.sexec.factory();
+    StateVector _createStateVector = _factory.createStateVector();
+    flow.setStateVector(_createStateVector);
+    StateVector _stateVector = flow.getStateVector();
+    _stateVector.setOffset(0);
+    StateVector _stateVector_1 = flow.getStateVector();
+    _stateVector_1.setSize(offset);
+  }
+  
+  /**
+   * calculates the maximum orthogonality (maximum number of possible active leaf states) of the statechart
+   */
+  public int defineStateVectors(final Statechart sc, final int offset) {
+    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 = StateVectorBuilder.this.sc.maxOrthogonality(r);
+          int _plus = IntegerExtensions.operator_plus(_maxOrthogonality, (o).intValue());
+          return Integer.valueOf(_plus);
+        }
+      };
+    Integer _fold = IterableExtensions.<Region, Integer>fold(_regions, Integer.valueOf(0), _function);
+    return (_fold).intValue();
+  }
+  
+  /**
+   * calculates the maximum orthogonality (maximum number of possible active leaf states) of a region
+   */
+  public int defineStateVectors(final Region r, final int offset) {
+    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;
+          {
+            final int mo = StateVectorBuilder.this.defineStateVectors(v, offset);
+            int _xifexpression = (int) 0;
+            boolean _greaterThan = IntegerExtensions.operator_greaterThan(mo, (s).intValue());
+            if (_greaterThan) {
+              _xifexpression = mo;
+            } else {
+              _xifexpression = s;
+            }
+            _xblockexpression = (_xifexpression);
+          }
+          return Integer.valueOf(_xblockexpression);
+        }
+      };
+    final Integer maxOrthogonality = IterableExtensions.<Vertex, Integer>fold(_vertices, Integer.valueOf(0), _function);
+    final ExecutionRegion er = this.mapping.create(r);
+    SexecFactory _factory = this.sexec.factory();
+    StateVector _createStateVector = _factory.createStateVector();
+    er.setStateVector(_createStateVector);
+    StateVector _stateVector = er.getStateVector();
+    _stateVector.setOffset(offset);
+    StateVector _stateVector_1 = er.getStateVector();
+    _stateVector_1.setSize((maxOrthogonality).intValue());
+    return (maxOrthogonality).intValue();
+  }
+  
+  /**
+   * the maximum orthogonality of all  pseudo states is 0
+   */
+  protected int _defineStateVectors(final Vertex v, final int offset) {
+    return 0;
+  }
+  
+  /**
+   * calculates the maximum orthogonality (maximum number of possible active leaf states) of a state
+   */
+  protected int _defineStateVectors(final State s, final int offset) {
+    int maxOrthogonality = 0;
+    EList<Region> _regions = s.getRegions();
+    int _size = _regions.size();
+    boolean _greaterThan = IntegerExtensions.operator_greaterThan(_size, 0);
+    if (_greaterThan) {
+      EList<Region> _regions_1 = s.getRegions();
+      for (final Region r : _regions_1) {
+        int _plus = IntegerExtensions.operator_plus(offset, maxOrthogonality);
+        int _defineStateVectors = this.defineStateVectors(r, _plus);
+        int _plus_1 = IntegerExtensions.operator_plus(maxOrthogonality, _defineStateVectors);
+        maxOrthogonality = _plus_1;
+      }
+    } else {
+      maxOrthogonality = 1;
+    }
+    final ExecutionState es = this.mapping.create(s);
+    SexecFactory _factory = this.sexec.factory();
+    StateVector _createStateVector = _factory.createStateVector();
+    es.setStateVector(_createStateVector);
+    StateVector _stateVector = es.getStateVector();
+    _stateVector.setOffset(offset);
+    StateVector _stateVector_1 = es.getStateVector();
+    _stateVector_1.setSize(maxOrthogonality);
+    return maxOrthogonality;
+  }
+  
+  /**
+   * calculates the maximum orthogonality (maximum number of possible active leaf states) of a state
+   */
+  protected int _defineStateVectors(final FinalState s, final int offset) {
+    final ExecutionState es = this.mapping.create(s);
+    SexecFactory _factory = this.sexec.factory();
+    StateVector _createStateVector = _factory.createStateVector();
+    es.setStateVector(_createStateVector);
+    StateVector _stateVector = es.getStateVector();
+    _stateVector.setOffset(offset);
+    StateVector _stateVector_1 = es.getStateVector();
+    _stateVector_1.setSize(1);
+    return 1;
+  }
+  
+  protected StateVector _stateVector(final Vertex v) {
+    return null;
+  }
+  
+  protected StateVector _stateVector(final RegularState s) {
+    ExecutionState _create = this.mapping.create(s);
+    StateVector _stateVector = _create.getStateVector();
+    return _stateVector;
+  }
+  
+  protected StateVector _stateVector(final Choice choice) {
+    Region _parentRegion = choice.getParentRegion();
+    ExecutionRegion _create = this.mapping.create(_parentRegion);
+    StateVector _stateVector = _create.getStateVector();
+    return _stateVector;
+  }
+  
+  public int defineStateVectors(final Vertex s, final int offset) {
+    if (s instanceof FinalState) {
+      return _defineStateVectors((FinalState)s, offset);
+    } else if (s instanceof State) {
+      return _defineStateVectors((State)s, offset);
+    } else if (s != null) {
+      return _defineStateVectors(s, offset);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(s, offset).toString());
+    }
+  }
+  
+  public StateVector stateVector(final Vertex choice) {
+    if (choice instanceof Choice) {
+      return _stateVector((Choice)choice);
+    } else if (choice instanceof RegularState) {
+      return _stateVector((RegularState)choice);
+    } else if (choice != null) {
+      return _stateVector(choice);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(choice).toString());
+    }
+  }
+}

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

@@ -0,0 +1,461 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.EcoreUtil2;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+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.IteratorExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.yakindu.base.base.NamedElement;
+import org.yakindu.sct.model.sgraph.Choice;
+import org.yakindu.sct.model.sgraph.Entry;
+import org.yakindu.sct.model.sgraph.Reaction;
+import org.yakindu.sct.model.sgraph.ReactiveElement;
+import org.yakindu.sct.model.sgraph.Region;
+import org.yakindu.sct.model.sgraph.RegularState;
+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.Synchronization;
+import org.yakindu.sct.model.sgraph.Transition;
+import org.yakindu.sct.model.sgraph.Trigger;
+import org.yakindu.sct.model.sgraph.Vertex;
+import org.yakindu.sct.model.stext.stext.EntryEvent;
+import org.yakindu.sct.model.stext.stext.EventSpec;
+import org.yakindu.sct.model.stext.stext.ExitEvent;
+import org.yakindu.sct.model.stext.stext.LocalReaction;
+import org.yakindu.sct.model.stext.stext.ReactionTrigger;
+import org.yakindu.sct.model.stext.stext.StextFactory;
+import org.yakindu.sct.model.stext.stext.TimeEventSpec;
+
+@SuppressWarnings("all")
+public class StatechartExtensions {
+  /**
+   * calculates the maximum orthogonality (maximum number of possible active leaf states) of the statechart
+   */
+  protected 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 _plus = IntegerExtensions.operator_plus(_maxOrthogonality, (o).intValue());
+          return Integer.valueOf(_plus);
+        }
+      };
+    Integer _fold = IterableExtensions.<Region, Integer>fold(_regions, Integer.valueOf(0), _function);
+    return (_fold).intValue();
+  }
+  
+  /**
+   * calculates the maximum orthogonality (maximum number of possible active leaf states) of a region
+   */
+  protected 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;
+          {
+            final int mo = StatechartExtensions.this.maxOrthogonality(v);
+            int _xifexpression = (int) 0;
+            boolean _greaterThan = IntegerExtensions.operator_greaterThan(mo, (s).intValue());
+            if (_greaterThan) {
+              _xifexpression = mo;
+            } else {
+              _xifexpression = s;
+            }
+            _xblockexpression = (_xifexpression);
+          }
+          return Integer.valueOf(_xblockexpression);
+        }
+      };
+    Integer _fold = IterableExtensions.<Vertex, Integer>fold(_vertices, Integer.valueOf(0), _function);
+    return (_fold).intValue();
+  }
+  
+  /**
+   * the maximum orthogonality of all  pseudo states is 0
+   */
+  protected int _maxOrthogonality(final Vertex v) {
+    return 0;
+  }
+  
+  /**
+   * calculates the maximum orthogonality (maximum number of possible active leaf states) of a state
+   */
+  protected int _maxOrthogonality(final State s) {
+    Integer _xifexpression = null;
+    EList<Region> _regions = s.getRegions();
+    int _size = _regions.size();
+    boolean _greaterThan = IntegerExtensions.operator_greaterThan(_size, 0);
+    if (_greaterThan) {
+      EList<Region> _regions_1 = s.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 _plus = IntegerExtensions.operator_plus(_maxOrthogonality, (o).intValue());
+            return Integer.valueOf(_plus);
+          }
+        };
+      Integer _fold = IterableExtensions.<Region, Integer>fold(_regions_1, Integer.valueOf(0), _function);
+      _xifexpression = _fold;
+    } else {
+      _xifexpression = 1;
+    }
+    return (_xifexpression).intValue();
+  }
+  
+  public Reaction reaction(final Trigger tr) {
+    EObject _eContainer = tr.eContainer();
+    return ((Reaction) _eContainer);
+  }
+  
+  public Statechart statechart(final State state) {
+    Region _parentRegion = state.getParentRegion();
+    Statechart _statechart = this.statechart(_parentRegion);
+    return _statechart;
+  }
+  
+  public Statechart statechart(final Region region) {
+    Statechart _xifexpression = null;
+    EObject _eContainer = region.eContainer();
+    if ((_eContainer instanceof Statechart)) {
+      EObject _eContainer_1 = region.eContainer();
+      _xifexpression = ((Statechart) _eContainer_1);
+    } else {
+      EObject _eContainer_2 = region.eContainer();
+      Statechart _statechart = this.statechart(((State) _eContainer_2));
+      _xifexpression = _statechart;
+    }
+    return _xifexpression;
+  }
+  
+  /**
+   * Provides a list of all TimeEventSpecs that are defined in the context of 'statechart'.
+   */
+  public List<TimeEventSpec> timeEventSpecs(final Statechart state) {
+    ArrayList<TimeEventSpec> _arrayList = new ArrayList<TimeEventSpec>();
+    ArrayList<TimeEventSpec> tesList = _arrayList;
+    EList<Reaction> _localReactions = state.getLocalReactions();
+    final Function2<ArrayList<TimeEventSpec>,Reaction,ArrayList<TimeEventSpec>> _function = new Function2<ArrayList<TimeEventSpec>,Reaction,ArrayList<TimeEventSpec>>() {
+        public ArrayList<TimeEventSpec> apply(final ArrayList<TimeEventSpec> s, final Reaction r) {
+          ArrayList<TimeEventSpec> _xblockexpression = null;
+          {
+            List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(r);
+            Iterable<TimeEventSpec> _filter = IterableExtensions.<TimeEventSpec>filter(_eAllContentsAsList, TimeEventSpec.class);
+            final Procedure1<TimeEventSpec> _function = new Procedure1<TimeEventSpec>() {
+                public void apply(final TimeEventSpec tes) {
+                  s.add(tes);
+                }
+              };
+            IterableExtensions.<TimeEventSpec>forEach(_filter, _function);
+            _xblockexpression = (s);
+          }
+          return _xblockexpression;
+        }
+      };
+    IterableExtensions.<Reaction, ArrayList<TimeEventSpec>>fold(_localReactions, tesList, _function);
+    return tesList;
+  }
+  
+  /**
+   * Provides a list of all TimeEventSpecs that are defined in the context of 'state'.
+   */
+  protected List<TimeEventSpec> _timeEventSpecs(final State state) {
+    ArrayList<TimeEventSpec> _arrayList = new ArrayList<TimeEventSpec>();
+    ArrayList<TimeEventSpec> tesList = _arrayList;
+    EList<Transition> _outgoingTransitions = state.getOutgoingTransitions();
+    final Function2<ArrayList<TimeEventSpec>,Transition,ArrayList<TimeEventSpec>> _function = new Function2<ArrayList<TimeEventSpec>,Transition,ArrayList<TimeEventSpec>>() {
+        public ArrayList<TimeEventSpec> apply(final ArrayList<TimeEventSpec> s, final Transition r) {
+          ArrayList<TimeEventSpec> _xblockexpression = null;
+          {
+            List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(r);
+            Iterable<TimeEventSpec> _filter = IterableExtensions.<TimeEventSpec>filter(_eAllContentsAsList, TimeEventSpec.class);
+            final Procedure1<TimeEventSpec> _function = new Procedure1<TimeEventSpec>() {
+                public void apply(final TimeEventSpec tes) {
+                  s.add(tes);
+                }
+              };
+            IterableExtensions.<TimeEventSpec>forEach(_filter, _function);
+            _xblockexpression = (s);
+          }
+          return _xblockexpression;
+        }
+      };
+    IterableExtensions.<Transition, ArrayList<TimeEventSpec>>fold(_outgoingTransitions, tesList, _function);
+    EList<Reaction> _localReactions = state.getLocalReactions();
+    final Function2<ArrayList<TimeEventSpec>,Reaction,ArrayList<TimeEventSpec>> _function_1 = new Function2<ArrayList<TimeEventSpec>,Reaction,ArrayList<TimeEventSpec>>() {
+        public ArrayList<TimeEventSpec> apply(final ArrayList<TimeEventSpec> s, final Reaction r) {
+          ArrayList<TimeEventSpec> _xblockexpression = null;
+          {
+            List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(r);
+            Iterable<TimeEventSpec> _filter = IterableExtensions.<TimeEventSpec>filter(_eAllContentsAsList, TimeEventSpec.class);
+            final Procedure1<TimeEventSpec> _function = new Procedure1<TimeEventSpec>() {
+                public void apply(final TimeEventSpec tes) {
+                  s.add(tes);
+                }
+              };
+            IterableExtensions.<TimeEventSpec>forEach(_filter, _function);
+            _xblockexpression = (s);
+          }
+          return _xblockexpression;
+        }
+      };
+    IterableExtensions.<Reaction, ArrayList<TimeEventSpec>>fold(_localReactions, tesList, _function_1);
+    return tesList;
+  }
+  
+  /**
+   * Provides a list of all TimeEventSpecs that are defined in the context of 'state'.
+   */
+  protected List<TimeEventSpec> _timeEventSpecs(final Statechart state) {
+    ArrayList<TimeEventSpec> _arrayList = new ArrayList<TimeEventSpec>();
+    ArrayList<TimeEventSpec> tesList = _arrayList;
+    EList<Reaction> _localReactions = state.getLocalReactions();
+    final Function2<ArrayList<TimeEventSpec>,Reaction,ArrayList<TimeEventSpec>> _function = new Function2<ArrayList<TimeEventSpec>,Reaction,ArrayList<TimeEventSpec>>() {
+        public ArrayList<TimeEventSpec> apply(final ArrayList<TimeEventSpec> s, final Reaction r) {
+          ArrayList<TimeEventSpec> _xblockexpression = null;
+          {
+            List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(r);
+            Iterable<TimeEventSpec> _filter = IterableExtensions.<TimeEventSpec>filter(_eAllContentsAsList, TimeEventSpec.class);
+            final Procedure1<TimeEventSpec> _function = new Procedure1<TimeEventSpec>() {
+                public void apply(final TimeEventSpec tes) {
+                  s.add(tes);
+                }
+              };
+            IterableExtensions.<TimeEventSpec>forEach(_filter, _function);
+            _xblockexpression = (s);
+          }
+          return _xblockexpression;
+        }
+      };
+    IterableExtensions.<Reaction, ArrayList<TimeEventSpec>>fold(_localReactions, tesList, _function);
+    return tesList;
+  }
+  
+  protected ReactiveElement _reactiveElement(final Reaction r) {
+    Scope _scope = this.scope(r);
+    ReactiveElement _reactiveElement = this.reactiveElement(_scope);
+    return _reactiveElement;
+  }
+  
+  protected ReactiveElement _reactiveElement(final Transition tr) {
+    State _xifexpression = null;
+    Vertex _source = tr.getSource();
+    if ((_source instanceof State)) {
+      _xifexpression = ((State) tr);
+    } else {
+      _xifexpression = null;
+    }
+    return _xifexpression;
+  }
+  
+  public Scope scope(final Reaction r) {
+    Scope _xifexpression = null;
+    EObject _eContainer = r.eContainer();
+    if ((_eContainer instanceof Scope)) {
+      EObject _eContainer_1 = r.eContainer();
+      _xifexpression = ((Scope) _eContainer_1);
+    }
+    return _xifexpression;
+  }
+  
+  public ReactiveElement reactiveElement(final Scope s) {
+    ReactiveElement _xifexpression = null;
+    EObject _eContainer = s.eContainer();
+    if ((_eContainer instanceof ReactiveElement)) {
+      EObject _eContainer_1 = s.eContainer();
+      _xifexpression = ((ReactiveElement) _eContainer_1);
+    }
+    return _xifexpression;
+  }
+  
+  public List<RegularState> allRegularStates(final Statechart sc) {
+    List<EObject> content = EcoreUtil2.eAllContentsAsList(sc);
+    final Iterable<RegularState> allStates = IterableExtensions.<RegularState>filter(content, RegularState.class);
+    return IterableExtensions.<RegularState>toList(allStates);
+  }
+  
+  public List<Region> allRegions(final Statechart sc) {
+    List<EObject> content = EcoreUtil2.eAllContentsAsList(sc);
+    final Iterable<Region> allRegions = IterableExtensions.<Region>filter(content, Region.class);
+    return IterableExtensions.<Region>toList(allRegions);
+  }
+  
+  public Iterable<Choice> allChoices(final Statechart sc) {
+    List<EObject> content = EcoreUtil2.eAllContentsAsList(sc);
+    final Iterable<Choice> allChoices = IterableExtensions.<Choice>filter(content, Choice.class);
+    return allChoices;
+  }
+  
+  public Iterable<Entry> allEntries(final Statechart sc) {
+    TreeIterator<EObject> _eAllContents = sc.eAllContents();
+    Iterator<Entry> _filter = IteratorExtensions.<Entry>filter(_eAllContents, Entry.class);
+    return IteratorExtensions.<Entry>toIterable(_filter);
+  }
+  
+  public Iterable<Synchronization> allSynchronizations(final Statechart sc) {
+    TreeIterator<EObject> _eAllContents = sc.eAllContents();
+    Iterator<Synchronization> _filter = IteratorExtensions.<Synchronization>filter(_eAllContents, Synchronization.class);
+    return IteratorExtensions.<Synchronization>toIterable(_filter);
+  }
+  
+  public List<LocalReaction> entryReactions(final ReactiveElement state) {
+    EList<Reaction> _localReactions = state.getLocalReactions();
+    final Function1<Reaction,Boolean> _function = new Function1<Reaction,Boolean>() {
+        public Boolean apply(final Reaction r) {
+          Trigger _trigger = ((LocalReaction) r).getTrigger();
+          EList<EventSpec> _triggers = ((ReactionTrigger) _trigger).getTriggers();
+          final Function1<EventSpec,Boolean> _function = new Function1<EventSpec,Boolean>() {
+              public Boolean apply(final EventSpec t) {
+                return Boolean.valueOf((t instanceof EntryEvent));
+              }
+            };
+          boolean _exists = IterableExtensions.<EventSpec>exists(_triggers, _function);
+          return Boolean.valueOf(_exists);
+        }
+      };
+    Iterable<Reaction> _filter = IterableExtensions.<Reaction>filter(_localReactions, _function);
+    final Function1<Reaction,LocalReaction> _function_1 = new Function1<Reaction,LocalReaction>() {
+        public LocalReaction apply(final Reaction lr) {
+          return ((LocalReaction) lr);
+        }
+      };
+    Iterable<LocalReaction> _map = IterableExtensions.<Reaction, LocalReaction>map(_filter, _function_1);
+    List<LocalReaction> _list = IterableExtensions.<LocalReaction>toList(_map);
+    return _list;
+  }
+  
+  public List<LocalReaction> exitReactions(final ReactiveElement state) {
+    EList<Reaction> _localReactions = state.getLocalReactions();
+    final Function1<Reaction,Boolean> _function = new Function1<Reaction,Boolean>() {
+        public Boolean apply(final Reaction r) {
+          Trigger _trigger = ((LocalReaction) r).getTrigger();
+          EList<EventSpec> _triggers = ((ReactionTrigger) _trigger).getTriggers();
+          final Function1<EventSpec,Boolean> _function = new Function1<EventSpec,Boolean>() {
+              public Boolean apply(final EventSpec t) {
+                return Boolean.valueOf((t instanceof ExitEvent));
+              }
+            };
+          boolean _exists = IterableExtensions.<EventSpec>exists(_triggers, _function);
+          return Boolean.valueOf(_exists);
+        }
+      };
+    Iterable<Reaction> _filter = IterableExtensions.<Reaction>filter(_localReactions, _function);
+    final Function1<Reaction,LocalReaction> _function_1 = new Function1<Reaction,LocalReaction>() {
+        public LocalReaction apply(final Reaction lr) {
+          return ((LocalReaction) lr);
+        }
+      };
+    Iterable<LocalReaction> _map = IterableExtensions.<Reaction, LocalReaction>map(_filter, _function_1);
+    List<LocalReaction> _list = IterableExtensions.<LocalReaction>toList(_map);
+    return _list;
+  }
+  
+  protected String _id(final Object obj) {
+    return null;
+  }
+  
+  /**
+   * The id of a transition is unique within the context of its source vertex.
+   */
+  protected String _id(final Transition t) {
+    Object _xifexpression = null;
+    Vertex _source = t.getSource();
+    boolean _notEquals = ObjectExtensions.operator_notEquals(_source, null);
+    if (_notEquals) {
+      Vertex _source_1 = t.getSource();
+      EList<Transition> _outgoingTransitions = _source_1.getOutgoingTransitions();
+      int _indexOf = _outgoingTransitions.indexOf(t);
+      _xifexpression = _indexOf;
+    } else {
+      _xifexpression = "";
+    }
+    String _plus = StringExtensions.operator_plus(
+      "tr", ((Comparable<Object>)_xifexpression));
+    return _plus;
+  }
+  
+  /**
+   * The id of a local reaction is unique within the context of its source vertex.
+   */
+  protected String _id(final LocalReaction t) {
+    Object _xifexpression = null;
+    ReactiveElement _reactiveElement = this.reactiveElement(t);
+    boolean _notEquals = ObjectExtensions.operator_notEquals(_reactiveElement, null);
+    if (_notEquals) {
+      ReactiveElement _reactiveElement_1 = this.reactiveElement(t);
+      EList<Reaction> _localReactions = _reactiveElement_1.getLocalReactions();
+      int _indexOf = _localReactions.indexOf(t);
+      _xifexpression = _indexOf;
+    } else {
+      _xifexpression = "";
+    }
+    String _plus = StringExtensions.operator_plus(
+      "lr", ((Comparable<Object>)_xifexpression));
+    return _plus;
+  }
+  
+  public StextFactory stextFactory() {
+    return StextFactory.eINSTANCE;
+  }
+  
+  public int maxOrthogonality(final NamedElement s) {
+    if (s instanceof State) {
+      return _maxOrthogonality((State)s);
+    } else if (s instanceof Region) {
+      return _maxOrthogonality((Region)s);
+    } else if (s instanceof Statechart) {
+      return _maxOrthogonality((Statechart)s);
+    } else if (s instanceof Vertex) {
+      return _maxOrthogonality((Vertex)s);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(s).toString());
+    }
+  }
+  
+  public List<TimeEventSpec> timeEventSpecs(final EObject state) {
+    if (state instanceof State) {
+      return _timeEventSpecs((State)state);
+    } else if (state instanceof Statechart) {
+      return _timeEventSpecs((Statechart)state);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(state).toString());
+    }
+  }
+  
+  public ReactiveElement reactiveElement(final Reaction tr) {
+    if (tr instanceof Transition) {
+      return _reactiveElement((Transition)tr);
+    } else if (tr != null) {
+      return _reactiveElement(tr);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(tr).toString());
+    }
+  }
+  
+  public String id(final Object t) {
+    if (t instanceof LocalReaction) {
+      return _id((LocalReaction)t);
+    } else if (t instanceof Transition) {
+      return _id((Transition)t);
+    } else if (t != null) {
+      return _id(t);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(t).toString());
+    }
+  }
+}

+ 53 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StextExtensions.java

@@ -0,0 +1,53 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import org.yakindu.sct.model.sgraph.State;
+import org.yakindu.sct.model.stext.stext.ActiveStateReferenceExpression;
+import org.yakindu.sct.model.stext.stext.Expression;
+import org.yakindu.sct.model.stext.stext.LogicalAndExpression;
+import org.yakindu.sct.model.stext.stext.LogicalOrExpression;
+import org.yakindu.sct.model.stext.stext.StextFactory;
+
+/**
+ * @author Axel Terfloth added 'active' extension
+ */
+@SuppressWarnings("all")
+public class StextExtensions {
+  public StextFactory factory() {
+    return StextFactory.eINSTANCE;
+  }
+  
+  public Expression or(final Expression left, final Expression right) {
+    LogicalOrExpression _xblockexpression = null;
+    {
+      StextFactory _factory = this.factory();
+      final LogicalOrExpression or = _factory.createLogicalOrExpression();
+      or.setLeftOperand(left);
+      or.setRightOperand(right);
+      _xblockexpression = (or);
+    }
+    return _xblockexpression;
+  }
+  
+  public Expression and(final Expression left, final Expression right) {
+    LogicalAndExpression _xblockexpression = null;
+    {
+      StextFactory _factory = this.factory();
+      final LogicalAndExpression and = _factory.createLogicalAndExpression();
+      and.setLeftOperand(left);
+      and.setRightOperand(right);
+      _xblockexpression = (and);
+    }
+    return _xblockexpression;
+  }
+  
+  public Expression active(final State state) {
+    ActiveStateReferenceExpression _xblockexpression = null;
+    {
+      StextFactory _factory = this.factory();
+      final ActiveStateReferenceExpression active = _factory.createActiveStateReferenceExpression();
+      active.setValue(state);
+      _xblockexpression = (active);
+    }
+    return _xblockexpression;
+  }
+}

+ 319 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StructureMapping.java

@@ -0,0 +1,319 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import com.google.inject.Inject;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.EcoreUtil2;
+import org.eclipse.xtext.xbase.lib.CollectionExtensions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ListExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.yakindu.sct.model.sexec.ExecutionChoice;
+import org.yakindu.sct.model.sexec.ExecutionEntry;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sexec.ExecutionNode;
+import org.yakindu.sct.model.sexec.ExecutionRegion;
+import org.yakindu.sct.model.sexec.ExecutionScope;
+import org.yakindu.sct.model.sexec.ExecutionState;
+import org.yakindu.sct.model.sexec.ExecutionSynchronization;
+import org.yakindu.sct.model.sexec.TimeEvent;
+import org.yakindu.sct.model.sexec.transformation.SexecElementMapping;
+import org.yakindu.sct.model.sexec.transformation.StatechartExtensions;
+import org.yakindu.sct.model.sgraph.Choice;
+import org.yakindu.sct.model.sgraph.CompositeElement;
+import org.yakindu.sct.model.sgraph.Declaration;
+import org.yakindu.sct.model.sgraph.Entry;
+import org.yakindu.sct.model.sgraph.FinalState;
+import org.yakindu.sct.model.sgraph.Region;
+import org.yakindu.sct.model.sgraph.RegularState;
+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.Synchronization;
+import org.yakindu.sct.model.sgraph.Vertex;
+import org.yakindu.sct.model.stext.stext.EventDefinition;
+import org.yakindu.sct.model.stext.stext.OperationDefinition;
+import org.yakindu.sct.model.stext.stext.TimeEventSpec;
+import org.yakindu.sct.model.stext.stext.VariableDefinition;
+
+@SuppressWarnings("all")
+public class StructureMapping {
+  @Inject
+  private SexecElementMapping mapping;
+  
+  @Inject
+  private StatechartExtensions sct;
+  
+  /**
+   * maps all required scope defined in the statechart to the execution flow.
+   * This includes creating the scopes and adding all relevant declarations. Empty scopes wont be mapped.
+   */
+  public ExecutionFlow mapScopes(final Statechart sc, final ExecutionFlow flow) {
+    ExecutionFlow _xblockexpression = null;
+    {
+      EList<Scope> _scopes = flow.getScopes();
+      EList<Scope> _scopes_1 = sc.getScopes();
+      final Function1<Scope,Scope> _function = new Function1<Scope,Scope>() {
+          public Scope apply(final Scope scope) {
+            Scope _map = StructureMapping.this.map(scope);
+            return _map;
+          }
+        };
+      List<Scope> _map = ListExtensions.<Scope, Scope>map(_scopes_1, _function);
+      _scopes.addAll(_map);
+      _xblockexpression = (flow);
+    }
+    return _xblockexpression;
+  }
+  
+  public Scope map(final Scope scope) {
+    final Scope _scope = this.mapping.create(scope);
+    EList<Declaration> _declarations = _scope.getDeclarations();
+    EList<Declaration> _declarations_1 = scope.getDeclarations();
+    final Function1<Declaration,Declaration> _function = new Function1<Declaration,Declaration>() {
+        public Declaration apply(final Declaration decl) {
+          Declaration _map = StructureMapping.this.map(decl);
+          return _map;
+        }
+      };
+    List<Declaration> _map = ListExtensions.<Declaration, Declaration>map(_declarations_1, _function);
+    final Function1<Declaration,Boolean> _function_1 = new Function1<Declaration,Boolean>() {
+        public Boolean apply(final Declaration e) {
+          boolean _notEquals = ObjectExtensions.operator_notEquals(e, null);
+          return Boolean.valueOf(_notEquals);
+        }
+      };
+    Iterable<Declaration> _filter = IterableExtensions.<Declaration>filter(_map, _function_1);
+    CollectionExtensions.<Declaration>addAll(_declarations, _filter);
+    return _scope;
+  }
+  
+  protected Declaration _map(final Declaration decl) {
+    return null;
+  }
+  
+  protected Declaration _map(final EventDefinition e) {
+    final EventDefinition _e = this.mapping.create(e);
+    return _e;
+  }
+  
+  protected Declaration _map(final VariableDefinition v) {
+    final VariableDefinition _v = this.mapping.create(v);
+    return _v;
+  }
+  
+  protected Declaration _map(final OperationDefinition v) {
+    final OperationDefinition _v = this.mapping.create(v);
+    return _v;
+  }
+  
+  public ExecutionFlow mapRegularStates(final Statechart statechart, final ExecutionFlow r) {
+    final List<RegularState> allStates = this.sct.allRegularStates(statechart);
+    EList<ExecutionState> _states = r.getStates();
+    final Function1<RegularState,ExecutionState> _function = new Function1<RegularState,ExecutionState>() {
+        public ExecutionState apply(final RegularState s) {
+          ExecutionState _mapState = StructureMapping.this.mapState(s);
+          return _mapState;
+        }
+      };
+    List<ExecutionState> _map = ListExtensions.<RegularState, ExecutionState>map(allStates, _function);
+    _states.addAll(_map);
+    return r;
+  }
+  
+  protected ExecutionState _mapState(final FinalState state) {
+    final ExecutionState _state = this.mapping.create(state);
+    _state.setLeaf(true);
+    _state.setEntryAction(null);
+    _state.setExitAction(null);
+    return _state;
+  }
+  
+  protected ExecutionState _mapState(final State state) {
+    final ExecutionState _state = this.mapping.create(state);
+    boolean _isSimple = state.isSimple();
+    _state.setLeaf(_isSimple);
+    return _state;
+  }
+  
+  protected ExecutionState _mapState(final RegularState state) {
+    return null;
+  }
+  
+  public ExecutionFlow mapRegions(final Statechart statechart, final ExecutionFlow flow) {
+    final List<Region> allRegions = this.sct.allRegions(statechart);
+    EList<ExecutionRegion> _regions = flow.getRegions();
+    final Function1<Region,ExecutionRegion> _function = new Function1<Region,ExecutionRegion>() {
+        public ExecutionRegion apply(final Region r) {
+          ExecutionRegion _mapRegion = StructureMapping.this.mapRegion(r);
+          return _mapRegion;
+        }
+      };
+    List<ExecutionRegion> _map = ListExtensions.<Region, ExecutionRegion>map(allRegions, _function);
+    _regions.addAll(_map);
+    return flow;
+  }
+  
+  public ExecutionRegion mapRegion(final Region region) {
+    final ExecutionRegion _region = this.mapping.create(region);
+    CompositeElement _composite = region.getComposite();
+    if ((_composite instanceof Statechart)) {
+      CompositeElement _composite_1 = region.getComposite();
+      ExecutionFlow _create = this.mapping.create(((Statechart) _composite_1));
+      _region.setSuperScope(_create);
+    } else {
+      CompositeElement _composite_2 = region.getComposite();
+      ExecutionState _create_1 = this.mapping.create(((State) _composite_2));
+      _region.setSuperScope(_create_1);
+    }
+    EList<ExecutionScope> _subScopes = _region.getSubScopes();
+    EList<Vertex> _vertices = region.getVertices();
+    Iterable<RegularState> _filter = IterableExtensions.<RegularState>filter(_vertices, RegularState.class);
+    final Function1<RegularState,ExecutionScope> _function = new Function1<RegularState,ExecutionScope>() {
+        public ExecutionScope apply(final RegularState v) {
+          ExecutionState _create = StructureMapping.this.mapping.create(v);
+          return ((ExecutionScope) _create);
+        }
+      };
+    Iterable<ExecutionScope> _map = IterableExtensions.<RegularState, ExecutionScope>map(_filter, _function);
+    CollectionExtensions.<ExecutionScope>addAll(_subScopes, _map);
+    return _region;
+  }
+  
+  public ExecutionFlow mapPseudoStates(final Statechart statechart, final ExecutionFlow r) {
+    EList<ExecutionNode> _nodes = r.getNodes();
+    Iterable<Choice> _allChoices = this.sct.allChoices(statechart);
+    final Function1<Choice,ExecutionChoice> _function = new Function1<Choice,ExecutionChoice>() {
+        public ExecutionChoice apply(final Choice choice) {
+          ExecutionChoice _create = StructureMapping.this.mapping.create(choice);
+          return _create;
+        }
+      };
+    Iterable<ExecutionChoice> _map = IterableExtensions.<Choice, ExecutionChoice>map(_allChoices, _function);
+    CollectionExtensions.<ExecutionNode>addAll(_nodes, _map);
+    EList<ExecutionNode> _nodes_1 = r.getNodes();
+    Iterable<Entry> _allEntries = this.sct.allEntries(statechart);
+    final Function1<Entry,ExecutionEntry> _function_1 = new Function1<Entry,ExecutionEntry>() {
+        public ExecutionEntry apply(final Entry entry) {
+          ExecutionEntry _create = StructureMapping.this.mapping.create(entry);
+          return _create;
+        }
+      };
+    Iterable<ExecutionEntry> _map_1 = IterableExtensions.<Entry, ExecutionEntry>map(_allEntries, _function_1);
+    CollectionExtensions.<ExecutionNode>addAll(_nodes_1, _map_1);
+    EList<ExecutionNode> _nodes_2 = r.getNodes();
+    Iterable<Synchronization> _allSynchronizations = this.sct.allSynchronizations(statechart);
+    final Function1<Synchronization,ExecutionSynchronization> _function_2 = new Function1<Synchronization,ExecutionSynchronization>() {
+        public ExecutionSynchronization apply(final Synchronization sync) {
+          ExecutionSynchronization _create = StructureMapping.this.mapping.create(sync);
+          return _create;
+        }
+      };
+    Iterable<ExecutionSynchronization> _map_2 = IterableExtensions.<Synchronization, ExecutionSynchronization>map(_allSynchronizations, _function_2);
+    CollectionExtensions.<ExecutionNode>addAll(_nodes_2, _map_2);
+    return r;
+  }
+  
+  /**
+   * Time trigger will be mapped to execution model time events for each real state.
+   */
+  public ExecutionFlow mapTimeEvents(final Statechart statechart, final ExecutionFlow r) {
+    List<EObject> content = EcoreUtil2.eAllContentsAsList(statechart);
+    final Iterable<State> allStates = IterableExtensions.<State>filter(content, State.class);
+    final Procedure1<State> _function = new Procedure1<State>() {
+        public void apply(final State s) {
+          StructureMapping.this.mapTimeEventSpecs(s);
+        }
+      };
+    IterableExtensions.<State>forEach(allStates, _function);
+    this.mapTimeEventSpecs(statechart);
+    return r;
+  }
+  
+  public ArrayList<TimeEvent> mapTimeEventSpecs(final State state) {
+    ArrayList<TimeEvent> _xblockexpression = null;
+    {
+      final List<TimeEventSpec> timeEventSpecs = this.sct.timeEventSpecs(state);
+      ArrayList<TimeEvent> _arrayList = new ArrayList<TimeEvent>();
+      final ArrayList<TimeEvent> result = _arrayList;
+      for (final TimeEventSpec tes : timeEventSpecs) {
+        {
+          final TimeEvent timeEvent = this.mapping.createDerivedEvent(tes);
+          String _name = state.getName();
+          String _plus = ObjectExtensions.operator_plus(_name, "_time_event_");
+          int _indexOf = timeEventSpecs.indexOf(tes);
+          String _plus_1 = StringExtensions.operator_plus(_plus, Integer.valueOf(_indexOf));
+          timeEvent.setName(_plus_1);
+          Statechart _statechart = this.sct.statechart(state);
+          ExecutionFlow _create = this.mapping.create(_statechart);
+          Scope _timeEventScope = this.mapping.timeEventScope(_create);
+          EList<Declaration> _declarations = _timeEventScope.getDeclarations();
+          _declarations.add(timeEvent);
+          result.add(timeEvent);
+        }
+      }
+      _xblockexpression = (result);
+    }
+    return _xblockexpression;
+  }
+  
+  public ArrayList<TimeEvent> mapTimeEventSpecs(final Statechart statechart) {
+    ArrayList<TimeEvent> _xblockexpression = null;
+    {
+      final List<TimeEventSpec> timeEventSpecs = this.sct.timeEventSpecs(statechart);
+      ArrayList<TimeEvent> _arrayList = new ArrayList<TimeEvent>();
+      final ArrayList<TimeEvent> result = _arrayList;
+      for (final TimeEventSpec tes : timeEventSpecs) {
+        {
+          final TimeEvent timeEvent = this.mapping.createDerivedEvent(tes);
+          String _name = statechart.getName();
+          String _plus = ObjectExtensions.operator_plus(_name, "_time_event_");
+          int _indexOf = timeEventSpecs.indexOf(tes);
+          String _plus_1 = StringExtensions.operator_plus(_plus, Integer.valueOf(_indexOf));
+          timeEvent.setName(_plus_1);
+          ExecutionFlow _create = this.mapping.create(statechart);
+          Scope _timeEventScope = this.mapping.timeEventScope(_create);
+          EList<Declaration> _declarations = _timeEventScope.getDeclarations();
+          _declarations.add(timeEvent);
+          result.add(timeEvent);
+        }
+      }
+      _xblockexpression = (result);
+    }
+    return _xblockexpression;
+  }
+  
+  public Declaration map(final Declaration e) {
+    if (e instanceof EventDefinition) {
+      return _map((EventDefinition)e);
+    } else if (e instanceof OperationDefinition) {
+      return _map((OperationDefinition)e);
+    } else if (e instanceof VariableDefinition) {
+      return _map((VariableDefinition)e);
+    } else if (e != null) {
+      return _map(e);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(e).toString());
+    }
+  }
+  
+  public ExecutionState mapState(final RegularState state) {
+    if (state instanceof FinalState) {
+      return _mapState((FinalState)state);
+    } else if (state instanceof State) {
+      return _mapState((State)state);
+    } else if (state != null) {
+      return _mapState(state);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(state).toString());
+    }
+  }
+}

+ 102 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/TraceExtensions.java

@@ -0,0 +1,102 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import com.google.inject.Inject;
+import com.google.inject.name.Named;
+import org.eclipse.emf.common.util.EList;
+import org.yakindu.sct.model.sexec.ExecutionNode;
+import org.yakindu.sct.model.sexec.ExecutionState;
+import org.yakindu.sct.model.sexec.Reaction;
+import org.yakindu.sct.model.sexec.ReactionFired;
+import org.yakindu.sct.model.sexec.Sequence;
+import org.yakindu.sct.model.sexec.SexecFactory;
+import org.yakindu.sct.model.sexec.Step;
+import org.yakindu.sct.model.sexec.TraceNodeExecuted;
+import org.yakindu.sct.model.sexec.TraceStateEntered;
+import org.yakindu.sct.model.sexec.TraceStateExited;
+import org.yakindu.sct.model.sexec.transformation.SexecElementMapping;
+import org.yakindu.sct.model.sexec.transformation.SexecExtensions;
+import org.yakindu.sct.model.sgraph.RegularState;
+
+@SuppressWarnings("all")
+public class TraceExtensions {
+  @Inject
+  private SexecExtensions sexec;
+  
+  @Inject
+  private SexecElementMapping mapping;
+  
+  @Inject
+  @Named(value = "ADD_TRACES")
+  private boolean _addTraceSteps;
+  
+  public boolean isAddTraceSteps() {
+    return this._addTraceSteps;
+  }
+  
+  public ReactionFired newTraceReactionFired(final Reaction r) {
+    ReactionFired _xblockexpression = null;
+    {
+      SexecFactory _factory = this.sexec.factory();
+      final ReactionFired rf = _factory.createReactionFired();
+      rf.setReaction(r);
+      _xblockexpression = (rf);
+    }
+    return _xblockexpression;
+  }
+  
+  public TraceNodeExecuted newTraceNodeExecuted(final ExecutionNode node) {
+    TraceNodeExecuted _xblockexpression = null;
+    {
+      SexecFactory _factory = this.sexec.factory();
+      final TraceNodeExecuted t = _factory.createTraceNodeExecuted();
+      t.setNode(node);
+      _xblockexpression = (t);
+    }
+    return _xblockexpression;
+  }
+  
+  public TraceStateEntered newTraceStateEntered(final ExecutionState state) {
+    TraceStateEntered _xblockexpression = null;
+    {
+      SexecFactory _factory = this.sexec.factory();
+      final TraceStateEntered t = _factory.createTraceStateEntered();
+      t.setState(state);
+      _xblockexpression = (t);
+    }
+    return _xblockexpression;
+  }
+  
+  public TraceStateExited newTraceStateExited(final ExecutionState state) {
+    TraceStateExited _xblockexpression = null;
+    {
+      SexecFactory _factory = this.sexec.factory();
+      final TraceStateExited t = _factory.createTraceStateExited();
+      t.setState(state);
+      _xblockexpression = (t);
+    }
+    return _xblockexpression;
+  }
+  
+  public boolean traceStateExited(final Sequence seq, final ExecutionState state) {
+    boolean _xifexpression = false;
+    boolean _isAddTraceSteps = this.isAddTraceSteps();
+    if (_isAddTraceSteps) {
+      EList<Step> _steps = seq.getSteps();
+      TraceStateExited _newTraceStateExited = this.newTraceStateExited(state);
+      boolean _add = _steps.add(_newTraceStateExited);
+      _xifexpression = _add;
+    }
+    return _xifexpression;
+  }
+  
+  public boolean traceStateExited(final Sequence seq, final RegularState state) {
+    boolean _xifexpression = false;
+    boolean _isAddTraceSteps = this.isAddTraceSteps();
+    if (_isAddTraceSteps) {
+      ExecutionState _create = this.mapping.create(state);
+      boolean _traceStateExited = this.traceStateExited(seq, _create);
+      _xifexpression = _traceStateExited;
+    }
+    return _xifexpression;
+  }
+}