浏览代码

states now include parent state reactions in cycle -> it is necessary for hierarchical statecharts ( YAKHMI-304 )

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

+ 40 - 7
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/ModelSequencer.xtend

@@ -80,8 +80,6 @@ class ModelSequencer {
 		sc.mapScopes(ef)
 		sc.mapStates(ef)
 		sc.mapTimeEvents(ef)
-		// sc.mapTransitions(ef)
-		// sc.mapLocalReactions(ef)
 		
 		// derive all additional information that is necessary for the execution
 		ef.defineStateVector(sc)
@@ -146,11 +144,20 @@ class ModelSequencer {
 		
 	def ExecutionFlow mapStates(Statechart statechart, ExecutionFlow r){
 		var content = EcoreUtil2::eAllContentsAsList(statechart)
-		val allStates = content.filter(e | e instanceof State)
-		r.states.addAll(allStates.map( s | (s as State).mapState));
+		val allStates = statechart.allStates
+		r.states.addAll(allStates.map( s | s.mapState));
 		return r
 	}
 
+
+	// TODO : move to other extension
+	def List<State> allStates(Statechart sc) {
+		var content = EcoreUtil2::eAllContentsAsList(sc)
+		val allStates = content.filter( typeof(State) )
+		
+		return allStates.toList
+	}
+	
 	
 	def ExecutionState mapState(State state) {
 		val _state = state.create
@@ -278,6 +285,7 @@ class ModelSequencer {
 	}	
 	
 	
+	
 	def List<State> exitStates(Transition t) {
 		val l = t.source.containers
 		l.removeAll(t.target.containers)
@@ -290,6 +298,9 @@ class ModelSequencer {
 		l.filter( typeof(State) ).toList
 	}
 	
+	def List<State> parentStates(State s) {
+		s.containers.filter( typeof(State) ).toList		
+	}
 	
 	
 	def List<EObject> containers(EObject obj) {
@@ -415,14 +426,35 @@ class ModelSequencer {
 	 */
 	
 	def defineStateCycles(ExecutionFlow flow, Statechart sc) {
-		flow.states.filter(s | s.leaf).forEach(s | defineCycle(s))	
+		
+		val states = sc.allStates
+		states.filter(s | s.isSimple()).forEach(s | defineCycle(s as State))
+		
+//		flow.states.filter(s | s.leaf).forEach(s | defineCycle(s))	
 		return flow
 	}
 	
 
+	def Cycle defineCycle(State state) {
+	
+		val execState = state.create
+		val stateReaction = execState.createReactionSequence(null)
+		val parents = state.parentStates		
+		execState.cycle = parents.fold(null, [r, s | {
+			s.create.createReactionSequence(r)
+		}])
+		
+		return execState.cycle
+	}	
+
 	def Cycle defineCycle(ExecutionState state) {	
+		state.cycle = state.createReactionSequence(null)
+		return state.cycle
+	}
+	
+
+	def Cycle createReactionSequence(ExecutionState state, Step localStep) {	
 		val cycle = sexecFactory.createCycle
-		state.cycle = cycle
 		
 		val localReactions = state.reactions.filter(r | ! r.transition).toList
 		var localSteps = sexecFactory.createSequence
@@ -432,6 +464,7 @@ class ModelSequencer {
 				ifStep.thenStep = lr.effect.newCall
 				ifStep
 		}))
+		if (localStep != null) localSteps.steps += localStep
 		if (localSteps.steps.empty) localSteps = null
 				
 				
@@ -450,7 +483,7 @@ class ModelSequencer {
 		
 		return cycle
 	}
-	
+
 	
 	def dispatch Check mapToCheck(Trigger tr) { null }
 	  

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

@@ -46,7 +46,7 @@ public class FactoryExtension {
   
   public ExecutionFlow create(final Statechart statechart) {
     final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(statechart);
-    final ExecutionFlow r;
+    ExecutionFlow r;
     synchronized (_createCache_create) {
       if (_createCache_create.containsKey(_cacheKey)) {
         return _createCache_create.get(_cacheKey);
@@ -65,7 +65,7 @@ public class FactoryExtension {
   
   protected Scope _create(final InterfaceScope scope) {
     final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(scope);
-    final InterfaceScope r;
+    InterfaceScope r;
     synchronized (_createCache_create_1) {
       if (_createCache_create_1.containsKey(_cacheKey)) {
         return _createCache_create_1.get(_cacheKey);
@@ -84,7 +84,7 @@ public class FactoryExtension {
   
   protected Scope _create(final InternalScope scope) {
     final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(scope);
-    final InternalScope r;
+    InternalScope r;
     synchronized (_createCache_create_2) {
       if (_createCache_create_2.containsKey(_cacheKey)) {
         return _createCache_create_2.get(_cacheKey);
@@ -101,7 +101,7 @@ public class FactoryExtension {
   
   public EventDefinition create(final EventDefinition event) {
     final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(event);
-    final EventDefinition r;
+    EventDefinition r;
     synchronized (_createCache_create_3) {
       if (_createCache_create_3.containsKey(_cacheKey)) {
         return _createCache_create_3.get(_cacheKey);
@@ -117,7 +117,7 @@ public class FactoryExtension {
   
   public VariableDefinition create(final VariableDefinition v) {
     final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(v);
-    final VariableDefinition r;
+    VariableDefinition r;
     synchronized (_createCache_create_4) {
       if (_createCache_create_4.containsKey(_cacheKey)) {
         return _createCache_create_4.get(_cacheKey);
@@ -133,7 +133,7 @@ public class FactoryExtension {
   
   public ExecutionState create(final State state) {
     final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(state);
-    final ExecutionState r;
+    ExecutionState r;
     synchronized (_createCache_create_5) {
       if (_createCache_create_5.containsKey(_cacheKey)) {
         return _createCache_create_5.get(_cacheKey);
@@ -161,7 +161,7 @@ public class FactoryExtension {
   
   public Check createCheck(final ReactionTrigger tr) {
     final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(tr);
-    final Check r;
+    Check r;
     synchronized (_createCache_createCheck) {
       if (_createCache_createCheck.containsKey(_cacheKey)) {
         return _createCache_createCheck.get(_cacheKey);
@@ -181,7 +181,7 @@ public class FactoryExtension {
   
   public org.yakindu.sct.model.sexec.Reaction create(final Transition tr) {
     final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(tr);
-    final org.yakindu.sct.model.sexec.Reaction r;
+    org.yakindu.sct.model.sexec.Reaction r;
     synchronized (_createCache_create_6) {
       if (_createCache_create_6.containsKey(_cacheKey)) {
         return _createCache_create_6.get(_cacheKey);
@@ -203,7 +203,7 @@ public class FactoryExtension {
   
   public org.yakindu.sct.model.sexec.Reaction create(final LocalReaction lr) {
     final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(lr);
-    final org.yakindu.sct.model.sexec.Reaction r;
+    org.yakindu.sct.model.sexec.Reaction r;
     synchronized (_createCache_create_7) {
       if (_createCache_create_7.containsKey(_cacheKey)) {
         return _createCache_create_7.get(_cacheKey);

+ 103 - 54
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/ModelSequencer.java

@@ -173,26 +173,32 @@ public class ModelSequencer {
     {
       List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(statechart);
       List<EObject> content = _eAllContentsAsList;
-      final Function1<EObject,Boolean> _function = new Function1<EObject,Boolean>() {
-          public Boolean apply(final EObject e) {
-            return ((Boolean)(e instanceof org.yakindu.sct.model.sgraph.State));
-          }
-        };
-      Iterable<EObject> _filter = IterableExtensions.<EObject>filter(content, _function);
-      final Iterable<EObject> allStates = _filter;
+      List<State> _allStates = this.allStates(statechart);
+      final List<State> allStates = _allStates;
       EList<ExecutionState> _states = r.getStates();
-      final Function1<EObject,ExecutionState> _function_1 = new Function1<EObject,ExecutionState>() {
-          public ExecutionState apply(final EObject s) {
-            ExecutionState _mapState = ModelSequencer.this.mapState(((State) s));
+      final Function1<State,ExecutionState> _function = new Function1<State,ExecutionState>() {
+          public ExecutionState apply(final State s) {
+            ExecutionState _mapState = ModelSequencer.this.mapState(s);
             return _mapState;
           }
         };
-      Iterable<ExecutionState> _map = IterableExtensions.<EObject, ExecutionState>map(allStates, _function_1);
-      CollectionExtensions.<ExecutionState>addAll(_states, _map);
+      List<ExecutionState> _map = ListExtensions.<State, ExecutionState>map(allStates, _function);
+      _states.addAll(_map);
       return r;
     }
   }
   
+  public List<State> allStates(final Statechart sc) {
+    {
+      List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(sc);
+      List<EObject> content = _eAllContentsAsList;
+      Iterable<State> _filter = IterableExtensions.<State>filter(content, org.yakindu.sct.model.sgraph.State.class);
+      final Iterable<State> allStates = _filter;
+      List<State> _list = IterableExtensions.<State>toList(allStates);
+      return _list;
+    }
+  }
+  
   public ExecutionState mapState(final State state) {
     {
       ExecutionState _create = this.factory.create(state);
@@ -231,7 +237,7 @@ public class ModelSequencer {
       final List<TimeEventSpec> timeEventSpecs = _timeEventSpecs;
       ArrayList<TimeEvent> _arrayList = new ArrayList<TimeEvent>();
       final ArrayList<TimeEvent> result = _arrayList;
-      for (final TimeEventSpec tes : timeEventSpecs) {
+      for (TimeEventSpec tes : timeEventSpecs) {
         {
           TimeEvent _createDerivedEvent = this.createDerivedEvent(tes);
           final TimeEvent timeEvent = _createDerivedEvent;
@@ -259,7 +265,7 @@ public class ModelSequencer {
       List<EObject> content = _eAllContentsAsList;
       final Function1<EObject,Boolean> _function = new Function1<EObject,Boolean>() {
           public Boolean apply(final EObject e) {
-            return ((Boolean)(e instanceof org.yakindu.sct.model.sgraph.State));
+            return (e instanceof org.yakindu.sct.model.sgraph.State);
           }
         };
       Iterable<EObject> _filter = IterableExtensions.<EObject>filter(content, _function);
@@ -316,7 +322,7 @@ public class ModelSequencer {
       List<EObject> content = _eAllContentsAsList;
       final Function1<EObject,Boolean> _function = new Function1<EObject,Boolean>() {
           public Boolean apply(final EObject e) {
-            return ((Boolean)(e instanceof org.yakindu.sct.model.sgraph.State));
+            return (e instanceof org.yakindu.sct.model.sgraph.State);
           }
         };
       Iterable<EObject> _filter = IterableExtensions.<EObject>filter(content, _function);
@@ -542,6 +548,13 @@ public class ModelSequencer {
     return _xblockexpression;
   }
   
+  public List<State> parentStates(final State s) {
+    List<EObject> _containers = this.containers(s);
+    Iterable<State> _filter = IterableExtensions.<State>filter(_containers, org.yakindu.sct.model.sgraph.State.class);
+    List<State> _list = IterableExtensions.<State>toList(_filter);
+    return _list;
+  }
+  
   public List<EObject> containers(final EObject obj) {
     {
       ArrayList<EObject> _arrayList = new ArrayList<EObject>();
@@ -631,7 +644,7 @@ public class ModelSequencer {
       String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, "\'.");
       seq.setComment(_operator_plus_1);
       List<TimeEventSpec> _timeEventSpecs = this.sct.timeEventSpecs(state);
-      for (final TimeEventSpec tes : _timeEventSpecs) {
+      for (TimeEventSpec tes : _timeEventSpecs) {
         {
           TimeEvent _createDerivedEvent = this.createDerivedEvent(tes);
           final TimeEvent timeEvent = _createDerivedEvent;
@@ -773,7 +786,7 @@ public class ModelSequencer {
       final Sequence seq = _createSequence;
       seq.setName("exitAction");
       List<TimeEventSpec> _timeEventSpecs = this.sct.timeEventSpecs(state);
-      for (final TimeEventSpec tes : _timeEventSpecs) {
+      for (TimeEventSpec tes : _timeEventSpecs) {
         {
           TimeEvent _createDerivedEvent = this.createDerivedEvent(tes);
           final TimeEvent timeEvent = _createDerivedEvent;
@@ -829,31 +842,62 @@ public class ModelSequencer {
   
   public ExecutionFlow defineStateCycles(final ExecutionFlow flow, final Statechart sc) {
     {
-      EList<ExecutionState> _states = flow.getStates();
-      final Function1<ExecutionState,Boolean> _function = new Function1<ExecutionState,Boolean>() {
-          public Boolean apply(final ExecutionState s) {
-            boolean _isLeaf = s.isLeaf();
-            return ((Boolean)_isLeaf);
+      List<State> _allStates = this.allStates(sc);
+      final List<State> states = _allStates;
+      final Function1<State,Boolean> _function = new Function1<State,Boolean>() {
+          public Boolean apply(final State s) {
+            boolean _isSimple = s.isSimple();
+            return ((Boolean)_isSimple);
           }
         };
-      Iterable<ExecutionState> _filter = IterableExtensions.<ExecutionState>filter(_states, _function);
-      final Function1<ExecutionState,Cycle> _function_1 = new Function1<ExecutionState,Cycle>() {
-          public Cycle apply(final ExecutionState s_1) {
-            Cycle _defineCycle = ModelSequencer.this.defineCycle(s_1);
+      Iterable<State> _filter = IterableExtensions.<State>filter(states, _function);
+      final Function1<State,Cycle> _function_1 = new Function1<State,Cycle>() {
+          public Cycle apply(final State s_1) {
+            Cycle _defineCycle = ModelSequencer.this.defineCycle(((State) s_1));
             return _defineCycle;
           }
         };
-      IterableExtensions.<ExecutionState>forEach(_filter, _function_1);
+      IterableExtensions.<State>forEach(_filter, _function_1);
       return flow;
     }
   }
   
+  public Cycle defineCycle(final State state) {
+    {
+      ExecutionState _create = this.factory.create(state);
+      final ExecutionState execState = _create;
+      Cycle _createReactionSequence = this.createReactionSequence(execState, null);
+      final Cycle stateReaction = _createReactionSequence;
+      List<State> _parentStates = this.parentStates(state);
+      final List<State> parents = _parentStates;
+      final Function2<Cycle,State,Cycle> _function = new Function2<Cycle,State,Cycle>() {
+          public Cycle apply(final Cycle r , final State s) {
+            ExecutionState _create_1 = ModelSequencer.this.factory.create(s);
+            Cycle _createReactionSequence_1 = ModelSequencer.this.createReactionSequence(_create_1, r);
+            return _createReactionSequence_1;
+          }
+        };
+      Cycle _fold = IterableExtensions.<State, Cycle>fold(parents, null, _function);
+      execState.setCycle(_fold);
+      Cycle _cycle = execState.getCycle();
+      return _cycle;
+    }
+  }
+  
   public Cycle defineCycle(final ExecutionState state) {
+    {
+      Cycle _createReactionSequence = this.createReactionSequence(state, null);
+      state.setCycle(_createReactionSequence);
+      Cycle _cycle = state.getCycle();
+      return _cycle;
+    }
+  }
+  
+  public Cycle createReactionSequence(final ExecutionState state, final Step localStep) {
     {
       SexecFactory _sexecFactory = this.sexecFactory();
       Cycle _createCycle = _sexecFactory.createCycle();
       final Cycle cycle = _createCycle;
-      state.setCycle(cycle);
       EList<Reaction> _reactions = state.getReactions();
       final Function1<Reaction,Boolean> _function = new Function1<Reaction,Boolean>() {
           public Boolean apply(final Reaction r) {
@@ -889,8 +933,13 @@ public class ModelSequencer {
         };
       List<If> _map = ListExtensions.<Reaction, If>map(localReactions, _function_1);
       _steps.addAll(_map);
-      EList<Step> _steps_1 = localSteps.getSteps();
-      boolean _isEmpty = _steps_1.isEmpty();
+      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(localStep, null);
+      if (_operator_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;
       }
@@ -926,15 +975,15 @@ public class ModelSequencer {
         };
       Step _fold = IterableExtensions.<Reaction, Step>fold(_reverseView, ((Step) localSteps), _function_3);
       final Step transitionStep = _fold;
-      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(transitionStep, null);
-      if (_operator_notEquals) {
-        EList<Step> _steps_2 = cycle.getSteps();
-        _steps_2.add(transitionStep);
+      boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(transitionStep, null);
+      if (_operator_notEquals_1) {
+        EList<Step> _steps_3 = cycle.getSteps();
+        _steps_3.add(transitionStep);
       } else {
-        boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(localSteps, null);
-        if (_operator_notEquals_1) {
-          EList<Step> _steps_3 = cycle.getSteps();
-          _steps_3.add(localSteps);
+        boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(localSteps, null);
+        if (_operator_notEquals_2) {
+          EList<Step> _steps_4 = cycle.getSteps();
+          _steps_4.add(localSteps);
         }
       }
       return cycle;
@@ -1096,7 +1145,7 @@ public class ModelSequencer {
   
   public TimeEvent createDerivedEvent(final TimeEventSpec tes) {
     final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(tes);
-    final TimeEvent r;
+    TimeEvent r;
     synchronized (_createCache_createDerivedEvent) {
       if (_createCache_createDerivedEvent.containsKey(_cacheKey)) {
         return _createCache_createDerivedEvent.get(_cacheKey);
@@ -1116,7 +1165,7 @@ public class ModelSequencer {
   
   public Scope timeEventScope(final ExecutionFlow flow) {
     final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(flow);
-    final Scope r;
+    Scope r;
     synchronized (_createCache_timeEventScope) {
       if (_createCache_timeEventScope.containsKey(_cacheKey)) {
         return _createCache_timeEventScope.get(_cacheKey);
@@ -1146,7 +1195,7 @@ public class ModelSequencer {
   
   public void defineStateEnterSequences(final ExecutionFlow flow, final Statechart sc) {
     EList<Region> _regions = sc.getRegions();
-    for (final Region r : _regions) {
+    for (Region r : _regions) {
       this.defineStateEnterSequence(r);
     }
   }
@@ -1154,7 +1203,7 @@ public class ModelSequencer {
   public void defineStateEnterSequence(final Region r) {
     EList<Vertex> _vertices = r.getVertices();
     Iterable<State> _filter = IterableExtensions.<State>filter(_vertices, org.yakindu.sct.model.sgraph.State.class);
-    for (final State s : _filter) {
+    for (State s : _filter) {
       this.defineStateEnterSequence(s);
     }
   }
@@ -1182,10 +1231,10 @@ public class ModelSequencer {
       if (_isLeaf) {
         EList<Step> _steps_1 = seq.getSteps();
         EnterState _newEnterStateStep = this.newEnterStateStep(state);
-        CollectionExtensions.<Step>operator_add(_steps_1, _newEnterStateStep);
+        CollectionExtensions.<EnterState>operator_add(_steps_1, _newEnterStateStep);
       } else {
         EList<Region> _subRegions = state.getSubRegions();
-        for (final Region r : _subRegions) {
+        for (Region r : _subRegions) {
           {
             this.defineStateEnterSequence(r);
             Entry _entry = this.entry(r);
@@ -1216,7 +1265,7 @@ public class ModelSequencer {
   
   public void defineStateExitSequences(final ExecutionFlow flow, final Statechart sc) {
     EList<Region> _regions = sc.getRegions();
-    for (final Region r : _regions) {
+    for (Region r : _regions) {
       this.defineStateExitSequence(r);
     }
   }
@@ -1224,7 +1273,7 @@ public class ModelSequencer {
   public void defineStateExitSequence(final Region r) {
     EList<Vertex> _vertices = r.getVertices();
     Iterable<State> _filter = IterableExtensions.<State>filter(_vertices, org.yakindu.sct.model.sgraph.State.class);
-    for (final State s : _filter) {
+    for (State s : _filter) {
       this.defineStateExitSequence(s);
     }
   }
@@ -1244,17 +1293,17 @@ public class ModelSequencer {
       if (_isLeaf) {
         EList<Step> _steps = seq.getSteps();
         ExitState _newExitStateStep = this.newExitStateStep(state);
-        CollectionExtensions.<Step>operator_add(_steps, _newExitStateStep);
+        CollectionExtensions.<ExitState>operator_add(_steps, _newExitStateStep);
       } else {
         EList<Region> _subRegions = state.getSubRegions();
-        for (final Region r : _subRegions) {
+        for (Region r : _subRegions) {
           {
             this.defineStateExitSequence(r);
             SexecFactory _sexecFactory_1 = this.sexecFactory();
             StateSwitch _createStateSwitch = _sexecFactory_1.createStateSwitch();
             final StateSwitch sSwitch = _createStateSwitch;
             Iterable<State> _states = this.states(r);
-            for (final State s : _states) {
+            for (State s : _states) {
               ExecutionState _create_1 = this.factory.create(s);
               Sequence _exitSequence = _create_1.getExitSequence();
               boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_exitSequence, null);
@@ -1312,7 +1361,7 @@ public class ModelSequencer {
       String _operator_plus = StringExtensions.operator_plus("Default enter sequence for statechart ", _name);
       enterSequence.setComment(_operator_plus);
       EList<Region> _regions = sc.getRegions();
-      for (final Region r : _regions) {
+      for (Region r : _regions) {
         Entry _entry = this.entry(r);
         State _target = this==null?(State)null:this.target(_entry);
         boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_target, null);
@@ -1391,7 +1440,7 @@ public class ModelSequencer {
       final List<EObject> declared = _list;
       final Function1<EObject,Boolean> _function_1 = new Function1<EObject,Boolean>() {
           public Boolean apply(final EObject e_1) {
-            return ((Boolean)(e_1 instanceof org.yakindu.sct.model.stext.stext.ElementReferenceExpression));
+            return (e_1 instanceof org.yakindu.sct.model.stext.stext.ElementReferenceExpression);
           }
         };
       Iterable<EObject> _filter_1 = IterableExtensions.<EObject>filter(allContent, _function_1);
@@ -1410,7 +1459,7 @@ public class ModelSequencer {
       IterableExtensions.<ElementReferenceExpression>forEach(_map, _function_3);
       final Function1<EObject,Boolean> _function_4 = new Function1<EObject,Boolean>() {
           public Boolean apply(final EObject e_2) {
-            return ((Boolean)(e_2 instanceof org.yakindu.sct.model.stext.stext.Assignment));
+            return (e_2 instanceof org.yakindu.sct.model.stext.stext.Assignment);
           }
         };
       Iterable<EObject> _filter_2 = IterableExtensions.<EObject>filter(allContent, _function_4);
@@ -1554,7 +1603,7 @@ public class ModelSequencer {
           EList<EventSpec> _triggers = ((ReactionTrigger) _trigger).getTriggers();
           final Function1<EventSpec,Boolean> _function_1 = new Function1<EventSpec,Boolean>() {
               public Boolean apply(final EventSpec t) {
-                return ((Boolean)(t instanceof org.yakindu.sct.model.stext.stext.EntryEvent));
+                return (t instanceof org.yakindu.sct.model.stext.stext.EntryEvent);
               }
             };
           boolean _exists = IterableExtensions.<EventSpec>exists(_triggers, _function_1);
@@ -1580,7 +1629,7 @@ public class ModelSequencer {
           EList<EventSpec> _triggers = ((ReactionTrigger) _trigger).getTriggers();
           final Function1<EventSpec,Boolean> _function_1 = new Function1<EventSpec,Boolean>() {
               public Boolean apply(final EventSpec t) {
-                return ((Boolean)(t instanceof org.yakindu.sct.model.stext.stext.ExitEvent));
+                return (t instanceof org.yakindu.sct.model.stext.stext.ExitEvent);
               }
             };
           boolean _exists = IterableExtensions.<EventSpec>exists(_triggers, _function_1);

+ 97 - 1
test-plugins/org.yakindu.sct.model.sexec.test/src/org/yakindu/sct/model/sexec/transformation/test/ModelSequencerStateTest.java

@@ -5,6 +5,7 @@ import static org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.*;
 
 import org.junit.Test;
 import org.yakindu.sct.model.sexec.Call;
+import org.yakindu.sct.model.sexec.Cycle;
 import org.yakindu.sct.model.sexec.EnterState;
 import org.yakindu.sct.model.sexec.Execution;
 import org.yakindu.sct.model.sexec.ExecutionFlow;
@@ -22,9 +23,12 @@ import org.yakindu.sct.model.sgraph.Region;
 import org.yakindu.sct.model.sgraph.Scope;
 import org.yakindu.sct.model.sgraph.State;
 import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.sgraph.Transition;
 import org.yakindu.sct.model.stext.stext.Assignment;
 import org.yakindu.sct.model.stext.stext.AssignmentOperator;
 import org.yakindu.sct.model.stext.stext.ElementReferenceExpression;
+import org.yakindu.sct.model.stext.stext.EventDefinition;
+import org.yakindu.sct.model.stext.stext.InterfaceScope;
 import org.yakindu.sct.model.stext.stext.LocalReaction;
 import org.yakindu.sct.model.stext.stext.LogicalAndExpression;
 import org.yakindu.sct.model.stext.stext.LogicalRelationExpression;
@@ -39,7 +43,6 @@ import org.yakindu.sct.model.stext.stext.VariableDefinition;
 
 public class ModelSequencerStateTest extends ModelSequencerTest {
 
-	
 
 	/**
 	 * if a state defines a entry action then the execution state must have a entryAction.
@@ -730,4 +733,97 @@ public class ModelSequencerStateTest extends ModelSequencerTest {
 	}
 
 	
+	/**
+	 * The state cycle must contain all reactions of parent states.
+	 */
+	@Test public void testStateCycle_WithParent() {
+		
+		Statechart sc = _createStatechart("sc"); {  
+			
+			InterfaceScope s_scope = _createInterfaceScope("Interface", sc);
+			VariableDefinition v1 = _createVariableDefinition("v1", Type.INTEGER, s_scope);
+			EventDefinition e1 = _createEventDefinition("e1", s_scope);
+			
+
+			Region r = _createRegion("r", sc); {
+				State s1 = _createState("s1", r); {
+					// a local reaction: "e1 / x=42;" 
+					LocalReaction lr1 = _createLocalReaction(s1, null);
+					_createRegularEventSpec(e1, (ReactionTrigger) lr1.getTrigger());
+					ReactionEffect lr1_eff = _createReactionEffect(lr1);
+					Assignment assign1 = _createVariableAssignment(v1, AssignmentOperator.ASSIGN, _createValue("42"), lr1_eff); 
+
+					Region r_s1 = _createRegion("r", s1); {
+						State s3 = _createState("s3", r_s1); {
+							_createEntryAssignment(v1, s3, "2");
+							
+							Region r_s3 = _createRegion("r", s3); {
+								State s4 = _createState("s4", r_s3);
+								_createEntryAssignment(v1, s4, "3");
+
+								State s5 = _createState("s5", r_s3);
+							}
+						}
+					}
+				}		
+				State s2 = _createState("s2", r); {
+					Region r_s1 = _createRegion("r", s2); {
+						_createState("s6", r_s1);
+					}
+				}
+			}
+
+			Transition t_s4_s5 = _createTransition(findState(sc, "s4"), findState(sc, "s5"));
+			_createRegularEventSpec(e1, (ReactionTrigger) t_s4_s5.getTrigger());
+
+			
+			Transition t_s3_s6 =_createTransition(findState(sc, "s3"), findState(sc, "s6"));
+			_createRegularEventSpec(e1, (ReactionTrigger) t_s3_s6.getTrigger());
+		
+		}
+		
+
+		ExecutionFlow flow = sequencer.transform(sc);
+		 
+		
+		ExecutionState _s1 = flow.getStates().get(0);
+		assertEquals("sc.r.s1", _s1.getName());
+
+		ExecutionState _s3 = flow.getStates().get(1);
+		assertEquals("sc.r.s1.r.s3", _s3.getName());
+
+		ExecutionState _s4 = flow.getStates().get(2);
+		assertEquals("sc.r.s1.r.s3.r.s4", _s4.getName());
+		
+		ExecutionState _s6 = flow.getStates().get(5);
+		assertEquals("sc.r.s2.r.s6", _s6.getName());
+		
+			
+		Cycle cycle = _s4.getCycle();
+		
+		Sequence _seq = (Sequence) cycle.getSteps().get(0);
+		
+		// first entry is the s1 local reaction
+		If _if = (If) _seq.getSteps().get(0);
+		assertCall(_if.getThenStep(), _s1.getReactions().get(0).getEffect());
+		
+		// second entry is the s3 cycle with the transition reaction
+		cycle = (Cycle) _seq.getSteps().get(1);
+		_if = (If) cycle.getSteps().get(0);
+		assertCall(_if.getThenStep(), _s3.getReactions().get(0).getEffect());
+		assertTrue(_s3.getReactions().get(0).isTransition());
+		assertEquals(1,	cycle.getSteps().size());
+				
+		// third is the s4 cycle with the transition reaction
+		_seq = (Sequence) _if.getElseStep();
+		cycle = (Cycle) _seq.getSteps().get(0);
+		_if = (If) cycle.getSteps().get(0);
+		assertCall(_if.getThenStep(), _s4.getReactions().get(0).getEffect());
+		assertTrue(_s4.getReactions().get(0).isTransition());
+		assertNull(_if.getElseStep());
+		assertEquals(1,	cycle.getSteps().size());
+
+	}
+
+	
 }