Search in sources :

Example 11 with ErrorBehaviorState

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

the class OutgoingPropagationConditionImpl method setState.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setState(ErrorBehaviorState newState) {
    ErrorBehaviorState oldState = state;
    state = newState;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, ErrorModelPackage.OUTGOING_PROPAGATION_CONDITION__STATE, oldState, state));
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 12 with ErrorBehaviorState

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

the class EMV2Properties method getFailure.

/**
 * @param element - the EMV2 element that referes to the artifact
 * @param relatedComponent - the component the component (instance, subcomponent or classifier) that have the property association
 * @return - the text related to the failure part of the hazards property. Null if not defined
 */
public static String getFailure(NamedElement element, NamedElement relatedComponent) {
    TypeSet ts = null;
    if (element instanceof ErrorBehaviorState) {
        ts = ((ErrorBehaviorState) element).getTypeSet();
    }
    if (element instanceof ErrorPropagation) {
        ts = ((ErrorPropagation) element).getTypeSet();
    }
    if (element instanceof ErrorEvent) {
        ts = ((ErrorEvent) element).getTypeSet();
    }
    List<EMV2PropertyAssociation> PA = EMV2Properties.getHazardsProperty(relatedComponent, element, ts);
    if (PA.isEmpty()) {
        return null;
    }
    // XXX TODO we may get more than one back, one each for different types
    PropertyExpression val = getPropertyValue(PA.get(0));
    if (val instanceof RecordValue) {
        RecordValue rv = (RecordValue) val;
        EList<BasicPropertyAssociation> fields = rv.getOwnedFieldValues();
        BasicPropertyAssociation xref = GetProperties.getRecordField(fields, "failure");
        if (xref != null) {
            PropertyExpression peVal = getPropertyValue(xref);
            if (peVal instanceof StringLiteral) {
                return ((StringLiteral) peVal).getValue();
            }
        }
    }
    if (val instanceof ListValue) {
        ListValue lv = (ListValue) val;
        for (PropertyExpression pe : lv.getOwnedListElements()) {
            if (pe instanceof RecordValue) {
                RecordValue rv = (RecordValue) pe;
                EList<BasicPropertyAssociation> fields = rv.getOwnedFieldValues();
                BasicPropertyAssociation xref = GetProperties.getRecordField(fields, "failure");
                if (xref != null) {
                    PropertyExpression peVal = getPropertyValue(xref);
                    if (peVal instanceof StringLiteral) {
                        return ((StringLiteral) peVal).getValue();
                    }
                }
            }
        }
    }
    return null;
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) StringLiteral(org.osate.aadl2.StringLiteral) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) ListValue(org.osate.aadl2.ListValue) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent) EMV2PropertyAssociation(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation) RecordValue(org.osate.aadl2.RecordValue) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) PropertyExpression(org.osate.aadl2.PropertyExpression) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation)

Example 13 with ErrorBehaviorState

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

