Search in sources :

Example 6 with ErrorBehaviorState

use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState 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 7 with ErrorBehaviorState

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

the class ErrorModelValidator method checkTransitionSourceTypes.

private void checkTransitionSourceTypes(ErrorBehaviorTransition ebt) {
    ErrorBehaviorState ebs = ebt.getSource();
    if (ebs == null) {
        return;
    }
    TypeSet ebsTS = ebs.getTypeSet();
    TypeSet srcTS = ebt.getTypeTokenConstraint();
    if (srcTS == null) {
        return;
    }
    if (ebsTS == null && srcTS != null) {
        error(ebt, "Source state " + ebs.getName() + " does not have a type set declared but the transition source specifies " + EMV2Util.getPrintName(srcTS));
    } else if (!EMV2TypeSetUtil.contains(ebsTS, srcTS)) {
        error(ebt, "Source type " + EMV2Util.getPrintName(srcTS) + " is not contained in type set of error behavior state \'" + ebs.getName() + "\'");
    }
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet)

Example 8 with ErrorBehaviorState

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

the class ErrorModelValidator method checkOutgoingConditionSourceTypes.

private void checkOutgoingConditionSourceTypes(OutgoingPropagationCondition opc) {
    ErrorBehaviorState ebs = opc.getState();
    if (ebs == null) {
        return;
    }
    TypeSet ebsTS = ebs.getTypeSet();
    TypeSet srcTS = opc.getTypeTokenConstraint();
    if (srcTS == null) {
        return;
    }
    if (ebsTS == null && srcTS != null) {
        error(opc, "Error state " + ebs.getName() + " does not have a type set declared but the outgoing propagation condition has type token " + EMV2Util.getPrintName(srcTS));
    } else if (!EMV2TypeSetUtil.contains(ebsTS, srcTS)) {
        error(opc, "Outgoing condition state type set " + EMV2Util.getPrintName(srcTS) + " is not contained in type set of error behavior state \'" + ebs.getName() + "\'");
    }
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet)

Example 9 with ErrorBehaviorState

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

the class EMV2Util method getAllErrorBehaviorStates.

/**
 * return list of ErrorBehaviorStates including those inherited from classifiers being extended
 * @param cl Classifier
 * @return Collection<ErrorBehaviorState> list of ErrorBehaviorStates as HashMap for quick lookup of names
 */
public static Collection<ErrorBehaviorState> getAllErrorBehaviorStates(Classifier cl) {
    HashMap<String, ErrorBehaviorState> result = new LinkedHashMap<>();
    EList<ErrorModelSubclause> emslist = getAllContainingClassifierEMV2Subclauses(cl);
    for (ErrorModelSubclause errorModelSubclause : emslist) {
        ErrorBehaviorStateMachine ebsm = errorModelSubclause.getUseBehavior();
        if (ebsm != null) {
            EList<ErrorBehaviorState> eflist = ebsm.getStates();
            for (ErrorBehaviorState ebs : eflist) {
                if (!result.containsKey(ebs.getName())) {
                    result.put(ebs.getName(), ebs);
                }
            }
            return result.values();
        }
    }
    return Collections.emptyList();
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) QualifiedErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.QualifiedErrorBehaviorState) ErrorModelSubclause(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause) ErrorBehaviorStateMachine(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorStateMachine) LinkedHashMap(java.util.LinkedHashMap)

Example 10 with ErrorBehaviorState

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

the class ErrorModelValidator method checkTransitionTargetTypes.

private void checkTransitionTargetTypes(TransitionBranch ebt) {
    if (ebt.isSteadyState()) {
        return;
    }
    ErrorBehaviorState ebs = ebt.getTarget();
    if (ebs != null) {
        TypeSet ebsTS = ebs.getTypeSet();
        TypeSet tt = ebt.getTargetToken();
        if (tt == null || tt.getTypeTokens().isEmpty()) {
            return;
        }
        TypeToken ebtargetTS = tt.getTypeTokens().get(0);
        if (ebtargetTS == null) {
            return;
        }
        if (ebsTS == null && ebtargetTS != null) {
            error(ebt, "Target state " + ebs.getName() + " does not have a type set declared but the transition target specifies " + EMV2Util.getPrintName(ebtargetTS));
        } else if (!EMV2TypeSetUtil.contains(ebsTS, ebtargetTS)) {
            error(ebt, "Target type " + EMV2Util.getPrintName(ebt.getTargetToken()) + " is not contained in type set of error behavior state \'" + ebs.getName() + "\'");
        }
    }
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet)

Aggregations

ErrorBehaviorState (org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState)35 TypeSet (org.osate.xtext.aadl2.errormodel.errorModel.TypeSet)20 ErrorPropagation (org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)14 TypeToken (org.osate.xtext.aadl2.errormodel.errorModel.TypeToken)14 ErrorEvent (org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent)12 EObject (org.eclipse.emf.ecore.EObject)9 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)9 ConditionElement (org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement)7 ErrorBehaviorTransition (org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorTransition)7 NamedElement (org.osate.aadl2.NamedElement)6 QualifiedErrorBehaviorState (org.osate.xtext.aadl2.errormodel.errorModel.QualifiedErrorBehaviorState)6 LinkedList (java.util.LinkedList)5 EList (org.eclipse.emf.common.util.EList)5 ConditionExpression (org.osate.xtext.aadl2.errormodel.errorModel.ConditionExpression)5 EMV2PropertyAssociation (org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation)5 ErrorSource (org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource)4 ErrorType (org.osate.xtext.aadl2.errormodel.errorModel.ErrorType)4 EventOrPropagation (org.osate.xtext.aadl2.errormodel.errorModel.EventOrPropagation)4 SConditionElement (org.osate.xtext.aadl2.errormodel.errorModel.SConditionElement)4 BigDecimal (java.math.BigDecimal)3