Search in sources :

Example 26 with ErrorBehaviorState

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

the class PropagateErrorSources method startErrorFlows.

/**
 * traverse error flow if the component instance is an error source
 * @param ci component instance
 */
public void startErrorFlows(ComponentInstance ci) {
    Collection<ErrorSource> eslist = EMV2Util.getAllErrorSources(ci.getComponentClassifier());
    String componentText = ci.getComponentInstancePath();
    HashMultimap<ErrorPropagation, String> handledPropagations = HashMultimap.create();
    for (ErrorBehaviorEvent event : EMV2Util.getAllErrorBehaviorEvents(ci)) {
        if (!(event instanceof ErrorEvent) || !Util.conditionHolds((ErrorEvent) event, ci)) {
            continue;
        }
        TypeSet sourcetype = ((ErrorEvent) event).getTypeSet();
        if (sourcetype == null) {
            // no type on event
            for (ErrorBehaviorTransition trans : EMV2Util.getAllErrorBehaviorTransitions(ci)) {
                if (trans.getCondition() instanceof ConditionElement) {
                    ConditionElement conditionElement = (ConditionElement) trans.getCondition();
                    processTransition(ci, event, null, trans, conditionElement, componentText, handledPropagations);
                } else if (trans.getCondition() instanceof OrmoreExpression) {
                    EList<ConditionExpression> elems = ((OrmoreExpression) trans.getCondition()).getOperands();
                    for (ConditionExpression conditionExpression : elems) {
                        if (conditionExpression instanceof ConditionElement) {
                            ConditionElement conditionElement = (ConditionElement) conditionExpression;
                            processTransition(ci, event, null, trans, conditionElement, componentText, handledPropagations);
                        }
                    }
                } else if (trans.getCondition() instanceof OrExpression) {
                    EList<ConditionExpression> elems = ((OrExpression) trans.getCondition()).getOperands();
                    for (ConditionExpression conditionExpression : elems) {
                        if (conditionExpression instanceof ConditionElement) {
                            ConditionElement conditionElement = (ConditionElement) conditionExpression;
                            processTransition(ci, event, null, trans, conditionElement, componentText, handledPropagations);
                        }
                    }
                }
            }
        } else {
            EList<TypeToken> tokens = EMV2TypeSetUtil.generateAllLeafTypeTokens(((ErrorEvent) event).getTypeSet(), EMV2Util.getUseTypes(event));
            for (TypeToken typeToken : tokens) {
                for (ErrorBehaviorTransition trans : EMV2Util.getAllErrorBehaviorTransitions(ci)) {
                    // the only one that makes sense is an or of error events
                    if (trans.getCondition() instanceof ConditionElement) {
                        ConditionElement conditionElement = (ConditionElement) trans.getCondition();
                        processTransition(ci, event, typeToken, trans, conditionElement, componentText, handledPropagations);
                    } else if (trans.getCondition() instanceof OrmoreExpression) {
                        EList<ConditionExpression> elems = ((OrmoreExpression) trans.getCondition()).getOperands();
                        for (ConditionExpression conditionExpression : elems) {
                            if (conditionExpression instanceof ConditionElement) {
                                ConditionElement conditionElement = (ConditionElement) conditionExpression;
                                processTransition(ci, event, typeToken, trans, conditionElement, componentText, handledPropagations);
                            }
                        }
                    } else if (trans.getCondition() instanceof OrExpression) {
                        EList<ConditionExpression> elems = ((OrExpression) trans.getCondition()).getOperands();
                        for (ConditionExpression conditionExpression : elems) {
                            if (conditionExpression instanceof ConditionElement) {
                                ConditionElement conditionElement = (ConditionElement) conditionExpression;
                                processTransition(ci, event, typeToken, trans, conditionElement, componentText, handledPropagations);
                            }
                        }
                    }
                }
            }
        }
    }
    for (ErrorSource errorSource : eslist) {
        if (!Util.conditionHolds(errorSource, ci)) {
            continue;
        }
        EMSUtil.unsetAll(ci.getSystemInstance());
        Collection<ErrorPropagation> eplist = EMV2Util.getOutgoingPropagationOrAll(errorSource);
        TypeSet ts = errorSource.getTypeTokenConstraint();
        ErrorBehaviorState failureMode = errorSource.getFailureModeReference();
        TypeSet failureTypeSet = null;
        if (failureMode != null) {
            failureTypeSet = failureMode.getTypeSet();
        } else {
            // reference to named type set
            // or type set constructor
            failureTypeSet = errorSource.getFailureModeType();
        }
        String failuremodeDesc = errorSource.getFailureModeDescription();
        for (ErrorPropagation ep : eplist) {
            TypeSet tsep = ep.getTypeSet();
            if (ts != null || tsep != null) {
                EList<TypeToken> result = ts != null ? ts.getTypeTokens() : tsep.getTypeTokens();
                for (TypeToken typeToken : result) {
                    String failuremodeText;
                    if (handledPropagations.containsEntry(ep, EMV2Util.getPrintName(typeToken))) {
                        continue;
                    }
                    if (failuremodeDesc == null) {
                        failuremodeText = generateOriginalFailureModeText(failureMode != null ? failureMode : (failureTypeSet != null ? failureTypeSet : typeToken));
                    } else {
                        failuremodeText = failuremodeDesc;
                    }
                    traceErrorPaths(ci, ep, typeToken, 2, componentText + "," + failuremodeText);
                }
            }
        }
    }
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) OrmoreExpression(org.osate.xtext.aadl2.errormodel.errorModel.OrmoreExpression) OrExpression(org.osate.xtext.aadl2.errormodel.errorModel.OrExpression) ConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement) ErrorBehaviorTransition(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorTransition) ErrorSource(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource) ErrorBehaviorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorEvent) BasicEList(org.eclipse.emf.common.util.BasicEList) EList(org.eclipse.emf.common.util.EList) ConditionExpression(org.osate.xtext.aadl2.errormodel.errorModel.ConditionExpression) TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)

