Search in sources :

Example 11 with TypeMappingSet

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

the class ErrorModelValidator method checkConnectionErrorTypes.

private void checkConnectionErrorTypes(Connection conn) {
    ComponentImplementation cimpl = conn.getContainingComponentImpl();
    ConnectionEnd src = conn.getAllSource();
    Context srcCxt = conn.getAllSourceContext();
    ErrorPropagation srcprop = null;
    ErrorPropagation srccontain = null;
    Classifier srccl = null;
    String srcname = (src instanceof Subcomponent) ? "access" : src.getName();
    if (srcCxt instanceof Subcomponent) {
        srccl = ((Subcomponent) srcCxt).getClassifier();
    } else if (src instanceof Subcomponent) {
        srccl = ((Subcomponent) src).getClassifier();
    } else {
        srccl = cimpl;
    }
    if (srccl != null) {
        if (AadlUtil.isIncomingConnection(conn)) {
            srcprop = EMV2Util.findIncomingErrorPropagation(srccl, srcname);
            srccontain = EMV2Util.findIncomingErrorContainment(srccl, srcname);
        } else {
            srcprop = EMV2Util.findOutgoingErrorPropagation(srccl, srcname);
            srccontain = EMV2Util.findOutgoingErrorContainment(srccl, srcname);
        }
    }
    ConnectionEnd dst = conn.getAllDestination();
    Context dstCxt = conn.getAllDestinationContext();
    Classifier dstcl = null;
    ErrorPropagation dstprop = null;
    ErrorPropagation dstcontain = null;
    String dstname = (dst instanceof Subcomponent) ? "access" : dst.getName();
    if (dstCxt instanceof Subcomponent) {
        dstcl = ((Subcomponent) dstCxt).getClassifier();
    } else if (dst instanceof Subcomponent) {
        dstcl = ((Subcomponent) dst).getClassifier();
    } else {
        dstcl = cimpl;
    }
    if (dstcl != null) {
        if (AadlUtil.isOutgoingConnection(conn)) {
            dstprop = EMV2Util.findOutgoingErrorPropagation(dstcl, dstname);
            dstcontain = EMV2Util.findOutgoingErrorContainment(dstcl, dstname);
        } else {
            dstprop = EMV2Util.findIncomingErrorPropagation(dstcl, dstname);
            dstcontain = EMV2Util.findIncomingErrorContainment(dstcl, dstname);
        }
    }
    if (srcprop != null && dstprop != null) {
        if (!EMV2TypeSetUtil.contains(dstprop.getTypeSet(), srcprop.getTypeSet())) {
            TypeMappingSet typeEquivalence = EMV2Util.getAllTypeEquivalenceMapping(cimpl);
            if (typeEquivalence != null) {
                TypeToken mappedtt = EMV2TypeSetUtil.mapTypeToken(srcprop.getTypeSet(), typeEquivalence);
                if (mappedtt != null) {
                    if (!EMV2TypeSetUtil.contains(dstprop.getTypeSet(), mappedtt)) {
                        error(conn, "Source propagation  " + EMV2Util.getPrintName(srcprop) + EMV2Util.getPrintName(srcprop.getTypeSet()) + " has error types not handled by destination propagation " + EMV2Util.getPrintName(dstprop) + EMV2Util.getPrintName(dstprop.getTypeSet()));
                    }
                }
            } else {
                error(conn, "Source propagation  " + EMV2Util.getPrintName(srcprop) + EMV2Util.getPrintName(srcprop.getTypeSet()) + " has error types not handled by destination propagation " + EMV2Util.getPrintName(dstprop) + EMV2Util.getPrintName(dstprop.getTypeSet()));
            }
        }
    }
    if (srccontain != null && dstcontain != null) {
        if (!EMV2TypeSetUtil.contains(srcprop.getTypeSet(), dstprop.getTypeSet())) {
            error(conn, "Source containment  " + EMV2Util.getPrintName(srcprop) + EMV2Util.getPrintName(srcprop.getTypeSet()) + " does not contain error types listed by Source containment " + EMV2Util.getPrintName(dstprop) + EMV2Util.getPrintName(dstprop.getTypeSet()));
        }
    }
    // instance level
    if (srcCxt instanceof Subcomponent && dstCxt instanceof Subcomponent) {
        // only when going across
        if (srccontain == null && dstcontain != null) {
            EList<ErrorModelSubclause> srcsubclauses = EMV2Util.getAllContainingClassifierEMV2Subclauses(srccl);
            if (!srcsubclauses.isEmpty()) {
                warning(conn, "No outgoing containment from " + srcCxt.getName() + " for incoming containment " + EMV2Util.getPrintName(dstcontain) + EMV2Util.getPrintName(dstcontain.getTypeSet()) + ". Check for Unhandled Faults.");
            }
        }
        if (srcprop != null && dstprop == null) {
            EList<ErrorModelSubclause> dstsubclauses = EMV2Util.getAllContainingClassifierEMV2Subclauses(dstcl);
            if (!dstsubclauses.isEmpty()) {
                warning(conn, "No incoming error propagation from " + dstCxt.getName() + " for outgoing propagation " + EMV2Util.getPrintName(srcprop) + EMV2Util.getPrintName(srcprop.getTypeSet()) + ". Check for Unhandled Faults.");
            }
        }
    }
    if (conn.isAllBidirectional()) {
        // check for error flow in the opposite direction
        if (srccl != null) {
            if (AadlUtil.isIncomingConnection(conn)) {
                dstprop = EMV2Util.findOutgoingErrorPropagation(srccl, srcname);
                dstcontain = EMV2Util.findOutgoingErrorContainment(srccl, srcname);
            } else {
                dstprop = EMV2Util.findIncomingErrorPropagation(srccl, srcname);
                dstcontain = EMV2Util.findIncomingErrorContainment(srccl, srcname);
            }
        } else {
            dstprop = null;
            dstcontain = null;
        }
        if (dstcl != null) {
            if (AadlUtil.isOutgoingConnection(conn)) {
                srcprop = EMV2Util.findIncomingErrorPropagation(dstcl, dstname);
                srccontain = EMV2Util.findIncomingErrorContainment(dstcl, dstname);
            } else {
                srcprop = EMV2Util.findOutgoingErrorPropagation(dstcl, dstname);
                srccontain = EMV2Util.findOutgoingErrorContainment(dstcl, dstname);
            }
        } else {
            srcprop = null;
            srccontain = null;
        }
        if (srcprop != null && dstprop != null) {
            if (!EMV2TypeSetUtil.contains(dstprop.getTypeSet(), srcprop.getTypeSet())) {
                error(conn, "Reverse direction: Destination propagation  " + EMV2Util.getPrintName(srcprop) + EMV2Util.getPrintName(srcprop.getTypeSet()) + " has error types not handled by source propagation " + EMV2Util.getPrintName(dstprop) + EMV2Util.getPrintName(dstprop.getTypeSet()));
            }
        }
        if (srccontain != null && dstcontain != null) {
            if (!EMV2TypeSetUtil.contains(srcprop.getTypeSet(), dstprop.getTypeSet())) {
                error(conn, "Reverse direction: Destination containment  " + EMV2Util.getPrintName(srcprop) + EMV2Util.getPrintName(srcprop.getTypeSet()) + " does not contain error types listed by source containment " + EMV2Util.getPrintName(dstprop) + EMV2Util.getPrintName(dstprop.getTypeSet()));
            }
        }
        // instance level
        if (srcCxt instanceof Subcomponent && dstCxt instanceof Subcomponent) {
            // only when going across
            if (srccontain == null && dstcontain != null) {
                warning(conn, "No outgoing containment for incoming containment " + EMV2Util.getPrintName(dstcontain) + EMV2Util.getPrintName(dstcontain.getTypeSet()));
            }
            if (srcprop != null && dstprop == null) {
                warning(conn, "No incoming error propagation for outgoing propagation " + EMV2Util.getPrintName(srcprop) + EMV2Util.getPrintName(srcprop.getTypeSet()));
            }
        }
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) MathContext(java.math.MathContext) Context(org.osate.aadl2.Context) TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) ErrorModelSubclause(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause) Subcomponent(org.osate.aadl2.Subcomponent) ConnectionEnd(org.osate.aadl2.ConnectionEnd) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) TypeMappingSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeMappingSet) Classifier(org.osate.aadl2.Classifier)

Aggregations

TypeMappingSet (org.osate.xtext.aadl2.errormodel.errorModel.TypeMappingSet)8 TypeSet (org.osate.xtext.aadl2.errormodel.errorModel.TypeSet)6 TypeToken (org.osate.xtext.aadl2.errormodel.errorModel.TypeToken)5 ErrorModelSubclause (org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause)4 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)3 TypeTransformationSet (org.osate.xtext.aadl2.errormodel.errorModel.TypeTransformationSet)3 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)2 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)2 ErrorPropagation (org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)2 ErrorType (org.osate.xtext.aadl2.errormodel.errorModel.ErrorType)2 MathContext (java.math.MathContext)1 EPackage (org.eclipse.emf.ecore.EPackage)1 Action (org.eclipse.xtext.Action)1 Parameter (org.eclipse.xtext.Parameter)1 ParserRule (org.eclipse.xtext.ParserRule)1 AadlPackage (org.osate.aadl2.AadlPackage)1 ArrayRange (org.osate.aadl2.ArrayRange)1 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)1 BooleanLiteral (org.osate.aadl2.BooleanLiteral)1 Classifier (org.osate.aadl2.Classifier)1