Search in sources :

Example 36 with TypeToken

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

the class PropagateErrorSources method doAllOutPropagationsOrFeatures.

protected boolean doAllOutPropagationsOrFeatures(ComponentInstance ci, EList<FeatureInstance> filist, ErrorPropagation ep, TypeToken tt, int depth, String entryText) {
    boolean handled = false;
    for (FeatureInstance fi : filist) {
        if (fi.getFlowDirection().outgoing()) {
            ErrorPropagation outp = EMV2Util.getOutgoingErrorPropagation(fi);
            if (outp != null) {
                TypeToken newtt = EMV2Util.mapToken(tt, null);
                if (EMV2TypeSetUtil.contains(outp.getTypeSet(), newtt)) {
                    traceErrorPaths(ci, outp, newtt, depth + 1, entryText + "," + generateFailureModeText(ci, ep, tt) + " [All Out Props]");
                    handled = true;
                } else {
                    Collection<TypeToken> intersection = EMV2TypeSetUtil.getConstrainedTypeTokens(outp.getTypeSet(), newtt);
                    if (intersection.isEmpty()) {
                        String errorText = ",\"" + generateFailureModeText(ci, outp, newtt) + " [Not in type constraint " + EMV2Util.getPrintName(outp.getTypeSet()) + " ]\"";
                        reportEntry(entryText + errorText, depth);
                        handled = true;
                    } else {
                        for (TypeToken typeToken : intersection) {
                            traceErrorPaths(ci, outp, typeToken, depth + 1, entryText + "," + generateFailureModeText(ci, ep, tt) + " [All Out Subtype]");
                            handled = true;
                        }
                    }
                }
            } else {
                if (!fi.getFeatureInstances().isEmpty()) {
                    boolean res = doAllOutPropagationsOrFeatures(ci, fi.getFeatureInstances(), ep, tt, depth, entryText);
                    if (res) {
                        handled = true;
                    } else {
                        // report only for the top feature instance
                        if (fi.getOwner() instanceof ComponentInstance) {
                            String errorText = "," + generateFailureModeText(ci, outp, tt) + " [No feature with out propagation ]";
                            reportEntry(entryText + errorText, depth);
                        }
                    }
                }
            }
        }
    }
    return handled;
}
Also used : FeatureInstance(org.osate.aadl2.instance.FeatureInstance) TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)

Example 37 with TypeToken

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

the class PropagateErrorSources method processTransition.