Example 27 with ErrorBehaviorState

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

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

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

the class FTAGenerator method getftaModel.

public FaultTree getftaModel(ComponentInstance rootComponent, NamedElement rootStateOrPropagation, TypeToken rootComponentType, FaultTreeType faultTreeType) {
    if (ftaModel == null) {
        Event ftaRootEvent = null;
        String errorMsg = "";
        ftaModel = FaultTreeFactory.eINSTANCE.createFaultTree();
        ftaModel.setName(FaultTreeUtils.buildName(rootComponent, rootStateOrPropagation, rootComponentType));
        ftaModel.setInstanceRoot(rootComponent);
        ftaModel.setFaultTreeType(faultTreeType);
        if (rootStateOrPropagation instanceof ErrorBehaviorState) {
            if (faultTreeType.equals(FaultTreeType.COMPOSITE_PARTS)) {
                ftaRootEvent = (Event) traverseCompositeErrorStateOnly(rootComponent, (ErrorBehaviorState) rootStateOrPropagation, rootComponentType, BigOne);
            } else {
                ftaRootEvent = (Event) traverseCompositeErrorState(rootComponent, (ErrorBehaviorState) rootStateOrPropagation, rootComponentType, BigOne);
            }
        } else {
            if (faultTreeType.equals(FaultTreeType.COMPOSITE_PARTS)) {
                errorMsg = "Select error state for composite parts fault tree";
                ftaRootEvent = FaultTreeUtils.createIntermediateEvent(ftaModel, rootComponent, rootStateOrPropagation, rootComponentType);
                ftaModel.setMessage(errorMsg);
                ftaModel.setRoot(ftaRootEvent);
                return ftaModel;
            } else {
                ftaRootEvent = (Event) traverseOutgoingErrorPropagation(rootComponent, (ErrorPropagation) rootStateOrPropagation, rootComponentType, BigOne);
            }
        }
        if (ftaRootEvent == null) {
            ftaRootEvent = FaultTreeUtils.createIntermediateEvent(ftaModel, rootComponent, rootStateOrPropagation, rootComponentType);
        }
        String longName = FaultTreeUtils.buildName(rootComponent, rootStateOrPropagation, rootComponentType);
        if (ftaRootEvent.getSubEvents().isEmpty() && !ftaRootEvent.getName().equals(longName)) {
            Event topEvent = FaultTreeUtils.createIntermediateEvent(ftaModel, rootComponent, rootStateOrPropagation, rootComponentType);
            topEvent.getSubEvents().add(ftaRootEvent);
            ftaRootEvent = topEvent;
        }
        if (!faultTreeType.equals(FaultTreeType.FAULT_TRACE) && !faultTreeType.equals(FaultTreeType.COMPOSITE_PARTS)) {
            flattenGates(ftaRootEvent);
            cleanupXORGates(ftaRootEvent);
            // xformXORtoOR(emftaRootEvent);
            if (faultTreeType.equals(FaultTreeType.FAULT_TREE)) {
                flattenGates(ftaRootEvent);
                ftaRootEvent = optimizeGates(ftaRootEvent);
                flattenGates(ftaRootEvent);
            }
            // remove gate with single event from root
            if (ftaRootEvent.getSubEvents().size() == 1) {
                Event subevent = ftaRootEvent.getSubEvents().get(0);
                if (subevent.getType() == EventType.INTERMEDIATE) {
                    subevent.setName(ftaRootEvent.getName());
                    subevent.setMessage(ftaRootEvent.getMessage());
                    subevent.setRelatedInstanceObject(ftaRootEvent.getRelatedInstanceObject());
                    subevent.setRelatedErrorType(ftaRootEvent.getRelatedErrorType());
                    subevent.setRelatedEMV2Object(ftaRootEvent.getRelatedEMV2Object());
                    ftaRootEvent = subevent;
                }
            }
            if (faultTreeType.equals(FaultTreeType.MINIMAL_CUT_SET)) {
                ftaRootEvent = minimalCutSet(ftaRootEvent);
            }
        }
        ftaRootEvent.setName(longName);
        ftaModel.setRoot(ftaRootEvent);
        FaultTreeUtils.removeEventOrphans(ftaModel);
        FaultTreeUtils.fillProbabilities(ftaModel);
        FaultTreeUtils.computeProbabilities(ftaModel.getRoot());
    }
    return ftaModel;
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) Event(org.osate.aadl2.errormodel.FaultTree.Event) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent)

Example 30 with ErrorBehaviorState

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

the class FTAGenerator method postProcessErrorBehaviorState.

@Override
protected EObject postProcessErrorBehaviorState(ComponentInstance component, ErrorBehaviorState state, TypeToken type, List<EObject> subResults, BigDecimal scale) {
    String name = FaultTreeUtils.buildName(component, state, type);
    Event found = FaultTreeUtils.findEvent(ftaModel, name);
    if (found != null) {
        return null;
    }
    Event result = finalizeAsUniqueOrEvents(component, state, type, subResults);
    return result;
}
Also used : Event(org.osate.aadl2.errormodel.FaultTree.Event) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent)

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