Search in sources :

Example 51 with TypeToken

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

the class FTAGenerator method transformSubgates.

/**
 * find common events in subgates and move them to an enclosing gate
 * Currently does it if all of the gates of a given type have something in common.
 * It also does it for various subsets of events with the matching gate type.
 * Distributive Law 3a and 3b (see NRC Fault Tree Handbook page 80).
 * @param topevent
 * @param gt
 * @return Event
 */
private Event transformSubgates(Event topevent, LogicOperation gt, LogicOperation topgt) {
    List<Event> subEvents = topevent.getSubEvents();
    if (subEvents.isEmpty()) {
        return topevent;
    }
    if (subEvents.size() == 1) {
        // (Event) subEvents.get(0);
        return topevent;
    }
    Set<Event> intersection = null;
    List<Event> todo = new LinkedList<Event>();
    while (true) {
        todo.clear();
        for (Event se : subEvents) {
            if (!se.getSubEvents().isEmpty() && (se.getSubEventLogic() == gt)) {
                if (intersection == null) {
                    intersection = new HashSet<Event>(se.getSubEvents());
                    todo.add(se);
                } else {
                    if (intersects(intersection, se.getSubEvents())) {
                        intersection.retainAll(se.getSubEvents());
                        todo.add(se);
                    }
                }
            }
        }
        if (todo.size() > 1 && intersection != null && !intersection.isEmpty()) {
            if (subEvents.size() == todo.size()) {
                // all subgates are involved
                // remove from lower OR and create an OR above top gate
                Event newtopevent = FaultTreeUtils.createUniqueIntermediateEvent(ftaModel, (ComponentInstance) topevent.getRelatedInstanceObject(), topevent.getRelatedEMV2Object(), (TypeToken) topevent.getRelatedErrorType());
                newtopevent.setSubEventLogic(gt);
                newtopevent.getSubEvents().add(topevent);
                for (Event event : intersection) {
                    newtopevent.getSubEvents().add(event);
                }
                for (Event se : todo) {
                    EList<Event> rem = se.getSubEvents();
                    rem.removeAll(intersection);
                }
                flattenSubgates(topevent);
                removeZeroOneEventSubGates(topevent);
                flattenSubgates(newtopevent);
                removeZeroOneEventSubGates(newtopevent);
                return newtopevent;
            } else {
                // transformed subtree to top gate replacing subset of events involved in transformation
                Event newtopevent = FaultTreeUtils.createIntermediateEvent(ftaModel, (ComponentInstance) topevent.getRelatedInstanceObject(), topevent.getRelatedEMV2Object(), (TypeToken) topevent.getRelatedErrorType());
                newtopevent.setSubEventLogic(gt);
                topevent.getSubEvents().add(newtopevent);
                // remove intersection fro subset of gates
                for (Event event : intersection) {
                    newtopevent.getSubEvents().add(event);
                }
                for (Event se : todo) {
                    EList<Event> rem = se.getSubEvents();
                    rem.removeAll(intersection);
                }
                topevent.getSubEvents().removeAll(todo);
                flattenSubgates(newtopevent);
                removeZeroOneEventSubGates(newtopevent);
                flattenSubgates(topevent);
                removeZeroOneEventSubGates(topevent);
                return topevent;
            }
        } else {
            flattenSubgates(topevent);
            removeZeroOneEventSubGates(topevent);
            return topevent;
        }
    }
}
Also used : Event(org.osate.aadl2.errormodel.FaultTree.Event) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent) LinkedList(java.util.LinkedList)

Example 52 with TypeToken

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

the class FTAGenerator method preProcessIncomingErrorPropagation.

@Override
protected EObject preProcessIncomingErrorPropagation(ComponentInstance component, ErrorPropagation errorPropagation, TypeToken targetType, BigDecimal scale) {
    String name = FaultTreeUtils.buildName(component, errorPropagation, targetType);
    Event result = FaultTreeUtils.findEvent(ftaModel, name);
    return result;
}
Also used : Event(org.osate.aadl2.errormodel.FaultTree.Event) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent)

Example 53 with TypeToken

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

the class FTAGenerator method processErrorEvent.

@Override
protected EObject processErrorEvent(ComponentInstance component, ErrorEvent errorEvent, TypeToken type, BigDecimal scale) {
    Event ftaEvent = FaultTreeUtils.createBasicEvent(ftaModel, component, errorEvent, type);
    ftaEvent.setScale(scale);
    return ftaEvent;
}
Also used : Event(org.osate.aadl2.errormodel.FaultTree.Event) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent)

Example 54 with TypeToken

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

the class CreateFTAModel method createModel.

public static FaultTree createModel(ComponentInstance selection, final String startingPoint, FaultTreeType faultTreeType) {
    NamedElement errorStateOrPropagation = null;
    TypeToken errorType = null;
    if (startingPoint.startsWith(prefixState)) {
        String toProcess = startingPoint.replace(prefixState, "");
        for (ErrorBehaviorState ebs : EMV2Util.getAllErrorBehaviorStates(selection)) {
            if (ebs.getName().equalsIgnoreCase(toProcess)) {
                errorStateOrPropagation = ebs;
            }
        }
    }
    if (startingPoint.startsWith(prefixOutgoingPropagation)) {
        String toProcess = startingPoint.replace(prefixOutgoingPropagation, "");
        for (ErrorPropagation opc : EMV2Util.getAllOutgoingErrorPropagations(selection.getComponentClassifier())) {
            EList<TypeToken> result = EMV2TypeSetUtil.flattenTypesetElements(opc.getTypeSet());
            for (TypeToken tt : result) {
                String longName = EMV2Util.getPrintName(opc) + EMV2Util.getPrintName(tt);
                if (longName.equalsIgnoreCase(toProcess) && !tt.getType().isEmpty()) {
                    errorStateOrPropagation = opc;
                    errorType = tt;
                }
            }
        }
    }
    if (errorStateOrPropagation == null) {
        return null;
    }
    PropagationGraph currentPropagationGraph = Util.generatePropagationGraph(selection.getSystemInstance(), false);
    FTAGenerator generator = new FTAGenerator(currentPropagationGraph);
    FaultTree ftamodel = generator.getftaModel(selection, errorStateOrPropagation, errorType, faultTreeType);
    String rootname = ftamodel.getName() + (faultTreeType.equals(FaultTreeType.MINIMAL_CUT_SET) ? "_cutset" : (faultTreeType.equals(FaultTreeType.FAULT_TRACE) ? "_trace" : (faultTreeType.equals(FaultTreeType.COMPOSITE_PARTS) ? "_parts" : "_tree")));
    ftamodel.setName(rootname);
    return ftamodel;
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) PropagationGraph(org.osate.aadl2.errormodel.PropagationGraph.PropagationGraph) TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) FaultTree(org.osate.aadl2.errormodel.FaultTree.FaultTree) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) NamedElement(org.osate.aadl2.NamedElement)

Example 55 with TypeToken

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

the class ErrorStateToModeMappingImpl method basicSetTypeToken.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetTypeToken(TypeSet newTypeToken, NotificationChain msgs) {
    TypeSet oldTypeToken = typeToken;
    typeToken = newTypeToken;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ErrorModelPackage.ERROR_STATE_TO_MODE_MAPPING__TYPE_TOKEN, oldTypeToken, newTypeToken);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet)

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