the class FTAHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ComponentInstance target;
    InstanceObject object = getTarget(HandlerUtil.getCurrentSelection(event));
    if (object == null) {
        Dialog.showInfo("Fault Tree Analysis", "Please choose an instance model");
        return IStatus.ERROR;
    }
    SystemInstance si = object.getSystemInstance();
    if (object instanceof ComponentInstance) {
        target = (ComponentInstance) object;
    } else {
        target = si;
    }
    if (!EMV2Util.hasComponentErrorBehaviorTransitions(target) && !EMV2Util.hasCompositeErrorBehavior(target) && !EMV2Util.hasOutgoingPropagations(target)) {
        Dialog.showInfo("Fault Tree Analysis", "Your system instance or selected component instance must have outgoing propagations, error state transitions, or composite error states.");
        return IStatus.ERROR;
    }
    stateNames = new ArrayList<String>();
    for (ErrorPropagation outprop : EMV2Util.getAllOutgoingErrorPropagations(target.getComponentClassifier())) {
        EList<TypeToken> result = EMV2TypeSetUtil.flattenTypesetElements(outprop.getTypeSet());
        for (TypeToken tt : result) {
            String epName = CreateFTAModel.prefixOutgoingPropagation + EMV2Util.getPrintName(outprop) + EMV2Util.getPrintName(tt);
            if (!stateNames.contains(epName)) {
                stateNames.add(epName);
            }
        }
    }
    Collection<ErrorBehaviorState> states = EMV2Util.getAllErrorBehaviorStates(target);
    if (!states.isEmpty()) {
        ErrorBehaviorState head = states.iterator().next();
        for (ErrorBehaviorState ebs : EMV2Util.getAllErrorBehaviorStates(target)) {
            if (ebs != head) {
                stateNames.add(CreateFTAModel.prefixState + EMV2Util.getPrintName(ebs));
            }
        }
        stateNames.add(CreateFTAModel.prefixState + EMV2Util.getPrintName(head));
    }
    if (stateNames.isEmpty()) {
        Dialog.showInfo("Fault Tree Analysis", "Selected system must have error states or error propagations");
        return IStatus.ERROR;
    }
    final Display d = PlatformUI.getWorkbench().getDisplay();
    d.syncExec(() -> {
        IWorkbenchWindow window;
        Shell sh;
        window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        sh = window.getShell();
        FTADialog diag = new FTADialog(sh);
        diag.setValues(stateNames);
        diag.setTarget("'" + (target instanceof SystemInstance ? target.getName() : target.getComponentInstancePath()) + "'");
        diag.open();
        ERROR_STATE_NAME = diag.getValue();
        FAULT_TREE_TYPE = diag.getFaultTreeType();
        GRAPHIC_VIEW = diag.isGraphicView();
    });
    if (ERROR_STATE_NAME != null) {
        if (FAULT_TREE_TYPE.equals(FaultTreeType.COMPOSITE_PARTS) && ERROR_STATE_NAME.startsWith(CreateFTAModel.prefixOutgoingPropagation)) {
            Dialog.showInfo("Fault Tree Analysis", "Select error state for composite parts fault tree");
            return IStatus.ERROR;
        }
        if (FAULT_TREE_TYPE.equals(FaultTreeType.COMPOSITE_PARTS) && !EMV2Util.hasCompositeErrorBehavior(target)) {
            Dialog.showInfo("Fault Tree Analysis", "Selected system must have composite error states for composite parts fault tree analysis");
            return IStatus.ERROR;
        }
        FaultTree ftmodel = CreateFTAModel.createModel(target, ERROR_STATE_NAME, FAULT_TREE_TYPE);
        if (ftmodel == null) {
            Dialog.showInfo("Fault Tree Analysis", "No fault tree generated. Selected error propagation has no out propagation condition or path from an inner component");
            return IStatus.ERROR;
        }
        saveFaultTree(ftmodel);
        if (GRAPHIC_VIEW) {
            SiriusUtil.INSTANCE.autoOpenModel(ftmodel, ResourceUtil.getFile(si.eResource()).getProject(), "viewpoint:/org.osate.aadl2.errormodel.faulttree.design/FaultTree", "IconicFaultTree", "Fault Tree");
        } else {
            if (FAULT_TREE_TYPE.equals(FaultTreeType.MINIMAL_CUT_SET)) {
                SiriusUtil.INSTANCE.autoOpenModel(ftmodel, ResourceUtil.getFile(si.eResource()).getProject(), "viewpoint:/org.osate.aadl2.errormodel.faulttree.design/FaultTree", "MinimalCutSetTable", "Minimal Cutset");
            } else {
                SiriusUtil.INSTANCE.autoOpenModel(ftmodel, ResourceUtil.getFile(si.eResource()).getProject(), "viewpoint:/org.osate.aadl2.errormodel.faulttree.design/FaultTree", "FaultTreeTable", "Fault Tree");
            }
        }
        return Status.OK_STATUS;
    }
    return IStatus.ERROR;
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) InstanceObject(org.osate.aadl2.instance.InstanceObject) Shell(org.eclipse.swt.widgets.Shell) SystemInstance(org.osate.aadl2.instance.SystemInstance) TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) FaultTree(org.osate.aadl2.errormodel.FaultTree.FaultTree) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) Display(org.eclipse.swt.widgets.Display)

Example 14 with ErrorBehaviorState

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

the class FHAReport method processHazards.