private void processTransition(ComponentInstance ci, ErrorBehaviorEvent event, TypeToken eventtype, ErrorBehaviorTransition trans, ConditionElement conditionElement, String componentText, HashMultimap<ErrorPropagation, String> handledPropagations) {
    EventOrPropagation eop = EMV2Util.getErrorEventOrPropagation(conditionElement);
    TypeSet constraint = conditionElement.getConstraint();
    if (eop instanceof ErrorPropagation) {
        return;
    }
    if (eop.getName().equalsIgnoreCase(event.getName())) {
        // match the event
        if (eventtype != null && constraint != null && !EMV2TypeSetUtil.contains(constraint, eventtype)) {
            return;
        }
        ErrorBehaviorState targetstate = trans.getTarget();
        TypeSet statetype = null;
        if (targetstate.getTypeSet() != null) {
            statetype = trans.getTargetToken();
        }
        // we have the state and possibly a type
        for (OutgoingPropagationCondition opc : EMV2Util.getAllOutgoingPropagationConditions(ci)) {
            if (EMV2TypeSetUtil.isNoError(opc.getTypeToken()) || opc.getCondition() != null) {
                continue;
            }
            if (opc.isAllStates() || (opc.getState() != null && targetstate.getName().equalsIgnoreCase(opc.getState().getName()))) {
                // either typeless state or type is contained in opc type constraint on state
                TypeSet statetypeconstraint = opc.getTypeTokenConstraint();
                if (statetypeconstraint == null || statetype == null || EMV2TypeSetUtil.contains(statetypeconstraint, statetype)) {
                    ErrorTypes outtype = opc.getTypeToken();
                    if (outtype == null) {
                        outtype = statetype;
                    }
                    if (opc.isAllPropagations()) {
                        Collection<ErrorPropagation> oeps = EMV2Util.getAllOutgoingErrorPropagations(ci.getComponentClassifier());
                        for (ErrorPropagation ep : oeps) {
                            if (outtype == null) {
                                if (eventtype != null) {
                                    traceErrorPaths(ci, ep, eventtype, 2, componentText + ", " + "error event " + event.getName() + EMV2Util.getPrintName(eventtype));
                                    handledPropagations.put(ep, EMV2Util.getPrintName(eventtype));
                                }
                            } else {
                                EList<TypeToken> result = EMV2TypeSetUtil.generateAllLeafTypeTokens((TypeSet) outtype, EMV2Util.getUseTypes(opc));
                                for (TypeToken tt : result) {
                                    traceErrorPaths(ci, ep, tt, 2, componentText + ", " + "error event " + event.getName() + EMV2Util.getPrintName(eventtype));
                                    handledPropagations.put(ep, EMV2Util.getPrintName(tt));
                                }
                            }
                        }
                    } else {
                        ErrorPropagation ep = opc.getOutgoing();
                        if (outtype == null) {
                            if (eventtype != null) {
                                traceErrorPaths(ci, ep, eventtype, 2, componentText + ", " + "error event " + event.getName() + EMV2Util.getPrintName(eventtype));
                                handledPropagations.put(ep, EMV2Util.getPrintName(eventtype));
                            }
                        } else {
                            EList<TypeToken> result = EMV2TypeSetUtil.generateAllLeafTypeTokens((TypeSet) outtype, EMV2Util.getUseTypes(opc));
                            for (TypeToken tt : result) {
                                traceErrorPaths(ci, ep, tt, 2, componentText + ", " + "error event " + event.getName() + EMV2Util.getPrintName(eventtype));
                                handledPropagations.put(ep, EMV2Util.getPrintName(tt));
                            }
                        }
                    }
                }
            }
        }
    }
}
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) EventOrPropagation(org.osate.xtext.aadl2.errormodel.errorModel.EventOrPropagation) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) OutgoingPropagationCondition(org.osate.xtext.aadl2.errormodel.errorModel.OutgoingPropagationCondition) ErrorTypes(org.osate.xtext.aadl2.errormodel.errorModel.ErrorTypes)

Example 38 with TypeToken

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

the class FHAReport method reportHazardProperty.

protected void reportHazardProperty(InstanceObject ci, List<EMV2PropertyAssociation> PAList, List<EMV2PropertyAssociation> SevList, List<EMV2PropertyAssociation> LikeList, NamedElement target, TypeSet ts, Element localContext, WriteToFile report) {
    String targetName;
    if (PAList.isEmpty()) {
        return;
    }
    if (target == null) {
        targetName = "";
    } else {
        targetName = EMV2Util.getPrintName(target);
        if (target instanceof ErrorEvent) {
            targetName = "event " + targetName;
        }
        if (target instanceof ErrorBehaviorState) {
            targetName = "state " + targetName;
        }
    }
    for (EMV2PropertyAssociation PA : PAList) {
        for (ModalPropertyValue modalPropertyValue : PA.getOwnedValues()) {
            PropertyExpression peVal = modalPropertyValue.getOwnedValue();
            ListValue lv = (ListValue) peVal;
            for (PropertyExpression pe : lv.getOwnedListElements()) {
                EList<BasicPropertyAssociation> fields = ((RecordValue) pe).getOwnedFieldValues();
                if (ts != null) {
                    // do smaller of ts or hazard type set.
                    EList<EMV2Path> epathlist = PA.getEmv2Path();
                    for (EMV2Path ep : epathlist) {
                        ErrorTypes et = EMV2Util.getErrorType(ep);
                        ErrorTypes targettype = ts;
                        if (et != null && EMV2TypeSetUtil.contains(ts, et)) {
                            targettype = et;
                        }
                        List<EMV2PropertyAssociation> Sevs = EMV2Properties.getSeverityProperty(ci, target, et);
                        List<EMV2PropertyAssociation> Likes = EMV2Properties.getLikelihoodProperty(ci, target, et);
                        EMV2PropertyAssociation Sev = Sevs.isEmpty() ? null : Sevs.get(0);
                        EMV2PropertyAssociation Like = Likes.isEmpty() ? null : Likes.get(0);
                        PropertyExpression severityValue = EMV2Properties.getPropertyValue(Sev);
                        PropertyExpression likelihoodValue = EMV2Properties.getPropertyValue(Like);
                        if (targettype instanceof TypeSet) {
                            for (TypeToken token : ((TypeSet) targettype).getTypeTokens()) {
                                reportFHAEntry(report, fields, severityValue, likelihoodValue, ci, targetName, EMV2Util.getName(token));
                            }
                        } else {
                            reportFHAEntry(report, fields, severityValue, likelihoodValue, ci, targetName, EMV2Util.getName(targettype));
                        }
                    }
                } else {
                    // did not have a type set. Let's use fmr (state of type set as failure mode.
                    EMV2PropertyAssociation Sev = SevList.isEmpty() ? null : SevList.get(0);
                    EMV2PropertyAssociation Like = LikeList.isEmpty() ? null : LikeList.get(0);
                    PropertyExpression severityValue = EMV2Properties.getPropertyValue(Sev);
                    PropertyExpression likelihoodValue = EMV2Properties.getPropertyValue(Like);
                    if (localContext == null) {
                        reportFHAEntry(report, fields, severityValue, likelihoodValue, ci, targetName, "");
                    } else {
                        reportFHAEntry(report, fields, severityValue, likelihoodValue, ci, EMV2Util.getPrintName(localContext), EMV2Util.getPrintName(target));
                    }
                }
            }
        }
    }
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) ListValue(org.osate.aadl2.ListValue) EMV2PropertyAssociation(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation) RecordValue(org.osate.aadl2.RecordValue) ErrorTypes(org.osate.xtext.aadl2.errormodel.errorModel.ErrorTypes) EMV2Path(org.osate.xtext.aadl2.errormodel.errorModel.EMV2Path) TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent) PropertyExpression(org.osate.aadl2.PropertyExpression) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation)

