Explorar o código

ReactionBuilder added and Entry defnition refactored

benjamin.schwertfeger@gmail.com %!s(int64=14) %!d(string=hai) anos
pai
achega
85a11bb625
Modificáronse 13 ficheiros con 968 adicións e 888 borrados
  1. 10 4
      plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/BehaviorMapping.xtend
  2. 2 112
      plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/ModelSequencer.xtend
  3. 231 0
      plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/ReactionBuilder.xtend
  4. 1 124
      plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/SequenceBuilder.xtend
  5. 11 1
      plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/SexecElementMapping.xtend
  6. 5 9
      plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/StatechartExtensions.xtend
  7. 32 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/BehaviorMapping.java
  8. 8 310
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/ModelSequencer.java
  9. 601 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/ReactionBuilder.java
  10. 20 310
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SequenceBuilder.java
  11. 36 3
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SexecElementMapping.java
  12. 6 10
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StatechartExtensions.java
  13. 5 5
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StructureMapping.java

+ 10 - 4
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/BehaviorMapping.xtend

@@ -39,6 +39,7 @@ import org.yakindu.sct.model.sgraph.Region
 import org.yakindu.sct.model.sexec.ExecutionRegion
 import org.yakindu.sct.model.sgraph.Choice
 import org.yakindu.sct.model.sgraph.Entry