protected void processHazards(ComponentInstance ci, WriteToFile report) {
    for (ErrorBehaviorTransition trans : EMV2Util.getAllErrorBehaviorTransitions(ci.getComponentClassifier())) {
        ConditionExpression cond = trans.getCondition();
        if (cond instanceof ConditionElement) {
            ConditionElement condElement = (ConditionElement) trans.getCondition();
            EventOrPropagation eop = EMV2Util.getErrorEventOrPropagation(condElement);
            if (eop instanceof ErrorEvent) {
                ErrorEvent errorEvent = (ErrorEvent) eop;
                List<EMV2PropertyAssociation> PA = getHazardsPropertyInCurrentFormat(ci, errorEvent, errorEvent.getTypeSet());
                List<EMV2PropertyAssociation> Sev = EMV2Properties.getSeverityProperty(ci, errorEvent, errorEvent.getTypeSet());
                List<EMV2PropertyAssociation> Like = EMV2Properties.getLikelihoodProperty(ci, errorEvent, errorEvent.getTypeSet());
                reportHazardProperty(ci, PA, Sev, Like, errorEvent, errorEvent.getTypeSet(), errorEvent, report);
            }
        // condElement.getIncoming()
        }
    }
    for (ErrorBehaviorState state : EMV2Util.getAllErrorBehaviorStates(ci)) {
        List<EMV2PropertyAssociation> PA = getHazardsPropertyInCurrentFormat(ci, state, state.getTypeSet());
        List<EMV2PropertyAssociation> Sev = EMV2Properties.getSeverityProperty(ci, state, state.getTypeSet());
        List<EMV2PropertyAssociation> Like = EMV2Properties.getLikelihoodProperty(ci, state, state.getTypeSet());
        reportHazardProperty(ci, PA, Sev, Like, state, state.getTypeSet(), state, report);
    }
    // report all error sources as hazards if they have the property
    Collection<ErrorSource> eslist = EMV2Util.getAllErrorSources(ci.getComponentClassifier());
    Collection<ErrorPropagation> oeplist = EMV2Util.getAllOutgoingErrorPropagations(ci.getComponentClassifier());
    for (ErrorSource errorSource : eslist) {
        NamedElement ne = errorSource.getSourceModelElement();
        ErrorBehaviorState failureMode = errorSource.getFailureModeReference();
        List<EMV2PropertyAssociation> HazardPA = Collections.emptyList();
        List<EMV2PropertyAssociation> Sev = Collections.emptyList();
        List<EMV2PropertyAssociation> Like = Collections.emptyList();
        TypeSet ts = null;
        NamedElement target = null;
        Element localContext = null;
        // not dealing with type set as failure mode
        if (failureMode != null) {
            // state is originating hazard, possibly with a type set
            ts = failureMode.getTypeSet();
            // error source a local context
            HazardPA = getHazardsPropertyInCurrentFormat(ci, failureMode, ts);
            Sev = EMV2Properties.getSeverityProperty(ci, failureMode, ts);
            Like = EMV2Properties.getLikelihoodProperty(ci, failureMode, ts);
            target = failureMode;
            localContext = errorSource;
        }
        if (HazardPA.isEmpty()) {
            // error source is originating hazard
            ts = errorSource.getTypeTokenConstraint();
            if (ts == null && ne instanceof ErrorPropagation) {
                ts = ((ErrorPropagation) ne).getTypeSet();
            }
            HazardPA = getHazardsPropertyInCurrentFormat(ci, errorSource, ts);
            Sev = EMV2Properties.getSeverityProperty(ci, errorSource, ts);
            Like = EMV2Properties.getLikelihoodProperty(ci, errorSource, ts);
            target = errorSource;
            localContext = null;
            if (HazardPA.isEmpty() && errorSource.getFailureModeType() != null) {
                ts = errorSource.getFailureModeType();
                HazardPA = getHazardsPropertyInCurrentFormat(ci, errorSource, ts);
                Sev = EMV2Properties.getSeverityProperty(ci, errorSource, ts);
                Like = EMV2Properties.getLikelihoodProperty(ci, errorSource, ts);
            }
        }
        if (!HazardPA.isEmpty()) {
            reportHazardProperty(ci, HazardPA, Sev, Like, target, ts, localContext, report);
        }
    }
    for (ErrorPropagation ep : oeplist) {
        TypeSet ts = null;
        NamedElement target = null;
        Element localContext = null;
        // error propagation is originating hazard
        ts = ep.getTypeSet();
        List<EMV2PropertyAssociation> HazardPA = getHazardsPropertyInCurrentFormat(ci, ep, ts);
        List<EMV2PropertyAssociation> Sev = EMV2Properties.getSeverityProperty(ci, ep, ts);
        List<EMV2PropertyAssociation> Like = EMV2Properties.getLikelihoodProperty(ci, ep, ts);
        target = ep;
        localContext = null;
        // XXX we may have more than one matching hazard
        if (!HazardPA.isEmpty()) {
            reportHazardProperty(ci, HazardPA, Sev, Like, target, ts, localContext, report);
        }
    }
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) Element(org.osate.aadl2.Element) ConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement) NamedElement(org.osate.aadl2.NamedElement) EMV2PropertyAssociation(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation) EventOrPropagation(org.osate.xtext.aadl2.errormodel.errorModel.EventOrPropagation) ConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement) ErrorBehaviorTransition(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorTransition) ErrorSource(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource) ConditionExpression(org.osate.xtext.aadl2.errormodel.errorModel.ConditionExpression) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) NamedElement(org.osate.aadl2.NamedElement)

Example 15 with ErrorBehaviorState

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

the class FTAGenerator method processErrorBehaviorState.

@Override
protected EObject processErrorBehaviorState(ComponentInstance component, ErrorBehaviorState state, TypeToken type, BigDecimal scale) {
    Event newEvent = FaultTreeUtils.createBasicEvent(ftaModel, component, state, type);
    newEvent.setScale(scale);
    return newEvent;
}
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