Search in sources :

Example 1 with ErrorPropagation

use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation in project osate2 by osate.

the class ErrorPathImpl method setIncoming.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setIncoming(ErrorPropagation newIncoming) {
    ErrorPropagation oldIncoming = incoming;
    incoming = newIncoming;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, ErrorModelPackage.ERROR_PATH__INCOMING, oldIncoming, incoming));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)

Example 2 with ErrorPropagation

use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation in project osate2 by osate.

the class ErrorModelValidator method checkConditionElementType.

private void checkConditionElementType(ConditionElement conditionElement) {
    EventOrPropagation ep = EMV2Util.getErrorEventOrPropagation(conditionElement);
    if (ep == null) {
        return;
    }
    TypeSet triggerTS = null;
    String triggerName = "";
    if (ep instanceof ErrorPropagation) {
        triggerTS = ((ErrorPropagation) ep).getTypeSet();
        triggerName = "propagation " + EMV2Util.getPrintName((ErrorPropagation) ep);
    } else if (ep instanceof ErrorEvent) {
        triggerTS = ((ErrorEvent) ep).getTypeSet();
        triggerName = "event " + ((ErrorBehaviorEvent) ep).getName();
    }
    TypeSet condTS = conditionElement.getConstraint();
    if (condTS == null) {
        return;
    }
    if (triggerTS == null && condTS != null) {
        // it is ok for a state not to have a type set.
        error(conditionElement, "Condition has type constraint but referenced " + triggerName + " does not.");
    } else if (!EMV2TypeSetUtil.isNoError(condTS) && !EMV2TypeSetUtil.contains(triggerTS, condTS)) {
        error(conditionElement, "Condition type constraint " + EMV2Util.getPrintName(condTS) + "is not contained in type set " + EMV2Util.getPrintName(triggerTS) + "of referenced " + triggerName);
    }
}
Also used : TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent) EventOrPropagation(org.osate.xtext.aadl2.errormodel.errorModel.EventOrPropagation) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)

Example 3 with ErrorPropagation

use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation in project osate2 by osate.

the class ErrorModelValidator method checkTransitionTargetTriggerTypes.

private void checkTransitionTargetTriggerTypes(ErrorBehaviorTransition ebt) {
    if (ebt.isSteadyState()) {
        return;
    }
    ErrorBehaviorState targetstate = ebt.getTarget();
    if (targetstate != null) {
        TypeSet targetTS = targetstate.getTypeSet();
        if (targetTS == null) {
            return;
        }
        TypeSet tt = ebt.getTargetToken();
        if (tt != null) {
            return;
        }
        // state requires a type
        if (ebt.getCondition() instanceof ConditionElement) {
            // either the event must be typed or the source state must be typed
            EventOrPropagation ep = EMV2Util.getErrorEventOrPropagation((ConditionElement) ebt.getCondition());
            if (ep instanceof ErrorEvent) {
                ErrorEvent ev = (ErrorEvent) ep;
                TypeSet evTS = ev.getTypeSet();
                if (evTS == null) {
                    TypeSet srcTS = ebt.getSource().getTypeSet();
                    if (srcTS == null) {
                        error(ebt, "Target state " + targetstate.getName() + " requires type but the triggering error event " + EMV2Util.getPrintName(ev) + " or source state " + EMV2Util.getPrintName(ebt.getSource()) + " does not have a type");
                    } else {
                        // source typeset must be contained in target type set
                        if (!EMV2TypeSetUtil.contains(targetTS, srcTS)) {
                            error(ebt, "Target state " + targetstate.getName() + " does not contain types of source state " + EMV2Util.getPrintName(ebt.getSource()));
                        }
                    }
                } else {
                    // error event has type. It must be consistent with the expected state type
                    if (!EMV2TypeSetUtil.contains(targetTS, evTS)) {
                        error(ebt, "Target state " + targetstate.getName() + " does not contain types of error event " + EMV2Util.getPrintName(ev));
                    }
                }
            } else if (ep instanceof ErrorPropagation) {
                ErrorPropagation eprop = (ErrorPropagation) ep;
                // we can check type compatibility
                if (!EMV2TypeSetUtil.contains(targetTS, eprop.getTypeSet())) {
                    error(ebt, "Target state " + targetstate.getName() + " does not contain types of error propagation " + EMV2Util.getPrintName(eprop));
                }
            }
        } else {
            // full condition expression
            // type transformation & events must be typed
            ErrorBehaviorStateMachine ebsm = (ErrorBehaviorStateMachine) targetstate.eContainer();
            if (ebsm.getUseTransformation().isEmpty()) {
                error(ebt, "Target state " + targetstate.getName() + " does not include a target type but requires types. For conditions on multiple elements a target type must be assigned explicitly or a type transformation must be specified in the error behavior state machine" + EMV2Util.getPrintName(ebsm));
            }
        }
    }
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) SConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.SConditionElement) ConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) ErrorBehaviorStateMachine(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorStateMachine) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent) EventOrPropagation(org.osate.xtext.aadl2.errormodel.errorModel.EventOrPropagation) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)