+import org.yakindu.sct.model.sexec.ExecutionChoice
  
 
 class BehaviorMapping {
@@ -82,9 +83,16 @@ class BehaviorMapping {
 		if (seq.steps.size > 0) seq else null
 	}	
 
+	def ExecutionFlow mapChoiceTransitions(Statechart statechart, ExecutionFlow r) {
+		statechart.allChoices.forEach( choice | choice.mapChoiceTransition);		
+		return r
+	}
 
-
-
+	def ExecutionChoice mapChoiceTransition(Choice choice) {
+		val _choice = choice.create
+		_choice.reactions.addAll( choice.outgoingTransitions.map(t | t.mapTransition) )
+		return _choice
+	}
 
 	def ExecutionFlow mapExitActions(Statechart statechart, ExecutionFlow r){
 		val allStates = statechart.allRegularStates.filter(typeof(State))
@@ -92,8 +100,6 @@ class BehaviorMapping {
 		return r
 	}
 
-
-
 	/** 
 	 * The exit action sequence of a state consist all action that are specified with the 'exit' pseudo trigger within local reactions
 	 * and all unscheduling actions for time triggers.

+ 2 - 112
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/ModelSequencer.xtend

@@ -86,6 +86,7 @@ class ModelSequencer {
 	@Inject extension SexecExtensions sexec
 	@Inject extension StructureMapping structureMapping
 	@Inject extension BehaviorMapping behaviorMapping
+	@Inject extension ReactionBuilder reactBuilder
 	@Inject extension SequenceBuilder seqBuilder
 	@Inject extension StateVectorBuilder svBuilder
 	@Inject extension TraceExtensions trace
@@ -126,6 +127,7 @@ class ModelSequencer {
 		sc.mapLocalReactions(ef)
 		sc.mapChoiceTransitions(ef)
 		
+		sc.defineEntryReactions(ef)
 		ef.defineRegularStateReactions(sc)
 		ef.definePseudoStateReactions(sc)
 		
@@ -139,118 +141,6 @@ class ModelSequencer {
 		return ef
 	}
 
-
-	/* ==========================================================================
-	 * STRUCTURAL MAPPING
-	 */
-
-	def ExecutionFlow mapChoiceTransitions(Statechart statechart, ExecutionFlow r) {
-		statechart.allChoices.forEach( choice | choice.mapChoiceTransition);		
-		return r
-	}
-
-	def ExecutionChoice mapChoiceTransition(Choice choice) {
-		val _choice = choice.create
-		_choice.reactions.addAll( choice.outgoingTransitions.map(t | t.mapTransition) )
-		return _choice
-	}
-
-	def defineRegularStateReactions(ExecutionFlow flow, Statechart sc) {
-		
-		val states = sc.allRegularStates
-		
-		states.filter(typeof(State)).filter(s | s.simple).forEach(s | defineCycle(s))
-		states.filter(typeof(FinalState)).forEach(s | defineCycle(s))
-		
-		return flow
-	}
-	
-
-	def definePseudoStateReactions(ExecutionFlow flow, Statechart sc) {
-		
-		sc.allChoices().forEach( choice | choice.defineReaction() )
-	}
-	
-
-	def Sequence defineReaction(Choice choice) {
-	
-		val execChoice = choice.create
-		
-		// move the default transition to the end of the reaction list
-		val _default_ = execChoice.reactions.filter([ r | r.check.alwaysTrue ]).toList.head
-		if ( _default_ != null ) execChoice.reactions.move(execChoice.reactions.size -1, _default_)
-		// TODO: raise an error if no default exists 
-		
-		val stateReaction = execChoice.createReactionSequence(null)
-		execChoice.reactSequence.steps.addAll(stateReaction.steps)
-
-		execChoice.reactSequence.name = 'react'
-		execChoice.reactSequence.comment = 'The reactions of state ' + choice.name + '.'
-		
-		if ( _addTraceSteps ) execChoice.reactSequence.steps.add(0,choice.create.newTraceNodeExecuted)
-		
-		return execChoice.reactSequence
-	}	
-	
-
-	def alwaysTrue(Check check) {
-		if (check != null && check.condition instanceof PrimitiveValueExpression) {
-			val pve = (check.condition as PrimitiveValueExpression)
-			return ( pve.value instanceof BoolLiteral && ( pve.value as BoolLiteral ).value )
-		} 
-		
-		return false
-	}
-
-
-
-	def Sequence defineCycle(RegularState state) {
-	
-		val execState = state.create
-		val stateReaction = execState.createReactionSequence(null)
-		val parents = state.parentStates		
-		execState.reactSequence = parents.fold(null, [r, s | {
-			s.create.createReactionSequence(r)
-		}])
-		
-		execState.reactSequence.name = 'react'
-		execState.reactSequence.comment = 'The reactions of state ' + state.name + '.'
-		
-		return execState.reactSequence
-	}	
-	
-
-	def Sequence createReactionSequence(ExecutionNode state, Step localStep) {	
-		val cycle = sexec.factory.createSequence
-				
-		val localReactions = state.reactions.filter(r | ! r.transition).toList
-		var localSteps = sexec.factory.createSequence
-		localSteps.steps.addAll(localReactions.map(lr | {
-				var ifStep = sexec.factory.createIf
-				ifStep.check = lr.check.newRef		
-				ifStep.thenStep = lr.effect.newCall
-				ifStep
-		}))
-		if (localStep != null) localSteps.steps += localStep
-		if (localSteps.steps.empty) localSteps = null
-				
-				
-		val transitionReactions = state.reactions.filter(r | r.transition).toList
-		val transitionStep = transitionReactions.reverseView.fold(localSteps as Step, [s, reaction | {
-				var ifStep = sexec.factory.createIf
-				ifStep.check = reaction.check.newRef		
-				ifStep.thenStep = reaction.effect.newCall
-				ifStep.elseStep = s
-				ifStep as Step
-			}])
-
-	
-		if (transitionStep != null) cycle.steps.add(transitionStep)		
-		else if (localSteps != null) cycle.steps.add(localSteps)
-		
-		return cycle
-	}
-	
 	/************** retarget declaration refs **************/
 	
 	def retargetDeclRefs(ExecutionFlow flow) {

+ 231 - 0
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/ReactionBuilder.xtend

@@ -0,0 +1,231 @@
+package org.yakindu.sct.model.sexec.transformation
+
+import org.yakindu.sct.model.sgraph.Entry
+import com.google.inject.Inject
+import org.yakindu.sct.model.sgraph.EntryKind
+import org.yakindu.sct.model.sgraph.Region
+import org.yakindu.sct.model.sexec.StateSwitch
+import org.yakindu.sct.model.sgraph.State
+import org.yakindu.sct.model.sexec.ExecutionRegion
+import org.yakindu.sct.model.sgraph.Statechart
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sexec.Sequence
+import org.yakindu.sct.model.sgraph.RegularState
+import org.yakindu.sct.model.sexec.Check
+import org.yakindu.sct.model.stext.stext.PrimitiveValueExpression
+import org.yakindu.sct.model.stext.stext.BoolLiteral
+import org.yakindu.sct.model.sgraph.Choice
+import org.yakindu.sct.model.sexec.ExecutionNode
+import org.yakindu.sct.model.sexec.Step
+import org.yakindu.sct.model.sgraph.FinalState
+
+class ReactionBuilder {
+	@Inject extension SexecElementMapping mapping
+	@Inject extension SexecExtensions sexec
+	@Inject extension SgraphExtensions sgraph
+	@Inject extension StatechartExtensions sct
+	@Inject extension TraceExtensions trace
+	
+	def defineRegularStateReactions(ExecutionFlow flow, Statechart sc) {
+		
+		val states = sc.allRegularStates
+		
+		states.filter(typeof(State)).filter(s | s.simple).forEach(s | defineCycle(s))
+		states.filter(typeof(FinalState)).forEach(s | defineCycle(s))
+		
+		return flow
+	}
+	
+
+	def definePseudoStateReactions(ExecutionFlow flow, Statechart sc) {
+		
+		sc.allChoices().forEach( choice | choice.defineReaction() )
+	}
+	
+
+	def Sequence defineReaction(Choice choice) {
+	
+		val execChoice = choice.create
+		
+		// move the default transition to the end of the reaction list
+		val _default_ = execChoice.reactions.filter([ r | r.check.alwaysTrue ]).toList.head
+		if ( _default_ != null ) execChoice.reactions.move(execChoice.reactions.size -1, _default_)
+		// TODO: raise an error if no default exists 
+		
+		val stateReaction = execChoice.createReactionSequence(null)
+		execChoice.reactSequence.steps.addAll(stateReaction.steps)
+
+		execChoice.reactSequence.name = 'react'
+		execChoice.reactSequence.comment = 'The reactions of state ' + choice.name + '.'
+		
+		if ( trace.addTraceSteps ) execChoice.reactSequence.steps.add(0,choice.create.newTraceNodeExecuted)
+		
+		return execChoice.reactSequence
+	}	
+	
+
+	def alwaysTrue(Check check) {
+		if (check != null && check.condition instanceof PrimitiveValueExpression) {
+			val pve = (check.condition as PrimitiveValueExpression)
+			return ( pve.value instanceof BoolLiteral && ( pve.value as BoolLiteral ).value )
+		} 
+		
+		return false
+	}
+
+
+
+	def Sequence defineCycle(RegularState state) {
+	
+		val execState = state.create
+		val stateReaction = execState.createReactionSequence(null)
+		val parents = state.parentStates		
+		execState.reactSequence = parents.fold(null, [r, s | {
+			s.create.createReactionSequence(r)
+		}])
+		
+		execState.reactSequence.name = 'react'
+		execState.reactSequence.comment = 'The reactions of state ' + state.name + '.'
+		
+		return execState.reactSequence
+	}	
+
+	def Sequence createReactionSequence(ExecutionNode state, Step localStep) {	
+		val cycle = sexec.factory.createSequence
+				
+		val localReactions = state.reactions.filter(r | ! r.transition).toList
+		var localSteps = sexec.factory.createSequence
+		localSteps.steps.addAll(localReactions.map(lr | {
+				var ifStep = sexec.factory.createIf
+				ifStep.check = lr.check.newRef		
+				ifStep.thenStep = lr.effect.newCall
+				ifStep
+		}))
+		if (localStep != null) localSteps.steps += localStep
+		if (localSteps.steps.empty) localSteps = null
+				
+				
+		val transitionReactions = state.reactions.filter(r | r.transition).toList
+		val transitionStep = transitionReactions.reverseView.fold(localSteps as Step, [s, reaction | {
+				var ifStep = sexec.factory.createIf
+				ifStep.check = reaction.check.newRef		
+				ifStep.thenStep = reaction.effect.newCall
+				ifStep.elseStep = s
+				ifStep as Step
+			}])
+
+	
+		if (transitionStep != null) cycle.steps.add(transitionStep)		
+		else if (localSteps != null) cycle.steps.add(localSteps)
+		
+		return cycle
+	}
+	
+	def ExecutionFlow defineEntryReactions(Statechart statechart, ExecutionFlow r) {
+		statechart.allEntries.forEach(e|e.defineReaction)
+		return r
+	}
+	
+	def defineReaction(Entry e) {
+		val execEntry = e.create
+		//Reuse already created react sequence from defineStateEnterSequence(Entry) 
+		val seq = execEntry.reactSequence
+		val target = e.target.create
+		
+		if ( trace.addTraceSteps ) seq.steps.add(0,execEntry.newTraceNodeExecuted)
+		
+		if (e.kind == EntryKind::INITIAL) {
+			if (target != null && target.enterSequence != null) {
+				seq.steps += target.enterSequence.newCall
+			}
+		} else if (e.kind == EntryKind::SHALLOW_HISTORY) {
+			val entryStep = sexec.factory.createHistoryEntry
+			entryStep.name = "HistoryEntry"
+			entryStep.comment = "Enter the region with shallow history"
+			entryStep.deep = false
+			entryStep.region = (e.eContainer as Region).create
+			
+			//Initial step, if no history is known
+			if (target != null && target.enterSequence != null) {
+				entryStep.initialStep = target.enterSequence.newCall
+			}
+			val sSwitch = (e.eContainer as Region).defineShallowHistorySwitch()
+			entryStep.historyStep = sSwitch
+			
+			seq.steps += entryStep
+		} else if (e.kind == EntryKind::DEEP_HISTORY) {
+			val entryStep = sexec.factory.createHistoryEntry
+			entryStep.name = "HistoryEntry"
+			entryStep.comment = "Enter the region with deep history"
+			entryStep.region = (e.eContainer as Region).create
+			entryStep.deep = true
+			
+			//Initial step, if no history is known
+			if (target != null && target.enterSequence != null) {
+				entryStep.initialStep = target.enterSequence.newCall
+			}
+			val sSwitch = (e.eContainer as Region).defineDeepHistorySwitch()
+			entryStep.historyStep = sSwitch
+
+			seq.steps += entryStep
+		}
+	}
+	
+	/**
+	 * Enter switch for a region with a deep history, which must be save before
+	 */
+	def StateSwitch defineDeepHistorySwitch(Region r) {
+		r.defineDeepHistorySwitch(r.create)
+	}
+	
+	def StateSwitch defineDeepHistorySwitch(Region r, ExecutionRegion historyRegion) {
+		val execRegion = r.create
+		
+		val StateSwitch sSwitch = sexec.factory.createStateSwitch
+		sSwitch.stateConfigurationIdx = execRegion.stateVector.offset
+		sSwitch.comment = "Handle shallow history entry of " +r.name
+		sSwitch.historyRegion = historyRegion
+		
+		for (child : r.vertices.filter(typeof(State))) {
+			for (childLeaf : child.collectLeafStates(newArrayList).filter(c|c.create.stateVector.offset == sSwitch.stateConfigurationIdx)) {
+				val execChild = child.create
+				val seq = sexec.factory.createSequence
+				seq.name = "enterSequence"
+				seq.comment = "enterSequence with history in child " + child.name+" for leaf "+childLeaf.name
+				if ( execChild.leaf ) {
+					seq.steps += execChild.enterSequence.newCall
+				} else {
+					if (execChild.entryAction != null ) seq.steps += execChild.entryAction.newCall
+					if ( trace.addTraceSteps ) seq.steps += execChild.newTraceStateEntered
+					for (childRegion : child.regions) {
+						seq.steps += childRegion.defineDeepHistorySwitch(historyRegion)
+					}
+				}
+				sSwitch.cases += childLeaf.create.newCase(seq)
+			}
+		}
+		
+		return sSwitch
+	}
+
+	/**
+	 * Enter switch for a region with a shallow history, which must be save before
+	 */
+	def StateSwitch defineShallowHistorySwitch(Region r) {
+		val execRegion = r.create
+		
+		val StateSwitch sSwitch = sexec.factory.createStateSwitch
+		sSwitch.stateConfigurationIdx = execRegion.stateVector.offset
+		sSwitch.comment = "Handle shallow history entry of " +r.name
+		sSwitch.historyRegion = r.create
+		
+		for (child : r.vertices.filter(typeof(State))) {
+			val execChild = child.create
+			for (childLeaf : child.collectLeafStates(newArrayList).filter(c|c.create.stateVector.offset == sSwitch.stateConfigurationIdx)) {
+				sSwitch.cases += childLeaf.create.newCase(execChild.enterSequence.newCall)
+			}
+		}
+		
+		return sSwitch
+	}
+}

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

@@ -64,28 +64,8 @@ class SequenceBuilder {
 //				seq.steps.add(entryState.enterSequence.newCall);
 		execState.enterSequence = seq
 	}
-	
-
-	/**
-	 * For entries the EnterSequence is the react part which must be defined before
-	 * the target sequence can be calculated.
-	 */
-	def dispatch void defineStateEnterSequence(Entry e) {
-		val execEntry = e.create
-		val seq = sexec.factory.createSequence
-		seq.name = "react"
-		seq.comment = "Default react sequence for "+switch (e.kind) {
-				case EntryKind::INITIAL: "initial "
-				case EntryKind::DEEP_HISTORY: "deep history "
-				case EntryKind::SHALLOW_HISTORY: "shallow history "
-				default: ""
-			}+"entry " + e.name
-
-		execEntry.reactSequence = seq
-	}
 
-	def dispatch void defineStateEnterSequence(Vertex v) {
-	}	
+	def dispatch void defineStateEnterSequence(Vertex v) {}	
 	
 	
 	def dispatch void defineStateEnterSequence(FinalState state) {
@@ -172,50 +152,6 @@ class SequenceBuilder {
 	
 	def dispatch void defineStateExitSequence(Vertex v) {}
 
-	def dispatch void defineStateExitSequence(Entry e) {
-		val execEntry = e.create
-		//Reuse already created react sequence from defineStateEnterSequence(Entry) 
-		val seq = execEntry.reactSequence
-		val target = e.target.create
-		
-		if (e.kind == EntryKind::INITIAL) {
-			if (target != null && target.enterSequence != null) {
-				seq.steps += target.enterSequence.newCall
-			}
-		} else if (e.kind == EntryKind::SHALLOW_HISTORY) {
-			val entryStep = sexec.factory.createHistoryEntry
-			entryStep.name = "HistoryEntry"
-			entryStep.comment = "Enter the region with shallow history"
-			entryStep.deep = false
-			entryStep.region = (e.eContainer as Region).create
-			
-			//Initial step, if no history is known
-			if (target != null && target.enterSequence != null) {
-				entryStep.initialStep = target.enterSequence.newCall
-			}
-			val sSwitch = (e.eContainer as Region).defineShallowHistorySwitch()
-			entryStep.historyStep = sSwitch
-			
-			seq.steps += entryStep
-		} else if (e.kind == EntryKind::DEEP_HISTORY) {
-			val entryStep = sexec.factory.createHistoryEntry
-			entryStep.name = "HistoryEntry"
-			entryStep.comment = "Enter the region with deep history"
-			entryStep.region = (e.eContainer as Region).create
-			entryStep.deep = true
-			
-			//Initial step, if no history is known
-			if (target != null && target.enterSequence != null) {
-				entryStep.initialStep = target.enterSequence.newCall
-			}
-			val sSwitch = (e.eContainer as Region).defineDeepHistorySwitch()
-			entryStep.historyStep = sSwitch
-
-			seq.steps += entryStep
-		}
-		
-	}
-	
 	def dispatch void defineStateExitSequence(FinalState s) {
 		val execState = s.create
 		val seq = sexec.factory.createSequence
@@ -259,66 +195,7 @@ class SequenceBuilder {
 		
 		execState.exitSequence = seq
 	}
-	
-	
-	
-	/**
-	 * Enter switch for a region with a deep history, which must be save before
-	 */
-	def StateSwitch defineDeepHistorySwitch(Region r) {
-		r.defineDeepHistorySwitch(r.create)
-	}
-	
-	def StateSwitch defineDeepHistorySwitch(Region r, ExecutionRegion historyRegion) {
-		val execRegion = r.create
-		
-		val StateSwitch sSwitch = sexec.factory.createStateSwitch
-		sSwitch.stateConfigurationIdx = execRegion.stateVector.offset
-		sSwitch.comment = "Handle shallow history entry of " +r.name
-		sSwitch.historyRegion = historyRegion
-		
-		for (child : r.vertices.filter(typeof(State))) {
-			for (childLeaf : child.collectLeafStates(newArrayList).filter(c|c.create.stateVector.offset == sSwitch.stateConfigurationIdx)) {
-				val execChild = child.create
-				val seq = sexec.factory.createSequence
-				seq.name = "enterSequence"
-				seq.comment = "enterSequence with history in child " + child.name+" for leaf "+childLeaf.name
-				if ( execChild.leaf ) {
-					seq.steps += execChild.enterSequence.newCall
-				} else {
-					if (execChild.entryAction != null ) seq.steps += execChild.entryAction.newCall
-					if ( _addTraceSteps ) seq.steps += execChild.newTraceStateEntered
-					for (childRegion : child.regions) {
-						seq.steps += childRegion.defineDeepHistorySwitch(historyRegion)
-					}
-				}
-				sSwitch.cases += childLeaf.create.newCase(seq)
-			}
-		}
-		
-		return sSwitch
-	}
 
-	/**
-	 * Enter switch for a region with a shallow history, which must be save before
-	 */
-	def StateSwitch defineShallowHistorySwitch(Region r) {
-		val execRegion = r.create
-		
-		val StateSwitch sSwitch = sexec.factory.createStateSwitch
-		sSwitch.stateConfigurationIdx = execRegion.stateVector.offset
-		sSwitch.comment = "Handle shallow history entry of " +r.name
-		sSwitch.historyRegion = r.create
-		
-		for (child : r.vertices.filter(typeof(State))) {
-			val execChild = child.create
-			for (childLeaf : child.collectLeafStates(newArrayList).filter(c|c.create.stateVector.offset == sSwitch.stateConfigurationIdx)) {
-				sSwitch.cases += childLeaf.create.newCase(execChild.enterSequence.newCall)
-			}
-		}
-		
-		return sSwitch
-	}
 	def StateSwitch defineExitSwitch(ExecutionScope state, Iterable<ExecutionState> leafStates, int pos) {
 
 		// create a state switch

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

@@ -55,6 +55,7 @@ import org.yakindu.sct.model.stext.stext.OperationCall
 import org.yakindu.sct.model.stext.stext.Operation
 import org.yakindu.sct.model.sgraph.Entry
 import org.yakindu.sct.model.sexec.ExecutionEntry
+import org.yakindu.sct.model.sgraph.EntryKind
  
 
 @Singleton class SexecElementMapping {
@@ -117,7 +118,16 @@ import org.yakindu.sct.model.sexec.ExecutionEntry
 			r.simpleName = {if (regionName!= null)regionName else ""}+"_"+{if (stateName!= null)stateName else ""}+"_"+entryName
 			r.name = entry.fullyQualifiedName.toString.replaceAll(" ", "")	
 			r.sourceElement = entry	
-			r.reactSequence = sexecFactory.createSequence
+			val seq = sexec.factory.createSequence
+			seq.name = "react"
+			seq.comment = "Default react sequence for "+switch (entry.kind) {
+					case EntryKind::INITIAL: "initial "
+					case EntryKind::DEEP_HISTORY: "deep history "
+					case EntryKind::SHALLOW_HISTORY: "shallow history "
+					default: ""
+				}+"entry " + entry.name
+
+			r.reactSequence = seq
 		}
 	}
 	

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

@@ -1,5 +1,7 @@
 package org.yakindu.sct.model.sexec.transformation
 
+import static extension org.eclipse.xtext.xtend2.lib.EObjectExtensions.*
+
 import org.yakindu.sct.model.sgraph.Statechart
 import org.yakindu.sct.model.sgraph.Region
 import org.yakindu.sct.model.sgraph.Vertex
@@ -124,23 +126,17 @@ class StatechartExtensions {
 		return allRegions.toList
 	}
 	
-	
-	
-	def List<Choice> allChoices(Statechart sc) {
+	def Iterable<Choice> allChoices(Statechart sc) {
 		var content = EcoreUtil2::eAllContentsAsList(sc)
 		val allChoices = content.filter( typeof(Choice) )
 		
-		return allChoices.toList
+		return allChoices
 	}
 
 	def Iterable<Entry> allEntries(Statechart sc) {
-		var content = EcoreUtil2::eAllContentsAsList(sc)
-		val allEntries = content.filter( typeof(Entry) )
-		
-		return allEntries
+		return sc.allContentsIterable.filter( typeof(Entry) )
 	}
 	
-	
 	def List<LocalReaction> entryReactions(State state) {
 		state.localReactions
 			.filter(r | ((r as LocalReaction).trigger as ReactionTrigger).triggers.exists( t | t instanceof EntryEvent))

+ 32 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/BehaviorMapping.java

@@ -185,6 +185,38 @@ public class BehaviorMapping {
     return _xblockexpression;
   }
   
+  public ExecutionFlow mapChoiceTransitions(final Statechart statechart, final ExecutionFlow r) {
+    {
+      Iterable<Choice> _allChoices = this.sc.allChoices(statechart);
+      final Function1<Choice,ExecutionChoice> _function = new Function1<Choice,ExecutionChoice>() {
+          public ExecutionChoice apply(final Choice choice) {
+            ExecutionChoice _mapChoiceTransition = BehaviorMapping.this.mapChoiceTransition(choice);
+            return _mapChoiceTransition;
+          }
+        };
+      IterableExtensions.<Choice>forEach(_allChoices, _function);
+      return r;
+    }
+  }
+  
+  public ExecutionChoice mapChoiceTransition(final Choice choice) {
+    {
+      ExecutionChoice _create = this.factory.create(choice);
+      final ExecutionChoice _choice = _create;
+      EList<Reaction> _reactions = _choice.getReactions();
+      EList<Transition> _outgoingTransitions = choice.getOutgoingTransitions();
+      final Function1<Transition,Reaction> _function = new Function1<Transition,Reaction>() {
+          public Reaction apply(final Transition t) {
+            Reaction _mapTransition = BehaviorMapping.this.mapTransition(t);
+            return _mapTransition;
+          }
+        };
+      List<Reaction> _map = ListExtensions.<Transition, Reaction>map(_outgoingTransitions, _function);
+      _reactions.addAll(_map);
+      return _choice;
+    }
+  }
+  
   public ExecutionFlow mapExitActions(final Statechart statechart, final ExecutionFlow r) {
     {
       List<RegularState> _allRegularStates = this.sc.allRegularStates(statechart);

+ 8 - 310
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/ModelSequencer.java

@@ -5,34 +5,16 @@ import com.google.inject.name.Named;
 import java.util.Collection;
 import java.util.List;
 import java.util.Set;
-import org.eclipse.emf.common.util.EList;
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.xtext.EcoreUtil2;
 import org.eclipse.xtext.naming.IQualifiedNameProvider;
 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.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.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.ExecutionFlow;
-import org.yakindu.sct.model.sexec.ExecutionNode;
-import org.yakindu.sct.model.sexec.ExecutionState;
-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.Step;
 import org.yakindu.sct.model.sexec.TimeEvent;
-import org.yakindu.sct.model.sexec.TraceNodeExecuted;
 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.SexecExtensions;
@@ -42,23 +24,14 @@ import org.yakindu.sct.model.sexec.transformation.StatechartExtensions;
 import org.yakindu.sct.model.sexec.transformation.StextExtensions;
 import org.yakindu.sct.model.sexec.transformation.StructureMapping;
 import org.yakindu.sct.model.sexec.transformation.TraceExtensions;
-import org.yakindu.sct.model.sgraph.Choice;
 import org.yakindu.sct.model.sgraph.Declaration;
-import org.yakindu.sct.model.sgraph.FinalState;
-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.Transition;
 import org.yakindu.sct.model.sgraph.Variable;
 import org.yakindu.sct.model.stext.stext.Assignment;
-import org.yakindu.sct.model.stext.stext.BoolLiteral;
 import org.yakindu.sct.model.stext.stext.ElementReferenceExpression;
 import org.yakindu.sct.model.stext.stext.EventDefinition;
-import org.yakindu.sct.model.stext.stext.Literal;
 import org.yakindu.sct.model.stext.stext.Operation;
 import org.yakindu.sct.model.stext.stext.OperationCall;
-import org.yakindu.sct.model.stext.stext.PrimitiveValueExpression;
 import org.yakindu.sct.model.stext.stext.VariableDefinition;
 
 @SuppressWarnings("all")
@@ -88,6 +61,9 @@ public class ModelSequencer {
   @Inject
   private BehaviorMapping behaviorMapping;
   
+  @Inject
+  private ReactionBuilder reactBuilder;
+  
   @Inject
   private SequenceBuilder seqBuilder;
   
@@ -120,293 +96,15 @@ public class ModelSequencer {
       this.seqBuilder.defineStatechartExitSequence(ef, sc);
       this.behaviorMapping.mapTransitions(sc, ef);
       this.behaviorMapping.mapLocalReactions(sc, ef);
-      this.mapChoiceTransitions(sc, ef);
-      this.defineRegularStateReactions(ef, sc);
-      this.definePseudoStateReactions(ef, sc);
+      this.behaviorMapping.mapChoiceTransitions(sc, ef);
+      this.reactBuilder.defineEntryReactions(sc, ef);
+      this.reactBuilder.defineRegularStateReactions(ef, sc);
+      this.reactBuilder.definePseudoStateReactions(ef, sc);
       this.retargetDeclRefs(ef);
       return ef;
     }
   }
   
-  public ExecutionFlow mapChoiceTransitions(final Statechart statechart, final ExecutionFlow r) {
-    {
-      List<Choice> _allChoices = this.sct.allChoices(statechart);
-      final Function1<Choice,ExecutionChoice> _function = new Function1<Choice,ExecutionChoice>() {
-          public ExecutionChoice apply(final Choice choice) {
-            ExecutionChoice _mapChoiceTransition = ModelSequencer.this.mapChoiceTransition(choice);
-            return _mapChoiceTransition;
-          }
-        };
-      IterableExtensions.<Choice>forEach(_allChoices, _function);
-      return r;
-    }
-  }
-  
-  public ExecutionChoice mapChoiceTransition(final Choice choice) {
-    {
-      ExecutionChoice _create = this.mapping.create(choice);
-      final ExecutionChoice _choice = _create;
-      EList<Reaction> _reactions = _choice.getReactions();
-      EList<Transition> _outgoingTransitions = choice.getOutgoingTransitions();
-      final Function1<Transition,Reaction> _function = new Function1<Transition,Reaction>() {
-          public Reaction apply(final Transition t) {
-            Reaction _mapTransition = ModelSequencer.this.behaviorMapping.mapTransition(t);
-            return _mapTransition;
-          }
-        };
-      List<Reaction> _map = ListExtensions.<Transition, Reaction>map(_outgoingTransitions, _function);
-      _reactions.addAll(_map);
-      return _choice;
-    }
-  }
-  
-  public ExecutionFlow defineRegularStateReactions(final ExecutionFlow flow, final Statechart sc) {
-    {
-      List<RegularState> _allRegularStates = this.sct.allRegularStates(sc);
-      final List<RegularState> states = _allRegularStates;
-      Iterable<State> _filter = IterableExtensions.<State>filter(states, org.yakindu.sct.model.sgraph.State.class);
-      final Function1<State,Boolean> _function = new Function1<State,Boolean>() {
-          public Boolean apply(final State s) {
-            boolean _isSimple = s.isSimple();
-            return ((Boolean)_isSimple);
-          }
-        };
-      Iterable<State> _filter_1 = IterableExtensions.<State>filter(_filter, _function);
-      final Function1<State,Sequence> _function_1 = new Function1<State,Sequence>() {
-          public Sequence apply(final State s_1) {
-            Sequence _defineCycle = ModelSequencer.this.defineCycle(s_1);
-            return _defineCycle;
-          }
-        };
-      IterableExtensions.<State>forEach(_filter_1, _function_1);
-      Iterable<FinalState> _filter_2 = IterableExtensions.<FinalState>filter(states, org.yakindu.sct.model.sgraph.FinalState.class);
-      final Function1<FinalState,Sequence> _function_2 = new Function1<FinalState,Sequence>() {
-          public Sequence apply(final FinalState s_2) {
-            Sequence _defineCycle_1 = ModelSequencer.this.defineCycle(s_2);
-            return _defineCycle_1;
-          }
-        };
-      IterableExtensions.<FinalState>forEach(_filter_2, _function_2);
-      return flow;
-    }
-  }
-  
-  public void definePseudoStateReactions(final ExecutionFlow flow, final Statechart sc) {
-    List<Choice> _allChoices = this.sct.allChoices(sc);
-    final Function1<Choice,Sequence> _function = new Function1<Choice,Sequence>() {
-        public Sequence apply(final Choice choice) {
-          Sequence _defineReaction = ModelSequencer.this.defineReaction(choice);
-          return _defineReaction;
-        }
-      };
-    IterableExtensions.<Choice>forEach(_allChoices, _function);
-  }
-  
-  public Sequence defineReaction(final Choice choice) {
-    {
-      ExecutionChoice _create = this.mapping.create(choice);
-      final ExecutionChoice execChoice = _create;
-      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 = ModelSequencer.this.alwaysTrue(_check);
-            return ((Boolean)_alwaysTrue);
-          }
-        };
-      Iterable<Reaction> _filter = IterableExtensions.<Reaction>filter(_reactions, _function);
-      List<Reaction> _list = IterableExtensions.<Reaction>toList(_filter);
-      Reaction _head = IterableExtensions.<Reaction>head(_list);
-      final Reaction _default_ = _head;
-      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_default_, null);
-      if (_operator_notEquals) {
-        EList<Reaction> _reactions_1 = execChoice.getReactions();
-        EList<Reaction> _reactions_2 = execChoice.getReactions();
-        int _size = _reactions_2.size();
-        int _operator_minus = IntegerExtensions.operator_minus(((Integer)_size), ((Integer)1));
-        _reactions_1.move(_operator_minus, _default_);
-      }
-      Sequence _createReactionSequence = this.createReactionSequence(execChoice, null);
-      final Sequence stateReaction = _createReactionSequence;
-      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 _operator_plus = StringExtensions.operator_plus("The reactions of state ", _name);
-      String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, ".");
-      _reactSequence_2.setComment(_operator_plus_1);
-      if (this._addTraceSteps) {
-        Sequence _reactSequence_3 = execChoice.getReactSequence();
-        EList<Step> _steps_2 = _reactSequence_3.getSteps();
-        ExecutionChoice _create_1 = this.mapping.create(choice);
-        TraceNodeExecuted _newTraceNodeExecuted = this.trace.newTraceNodeExecuted(_create_1);
-        _steps_2.add(0, _newTraceNodeExecuted);
-      }
-      Sequence _reactSequence_4 = execChoice.getReactSequence();
-      return _reactSequence_4;
-    }
-  }
-  
-  public boolean alwaysTrue(final Check check) {
-    {
-      boolean _operator_and = false;
-      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(check, null);
-      if (!_operator_notEquals) {
-        _operator_and = false;
-      } else {
-        Statement _condition = check.getCondition();
-        _operator_and = BooleanExtensions.operator_and(_operator_notEquals, (_condition instanceof org.yakindu.sct.model.stext.stext.PrimitiveValueExpression));
-      }
-      if (_operator_and) {
-        {
-          Statement _condition_1 = check.getCondition();
-          final PrimitiveValueExpression pve = ((PrimitiveValueExpression) _condition_1);
-          boolean _operator_and_1 = false;
-          Literal _value = pve.getValue();
-          if (!(_value instanceof org.yakindu.sct.model.stext.stext.BoolLiteral)) {
-            _operator_and_1 = false;
-          } else {
-            Literal _value_1 = pve.getValue();
-            boolean _isValue = ((BoolLiteral) _value_1).isValue();
-            _operator_and_1 = BooleanExtensions.operator_and((_value instanceof org.yakindu.sct.model.stext.stext.BoolLiteral), _isValue);
-          }
-          return _operator_and_1;
-        }
-      }
-      return false;
-    }
-  }
-  
-  public Sequence defineCycle(final RegularState state) {
-    {
-      ExecutionState _create = this.mapping.create(state);
-      final ExecutionState execState = _create;
-      Sequence _createReactionSequence = this.createReactionSequence(execState, null);
-      final Sequence stateReaction = _createReactionSequence;
-      List<RegularState> _parentStates = this.sgraph.parentStates(state);
-      final List<RegularState> parents = _parentStates;
-      final Function2<Sequence,RegularState,Sequence> _function = new Function2<Sequence,RegularState,Sequence>() {
-          public Sequence apply(final Sequence r , final RegularState s) {
-            ExecutionState _create_1 = ModelSequencer.this.mapping.create(s);
-            Sequence _createReactionSequence_1 = ModelSequencer.this.createReactionSequence(_create_1, r);
-            return _createReactionSequence_1;
-          }
-        };
-      Sequence _fold = IterableExtensions.<RegularState, Sequence>fold(parents, null, _function);
-      execState.setReactSequence(_fold);
-      Sequence _reactSequence = execState.getReactSequence();
-      _reactSequence.setName("react");
-      Sequence _reactSequence_1 = execState.getReactSequence();
-      String _name = state.getName();
-      String _operator_plus = StringExtensions.operator_plus("The reactions of state ", _name);
-      String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, ".");
-      _reactSequence_1.setComment(_operator_plus_1);
-      Sequence _reactSequence_2 = execState.getReactSequence();
-      return _reactSequence_2;
-    }
-  }
-  
-  public Sequence createReactionSequence(final ExecutionNode state, final Step localStep) {
-    {
-      SexecFactory _factory = this.sexec.factory();
-      Sequence _createSequence = _factory.createSequence();
-      final Sequence cycle = _createSequence;
-      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 _operator_not = BooleanExtensions.operator_not(_isTransition);
-            return ((Boolean)_operator_not);
-          }
-        };
-      Iterable<Reaction> _filter = IterableExtensions.<Reaction>filter(_reactions, _function);
-      List<Reaction> _list = IterableExtensions.<Reaction>toList(_filter);
-      final List<Reaction> localReactions = _list;
-      SexecFactory _factory_1 = this.sexec.factory();
-      Sequence _createSequence_1 = _factory_1.createSequence();
-      Sequence localSteps = _createSequence_1;
-      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_2 = ModelSequencer.this.sexec.factory();
-              If _createIf = _factory_2.createIf();
-              If ifStep = _createIf;
-              Check _check = lr.getCheck();
-              CheckRef _newRef = ModelSequencer.this.mapping.newRef(_check);
-              ifStep.setCheck(_newRef);
-              Step _effect = lr.getEffect();
-              Call _newCall = ModelSequencer.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 _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;
-      }
-      EList<Reaction> _reactions_1 = state.getReactions();
-      final Function1<Reaction,Boolean> _function_2 = new Function1<Reaction,Boolean>() {
-          public Boolean apply(final Reaction r_1) {
-            boolean _isTransition_1 = r_1.isTransition();
-            return ((Boolean)_isTransition_1);
-          }
-        };
-      Iterable<Reaction> _filter_1 = IterableExtensions.<Reaction>filter(_reactions_1, _function_2);
-      List<Reaction> _list_1 = IterableExtensions.<Reaction>toList(_filter_1);
-      final List<Reaction> transitionReactions = _list_1;
-      Iterable<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_1 = null;
-            {
-              SexecFactory _factory_3 = ModelSequencer.this.sexec.factory();
-              If _createIf_1 = _factory_3.createIf();
-              If ifStep_1 = _createIf_1;
-              Check _check_1 = reaction.getCheck();
-              CheckRef _newRef_1 = ModelSequencer.this.mapping.newRef(_check_1);
-              ifStep_1.setCheck(_newRef_1);
-              Step _effect_1 = reaction.getEffect();
-              Call _newCall_1 = ModelSequencer.this.mapping.newCall(_effect_1);
-              ifStep_1.setThenStep(_newCall_1);
-              ifStep_1.setElseStep(s);
-              _xblockexpression_1 = (((Step) ifStep_1));
-            }
-            return _xblockexpression_1;
-          }
-        };
-      Step _fold = IterableExtensions.<Reaction, Step>fold(_reverseView, ((Step) localSteps), _function_3);
-      final Step transitionStep = _fold;
-      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_2 = ObjectExtensions.operator_notEquals(localSteps, null);
-        if (_operator_notEquals_2) {
-          EList<Step> _steps_4 = cycle.getSteps();
-          _steps_4.add(localSteps);
-        }
-      }
-      return cycle;
-    }
-  }
-  
   public void retargetDeclRefs(final ExecutionFlow flow) {
     {
       List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(flow);

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

@@ -0,0 +1,601 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import com.google.inject.Inject;
+import java.util.ArrayList;
+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.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.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.StateVector;
+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.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.Vertex;
+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 defineRegularStateReactions(final ExecutionFlow flow, final Statechart sc) {
+    {
+      List<RegularState> _allRegularStates = this.sct.allRegularStates(sc);
+      final List<RegularState> states = _allRegularStates;
+      Iterable<State> _filter = IterableExtensions.<State>filter(states, org.yakindu.sct.model.sgraph.State.class);
+      final Function1<State,Boolean> _function = new Function1<State,Boolean>() {
+          public Boolean apply(final State s) {
+            boolean _isSimple = s.isSimple();
+            return ((Boolean)_isSimple);
+          }
+        };
+      Iterable<State> _filter_1 = IterableExtensions.<State>filter(_filter, _function);
+      final Function1<State,Sequence> _function_1 = new Function1<State,Sequence>() {
+          public Sequence apply(final State s_1) {
+            Sequence _defineCycle = ReactionBuilder.this.defineCycle(s_1);
+            return _defineCycle;
+          }
+        };
+      IterableExtensions.<State>forEach(_filter_1, _function_1);
+      Iterable<FinalState> _filter_2 = IterableExtensions.<FinalState>filter(states, org.yakindu.sct.model.sgraph.FinalState.class);
+      final Function1<FinalState,Sequence> _function_2 = new Function1<FinalState,Sequence>() {
+          public Sequence apply(final FinalState s_2) {
+            Sequence _defineCycle_1 = ReactionBuilder.this.defineCycle(s_2);
+            return _defineCycle_1;
+          }
+        };
+      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 Function1<Choice,Sequence> _function = new Function1<Choice,Sequence>() {
+        public Sequence apply(final Choice choice) {
+          Sequence _defineReaction = ReactionBuilder.this.defineReaction(choice);
+          return _defineReaction;
+        }
+      };
+    IterableExtensions.<Choice>forEach(_allChoices, _function);
+  }
+  
+  public Sequence defineReaction(final Choice choice) {
+    {
+      ExecutionChoice _create = this.mapping.create(choice);
+      final ExecutionChoice execChoice = _create;
+      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)_alwaysTrue);
+          }
+        };
+      Iterable<Reaction> _filter = IterableExtensions.<Reaction>filter(_reactions, _function);
+      List<Reaction> _list = IterableExtensions.<Reaction>toList(_filter);
+      Reaction _head = IterableExtensions.<Reaction>head(_list);
+      final Reaction _default_ = _head;
+      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_default_, null);
+      if (_operator_notEquals) {
+        EList<Reaction> _reactions_1 = execChoice.getReactions();
+        EList<Reaction> _reactions_2 = execChoice.getReactions();
+        int _size = _reactions_2.size();
+        int _operator_minus = IntegerExtensions.operator_minus(((Integer)_size), ((Integer)1));
+        _reactions_1.move(_operator_minus, _default_);
+      }
+      Sequence _createReactionSequence = this.createReactionSequence(execChoice, null);
+      final Sequence stateReaction = _createReactionSequence;
+      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 _operator_plus = StringExtensions.operator_plus("The reactions of state ", _name);
+      String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, ".");
+      _reactSequence_2.setComment(_operator_plus_1);
+      boolean _isAddTraceSteps = this.trace.isAddTraceSteps();
+      if (_isAddTraceSteps) {
+        Sequence _reactSequence_3 = execChoice.getReactSequence();
+        EList<Step> _steps_2 = _reactSequence_3.getSteps();
+        ExecutionChoice _create_1 = this.mapping.create(choice);
+        TraceNodeExecuted _newTraceNodeExecuted = this.trace.newTraceNodeExecuted(_create_1);
+        _steps_2.add(0, _newTraceNodeExecuted);
+      }
+      Sequence _reactSequence_4 = execChoice.getReactSequence();
+      return _reactSequence_4;
+    }
+  }
+  
+  public boolean alwaysTrue(final Check check) {
+    {
+      boolean _operator_and = false;
+      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(check, null);
+      if (!_operator_notEquals) {
+        _operator_and = false;
+      } else {
+        Statement _condition = check.getCondition();
+        _operator_and = BooleanExtensions.operator_and(_operator_notEquals, (_condition instanceof org.yakindu.sct.model.stext.stext.PrimitiveValueExpression));
+      }
+      if (_operator_and) {
+        {
+          Statement _condition_1 = check.getCondition();
+          final PrimitiveValueExpression pve = ((PrimitiveValueExpression) _condition_1);
+          boolean _operator_and_1 = false;
+          Literal _value = pve.getValue();
+          if (!(_value instanceof org.yakindu.sct.model.stext.stext.BoolLiteral)) {
+            _operator_and_1 = false;
+          } else {
+            Literal _value_1 = pve.getValue();
+            boolean _isValue = ((BoolLiteral) _value_1).isValue();
+            _operator_and_1 = BooleanExtensions.operator_and((_value instanceof org.yakindu.sct.model.stext.stext.BoolLiteral), _isValue);
+          }
+          return _operator_and_1;
+        }
+      }
+      return false;
+    }
+  }
+  
+  public Sequence defineCycle(final RegularState state) {
+    {
+      ExecutionState _create = this.mapping.create(state);
+      final ExecutionState execState = _create;
+      Sequence _createReactionSequence = this.createReactionSequence(execState, null);
+      final Sequence stateReaction = _createReactionSequence;
+      List<RegularState> _parentStates = this.sgraph.parentStates(state);
+      final List<RegularState> parents = _parentStates;
+      final Function2<Sequence,RegularState,Sequence> _function = new Function2<Sequence,RegularState,Sequence>() {
+          public Sequence apply(final Sequence r , final RegularState s) {
+            ExecutionState _create_1 = ReactionBuilder.this.mapping.create(s);
+            Sequence _createReactionSequence_1 = ReactionBuilder.this.createReactionSequence(_create_1, r);
+            return _createReactionSequence_1;
+          }
+        };
+      Sequence _fold = IterableExtensions.<RegularState, Sequence>fold(parents, null, _function);
+      execState.setReactSequence(_fold);
+      Sequence _reactSequence = execState.getReactSequence();
+      _reactSequence.setName("react");
+      Sequence _reactSequence_1 = execState.getReactSequence();
+      String _name = state.getName();
+      String _operator_plus = StringExtensions.operator_plus("The reactions of state ", _name);
+      String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, ".");
+      _reactSequence_1.setComment(_operator_plus_1);
+      Sequence _reactSequence_2 = execState.getReactSequence();
+      return _reactSequence_2;
+    }
+  }
+  
+  public Sequence createReactionSequence(final ExecutionNode state, final Step localStep) {
+    {
+      SexecFactory _factory = this.sexec.factory();
+      Sequence _createSequence = _factory.createSequence();
+      final Sequence cycle = _createSequence;
+      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 _operator_not = BooleanExtensions.operator_not(_isTransition);
+            return ((Boolean)_operator_not);
+          }
+        };
+      Iterable<Reaction> _filter = IterableExtensions.<Reaction>filter(_reactions, _function);
+      List<Reaction> _list = IterableExtensions.<Reaction>toList(_filter);
+      final List<Reaction> localReactions = _list;
+      SexecFactory _factory_1 = this.sexec.factory();
+      Sequence _createSequence_1 = _factory_1.createSequence();
+      Sequence localSteps = _createSequence_1;
+      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_2 = ReactionBuilder.this.sexec.factory();
+              If _createIf = _factory_2.createIf();
+              If ifStep = _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 _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;
+      }
+      EList<Reaction> _reactions_1 = state.getReactions();
+      final Function1<Reaction,Boolean> _function_2 = new Function1<Reaction,Boolean>() {
+          public Boolean apply(final Reaction r_1) {
+            boolean _isTransition_1 = r_1.isTransition();
+            return ((Boolean)_isTransition_1);
+          }
+        };
+      Iterable<Reaction> _filter_1 = IterableExtensions.<Reaction>filter(_reactions_1, _function_2);
+      List<Reaction> _list_1 = IterableExtensions.<Reaction>toList(_filter_1);
+      final List<Reaction> transitionReactions = _list_1;
+      Iterable<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_1 = null;
+            {
+              SexecFactory _factory_3 = ReactionBuilder.this.sexec.factory();
+              If _createIf_1 = _factory_3.createIf();
+              If ifStep_1 = _createIf_1;
+              Check _check_1 = reaction.getCheck();
+              CheckRef _newRef_1 = ReactionBuilder.this.mapping.newRef(_check_1);
+              ifStep_1.setCheck(_newRef_1);
+              Step _effect_1 = reaction.getEffect();
+              Call _newCall_1 = ReactionBuilder.this.mapping.newCall(_effect_1);
+              ifStep_1.setThenStep(_newCall_1);
+              ifStep_1.setElseStep(s);
+              _xblockexpression_1 = (((Step) ifStep_1));
+            }
+            return _xblockexpression_1;
+          }
+        };
+      Step _fold = IterableExtensions.<Reaction, Step>fold(_reverseView, ((Step) localSteps), _function_3);
+      final Step transitionStep = _fold;
+      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_2 = ObjectExtensions.operator_notEquals(localSteps, null);
+        if (_operator_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 Function1<Entry,Boolean> _function = new Function1<Entry,Boolean>() {
+          public Boolean apply(final Entry e) {
+            Boolean _defineReaction = ReactionBuilder.this.defineReaction(e);
+            return _defineReaction;
+          }
+        };
+      IterableExtensions.<Entry>forEach(_allEntries, _function);
+      return r;
+    }
+  }
+  
+  public Boolean defineReaction(final Entry e) {
+    Boolean _xblockexpression = null;
+    {
+      ExecutionEntry _create = this.mapping.create(e);
+      final ExecutionEntry execEntry = _create;
+      Sequence _reactSequence = execEntry.getReactSequence();
+      final Sequence seq = _reactSequence;
+      State _target = this.sgraph.target(e);
+      ExecutionState _create_1 = this.mapping.create(_target);
+      final ExecutionState target = _create_1;
+      boolean _isAddTraceSteps = this.trace.isAddTraceSteps();
+      if (_isAddTraceSteps) {
+        EList<Step> _steps = seq.getSteps();
+        TraceNodeExecuted _newTraceNodeExecuted = this.trace.newTraceNodeExecuted(execEntry);
+        _steps.add(0, _newTraceNodeExecuted);
+      }
+      Boolean _xifexpression = null;
+      EntryKind _kind = e.getKind();
+      boolean _operator_equals = ObjectExtensions.operator_equals(_kind, EntryKind.INITIAL);
+      if (_operator_equals) {
+        Boolean _xifexpression_1 = null;
+        boolean _operator_and = false;
+        boolean _operator_notEquals = ObjectExtensions.operator_notEquals(target, null);
+        if (!_operator_notEquals) {
+          _operator_and = false;
+        } else {
+          Sequence _enterSequence = target.getEnterSequence();
+          boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_enterSequence, null);
+          _operator_and = BooleanExtensions.operator_and(_operator_notEquals, _operator_notEquals_1);
+        }
+        if (_operator_and) {
+          EList<Step> _steps_1 = seq.getSteps();
+          Sequence _enterSequence_1 = target.getEnterSequence();
+          Call _newCall = this.mapping.newCall(_enterSequence_1);
+          boolean _operator_add = CollectionExtensions.<Step>operator_add(_steps_1, _newCall);
+          _xifexpression_1 = _operator_add;
+        }
+        _xifexpression = _xifexpression_1;
+      } else {
+        boolean _xifexpression_2 = false;
+        EntryKind _kind_1 = e.getKind();
+        boolean _operator_equals_1 = ObjectExtensions.operator_equals(_kind_1, EntryKind.SHALLOW_HISTORY);
+        if (_operator_equals_1) {
+          boolean _xblockexpression_1 = false;
+          {
+            SexecFactory _factory = this.sexec.factory();
+            HistoryEntry _createHistoryEntry = _factory.createHistoryEntry();
+            final HistoryEntry entryStep = _createHistoryEntry;
+            entryStep.setName("HistoryEntry");
+            entryStep.setComment("Enter the region with shallow history");
+            entryStep.setDeep(false);
+            EObject _eContainer = e.eContainer();
+            ExecutionRegion _create_2 = this.mapping.create(((Region) _eContainer));
+            entryStep.setRegion(_create_2);
+            boolean _operator_and_1 = false;
+            boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(target, null);
+            if (!_operator_notEquals_2) {
+              _operator_and_1 = false;
+            } else {
+              Sequence _enterSequence_2 = target.getEnterSequence();
+              boolean _operator_notEquals_3 = ObjectExtensions.operator_notEquals(_enterSequence_2, null);
+              _operator_and_1 = BooleanExtensions.operator_and(_operator_notEquals_2, _operator_notEquals_3);
+            }
+            if (_operator_and_1) {
+              Sequence _enterSequence_3 = target.getEnterSequence();
+              Call _newCall_1 = this.mapping.newCall(_enterSequence_3);
+              entryStep.setInitialStep(_newCall_1);
+            }
+            EObject _eContainer_1 = e.eContainer();
+            StateSwitch _defineShallowHistorySwitch = this.defineShallowHistorySwitch(((Region) _eContainer_1));
+            final StateSwitch sSwitch = _defineShallowHistorySwitch;
+            entryStep.setHistoryStep(sSwitch);
+            EList<Step> _steps_2 = seq.getSteps();
+            boolean _operator_add_1 = CollectionExtensions.<Step>operator_add(_steps_2, entryStep);
+            _xblockexpression_1 = (_operator_add_1);
+          }
+          _xifexpression_2 = _xblockexpression_1;
+        } else {
+          Boolean _xifexpression_3 = null;
+          EntryKind _kind_2 = e.getKind();
+          boolean _operator_equals_2 = ObjectExtensions.operator_equals(_kind_2, EntryKind.DEEP_HISTORY);
+          if (_operator_equals_2) {
+            boolean _xblockexpression_2 = false;
+            {
+              SexecFactory _factory_1 = this.sexec.factory();
+              HistoryEntry _createHistoryEntry_1 = _factory_1.createHistoryEntry();
+              final HistoryEntry entryStep_1 = _createHistoryEntry_1;
+              entryStep_1.setName("HistoryEntry");
+              entryStep_1.setComment("Enter the region with deep history");
+              EObject _eContainer_2 = e.eContainer();
+              ExecutionRegion _create_3 = this.mapping.create(((Region) _eContainer_2));
+              entryStep_1.setRegion(_create_3);
+              entryStep_1.setDeep(true);
+              boolean _operator_and_2 = false;
+              boolean _operator_notEquals_4 = ObjectExtensions.operator_notEquals(target, null);
+              if (!_operator_notEquals_4) {
+                _operator_and_2 = false;
+              } else {
+                Sequence _enterSequence_4 = target.getEnterSequence();
+                boolean _operator_notEquals_5 = ObjectExtensions.operator_notEquals(_enterSequence_4, null);
+                _operator_and_2 = BooleanExtensions.operator_and(_operator_notEquals_4, _operator_notEquals_5);
+              }
+              if (_operator_and_2) {
+                Sequence _enterSequence_5 = target.getEnterSequence();
+                Call _newCall_2 = this.mapping.newCall(_enterSequence_5);
+                entryStep_1.setInitialStep(_newCall_2);
+              }
+              EObject _eContainer_3 = e.eContainer();
+              StateSwitch _defineDeepHistorySwitch = this.defineDeepHistorySwitch(((Region) _eContainer_3));
+              final StateSwitch sSwitch_1 = _defineDeepHistorySwitch;
+              entryStep_1.setHistoryStep(sSwitch_1);
+              EList<Step> _steps_3 = seq.getSteps();
+              boolean _operator_add_2 = CollectionExtensions.<Step>operator_add(_steps_3, entryStep_1);
+              _xblockexpression_2 = (_operator_add_2);
+            }
+            _xifexpression_3 = _xblockexpression_2;
+          }
+          _xifexpression_2 = _xifexpression_3;
+        }
+        _xifexpression = _xifexpression_2;
+      }
+      _xblockexpression = (_xifexpression);
+    }
+    return _xblockexpression;
+  }
+  
+  public StateSwitch defineDeepHistorySwitch(final Region r) {
+    ExecutionRegion _create = this.mapping.create(r);
+    StateSwitch _defineDeepHistorySwitch = this.defineDeepHistorySwitch(r, _create);
+    return _defineDeepHistorySwitch;
+  }
+  
+  public StateSwitch defineDeepHistorySwitch(final Region r, final ExecutionRegion historyRegion) {
+    {
+      ExecutionRegion _create = this.mapping.create(r);
+      final ExecutionRegion execRegion = _create;
+      SexecFactory _factory = this.sexec.factory();
+      StateSwitch _createStateSwitch = _factory.createStateSwitch();
+      final StateSwitch sSwitch = _createStateSwitch;
+      StateVector _stateVector = execRegion.getStateVector();
+      int _offset = _stateVector.getOffset();
+      sSwitch.setStateConfigurationIdx(_offset);
+      String _name = r.getName();
+      String _operator_plus = StringExtensions.operator_plus("Handle shallow history entry of ", _name);
+      sSwitch.setComment(_operator_plus);
+      sSwitch.setHistoryRegion(historyRegion);
+      EList<Vertex> _vertices = r.getVertices();
+      Iterable<State> _filter = IterableExtensions.<State>filter(_vertices, org.yakindu.sct.model.sgraph.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_1 = ReactionBuilder.this.mapping.create(c);
+              StateVector _stateVector_1 = _create_1.getStateVector();
+              int _offset_1 = _stateVector_1.getOffset();
+              int _stateConfigurationIdx = sSwitch.getStateConfigurationIdx();
+              boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_offset_1), ((Integer)_stateConfigurationIdx));
+              return ((Boolean)_operator_equals);
+            }
+          };
+        Iterable<RegularState> _filter_1 = IterableExtensions.<RegularState>filter(_collectLeafStates, _function);
+        for (final RegularState childLeaf : _filter_1) {
+          {
+            ExecutionState _create_2 = this.mapping.create(child);
+            final ExecutionState execChild = _create_2;
+            SexecFactory _factory_1 = this.sexec.factory();
+            Sequence _createSequence = _factory_1.createSequence();
+            final Sequence seq = _createSequence;
+            seq.setName("enterSequence");
+            String _name_1 = child.getName();
+            String _operator_plus_1 = StringExtensions.operator_plus("enterSequence with history in child ", _name_1);
+            String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " for leaf ");
+            String _name_2 = childLeaf.getName();
+            String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, _name_2);
+            seq.setComment(_operator_plus_3);
+            boolean _isLeaf = execChild.isLeaf();
+            if (_isLeaf) {
+              EList<Step> _steps = seq.getSteps();
+              Sequence _enterSequence = execChild.getEnterSequence();
+              Call _newCall = this.mapping.newCall(_enterSequence);
+              CollectionExtensions.<Step>operator_add(_steps, _newCall);
+            } else {
+              {
+                Step _entryAction = execChild.getEntryAction();
+                boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_entryAction, null);
+                if (_operator_notEquals) {
+                  EList<Step> _steps_1 = seq.getSteps();
+                  Step _entryAction_1 = execChild.getEntryAction();
+                  Call _newCall_1 = this.mapping.newCall(_entryAction_1);
+                  CollectionExtensions.<Step>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.<Step>operator_add(_steps_2, _newTraceStateEntered);
+                }
+                EList<Region> _regions = child.getRegions();
+                for (final Region childRegion : _regions) {
+                  EList<Step> _steps_3 = seq.getSteps();
+                  StateSwitch _defineDeepHistorySwitch = this.defineDeepHistorySwitch(childRegion, historyRegion);
+                  CollectionExtensions.<Step>operator_add(_steps_3, _defineDeepHistorySwitch);
+                }
+              }
+            }
+            EList<StateCase> _cases = sSwitch.getCases();
+            ExecutionState _create_3 = this.mapping.create(childLeaf);
+            StateCase _newCase = this.sexec.newCase(_create_3, seq);
+            CollectionExtensions.<StateCase>operator_add(_cases, _newCase);
+          }
+        }
+      }
+      return sSwitch;
+    }
+  }
+  
+  public StateSwitch defineShallowHistorySwitch(final Region r) {
+    {
+      ExecutionRegion _create = this.mapping.create(r);
+      final ExecutionRegion execRegion = _create;
+      SexecFactory _factory = this.sexec.factory();
+      StateSwitch _createStateSwitch = _factory.createStateSwitch();
+      final StateSwitch sSwitch = _createStateSwitch;
+      StateVector _stateVector = execRegion.getStateVector();
+      int _offset = _stateVector.getOffset();
+      sSwitch.setStateConfigurationIdx(_offset);
+      String _name = r.getName();
+      String _operator_plus = StringExtensions.operator_plus("Handle shallow history entry of ", _name);
+      sSwitch.setComment(_operator_plus);
+      ExecutionRegion _create_1 = this.mapping.create(r);
+      sSwitch.setHistoryRegion(_create_1);
+      EList<Vertex> _vertices = r.getVertices();
+      Iterable<State> _filter = IterableExtensions.<State>filter(_vertices, org.yakindu.sct.model.sgraph.State.class);
+      for (final State child : _filter) {
+        {
+          ExecutionState _create_2 = this.mapping.create(child);
+          final ExecutionState execChild = _create_2;
+          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_3 = ReactionBuilder.this.mapping.create(c);
+                StateVector _stateVector_1 = _create_3.getStateVector();
+                int _offset_1 = _stateVector_1.getOffset();
+                int _stateConfigurationIdx = sSwitch.getStateConfigurationIdx();
+                boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_offset_1), ((Integer)_stateConfigurationIdx));
+                return ((Boolean)_operator_equals);
+              }
+            };
+          Iterable<RegularState> _filter_1 = IterableExtensions.<RegularState>filter(_collectLeafStates, _function);
+          for (final RegularState childLeaf : _filter_1) {
+            EList<StateCase> _cases = sSwitch.getCases();
+            ExecutionState _create_4 = this.mapping.create(childLeaf);
+            Sequence _enterSequence = execChild.getEnterSequence();
+            Call _newCall = this.mapping.newCall(_enterSequence);
+            StateCase _newCase = this.sexec.newCase(_create_4, _newCall);
+            CollectionExtensions.<StateCase>operator_add(_cases, _newCase);
+          }
+        }
+      }
+      return sSwitch;
+    }
+  }
+}

