فهرست منبع

intermediate solution for a statechart static init sequence.

AxelTerfloth@googlemail.com 10 سال پیش
والد
کامیت
258d9135c2

+ 2 - 0
plugins/org.yakindu.sct.model.sexec/model/sexec.ecore

@@ -17,6 +17,8 @@
         containment="true"/>
     <eStructuralFeatures xsi:type="ecore:EReference" name="exitAction" eType="#//Step"
         containment="true"/>
+    <eStructuralFeatures xsi:type="ecore:EReference" name="staticInitSequence" eType="#//Sequence"
+        containment="true"/>
   </eClassifiers>
   <eClassifiers xsi:type="ecore:EClass" name="ExecutionNode" eSuperTypes="#//MappedElement ../../org.yakindu.base.types/model/base.ecore#//NamedElement">
     <eStructuralFeatures xsi:type="ecore:EReference" name="reactions" upperBound="-1"

+ 27 - 0
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/ExecutionFlow.java

@@ -23,6 +23,7 @@ import org.yakindu.sct.model.sgraph.ScopedElement;
  *   <li>{@link org.yakindu.sct.model.sexec.ExecutionFlow#getHistoryVector <em>History Vector</em>}</li>
  *   <li>{@link org.yakindu.sct.model.sexec.ExecutionFlow#getEntryAction <em>Entry Action</em>}</li>
  *   <li>{@link org.yakindu.sct.model.sexec.ExecutionFlow#getExitAction <em>Exit Action</em>}</li>
+ *   <li>{@link org.yakindu.sct.model.sexec.ExecutionFlow#getStaticInitSequence <em>Static Init Sequence</em>}</li>
  * </ul>
  * </p>
  *
@@ -157,4 +158,30 @@ public interface ExecutionFlow extends ScopedElement, ExecutionScope, ExecutionN
 	 */
 	void setExitAction(Step value);
 
+	/**
+	 * Returns the value of the '<em><b>Static Init Sequence</b></em>' containment reference.
+	 * <!-- begin-user-doc -->
+	 * <p>
+	 * If the meaning of the '<em>Static Init Sequence</em>' containment reference isn't clear,
+	 * there really should be more of a description here...
+	 * </p>
+	 * <!-- end-user-doc -->
+	 * @return the value of the '<em>Static Init Sequence</em>' containment reference.
+	 * @see #setStaticInitSequence(Sequence)
+	 * @see org.yakindu.sct.model.sexec.SexecPackage#getExecutionFlow_StaticInitSequence()
+	 * @model containment="true"
+	 * @generated
+	 */
+	Sequence getStaticInitSequence();
+
+	/**
+	 * Sets the value of the '{@link org.yakindu.sct.model.sexec.ExecutionFlow#getStaticInitSequence <em>Static Init Sequence</em>}' containment reference.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @param value the new value of the '<em>Static Init Sequence</em>' containment reference.
+	 * @see #getStaticInitSequence()
+	 * @generated
+	 */
+	void setStaticInitSequence(Sequence value);
+
 } // ExecutionFlow

+ 29 - 1
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/SexecPackage.java

@@ -270,6 +270,15 @@ public interface SexecPackage extends EPackage {
 	 */
 	int EXECUTION_FLOW__EXIT_ACTION = SGraphPackage.SCOPED_ELEMENT_FEATURE_COUNT + 16;
 
+	/**
+	 * The feature id for the '<em><b>Static Init Sequence</b></em>' containment reference.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 * @ordered
+	 */
+	int EXECUTION_FLOW__STATIC_INIT_SEQUENCE = SGraphPackage.SCOPED_ELEMENT_FEATURE_COUNT + 17;
+
 	/**
 	 * The number of structural features of the '<em>Execution Flow</em>' class.
 	 * <!-- begin-user-doc -->
@@ -277,7 +286,7 @@ public interface SexecPackage extends EPackage {
 	 * @generated
 	 * @ordered
 	 */
-	int EXECUTION_FLOW_FEATURE_COUNT = SGraphPackage.SCOPED_ELEMENT_FEATURE_COUNT + 17;
+	int EXECUTION_FLOW_FEATURE_COUNT = SGraphPackage.SCOPED_ELEMENT_FEATURE_COUNT + 18;
 
 	/**
 	 * The meta object id for the '{@link org.yakindu.sct.model.sexec.impl.ExecutionNodeImpl <em>Execution Node</em>}' class.
@@ -2496,6 +2505,17 @@ public interface SexecPackage extends EPackage {
 	 */
 	EReference getExecutionFlow_ExitAction();
 
+	/**
+	 * Returns the meta object for the containment reference '{@link org.yakindu.sct.model.sexec.ExecutionFlow#getStaticInitSequence <em>Static Init Sequence</em>}'.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @return the meta object for the containment reference '<em>Static Init Sequence</em>'.
+	 * @see org.yakindu.sct.model.sexec.ExecutionFlow#getStaticInitSequence()
+	 * @see #getExecutionFlow()
+	 * @generated
+	 */
+	EReference getExecutionFlow_StaticInitSequence();
+
 	/**
 	 * Returns the meta object for class '{@link org.yakindu.sct.model.sexec.ExecutionNode <em>Execution Node</em>}'.
 	 * <!-- begin-user-doc -->
@@ -3531,6 +3551,14 @@ public interface SexecPackage extends EPackage {
 		 */
 		EReference EXECUTION_FLOW__EXIT_ACTION = eINSTANCE.getExecutionFlow_ExitAction();
 
+		/**
+		 * The meta object literal for the '<em><b>Static Init Sequence</b></em>' containment reference feature.
+		 * <!-- begin-user-doc -->
+		 * <!-- end-user-doc -->
+		 * @generated
+		 */
+		EReference EXECUTION_FLOW__STATIC_INIT_SEQUENCE = eINSTANCE.getExecutionFlow_StaticInitSequence();
+
 		/**
 		 * The meta object literal for the '{@link org.yakindu.sct.model.sexec.impl.ExecutionNodeImpl <em>Execution Node</em>}' class.
 		 * <!-- begin-user-doc -->

+ 66 - 0
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/impl/ExecutionFlowImpl.java

@@ -57,6 +57,7 @@ import org.yakindu.sct.model.sgraph.impl.ScopedElementImpl;
  *   <li>{@link org.yakindu.sct.model.sexec.impl.ExecutionFlowImpl#getHistoryVector <em>History Vector</em>}</li>
  *   <li>{@link org.yakindu.sct.model.sexec.impl.ExecutionFlowImpl#getEntryAction <em>Entry Action</em>}</li>
  *   <li>{@link org.yakindu.sct.model.sexec.impl.ExecutionFlowImpl#getExitAction <em>Exit Action</em>}</li>
+ *   <li>{@link org.yakindu.sct.model.sexec.impl.ExecutionFlowImpl#getStaticInitSequence <em>Static Init Sequence</em>}</li>
  * </ul>
  * </p>
  *
@@ -253,6 +254,16 @@ public class ExecutionFlowImpl extends ScopedElementImpl implements ExecutionFlo
 	 */
 	protected Step exitAction;
 
+	/**
+	 * The cached value of the '{@link #getStaticInitSequence() <em>Static Init Sequence</em>}' containment reference.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @see #getStaticInitSequence()
+	 * @generated
+	 * @ordered
+	 */
+	protected Sequence staticInitSequence;
+
 	/**
 	 * <!-- begin-user-doc -->
 	 * <!-- end-user-doc -->
@@ -709,6 +720,49 @@ public class ExecutionFlowImpl extends ScopedElementImpl implements ExecutionFlo
 			eNotify(new ENotificationImpl(this, Notification.SET, SexecPackage.EXECUTION_FLOW__EXIT_ACTION, newExitAction, newExitAction));
 	}
 
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	public Sequence getStaticInitSequence() {
+		return staticInitSequence;
+	}
+
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	public NotificationChain basicSetStaticInitSequence(Sequence newStaticInitSequence, NotificationChain msgs) {
+		Sequence oldStaticInitSequence = staticInitSequence;
+		staticInitSequence = newStaticInitSequence;
+		if (eNotificationRequired()) {
+			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SexecPackage.EXECUTION_FLOW__STATIC_INIT_SEQUENCE, oldStaticInitSequence, newStaticInitSequence);
+			if (msgs == null) msgs = notification; else msgs.add(notification);
+		}
+		return msgs;
+	}
+
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	public void setStaticInitSequence(Sequence newStaticInitSequence) {
+		if (newStaticInitSequence != staticInitSequence) {
+			NotificationChain msgs = null;
+			if (staticInitSequence != null)
+				msgs = ((InternalEObject)staticInitSequence).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - SexecPackage.EXECUTION_FLOW__STATIC_INIT_SEQUENCE, null, msgs);
+			if (newStaticInitSequence != null)
+				msgs = ((InternalEObject)newStaticInitSequence).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - SexecPackage.EXECUTION_FLOW__STATIC_INIT_SEQUENCE, null, msgs);
+			msgs = basicSetStaticInitSequence(newStaticInitSequence, msgs);
+			if (msgs != null) msgs.dispatch();
+		}
+		else if (eNotificationRequired())
+			eNotify(new ENotificationImpl(this, Notification.SET, SexecPackage.EXECUTION_FLOW__STATIC_INIT_SEQUENCE, newStaticInitSequence, newStaticInitSequence));
+	}
+
 	/**
 	 * <!-- begin-user-doc -->
 	 * <!-- end-user-doc -->
@@ -840,6 +894,8 @@ public class ExecutionFlowImpl extends ScopedElementImpl implements ExecutionFlo
 				return basicSetEntryAction(null, msgs);
 			case SexecPackage.EXECUTION_FLOW__EXIT_ACTION:
 				return basicSetExitAction(null, msgs);
+			case SexecPackage.EXECUTION_FLOW__STATIC_INIT_SEQUENCE:
+				return basicSetStaticInitSequence(null, msgs);
 		}
 		return super.eInverseRemove(otherEnd, featureID, msgs);
 	}
@@ -888,6 +944,8 @@ public class ExecutionFlowImpl extends ScopedElementImpl implements ExecutionFlo
 				return getEntryAction();
 			case SexecPackage.EXECUTION_FLOW__EXIT_ACTION:
 				return getExitAction();
+			case SexecPackage.EXECUTION_FLOW__STATIC_INIT_SEQUENCE:
+				return getStaticInitSequence();
 		}
 		return super.eGet(featureID, resolve, coreType);
 	}
@@ -958,6 +1016,9 @@ public class ExecutionFlowImpl extends ScopedElementImpl implements ExecutionFlo
 			case SexecPackage.EXECUTION_FLOW__EXIT_ACTION:
 				setExitAction((Step)newValue);
 				return;
+			case SexecPackage.EXECUTION_FLOW__STATIC_INIT_SEQUENCE:
+				setStaticInitSequence((Sequence)newValue);
+				return;
 		}
 		super.eSet(featureID, newValue);
 	}
@@ -1021,6 +1082,9 @@ public class ExecutionFlowImpl extends ScopedElementImpl implements ExecutionFlo
 			case SexecPackage.EXECUTION_FLOW__EXIT_ACTION:
 				setExitAction((Step)null);
 				return;
+			case SexecPackage.EXECUTION_FLOW__STATIC_INIT_SEQUENCE:
+				setStaticInitSequence((Sequence)null);
+				return;
 		}
 		super.eUnset(featureID);
 	}
@@ -1067,6 +1131,8 @@ public class ExecutionFlowImpl extends ScopedElementImpl implements ExecutionFlo
 				return entryAction != null;
 			case SexecPackage.EXECUTION_FLOW__EXIT_ACTION:
 				return exitAction != null;
+			case SexecPackage.EXECUTION_FLOW__STATIC_INIT_SEQUENCE:
+				return staticInitSequence != null;
 		}
 		return super.eIsSet(featureID);
 	}

+ 1 - 0
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/impl/SexecFactoryImpl.java

@@ -11,6 +11,7 @@ import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.EPackage;
 import org.eclipse.emf.ecore.impl.EFactoryImpl;
 import org.eclipse.emf.ecore.plugin.EcorePlugin;
+import org.yakindu.sct.model.sexec.*;
 import org.yakindu.sct.model.sexec.Call;
 import org.yakindu.sct.model.sexec.Check;
 import org.yakindu.sct.model.sexec.CheckRef;

+ 11 - 0
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/impl/SexecPackageImpl.java

@@ -440,6 +440,15 @@ public class SexecPackageImpl extends EPackageImpl implements SexecPackage {
 		return (EReference)executionFlowEClass.getEStructuralFeatures().get(5);
 	}
 
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	public EReference getExecutionFlow_StaticInitSequence() {
+		return (EReference)executionFlowEClass.getEStructuralFeatures().get(6);
+	}
+
 	/**
 	 * <!-- begin-user-doc -->
 	 * <!-- end-user-doc -->
@@ -1288,6 +1297,7 @@ public class SexecPackageImpl extends EPackageImpl implements SexecPackage {
 		createEReference(executionFlowEClass, EXECUTION_FLOW__HISTORY_VECTOR);
 		createEReference(executionFlowEClass, EXECUTION_FLOW__ENTRY_ACTION);
 		createEReference(executionFlowEClass, EXECUTION_FLOW__EXIT_ACTION);
+		createEReference(executionFlowEClass, EXECUTION_FLOW__STATIC_INIT_SEQUENCE);
 
 		executionNodeEClass = createEClass(EXECUTION_NODE);
 		createEReference(executionNodeEClass, EXECUTION_NODE__REACTIONS);
@@ -1496,6 +1506,7 @@ public class SexecPackageImpl extends EPackageImpl implements SexecPackage {
 		initEReference(getExecutionFlow_HistoryVector(), this.getStateVector(), null, "historyVector", null, 0, 1, ExecutionFlow.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
 		initEReference(getExecutionFlow_EntryAction(), this.getStep(), null, "entryAction", null, 0, 1, ExecutionFlow.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
 		initEReference(getExecutionFlow_ExitAction(), this.getStep(), null, "exitAction", null, 0, 1, ExecutionFlow.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+		initEReference(getExecutionFlow_StaticInitSequence(), this.getSequence(), null, "staticInitSequence", null, 0, 1, ExecutionFlow.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
 
 		initEClass(executionNodeEClass, ExecutionNode.class, "ExecutionNode", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
 		initEReference(getExecutionNode_Reactions(), this.getReaction(), null, "reactions", null, 0, -1, ExecutionNode.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

+ 22 - 3
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/SequenceBuilder.xtend

@@ -438,6 +438,25 @@ class SequenceBuilder {
 		return enterSequence
 	}
 
+	/**
+	 * Defines the sequence of static initialization steps for constant values. 
+	 * 
+	 * These steps basically include the initialization of constants.
+	 */
+	def defineStatechartStaticInitSequence(ExecutionFlow flow, Statechart sc) {
+
+		val initSequence = sexec.factory.createSequence
+		initSequence.name = "staticInit"
+		initSequence.comment = "The statecharts init sequence for constants." + sc.name
+	
+		for (VariableDefinition vd : flow.getVariablesForInitSequence(true)) {
+			initSequence.addVariableInitializationStep(vd)
+		}
+
+		flow.staticInitSequence = initSequence
+		return initSequence
+	}
+	
 	/**
 	 * Defines the sequence of initialization steps. 
 	 * 
@@ -449,7 +468,7 @@ class SequenceBuilder {
 		initSequence.name = "init"
 		initSequence.comment = "Default init sequence for statechart " + sc.name
 	
-		for (VariableDefinition vd : flow.getVariablesForInitSequence) {
+		for (VariableDefinition vd : flow.getVariablesForInitSequence(false)) {
 			initSequence.addVariableInitializationStep(vd)
 		}
 
@@ -457,8 +476,8 @@ class SequenceBuilder {
 		return initSequence
 	}
 	
-	protected def getVariablesForInitSequence(ExecutionFlow flow) {
-		val statechartVariables = flow.scopes.map(s|s.variables).flatten.filter(typeof(VariableDefinition))
+	protected def getVariablesForInitSequence(ExecutionFlow flow, boolean const) {
+		val statechartVariables = flow.scopes.map(s|s.variables).flatten.filter(typeof(VariableDefinition)).filter(v | v.writeable == const)
 		val importedVariables = flow.scopes.map(s|s.declarations).flatten.filter(typeof(ImportDeclaration)).map(d|d.declaration).filter(typeof(VariableDefinition))
 		return statechartVariables + importedVariables
 	}

+ 1 - 0
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/util/SexecAdapterFactory.java

@@ -11,6 +11,7 @@ import org.eclipse.emf.common.notify.Notifier;
 import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
 import org.eclipse.emf.ecore.EObject;
 import org.yakindu.base.base.NamedElement;
+import org.yakindu.sct.model.sexec.*;
 import org.yakindu.sct.model.sexec.Call;
 import org.yakindu.sct.model.sexec.Check;
 import org.yakindu.sct.model.sexec.CheckRef;

+ 1 - 0
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/util/SexecSwitch.java

@@ -10,6 +10,7 @@ import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.EPackage;
 import org.eclipse.emf.ecore.util.Switch;
 import org.yakindu.base.base.NamedElement;
+import org.yakindu.sct.model.sexec.*;
 import org.yakindu.sct.model.sexec.Call;
 import org.yakindu.sct.model.sexec.Check;
 import org.yakindu.sct.model.sexec.CheckRef;