Example 39 with TypeToken

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

the class FTAGenerator method finalizeAsUniqueOrEvents.

private Event finalizeAsUniqueOrEvents(ComponentInstance component, Element ne, TypeToken type, List<EObject> subEvents) {
    if (subEvents.size() == 0) {
        return null;
    }
    Event combined = FaultTreeUtils.createUniqueIntermediateEvent(ftaModel, component, ne, type);
    combined.setSubEventLogic(LogicOperation.OR);
    for (Object seobj : subEvents) {
        combined.getSubEvents().add((Event) seobj);
    }
    return combined;
}
Also used : Event(org.osate.aadl2.errormodel.FaultTree.Event) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent) EObject(org.eclipse.emf.ecore.EObject)

Example 40 with TypeToken

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

the class FTAGenerator method processIncomingErrorPropagation.

@Override
protected EObject processIncomingErrorPropagation(ComponentInstance component, ErrorPropagation incoming, TypeToken type, BigDecimal scale) {
    Event res = FaultTreeUtils.createBasicEvent(ftaModel, component, incoming, type);
    res.setScale(scale);
    if (component instanceof SystemInstance) {
        res.setType(EventType.EXTERNAL);
    } else {
        res.setType(EventType.UNDEVELOPED);
    }
    return res;
}
Also used : SystemInstance(org.osate.aadl2.instance.SystemInstance) Event(org.osate.aadl2.errormodel.FaultTree.Event) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent)

Aggregations

TypeToken (org.osate.xtext.aadl2.errormodel.errorModel.TypeToken)40 ErrorEvent (org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent)28 TypeSet (org.osate.xtext.aadl2.errormodel.errorModel.TypeSet)26 Event (org.osate.aadl2.errormodel.FaultTree.Event)24 ErrorPropagation (org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)17 EObject (org.eclipse.emf.ecore.EObject)14 ErrorBehaviorState (org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState)13 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)9 LinkedList (java.util.LinkedList)8 BasicEList (org.eclipse.emf.common.util.BasicEList)8 ErrorType (org.osate.xtext.aadl2.errormodel.errorModel.ErrorType)8 ErrorTypes (org.osate.xtext.aadl2.errormodel.errorModel.ErrorTypes)7 NamedElement (org.osate.aadl2.NamedElement)5 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)5 ErrorSource (org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource)5 EList (org.eclipse.emf.common.util.EList)4 ConditionExpression (org.osate.xtext.aadl2.errormodel.errorModel.ConditionExpression)4 ErrorBehaviorTransition (org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorTransition)4 OrmoreExpression (org.osate.xtext.aadl2.errormodel.errorModel.OrmoreExpression)4 BigDecimal (java.math.BigDecimal)3