+ 20 - 310
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SequenceBuilder.java

@@ -5,11 +5,9 @@ import com.google.inject.name.Named;
 import java.util.ArrayList;
 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.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;
@@ -26,7 +24,6 @@ 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.HistoryEntry;
 import org.yakindu.sct.model.sexec.SaveHistory;
 import org.yakindu.sct.model.sexec.Sequence;
 import org.yakindu.sct.model.sexec.SexecFactory;
@@ -124,48 +121,6 @@ public class SequenceBuilder {
     }
   }
   
-  protected void _defineStateEnterSequence(final Entry e) {
-    {
-      ExecutionEntry _create = this.mapping.create(e);
-      final ExecutionEntry execEntry = _create;
-      SexecFactory _factory = this.sexec.factory();
-      Sequence _createSequence = _factory.createSequence();
-      final Sequence seq = _createSequence;
-      seq.setName("react");
-      String _switchResult = null;
-      EntryKind _kind = e.getKind();
-      final EntryKind __valOfSwitchOver = _kind;
-      boolean matched = false;
-      if (!matched) {
-        if (org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_equals(__valOfSwitchOver,EntryKind.INITIAL)) {
-          matched=true;
-          _switchResult = "initial ";
-        }
-      }
-      if (!matched) {
-        if (org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_equals(__valOfSwitchOver,EntryKind.DEEP_HISTORY)) {
-          matched=true;
-          _switchResult = "deep history ";
-        }
-      }
-      if (!matched) {
-        if (org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_equals(__valOfSwitchOver,EntryKind.SHALLOW_HISTORY)) {
-          matched=true;
-          _switchResult = "shallow history ";
-        }
-      }
-      if (!matched) {
-        _switchResult = "";
-      }
-      String _operator_plus = StringExtensions.operator_plus("Default react sequence for ", _switchResult);
-      String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, "entry ");
-      String _name = e.getName();
-      String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, _name);
-      seq.setComment(_operator_plus_2);
-      execEntry.setReactSequence(seq);
-    }
-  }
-  
   protected void _defineStateEnterSequence(final Vertex v) {
   }
   