Example 4 with ErrorPropagation

use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation in project osate2 by osate.

the class ErrorModelValidator method checkAssociationAppliesTo.

private void checkAssociationAppliesTo(final EMV2PropertyAssociation pa) {
    final Property pn = pa.getProperty();
    final EList<EMV2Path> appliesTo = pa.getEmv2Path();
    if (appliesTo == null || appliesTo.size() == 0) {
        Element element = pa.getOwner();
        if (element instanceof NamedElement) {
            final boolean applies = ((NamedElement) element).acceptsProperty(pn);
            if (!applies) {
                error(pa, "Property " + pa.getProperty().getQualifiedName() + " does not apply to " + ((NamedElement) element).getName());
            // error(pa,
            // "Property " + pa.getQualifiedName() +
            // " does not apply to " + element.eClass().getName());
            }
        }
    } else {
        for (EMV2Path cna : appliesTo) {
            EMV2PathElement path = cna.getEmv2Target();
            if (path != null) {
                // only the last value is interesting to us
                final EMV2PathElement ph = EMV2Util.getLast(path);
                NamedElement ne = ph.getNamedElement();
                if (ne instanceof ErrorTypes) {
                    ErrorTypes et = (ErrorTypes) ne;
                    EObject prev = ph.eContainer();
                    if (prev instanceof EMV2PathElement) {
                        ne = ((EMV2PathElement) prev).getNamedElement();
                        boolean noMatch = false;
                        if (ne instanceof ErrorBehaviorState) {
                            TypeSet ts = ((ErrorBehaviorState) ne).getTypeSet();
                            noMatch = ts != null && !EMV2TypeSetUtil.contains(ts, et);
                        } else if (ne instanceof ErrorPropagation) {
                            String epname = EMV2Util.getPrintName((ErrorPropagation) ne);
                            EList<ErrorPropagation> eplist = EMV2Util.getContainingErrorModelSubclause(ne).getPropagations();
                            Boolean foundType = false;
                            for (ErrorPropagation ep : eplist) {
                                if (epname.equalsIgnoreCase(EMV2Util.getPrintName(ep))) {
                                    TypeSet ts = ep.getTypeSet();
                                    if (EMV2TypeSetUtil.contains(ts, et)) {
                                        foundType = true;
                                        break;
                                    }
                                }
                            }
                            noMatch = !foundType;
                        } else if (ne instanceof ErrorEvent) {
                            TypeSet ts = ((ErrorEvent) ne).getTypeSet();
                            noMatch = ts != null && !EMV2TypeSetUtil.contains(ts, et);
                        }
                        if (noMatch) {
                            error(pa, "Property " + pa.getProperty().getQualifiedName() + " applies to refers to type " + EMV2Util.getPrintName(et) + " not contained in type set of error propagation " + EMV2Util.getPrintName(ne));
                        }
                    }
                }
                if (!Aadl2Util.isNull(ne)) {
                    final boolean applies = ph.getNamedElement().acceptsProperty(pn);
                    if (!applies) {
                        error(pa, "Property " + pa.getProperty().getQualifiedName() + " does not apply to " + EMV2Util.getPrintName(cna));
                    }
                }
            }
        }
    }
}
Also used : EMV2PathElement(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement) ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) Element(org.osate.aadl2.Element) EMV2PathElement(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement) SConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.SConditionElement) ConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) ErrorTypes(org.osate.xtext.aadl2.errormodel.errorModel.ErrorTypes) EMV2Path(org.osate.xtext.aadl2.errormodel.errorModel.EMV2Path) BasicEList(org.eclipse.emf.common.util.BasicEList) EList(org.eclipse.emf.common.util.EList) EObject(org.eclipse.emf.ecore.EObject) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) Property(org.osate.aadl2.Property) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement)

