Commit 1f28b75b authored by Alexander Diewald's avatar Alexander Diewald
Browse files

YELLOW: Safety-Annotation: Improve null value support

* Introduce a new Enumerator for the SafetyIntegrityLevel annotation
  that allows to specify unset values by pointing to null. In case a
  value is set for an IModelElement, the attribute points to the
  standard specific enum.
* Update the haveDirectChildsSpecifiedSIL(...) method to consider only
  directly set safety levels of IModelElements.

Issue-Ref: 3859
Issue-Url: https://af3-developer.fortiss.org/issues/3859

Signed-off-by: Alexander Diewald's avatarAlexander Diewald <diewald@fortiss.org>
parent a866c9f9
safety.ecore 6394bb80e33ae0d0720bbd0ecea7164ab5c5d275 YELLOW
safety.ecore b92e234ad28258eae391834e4571396e2176ab0a YELLOW
......@@ -115,6 +115,9 @@
<details key="documentation" value="Dummy attributed used when saftey standard is set to {@code undefined}."/>
</eAnnotations>
</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">
<eTypeArguments eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EEnumerator"/>
</eGenericSuperTypes>
......
......@@ -65,6 +65,7 @@
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute safety.ecore#//annotation/SafetyIntegrityLevel/dalValue"/>
<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 createChild="false" ecoreFeature="ecore:EAttribute safety.ecore#//annotation/SafetyIntegrityLevel/selectedSafetyLevel"/>
<genOperations ecoreOperation="safety.ecore#//annotation/SafetyIntegrityLevel/getDerivedValue"
body="return SafetyIntegrityLevelStaticImpl.getDerivedValue(this);"/>
<genOperations ecoreOperation="safety.ecore#//annotation/SafetyIntegrityLevel/getDerivedFeature"
......
HwComplexityValueProvider.java 23583ed930bbd942485e317ecf485323c7152a4f GREEN
SafetyIntegrityLevelValueProvider.java 1d61a51eced9f7602a4b0d7aca0824c1963857e6 YELLOW
SafetyIntegrityLevelValueProvider.java ca2f9f0a95a09407f9967c41d027eb2a66826c1b YELLOW
......@@ -18,6 +18,7 @@ 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.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;
......@@ -63,6 +64,13 @@ public class SafetyIntegrityLevelValueProvider
return super.canEdit(specification);
}
/** {@inheritDoc} */
@Override
public <U> void setAnnotationValue(U value, SafetyIntegrityLevel specification)
throws Exception {
specification.setValue((Enumerator)value);
}
/** {@inheritDoc} */
@Override
public String getAnnotationName(SafetyIntegrityLevel specification) {
......
HwComplexityStaticImpl.java c2831359544871abc99c4b64d671090c5adb01cb GREEN
SafetyIntegrityLevelStaticImpl.java 9783e771570bb8b6ac6bbd0eceea7a139ce3be67 YELLOW
SafetyIntegrityLevelStaticImpl.java 7cfba4594a028154f4b551cc93ade81306747864 YELLOW
......@@ -15,11 +15,11 @@
+--------------------------------------------------------------------------*/
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.getSafetyIntegrityLevelEnumOf;
import static org.fortiss.af3.safety.utils.SafetyUtils.getSafetyStandardOf;
import static org.fortiss.af3.safety.utils.SafetyUtils.getStandardSpecificValue;
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;
......@@ -27,7 +27,6 @@ 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.KernelModelElementUtils.getParentElement;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -63,7 +62,7 @@ public class SafetyIntegrityLevelStaticImpl {
* DO178B/C.
*/
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.ASILA, DAL.DALD);
......@@ -78,7 +77,7 @@ public class SafetyIntegrityLevelStaticImpl {
* IEC61508.
*/
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.ASILA, SIL.SIL1);
......@@ -93,7 +92,7 @@ public class SafetyIntegrityLevelStaticImpl {
* ISO26262.
*/
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.DALD, ASIL.ASILA);
......@@ -107,8 +106,7 @@ public class SafetyIntegrityLevelStaticImpl {
* Map encoding the conversion rules if the safety standard in changed from ISO26262 to
* IEC61508.
*/
private static final Map<DAL, SIL> dalToSilConvMap =
Collections.unmodifiableMap(new HashMap<DAL, SIL>() {
private static final Map<DAL, SIL> dalToSilConvMap = unmodifiableMap(new HashMap<DAL, SIL>() {
{
put(DAL.DALE, SIL.SIL0);
put(DAL.DALD, SIL.SIL1);
......@@ -123,7 +121,7 @@ public class SafetyIntegrityLevelStaticImpl {
* ISO26262.
*/
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.SIL1, ASIL.ASILA);
......@@ -137,8 +135,7 @@ public class SafetyIntegrityLevelStaticImpl {
* Map encoding the conversion rules if the safety standard in changed from IEC61508 to
* DO178B/C.
*/
private static final Map<SIL, DAL> silToDalConvMap =
Collections.unmodifiableMap(new HashMap<SIL, DAL>() {
private static final Map<SIL, DAL> silToDalConvMap = unmodifiableMap(new HashMap<SIL, DAL>() {
{
put(SIL.SIL0, DAL.DALE);
put(SIL.SIL1, DAL.DALD);
......@@ -186,7 +183,7 @@ public class SafetyIntegrityLevelStaticImpl {
/** Returns the user annotated value based on the root {@link SafetyStandard}. */
public static Enumerator getUserAnnotatedValue(SafetyIntegrityLevelImpl specification) {
return getStandardSpecificValue(specification);
return specification.getSelectedSafetyLevel();
}
/**
......@@ -234,7 +231,8 @@ public class SafetyIntegrityLevelStaticImpl {
SafetyStandard safetyStandard = getSafetyStandardOf(specification);
if(safetyStandard != SafetyStandard.UNDEFINED) {
specification.eSet(getSafetyEnumeratorOf(safetyStandard), value);
return (Enumerator)specification.eGet(getSafetyEnumeratorOf(safetyStandard));
specification.setSelectedSafetyLevel(value);
return specification.getSelectedSafetyLevel();
}
return null;
......
SafetyUtils.java 16d1b500acf4932f12eeb5a88e8a7e11483e46ce YELLOW
SafetyUtils.java 835282ebd69ca332d1b14b5efd47ff5a6ce20760 YELLOW
......@@ -216,8 +216,9 @@ public class SafetyUtils {
.collect(toList());
// get(0): safe due to size check.
boolean childrenAnnNotSet = (safetyEnums.size() == 1 && safetyEnums.get(0) == null);
return !safetyEnums.isEmpty() && !childrenAnnNotSet;
Integer maxChildSafetyLevel = safetyEnums.stream().filter(e -> e != null)
.map(e -> e.getValue()).reduce((e1, e2) -> max(e1, e2)).orElse(0);
return !safetyEnums.isEmpty() && (maxChildSafetyLevel > 0);
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment