Commit a799683b authored by Alexander Diewald's avatar Alexander Diewald
Browse files

Merge branch '3859' into 'master'

3859

See merge request af3/af3!257
parents 666de4d8 550cac3f
...@@ -10,7 +10,7 @@ Bundle-Localization: plugin ...@@ -10,7 +10,7 @@ Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-11 Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Bundle-Activator: org.fortiss.af3.platform.hierarchic.HierarchicPlatformActivator Bundle-Activator: org.fortiss.af3.platform.hierarchic.HierarchicPlatformActivator
Require-Bundle: org.fortiss.af3.partition Require-Bundle: org.fortiss.af3.partition;visibility:=reexport
Export-Package: org.fortiss.af3.platform.hierarchic, Export-Package: org.fortiss.af3.platform.hierarchic,
org.fortiss.af3.platform.hierarchic.annotation.valueprovider, org.fortiss.af3.platform.hierarchic.annotation.valueprovider,
org.fortiss.af3.platform.hierarchic.compose, org.fortiss.af3.platform.hierarchic.compose,
......
...@@ -10,9 +10,8 @@ Bundle-Localization: plugin ...@@ -10,9 +10,8 @@ Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-11 Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Bundle-Activator: org.fortiss.af3.safety.AF3SafetyActivator Bundle-Activator: org.fortiss.af3.safety.AF3SafetyActivator
Require-Bundle: org.fortiss.af3.component, Require-Bundle: org.fortiss.af3.component;visibility:=reexport,
org.fortiss.af3.platform;bundle-version="2.16.0";visibility:=reexport, org.fortiss.af3.platform.hierarchic;visibility:=reexport
org.fortiss.tooling.kernel
Export-Package: org.fortiss.af3.safety, Export-Package: org.fortiss.af3.safety,
org.fortiss.af3.safety.model.annotation.impl, org.fortiss.af3.safety.model.annotation.impl,
org.fortiss.af3.safety.annotation.valueprovider, org.fortiss.af3.safety.annotation.valueprovider,
......
safety.ecore 1fd88c8c2be305f98af77de3d31c316df365ac19 GREEN safety.ecore b92e234ad28258eae391834e4571396e2176ab0a GREEN
...@@ -70,6 +70,12 @@ ...@@ -70,6 +70,12 @@
<details key="body" value="return SafetyIntegrityLevelStaticImpl.getDerivedFeature(this);"/> <details key="body" value="return SafetyIntegrityLevelStaticImpl.getDerivedFeature(this);"/>
</eAnnotations> </eAnnotations>
</eOperations> </eOperations>
<eOperations name="getUserAnnotatedValue" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EEnumerator">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Returns the {@link EEnumerator} of the annotation's user specified integrity level (ASIL, SIL, or DAL)."/>
<details key="body" value="return SafetyIntegrityLevelStaticImpl.getUserAnnotatedValue(this);"/>
</eAnnotations>
</eOperations>
<eOperations name="setValue" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EEnumerator"> <eOperations name="setValue" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EEnumerator">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Sets values of this {@link SilAnnotation}. Currently, this method handles changes of the {@link SafetyStandard} of the {@link ComponentArchitecture}. It manages the translation of SafetyValues from one standard to another."/> <details key="documentation" value="Sets values of this {@link SilAnnotation}. Currently, this method handles changes of the {@link SafetyStandard} of the {@link ComponentArchitecture}. It manages the translation of SafetyValues from one standard to another."/>
...@@ -77,6 +83,12 @@ ...@@ -77,6 +83,12 @@
</eAnnotations> </eAnnotations>
<eParameters name="value" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EEnumerator"/> <eParameters name="value" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EEnumerator"/>
</eOperations> </eOperations>
<eOperations name="isUserAnnotatedValuePreferred" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="{@inheritDoc}"/>
<details key="body" value="return true;"/>
</eAnnotations>
</eOperations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="safetyStandard" eType="#//SafetyStandard"> <eStructuralFeatures xsi:type="ecore:EAttribute" name="safetyStandard" eType="#//SafetyStandard">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Safety standard (if selected for this particular annotation). Value might also be derived from other model elements (see {@link #getValue()})."/> <details key="documentation" value="Safety standard (if selected for this particular annotation). Value might also be derived from other model elements (see {@link #getValue()})."/>
...@@ -103,6 +115,9 @@ ...@@ -103,6 +115,9 @@
<details key="documentation" value="Dummy attributed used when saftey standard is set to {@code undefined}."/> <details key="documentation" value="Dummy attributed used when saftey standard is set to {@code undefined}."/>
</eAnnotations> </eAnnotations>
</eStructuralFeatures> </eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="selectedSafetyLevel"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EEnumerator"
transient="true"/>
<eGenericSuperTypes eClassifier="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//base/DerivedAnnotationBase"> <eGenericSuperTypes eClassifier="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//base/DerivedAnnotationBase">
<eTypeArguments eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EEnumerator"/> <eTypeArguments eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EEnumerator"/>
</eGenericSuperTypes> </eGenericSuperTypes>
......
...@@ -65,14 +65,19 @@ ...@@ -65,14 +65,19 @@
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute safety.ecore#//annotation/SafetyIntegrityLevel/dalValue"/> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute safety.ecore#//annotation/SafetyIntegrityLevel/dalValue"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute safety.ecore#//annotation/SafetyIntegrityLevel/silValue"/> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute safety.ecore#//annotation/SafetyIntegrityLevel/silValue"/>
<genFeatures property="Readonly" createChild="false" ecoreFeature="ecore:EAttribute safety.ecore#//annotation/SafetyIntegrityLevel/undefinedStandardValue"/> <genFeatures property="Readonly" createChild="false" ecoreFeature="ecore:EAttribute safety.ecore#//annotation/SafetyIntegrityLevel/undefinedStandardValue"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute safety.ecore#//annotation/SafetyIntegrityLevel/selectedSafetyLevel"/>
<genOperations ecoreOperation="safety.ecore#//annotation/SafetyIntegrityLevel/getDerivedValue" <genOperations ecoreOperation="safety.ecore#//annotation/SafetyIntegrityLevel/getDerivedValue"
body="return SafetyIntegrityLevelStaticImpl.getDerivedValue(this);"/> body="return SafetyIntegrityLevelStaticImpl.getDerivedValue(this);"/>
<genOperations ecoreOperation="safety.ecore#//annotation/SafetyIntegrityLevel/getDerivedFeature" <genOperations ecoreOperation="safety.ecore#//annotation/SafetyIntegrityLevel/getDerivedFeature"
body="return SafetyIntegrityLevelStaticImpl.getDerivedFeature(this);"/> body="return SafetyIntegrityLevelStaticImpl.getDerivedFeature(this);"/>
<genOperations ecoreOperation="safety.ecore#//annotation/SafetyIntegrityLevel/getUserAnnotatedValue"
body="return SafetyIntegrityLevelStaticImpl.getUserAnnotatedValue(this);"/>
<genOperations ecoreOperation="safety.ecore#//annotation/SafetyIntegrityLevel/setValue" <genOperations ecoreOperation="safety.ecore#//annotation/SafetyIntegrityLevel/setValue"
body="return SafetyIntegrityLevelStaticImpl.setValue(this, value);"> body="return SafetyIntegrityLevelStaticImpl.setValue(this, value);">
<genParameters ecoreParameter="safety.ecore#//annotation/SafetyIntegrityLevel/setValue/value"/> <genParameters ecoreParameter="safety.ecore#//annotation/SafetyIntegrityLevel/setValue/value"/>
</genOperations> </genOperations>
<genOperations ecoreOperation="safety.ecore#//annotation/SafetyIntegrityLevel/isUserAnnotatedValuePreferred"
body="return true;"/>
</genClasses> </genClasses>
<genClasses ecoreClass="safety.ecore#//annotation/ProbabilisticMetricHardwareFailure"> <genClasses ecoreClass="safety.ecore#//annotation/ProbabilisticMetricHardwareFailure">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute safety.ecore#//annotation/ProbabilisticMetricHardwareFailure/pmhfValue"/> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute safety.ecore#//annotation/ProbabilisticMetricHardwareFailure/pmhfValue"/>
......
...@@ -26,8 +26,21 @@ ...@@ -26,8 +26,21 @@
<modelElementClass modelElementClass="org.fortiss.af3.component.model.Component"/> <modelElementClass modelElementClass="org.fortiss.af3.component.model.Component"/>
</annotation> </annotation>
<annotation binding="org.fortiss.af3.safety.annotation.valueprovider.SafetyIntegrityLevelValueProvider">
<modelElementClass modelElementClass="org.fortiss.af3.platform.model.PlatformArchitecture"/>
</annotation>
<annotation binding="org.fortiss.af3.safety.annotation.valueprovider.SafetyIntegrityLevelValueProvider"> <annotation binding="org.fortiss.af3.safety.annotation.valueprovider.SafetyIntegrityLevelValueProvider">
<modelElementClass modelElementClass="org.fortiss.af3.platform.model.generic.GenericExecutionUnit"/> <modelElementClass modelElementClass="org.fortiss.af3.platform.model.generic.GenericExecutionUnit"/>
</annotation> </annotation>
<annotation binding="org.fortiss.af3.safety.annotation.valueprovider.SafetyIntegrityLevelValueProvider">
<modelElementClass modelElementClass="org.fortiss.af3.platform.hierarchic.model.node.Node"/>
</annotation>
<annotation binding="org.fortiss.af3.safety.annotation.valueprovider.SafetyIntegrityLevelValueProvider">
<modelElementClass modelElementClass="org.fortiss.af3.platform.hierarchic.model.tile.Tile"/>
</annotation>
<annotation binding="org.fortiss.af3.safety.annotation.valueprovider.SafetyIntegrityLevelValueProvider">
<modelElementClass modelElementClass="org.fortiss.af3.platform.hierarchic.model.processor.Core"/>
</annotation>
</extension> </extension>
</plugin> </plugin>
HwComplexityValueProvider.java 23583ed930bbd942485e317ecf485323c7152a4f GREEN HwComplexityValueProvider.java 23583ed930bbd942485e317ecf485323c7152a4f GREEN
SafetyIntegrityLevelValueProvider.java 78f79cf24346d656220db495e707fe606e8d4430 GREEN SafetyIntegrityLevelValueProvider.java ca2f9f0a95a09407f9967c41d027eb2a66826c1b GREEN
...@@ -15,10 +15,18 @@ ...@@ -15,10 +15,18 @@
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.af3.safety.annotation.valueprovider; package org.fortiss.af3.safety.annotation.valueprovider;
import static org.fortiss.af3.safety.utils.SafetyUtils.haveDirectChildsSpecifiedSIL;
import static org.fortiss.af3.safety.utils.SafetyUtils.isElementTopElement;
import org.eclipse.emf.common.util.Enumerator; import org.eclipse.emf.common.util.Enumerator;
import org.fortiss.af3.platform.hierarchic.model.node.INodeDomain;
import org.fortiss.af3.platform.hierarchic.model.processor.IProcessorDomain;
import org.fortiss.af3.platform.hierarchic.model.tile.ITileDomain;
import org.fortiss.af3.safety.model.annotation.SafetyAnnotationPackage; import org.fortiss.af3.safety.model.annotation.SafetyAnnotationPackage;
import org.fortiss.af3.safety.model.annotation.SafetyIntegrityLevel; import org.fortiss.af3.safety.model.annotation.SafetyIntegrityLevel;
import org.fortiss.tooling.base.annotation.valueprovider.DerivedAnnotationValueProviderBase; import org.fortiss.tooling.base.annotation.valueprovider.DerivedAnnotationValueProviderBase;
import org.fortiss.tooling.base.model.element.IHierarchicElementContainer;
import org.fortiss.tooling.base.model.element.IModelElement;
/** /**
* Value provider for the {@link SafetyIntegrityLevel} annotation. Most logic is implemented in the * Value provider for the {@link SafetyIntegrityLevel} annotation. Most logic is implemented in the
...@@ -37,16 +45,35 @@ public class SafetyIntegrityLevelValueProvider ...@@ -37,16 +45,35 @@ public class SafetyIntegrityLevelValueProvider
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String getAnnotationName(SafetyIntegrityLevel specification) { public boolean canEdit(SafetyIntegrityLevel specification) {
return "Safety Level"; IModelElement modelElement = specification.getSpecificationOf();
if(isElementTopElement(modelElement)) {
return true;
}
if(modelElement instanceof INodeDomain) {
if(modelElement instanceof IHierarchicElementContainer) {
return !haveDirectChildsSpecifiedSIL(modelElement);
}
} else if(modelElement instanceof ITileDomain) {
return true;
} else if(modelElement instanceof IProcessorDomain) {
return false;
}
return super.canEdit(specification);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public <U> void setAnnotationValue(U value, SafetyIntegrityLevel specification) public <U> void setAnnotationValue(U value, SafetyIntegrityLevel specification)
throws Exception { throws Exception {
if(value instanceof Enumerator) { specification.setValue((Enumerator)value);
specification.setValue((Enumerator)value); }
}
/** {@inheritDoc} */
@Override
public String getAnnotationName(SafetyIntegrityLevel specification) {
return "Safety Level";
} }
} }
HwComplexityStaticImpl.java c2831359544871abc99c4b64d671090c5adb01cb GREEN HwComplexityStaticImpl.java c2831359544871abc99c4b64d671090c5adb01cb GREEN
SafetyIntegrityLevelStaticImpl.java 938963757f34655d8b62a4dfd9f59d7416e0a726 GREEN SafetyIntegrityLevelStaticImpl.java 7cfba4594a028154f4b551cc93ade81306747864 GREEN
...@@ -15,12 +15,18 @@ ...@@ -15,12 +15,18 @@
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.af3.safety.model.annotation.impl; package org.fortiss.af3.safety.model.annotation.impl;
import static java.util.Collections.unmodifiableMap;
import static org.fortiss.af3.safety.utils.SafetyUtils.getLowestChildSafetyLevelValue;
import static org.fortiss.af3.safety.utils.SafetyUtils.getSafetyEnumeratorOf; import static org.fortiss.af3.safety.utils.SafetyUtils.getSafetyEnumeratorOf;
import static org.fortiss.af3.safety.utils.SafetyUtils.getSafetyIntegrityLevelEnumOf;
import static org.fortiss.af3.safety.utils.SafetyUtils.getSafetyStandardOf; import static org.fortiss.af3.safety.utils.SafetyUtils.getSafetyStandardOf;
import static org.fortiss.af3.safety.utils.SafetyUtils.haveDirectChildsSpecifiedSIL;
import static org.fortiss.af3.safety.utils.SafetyUtils.isElementTopElement;
import static org.fortiss.tooling.base.utils.AnnotationUtils.getAnnotation;
import static org.fortiss.tooling.base.utils.AnnotationUtils.getAnnotationValue;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType; import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getParentElement; import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getParentElement;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -29,15 +35,19 @@ import org.eclipse.emf.common.util.Enumerator; ...@@ -29,15 +35,19 @@ import org.eclipse.emf.common.util.Enumerator;
import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EOperation; import org.eclipse.emf.ecore.EOperation;
import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.EStructuralFeature;
import org.fortiss.af3.component.model.Component; import org.fortiss.af3.platform.hierarchic.model.node.INodeDomain;
import org.fortiss.af3.component.model.ComponentArchitecture; import org.fortiss.af3.platform.hierarchic.model.processor.IProcessorDomain;
import org.fortiss.af3.platform.hierarchic.model.tile.ITileDomain;
import org.fortiss.af3.safety.model.ASIL; import org.fortiss.af3.safety.model.ASIL;
import org.fortiss.af3.safety.model.DAL; import org.fortiss.af3.safety.model.DAL;
import org.fortiss.af3.safety.model.SIL; import org.fortiss.af3.safety.model.SIL;
import org.fortiss.af3.safety.model.SafetyStandard; import org.fortiss.af3.safety.model.SafetyStandard;
import org.fortiss.af3.safety.model.annotation.SafetyAnnotationPackage; import org.fortiss.af3.safety.model.annotation.SafetyAnnotationPackage;
import org.fortiss.af3.safety.model.annotation.SafetyIntegrityLevel; import org.fortiss.af3.safety.model.annotation.SafetyIntegrityLevel;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.base.model.element.IHierarchicElementContainer;
import org.fortiss.tooling.base.model.element.IModelElement; import org.fortiss.tooling.base.model.element.IModelElement;
import org.fortiss.tooling.base.model.element.IModelElementSpecification;
import org.fortiss.tooling.kernel.model.IProjectRootElement; import org.fortiss.tooling.kernel.model.IProjectRootElement;
/** /**
...@@ -52,7 +62,7 @@ public class SafetyIntegrityLevelStaticImpl { ...@@ -52,7 +62,7 @@ public class SafetyIntegrityLevelStaticImpl {
* DO178B/C. * DO178B/C.
*/ */
private static final Map<ASIL, DAL> asilToDalConvMap = private static final Map<ASIL, DAL> asilToDalConvMap =
Collections.unmodifiableMap(new HashMap<ASIL, DAL>() { unmodifiableMap(new HashMap<ASIL, DAL>() {
{ {
put(ASIL.QM, DAL.DALE); put(ASIL.QM, DAL.DALE);
put(ASIL.ASILA, DAL.DALD); put(ASIL.ASILA, DAL.DALD);
...@@ -67,7 +77,7 @@ public class SafetyIntegrityLevelStaticImpl { ...@@ -67,7 +77,7 @@ public class SafetyIntegrityLevelStaticImpl {
* IEC61508. * IEC61508.
*/ */
private static final Map<ASIL, SIL> asilToSilConvMap = private static final Map<ASIL, SIL> asilToSilConvMap =
Collections.unmodifiableMap(new HashMap<ASIL, SIL>() { unmodifiableMap(new HashMap<ASIL, SIL>() {
{ {
put(ASIL.QM, SIL.SIL0); put(ASIL.QM, SIL.SIL0);
put(ASIL.ASILA, SIL.SIL1); put(ASIL.ASILA, SIL.SIL1);
...@@ -82,7 +92,7 @@ public class SafetyIntegrityLevelStaticImpl { ...@@ -82,7 +92,7 @@ public class SafetyIntegrityLevelStaticImpl {
* ISO26262. * ISO26262.
*/ */
private static final Map<DAL, ASIL> dalToAsilConvMap = private static final Map<DAL, ASIL> dalToAsilConvMap =
Collections.unmodifiableMap(new HashMap<DAL, ASIL>() { unmodifiableMap(new HashMap<DAL, ASIL>() {
{ {
put(DAL.DALE, ASIL.QM); put(DAL.DALE, ASIL.QM);
put(DAL.DALD, ASIL.ASILA); put(DAL.DALD, ASIL.ASILA);
...@@ -96,23 +106,22 @@ public class SafetyIntegrityLevelStaticImpl { ...@@ -96,23 +106,22 @@ public class SafetyIntegrityLevelStaticImpl {
* Map encoding the conversion rules if the safety standard in changed from ISO26262 to * Map encoding the conversion rules if the safety standard in changed from ISO26262 to
* IEC61508. * IEC61508.
*/ */
private static final Map<DAL, SIL> dalToSilConvMap = private static final Map<DAL, SIL> dalToSilConvMap = unmodifiableMap(new HashMap<DAL, SIL>() {
Collections.unmodifiableMap(new HashMap<DAL, SIL>() { {
{ put(DAL.DALE, SIL.SIL0);
put(DAL.DALE, SIL.SIL0); put(DAL.DALD, SIL.SIL1);
put(DAL.DALD, SIL.SIL1); put(DAL.DALC, SIL.SIL2);
put(DAL.DALC, SIL.SIL2); put(DAL.DALB, SIL.SIL3);
put(DAL.DALB, SIL.SIL3); put(DAL.DALA, SIL.SIL4);
put(DAL.DALA, SIL.SIL4); }
} });
});
/** /**
* Map encoding the conversion rules if the safety standard in changed from IEC61508 to * Map encoding the conversion rules if the safety standard in changed from IEC61508 to
* ISO26262. * ISO26262.
*/ */
private static final Map<SIL, ASIL> silToAsilConvMap = private static final Map<SIL, ASIL> silToAsilConvMap =
Collections.unmodifiableMap(new HashMap<SIL, ASIL>() { unmodifiableMap(new HashMap<SIL, ASIL>() {
{ {
put(SIL.SIL0, ASIL.ASILA); put(SIL.SIL0, ASIL.ASILA);
put(SIL.SIL1, ASIL.ASILA); put(SIL.SIL1, ASIL.ASILA);
...@@ -126,50 +135,55 @@ public class SafetyIntegrityLevelStaticImpl { ...@@ -126,50 +135,55 @@ public class SafetyIntegrityLevelStaticImpl {
* Map encoding the conversion rules if the safety standard in changed from IEC61508 to * Map encoding the conversion rules if the safety standard in changed from IEC61508 to
* DO178B/C. * DO178B/C.
*/ */
private static final Map<SIL, DAL> silToDalConvMap = private static final Map<SIL, DAL> silToDalConvMap = unmodifiableMap(new HashMap<SIL, DAL>() {
Collections.unmodifiableMap(new HashMap<SIL, DAL>() { {
{ put(SIL.SIL0, DAL.DALE);
put(SIL.SIL0, DAL.DALE); put(SIL.SIL1, DAL.DALD);
put(SIL.SIL1, DAL.DALD); put(SIL.SIL2, DAL.DALC);
put(SIL.SIL2, DAL.DALC); put(SIL.SIL3, DAL.DALB);
put(SIL.SIL3, DAL.DALB); put(SIL.SIL4, DAL.DALA);
put(SIL.SIL4, DAL.DALA); }
} });
});
/** /**
* Returns the safety level that is compatible with the domain in for which * Determines the {@link SafetyStandard}-specific Enumerator that encodes the safety level of
* the architecture is defined. * the given {@link SafetyIntegrityLevel} {@link IModelElementSpecification}. Here, a
* distinction for the achievable safety level of HW elements is done.
*/ */
public static Enumerator getDerivedValue(SafetyIntegrityLevel specification) { public static Enumerator getDerivedValue(SafetyIntegrityLevel specification) {
IModelElement modelElement = specification.getSpecificationOf(); IModelElement modelElement = specification.getSpecificationOf();
IProjectRootElement rootElement = if(modelElement instanceof INodeDomain) {
getParentElement(modelElement, IProjectRootElement.class, false); if(modelElement instanceof IHierarchicElementContainer) {
SafetyStandard safetyStandard = getSafetyStandardOf(specification); if(haveDirectChildsSpecifiedSIL(modelElement)) {
Integer lowestChildSIL = getLowestChildSafetyLevelValue(specification, false);
boolean isRootStandardUndefined = return (Enumerator)getSafetyIntegrityLevelEnumOf(specification)[lowestChildSIL];
safetyStandard == SafetyStandard.UNDEFINED && modelElement == rootElement; }
return specification.getUserAnnotatedValue();
if(isRootStandardUndefined || isElementTopComponent(modelElement)) { }
return safetyStandard; } else if(modelElement instanceof ITileDomain) {
// Return the parent SIL, if unspecified. Here, only the user annotated value is
// considered --> otherwise, there is a pingpong play between tiles and nodes.
Enumerator value = specification.getUserAnnotatedValue();
if(value == null && modelElement instanceof IHierarchicElement) {
IModelElement parent =
(IModelElement)((IHierarchicElement)modelElement).getContainer();
SafetyIntegrityLevel parentAnn = getAnnotation(parent, SafetyIntegrityLevel.class);
return parentAnn.getUserAnnotatedValue();
}
} else if(modelElement instanceof IProcessorDomain) {
if(modelElement instanceof IHierarchicElement) {
IModelElement parent =
(IModelElement)((IHierarchicElement)modelElement).getContainer();
return getAnnotationValue(parent, SafetyIntegrityLevel.class, Enumerator.class);
}
} }
return (Enumerator)specification.eGet(getSafetyEnumeratorOf(safetyStandard));
}
/** return specification.getUserAnnotatedValue();
* Returns whether the given {@link IModelElement} is the top {@link Component} of a }
* {@link ComponentArchitecture}.
*/
private static boolean isElementTopComponent(IModelElement element) {
IProjectRootElement rootElement =
getParentElement(element, IProjectRootElement.class, false);
if(rootElement instanceof ComponentArchitecture) { /** Returns the user annotated value based on the root {@link SafetyStandard}. */
if(((ComponentArchitecture)rootElement).getTopComponent() == element) { public static Enumerator getUserAnnotatedValue(SafetyIntegrityLevelImpl specification) {
return true; return specification.getSelectedSafetyLevel();
}
}
return false;
} }
/** /**
...@@ -193,7 +207,7 @@ public class SafetyIntegrityLevelStaticImpl { ...@@ -193,7 +207,7 @@ public class SafetyIntegrityLevelStaticImpl {
SafetyStandard safetyStandard = getSafetyStandardOf(specification); SafetyStandard safetyStandard = getSafetyStandardOf(specification);
if(modelElement == rootElement || isElementTopComponent(modelElement)) { if(modelElement == rootElement || isElementTopElement(modelElement)) {
return SafetyAnnotationPackage.Literals.SAFETY_INTEGRITY_LEVEL__SAFETY_STANDARD; return SafetyAnnotationPackage.Literals.SAFETY_INTEGRITY_LEVEL__SAFETY_STANDARD;
} }
return getSafetyEnumeratorOf(safetyStandard); return getSafetyEnumeratorOf(safetyStandard);
...@@ -217,7 +231,8 @@ public class SafetyIntegrityLevelStaticImpl { ...@@ -217,7 +231,8 @@ public class SafetyIntegrityLevelStaticImpl {
SafetyStandard safetyStandard = getSafetyStandardOf(specification); SafetyStandard safetyStandard = getSafetyStandardOf(specification);
if(safetyStandard != SafetyStandard.UNDEFINED) { if(safetyStandard != SafetyStandard.UNDEFINED) {
specification.eSet(getSafetyEnumeratorOf(safetyStandard), value); specification.eSet(getSafetyEnumeratorOf(safetyStandard), value);
return (Enumerator)specification.eGet(getSafetyEnumeratorOf(safetyStandard)); specification.setSelectedSafetyLevel(value);
return specification.getSelectedSafetyLevel();
} }
return null; return null;
......
SafetyUtils.java 91d4175f46ad59928d4aa6eed4a6147628e29ab0 GREEN SafetyUtils.java 7c920d22d4432cdebc7493a968e32035fd21c32a GREEN
package org.fortiss.af3.safety.utils; package org.fortiss.af3.safety.utils;
import static java.lang.Math.max; import static java.lang.Math.max;
import static java.util.stream.Collectors.toList;
import static org.fortiss.tooling.base.utils.AnnotationUtils.getAnnotation; import static org.fortiss.tooling.base.utils.AnnotationUtils.getAnnotation;
import static org.fortiss.tooling.base.utils.AnnotationUtils.getAnnotationValue;
import static org.fortiss.tooling.base.utils.AnnotationUtils.getParentAnnotationsWithType; import static org.fortiss.tooling.base.utils.AnnotationUtils.getParentAnnotationsWithType;
import static org.fortiss.tooling.common.util.LambdaUtils.filterByType;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getParentElement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import org.conqat.lib.commons.collections.Pair; import org.conqat.lib.commons.collections.Pair;
import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.Enumerator; import org.eclipse.emf.common.util.Enumerator;
import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.ComponentArchitecture;
import org.fortiss.af3.platform.model.ExecutionUnit;
import org.fortiss.af3.platform.model.generic.GenericExecutionUnit; import org.fortiss.af3.platform.model.generic.GenericExecutionUnit;
import org.fortiss.af3.platform.model.generic.GenericTransmissionUnit; import org.fortiss.af3.platform.model.generic.GenericTransmissionUnit;
import org.fortiss.af3.safety.model.ASIL; import org.fortiss.af3.safety.model.ASIL;
...@@ -23,7 +33,9 @@ import org.fortiss.af3.safety.model.SIL; ...@@ -23,7 +33,9 @@ import org.fortiss.af3.safety.model.SIL;
import org.fortiss.af3.safety.model.SafetyStandard; import org.fortiss.af3.safety.model.SafetyStandard;
import org.fortiss.af3.safety.model.annotation.SafetyAnnotationPackage; import org.fortiss.af3.safety.model.annotation.SafetyAnnotationPackage;
import org.fortiss.af3.safety.model.annotation.SafetyIntegrityLevel; import org.fortiss.af3.safety.model.annotation.SafetyIntegrityLevel;
import org.fortiss.tooling.base.model.element.IHierarchicElementContainer;
import org.fortiss.tooling.base.model.element.IModelElement; import org.fortiss.tooling.base.model.element.IModelElement;