@@ -337,109 +292,6 @@ public class SequenceBuilder {
   protected void _defineStateExitSequence(final Vertex v) {
   }
   
-  protected void _defineStateExitSequence(final Entry e) {
-    {
-      ExecutionEntry _create = this.mapping.create(e);
-      final ExecutionEntry execEntry = _create;
-      Sequence _reactSequence = execEntry.getReactSequence();
-      final Sequence seq = _reactSequence;
-      State _target = this.sgraph.target(e);
-      ExecutionState _create_1 = this.mapping.create(_target);
-      final ExecutionState target = _create_1;
-      EntryKind _kind = e.getKind();
-      boolean _operator_equals = ObjectExtensions.operator_equals(_kind, EntryKind.INITIAL);
-      if (_operator_equals) {
-        boolean _operator_and = false;
-        boolean _operator_notEquals = ObjectExtensions.operator_notEquals(target, null);
-        if (!_operator_notEquals) {
-          _operator_and = false;
-        } else {
-          Sequence _enterSequence = target.getEnterSequence();
-          boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_enterSequence, null);
-          _operator_and = BooleanExtensions.operator_and(_operator_notEquals, _operator_notEquals_1);
-        }
-        if (_operator_and) {
-          EList<Step> _steps = seq.getSteps();
-          Sequence _enterSequence_1 = target.getEnterSequence();
-          Call _newCall = this.mapping.newCall(_enterSequence_1);
-          CollectionExtensions.<Step>operator_add(_steps, _newCall);
-        }
-      } else {
-        EntryKind _kind_1 = e.getKind();
-        boolean _operator_equals_1 = ObjectExtensions.operator_equals(_kind_1, EntryKind.SHALLOW_HISTORY);
-        if (_operator_equals_1) {
-          {
-            SexecFactory _factory = this.sexec.factory();
-            HistoryEntry _createHistoryEntry = _factory.createHistoryEntry();
-            final HistoryEntry entryStep = _createHistoryEntry;
-            entryStep.setName("HistoryEntry");
-            entryStep.setComment("Enter the region with shallow history");
-            entryStep.setDeep(false);
-            EObject _eContainer = e.eContainer();
-            ExecutionRegion _create_2 = this.mapping.create(((Region) _eContainer));
-            entryStep.setRegion(_create_2);
-            boolean _operator_and_1 = false;
-            boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(target, null);
-            if (!_operator_notEquals_2) {
-              _operator_and_1 = false;
-            } else {
-              Sequence _enterSequence_2 = target.getEnterSequence();
-              boolean _operator_notEquals_3 = ObjectExtensions.operator_notEquals(_enterSequence_2, null);
-              _operator_and_1 = BooleanExtensions.operator_and(_operator_notEquals_2, _operator_notEquals_3);
-            }
-            if (_operator_and_1) {
-              Sequence _enterSequence_3 = target.getEnterSequence();
-              Call _newCall_1 = this.mapping.newCall(_enterSequence_3);
-              entryStep.setInitialStep(_newCall_1);
-            }
-            EObject _eContainer_1 = e.eContainer();
-            StateSwitch _defineShallowHistorySwitch = this.defineShallowHistorySwitch(((Region) _eContainer_1));
-            final StateSwitch sSwitch = _defineShallowHistorySwitch;
-            entryStep.setHistoryStep(sSwitch);
-            EList<Step> _steps_1 = seq.getSteps();
-            CollectionExtensions.<Step>operator_add(_steps_1, entryStep);
-          }
-        } else {
-          EntryKind _kind_2 = e.getKind();
-          boolean _operator_equals_2 = ObjectExtensions.operator_equals(_kind_2, EntryKind.DEEP_HISTORY);
-          if (_operator_equals_2) {
-            {
-              SexecFactory _factory_1 = this.sexec.factory();
-              HistoryEntry _createHistoryEntry_1 = _factory_1.createHistoryEntry();
-              final HistoryEntry entryStep_1 = _createHistoryEntry_1;
-              entryStep_1.setName("HistoryEntry");
-              entryStep_1.setComment("Enter the region with deep history");
-              EObject _eContainer_2 = e.eContainer();
-              ExecutionRegion _create_3 = this.mapping.create(((Region) _eContainer_2));
-              entryStep_1.setRegion(_create_3);
-              entryStep_1.setDeep(true);
-              boolean _operator_and_2 = false;
-              boolean _operator_notEquals_4 = ObjectExtensions.operator_notEquals(target, null);
-              if (!_operator_notEquals_4) {
-                _operator_and_2 = false;
-              } else {
-                Sequence _enterSequence_4 = target.getEnterSequence();
-                boolean _operator_notEquals_5 = ObjectExtensions.operator_notEquals(_enterSequence_4, null);
-                _operator_and_2 = BooleanExtensions.operator_and(_operator_notEquals_4, _operator_notEquals_5);
-              }
-              if (_operator_and_2) {
-                Sequence _enterSequence_5 = target.getEnterSequence();
-                Call _newCall_2 = this.mapping.newCall(_enterSequence_5);
-                entryStep_1.setInitialStep(_newCall_2);
-              }
-              EObject _eContainer_3 = e.eContainer();
-              StateSwitch _defineDeepHistorySwitch = this.defineDeepHistorySwitch(((Region) _eContainer_3));
-              final StateSwitch sSwitch_1 = _defineDeepHistorySwitch;
-              entryStep_1.setHistoryStep(sSwitch_1);
-              EList<Step> _steps_2 = seq.getSteps();
-              CollectionExtensions.<Step>operator_add(_steps_2, entryStep_1);
-            }
-          }
-        }
-      }
-    }
-  }
-  
   protected void _defineStateExitSequence(final FinalState s) {
     {
       ExecutionState _create = this.mapping.create(s);
@@ -512,144 +364,6 @@ public class SequenceBuilder {
     }
   }
   
-  public StateSwitch defineDeepHistorySwitch(final Region r) {
-    ExecutionRegion _create = this.mapping.create(r);
-    StateSwitch _defineDeepHistorySwitch = this.defineDeepHistorySwitch(r, _create);
-    return _defineDeepHistorySwitch;
-  }
-  
-  public StateSwitch defineDeepHistorySwitch(final Region r, final ExecutionRegion historyRegion) {
-    {
-      ExecutionRegion _create = this.mapping.create(r);
-      final ExecutionRegion execRegion = _create;
-      SexecFactory _factory = this.sexec.factory();
-      StateSwitch _createStateSwitch = _factory.createStateSwitch();
-      final StateSwitch sSwitch = _createStateSwitch;
-      StateVector _stateVector = execRegion.getStateVector();
-      int _offset = _stateVector.getOffset();
-      sSwitch.setStateConfigurationIdx(_offset);
-      String _name = r.getName();
-      String _operator_plus = StringExtensions.operator_plus("Handle shallow history entry of ", _name);
-      sSwitch.setComment(_operator_plus);
-      sSwitch.setHistoryRegion(historyRegion);
-      EList<Vertex> _vertices = r.getVertices();
-      Iterable<State> _filter = IterableExtensions.<State>filter(_vertices, org.yakindu.sct.model.sgraph.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_1 = SequenceBuilder.this.mapping.create(c);
-              StateVector _stateVector_1 = _create_1.getStateVector();
-              int _offset_1 = _stateVector_1.getOffset();
-              int _stateConfigurationIdx = sSwitch.getStateConfigurationIdx();
-              boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_offset_1), ((Integer)_stateConfigurationIdx));
-              return ((Boolean)_operator_equals);
-            }
-          };
-        Iterable<RegularState> _filter_1 = IterableExtensions.<RegularState>filter(_collectLeafStates, _function);
-        for (final RegularState childLeaf : _filter_1) {
-          {
-            ExecutionState _create_2 = this.mapping.create(child);
-            final ExecutionState execChild = _create_2;
-            SexecFactory _factory_1 = this.sexec.factory();
-            Sequence _createSequence = _factory_1.createSequence();
-            final Sequence seq = _createSequence;
-            seq.setName("enterSequence");
-            String _name_1 = child.getName();
-            String _operator_plus_1 = StringExtensions.operator_plus("enterSequence with history in child ", _name_1);
-            String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " for leaf ");
-            String _name_2 = childLeaf.getName();
-            String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, _name_2);
-            seq.setComment(_operator_plus_3);
-            boolean _isLeaf = execChild.isLeaf();
-            if (_isLeaf) {
-              EList<Step> _steps = seq.getSteps();
-              Sequence _enterSequence = execChild.getEnterSequence();
-              Call _newCall = this.mapping.newCall(_enterSequence);
-              CollectionExtensions.<Step>operator_add(_steps, _newCall);
-            } else {
-              {
-                Step _entryAction = execChild.getEntryAction();
-                boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_entryAction, null);
-                if (_operator_notEquals) {
-                  EList<Step> _steps_1 = seq.getSteps();
-                  Step _entryAction_1 = execChild.getEntryAction();
-                  Call _newCall_1 = this.mapping.newCall(_entryAction_1);
-                  CollectionExtensions.<Step>operator_add(_steps_1, _newCall_1);
-                }
-                if (this._addTraceSteps) {
-                  EList<Step> _steps_2 = seq.getSteps();
-                  TraceStateEntered _newTraceStateEntered = this.trace.newTraceStateEntered(execChild);
-                  CollectionExtensions.<Step>operator_add(_steps_2, _newTraceStateEntered);
-                }
-                EList<Region> _regions = child.getRegions();
-                for (final Region childRegion : _regions) {
-                  EList<Step> _steps_3 = seq.getSteps();
-                  StateSwitch _defineDeepHistorySwitch = this.defineDeepHistorySwitch(childRegion, historyRegion);
-                  CollectionExtensions.<Step>operator_add(_steps_3, _defineDeepHistorySwitch);
-                }
-              }
-            }
-            EList<StateCase> _cases = sSwitch.getCases();
-            ExecutionState _create_3 = this.mapping.create(childLeaf);
-            StateCase _newCase = this.sexec.newCase(_create_3, seq);
-            CollectionExtensions.<StateCase>operator_add(_cases, _newCase);
-          }
-        }
-      }
-      return sSwitch;
-    }
-  }
-  
-  public StateSwitch defineShallowHistorySwitch(final Region r) {
-    {
-      ExecutionRegion _create = this.mapping.create(r);
-      final ExecutionRegion execRegion = _create;
-      SexecFactory _factory = this.sexec.factory();
-      StateSwitch _createStateSwitch = _factory.createStateSwitch();
-      final StateSwitch sSwitch = _createStateSwitch;
-      StateVector _stateVector = execRegion.getStateVector();
-      int _offset = _stateVector.getOffset();
-      sSwitch.setStateConfigurationIdx(_offset);
-      String _name = r.getName();
-      String _operator_plus = StringExtensions.operator_plus("Handle shallow history entry of ", _name);
-      sSwitch.setComment(_operator_plus);
-      ExecutionRegion _create_1 = this.mapping.create(r);
-      sSwitch.setHistoryRegion(_create_1);
-      EList<Vertex> _vertices = r.getVertices();
-      Iterable<State> _filter = IterableExtensions.<State>filter(_vertices, org.yakindu.sct.model.sgraph.State.class);
-      for (final State child : _filter) {
-        {
-          ExecutionState _create_2 = this.mapping.create(child);
-          final ExecutionState execChild = _create_2;
-          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_3 = SequenceBuilder.this.mapping.create(c);
-                StateVector _stateVector_1 = _create_3.getStateVector();
-                int _offset_1 = _stateVector_1.getOffset();
-                int _stateConfigurationIdx = sSwitch.getStateConfigurationIdx();
-                boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_offset_1), ((Integer)_stateConfigurationIdx));
-                return ((Boolean)_operator_equals);
-              }
-            };
-          Iterable<RegularState> _filter_1 = IterableExtensions.<RegularState>filter(_collectLeafStates, _function);
-          for (final RegularState childLeaf : _filter_1) {
-            EList<StateCase> _cases = sSwitch.getCases();
-            ExecutionState _create_4 = this.mapping.create(childLeaf);
-            Sequence _enterSequence = execChild.getEnterSequence();
-            Call _newCall = this.mapping.newCall(_enterSequence);
-            StateCase _newCase = this.sexec.newCase(_create_4, _newCall);
-            CollectionExtensions.<StateCase>operator_add(_cases, _newCase);
-          }
-        }
-      }
-      return sSwitch;
-    }
-  }
-  
   public StateSwitch defineExitSwitch(final ExecutionScope state, final Iterable<ExecutionState> leafStates, final int pos) {
     {
       SexecFactory _factory = this.sexec.factory();
@@ -848,37 +562,33 @@ public class SequenceBuilder {
     }
   }
   
-  public void defineStateEnterSequence(final NamedElement e) {
-    if ((e instanceof Entry)) {
-      _defineStateEnterSequence((Entry)e);
-    } else if ((e instanceof FinalState)) {
-      _defineStateEnterSequence((FinalState)e);
-    } else if ((e instanceof State)) {
-      _defineStateEnterSequence((State)e);
-    } else if ((e instanceof Region)) {
-      _defineStateEnterSequence((Region)e);
-    } else if ((e instanceof Vertex)) {
-      _defineStateEnterSequence((Vertex)e);
+  public void defineStateEnterSequence(final NamedElement state) {
+    if ((state instanceof FinalState)) {
+      _defineStateEnterSequence((FinalState)state);
+    } else if ((state instanceof State)) {
+      _defineStateEnterSequence((State)state);
+    } else if ((state instanceof Region)) {
+      _defineStateEnterSequence((Region)state);
+    } else if ((state instanceof Vertex)) {
+      _defineStateEnterSequence((Vertex)state);
     } else {
       throw new IllegalArgumentException("Unhandled parameter types: " +
-        java.util.Arrays.<Object>asList(e).toString());
+        java.util.Arrays.<Object>asList(state).toString());
     }
   }
   
-  public void defineStateExitSequence(final NamedElement e) {
-    if ((e instanceof Entry)) {
-      _defineStateExitSequence((Entry)e);
-    } else if ((e instanceof FinalState)) {
-      _defineStateExitSequence((FinalState)e);
-    } else if ((e instanceof State)) {
-      _defineStateExitSequence((State)e);
-    } else if ((e instanceof Region)) {
-      _defineStateExitSequence((Region)e);
-    } else if ((e instanceof Vertex)) {
-      _defineStateExitSequence((Vertex)e);
+  public void defineStateExitSequence(final NamedElement s) {
+    if ((s instanceof FinalState)) {
+      _defineStateExitSequence((FinalState)s);
+    } else if ((s instanceof State)) {
+      _defineStateExitSequence((State)s);
+    } else if ((s instanceof Region)) {
+      _defineStateExitSequence((Region)s);
+    } else if ((s instanceof Vertex)) {
+      _defineStateExitSequence((Vertex)s);
     } else {
       throw new IllegalArgumentException("Unhandled parameter types: " +
-        java.util.Arrays.<Object>asList(e).toString());
+        java.util.Arrays.<Object>asList(s).toString());
     }
   }
 }

+ 36 - 3
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SexecElementMapping.java

@@ -35,6 +35,7 @@ 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.Entry;
+import org.yakindu.sct.model.sgraph.EntryKind;
 import org.yakindu.sct.model.sgraph.Event;
 import org.yakindu.sct.model.sgraph.Reaction;
 import org.yakindu.sct.model.sgraph.Region;
@@ -347,9 +348,41 @@ public class SexecElementMapping {
         String _replaceAll = _string.replaceAll(" ", "");
         r.setName(_replaceAll);
         r.setSourceElement(entry);
-        SexecFactory _sexecFactory_1 = this.sexecFactory();
-        Sequence _createSequence = _sexecFactory_1.createSequence();
-        r.setReactSequence(_createSequence);
+        SexecFactory _factory = this.sexec.factory();
+        Sequence _createSequence = _factory.createSequence();
+        final Sequence seq = _createSequence;
+        seq.setName("react");
+        String _switchResult = null;
+        EntryKind _kind = entry.getKind();
+        final EntryKind __valOfSwitchOver = _kind;
+        boolean matched = false;
+        if (!matched) {
+          if (org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_equals(__valOfSwitchOver,EntryKind.INITIAL)) {
+            matched=true;
+            _switchResult = "initial ";
+          }
+        }
+        if (!matched) {
+          if (org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_equals(__valOfSwitchOver,EntryKind.DEEP_HISTORY)) {
+            matched=true;
+            _switchResult = "deep history ";
+          }
+        }
+        if (!matched) {
+          if (org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_equals(__valOfSwitchOver,EntryKind.SHALLOW_HISTORY)) {
+            matched=true;
+            _switchResult = "shallow history ";
+          }
+        }
+        if (!matched) {
+          _switchResult = "";
+        }
+        String _operator_plus_4 = StringExtensions.operator_plus("Default react sequence for ", _switchResult);
+        String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "entry ");
+        String _name_4 = entry.getName();
+        String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, _name_4);
+        seq.setComment(_operator_plus_6);
+        r.setReactSequence(seq);
       }
     }
     return r;

