Procházet zdrojové kódy

Fixed issue #278 in transformation. Entry reactions now include
transition actions.

Axel Terfloth před 10 roky
rodič
revize
72f51a6baf

+ 23 - 14
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/ReactionBuilder.xtend

@@ -216,19 +216,33 @@ class ReactionBuilder {
 	}
 	
 	def defineReaction(Entry e) {
+
+		// first get the mapped control flow element the entry
 		val execEntry = e.create
-		//Reuse already created react sequence from defineStateEnterSequence(Entry) 
-		val seq = execEntry.reactSequence
+		
+		// if the entry defines a transition then we will derive the entry transition sequence
+		var Sequence entryTransSeq = null
+		val entryTransitionEffect = e?.transition?.effect		
 		val target = e.target.create
 		val targetEnterSequence = if (target != null && e.outgoingTransitions.size > 0) { e.outgoingTransitions.mapToStateConfigurationEnterSequence } else null
 			
+		if ( entryTransitionEffect != null || targetEnterSequence != null) {
+			entryTransSeq = sexecFactory.createSequence
+			if (entryTransitionEffect != null) {
+				entryTransSeq.steps += entryTransitionEffect.mapEffect	
+			}
+			if (targetEnterSequence != null) {
+				entryTransSeq.steps += targetEnterSequence
+			}
+		}	
+		
+		// we add behavior to the already created react sequence from defineStateEnterSequence(Entry) 
+		val seq = execEntry.reactSequence
 		
 		if ( trace.addTraceSteps ) seq.steps.add(0,execEntry.newTraceNodeExecuted)
 		
-		if (e.kind == EntryKind::INITIAL) {
-			if (targetEnterSequence != null) {
-				seq.steps += targetEnterSequence
-			}
+		if (e.kind == EntryKind::INITIAL) {			
+			if (entryTransSeq != null) seq.steps += entryTransSeq
 			
 		} else if (e.kind == EntryKind::SHALLOW_HISTORY) {
 			val entryStep = sexec.factory.createHistoryEntry
@@ -237,10 +251,7 @@ class ReactionBuilder {
 			entryStep.deep = false
 			entryStep.region = (e.eContainer as Region).create
 			
-			//Initial step, if no history is known
-			if (targetEnterSequence != null) {
-				entryStep.initialStep = targetEnterSequence
-			}
+			if (entryTransSeq != null) entryStep.initialStep = entryTransSeq
 			
 			entryStep.historyStep = (e.eContainer as Region).create.shallowEnterSequence.newCall
 			
@@ -252,10 +263,8 @@ class ReactionBuilder {
 			entryStep.region = (e.eContainer as Region).create
 			entryStep.deep = true
 			
-			//Initial step, if no history is known
-			if (targetEnterSequence != null) {
-				entryStep.initialStep = targetEnterSequence
-			}
+			if (entryTransSeq != null) entryStep.initialStep = entryTransSeq
+			
 			
 			entryStep.historyStep =  (e.eContainer as Region).create.deepEnterSequence.newCall
 

+ 12 - 6
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/SgraphExtensions.xtend

@@ -90,15 +90,21 @@ class SgraphExtensions {
 	 * Retrieves the target from an entry.
 	 * TODO: validation of preconditions for entry targets e.g every region needs an entry with appropriate target
 	 */
-	def target(Entry entry) {
-		var State target = null
+	def State target(Entry entry) {
+		val obj = entry.transition.target
+		if (obj instanceof State ) return obj as State		
+		
+		return null
+	}
+	
+	def Transition transition(Entry entry) {
 		if ( entry?.outgoingTransitions != null) {
 			if (entry.outgoingTransitions.size > 0) {
-				val obj =entry.outgoingTransitions.get(0).target
-				if (obj instanceof State ) target = obj as State	
+				return entry.outgoingTransitions.get(0)
 			}
-		}
-		return target
+		}	
+		
+		return null	
 	}