Example 5 with ErrorPropagation

use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation in project osate2 by osate.

the class ErrorModelValidator method caseErrorModelSubclause.

@Check(CheckType.FAST)
public void caseErrorModelSubclause(ErrorModelSubclause subclause) {
    if (EcoreUtil2.getContainerOfType(subclause, FeatureGroupType.class) != null) {
        error("Error model subclauses are not permitted in feature group types.", EcoreUtil2.getContainerOfType(subclause, DefaultAnnexSubclause.class), Aadl2Package.eINSTANCE.getNamedElement_Name());
        return;
    }
    checkSubclauseAssociationToClassifier(subclause);
    checkDuplicateSubclause(subclause);
    checkOnePropagationAndContainmentPoint(subclause);
    Collection<NamedElement> names = EMV2Util.getAllNamedElements(subclause);
    List<NamedElement> doubles = EMV2Util.findDoubleNamedElementsInList(names);
    for (NamedElement namedElement : doubles) {
        if (!(namedElement instanceof ErrorPropagation)) {
            error(namedElement, "Subclause has more than one element with the name '" + namedElement.getName() + "'.");
        }
    }
    Collection<ErrorPropagation> ins = EMV2Util.getAllIncomingErrorPropagations(subclause.getContainingClassifier());
    for (ErrorPropagation errorPropagation : ins) {
        checkTypePropagationAndContainment(errorPropagation);
    }
    Collection<ErrorPropagation> outs = EMV2Util.getAllOutgoingErrorPropagations(subclause.getContainingClassifier());
    for (ErrorPropagation errorPropagation : outs) {
        checkTypePropagationAndContainment(errorPropagation);
    }
    checkUseBehavior(subclause);
}
Also used : FeatureGroupType(org.osate.aadl2.FeatureGroupType) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) DefaultAnnexSubclause(org.osate.aadl2.DefaultAnnexSubclause) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) Check(org.eclipse.xtext.validation.Check)

Aggregations

ErrorPropagation (org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)64 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)20 TypeSet (org.osate.xtext.aadl2.errormodel.errorModel.TypeSet)20 TypeToken (org.osate.xtext.aadl2.errormodel.errorModel.TypeToken)18 NamedElement (org.osate.aadl2.NamedElement)15 ErrorBehaviorState (org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState)15 ErrorEvent (org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent)15 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)13 EObject (org.eclipse.emf.ecore.EObject)10 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)10 ErrorSource (org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource)10 Classifier (org.osate.aadl2.Classifier)8 ConditionElement (org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement)7 ErrorFlow (org.osate.xtext.aadl2.errormodel.errorModel.ErrorFlow)7 BasicEList (org.eclipse.emf.common.util.BasicEList)6 ErrorModelSubclause (org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause)6 PropagationPoint (org.osate.xtext.aadl2.errormodel.errorModel.PropagationPoint)6 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)5 Event (org.osate.aadl2.errormodel.FaultTree.Event)5 ErrorPath (org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath)5