+ 6 - 10
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StatechartExtensions.java

@@ -12,6 +12,7 @@ import org.eclipse.xtext.xbase.lib.IntegerExtensions;
 import org.eclipse.xtext.xbase.lib.IterableExtensions;
 import org.eclipse.xtext.xbase.lib.ObjectExtensions;
 import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.EObjectExtensions;
 import org.yakindu.sct.model.sgraph.Choice;
 import org.yakindu.sct.model.sgraph.Entry;
 import org.yakindu.sct.model.sgraph.Reaction;
@@ -228,25 +229,20 @@ public class StatechartExtensions {
     }
   }
   
-  public List<Choice> allChoices(final Statechart sc) {
+  public Iterable<Choice> allChoices(final Statechart sc) {
     {
       List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(sc);
       List<EObject> content = _eAllContentsAsList;
       Iterable<Choice> _filter = IterableExtensions.<Choice>filter(content, org.yakindu.sct.model.sgraph.Choice.class);
       final Iterable<Choice> allChoices = _filter;
-      List<Choice> _list = IterableExtensions.<Choice>toList(allChoices);
-      return _list;
+      return allChoices;
     }
   }
   
   public Iterable<Entry> allEntries(final Statechart sc) {
-    {
-      List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(sc);
-      List<EObject> content = _eAllContentsAsList;
-      Iterable<Entry> _filter = IterableExtensions.<Entry>filter(content, org.yakindu.sct.model.sgraph.Entry.class);
-      final Iterable<Entry> allEntries = _filter;
-      return allEntries;
-    }
+    Iterable<EObject> _allContentsIterable = EObjectExtensions.allContentsIterable(sc);
+    Iterable<Entry> _filter = IterableExtensions.<Entry>filter(_allContentsIterable, org.yakindu.sct.model.sgraph.Entry.class);
+    return _filter;
   }
   
   public List<LocalReaction> entryReactions(final State state) {

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

@@ -208,18 +208,18 @@ public class StructureMapping {
   
   public ExecutionFlow mapPseudoStates(final Statechart statechart, final ExecutionFlow r) {
     {
-      List<Choice> _allChoices = this.sct.allChoices(statechart);
-      final List<Choice> allChoices = _allChoices;
+      Iterable<Choice> _allChoices = this.sct.allChoices(statechart);
+      final Iterable<Choice> allChoices = _allChoices;
       EList<ExecutionNode> _nodes = r.getNodes();
-      List<Choice> _allChoices_1 = this.sct.allChoices(statechart);
+      Iterable<Choice> _allChoices_1 = 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;
           }
         };
-      List<ExecutionChoice> _map = ListExtensions.<Choice, ExecutionChoice>map(_allChoices_1, _function);
-      _nodes.addAll(_map);
+      Iterable<ExecutionChoice> _map = IterableExtensions.<Choice, ExecutionChoice>map(_allChoices_1, _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>() {