Search in sources :

Example 26 with Context

use of org.osate.aadl2.Context in project osate2 by osate.

the class FaultTreeUtils method getComputedProbability.

/**
 * return computed probability
 * @param context
 * @return
 */
public static String getComputedProbability(EObject context) {
    Event ev = (Event) context;
    if (ev.getComputedProbability() == null || ev.getComputedProbability().compareTo(BigZero) == 0) {
        return "";
    }
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(context.eResource().getURI().segment(1));
    String specProb = String.format("%1$." + FaultTreeModel.getPrecision(project) + "e", ev.getComputedProbability());
    return specProb + getScale(context);
}
Also used : Event(org.osate.aadl2.errormodel.FaultTree.Event) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent) IProject(org.eclipse.core.resources.IProject)

Example 27 with Context

use of org.osate.aadl2.Context in project osate2 by osate.

the class FaultTreeUtils method getHazardDescriptionAndProbability.

public static String getHazardDescriptionAndProbability(EObject context) {
    if (context instanceof Event) {
        Event ev = (Event) context;
        FaultTree ft = (FaultTree) ev.eContainer();
        String hazardDescription = EMV2Properties.getHazardDescription((InstanceObject) ev.getRelatedInstanceObject(), (NamedElement) ev.getRelatedEMV2Object(), (ErrorTypes) ev.getRelatedErrorType());
        String labeltext = FaultTreeUtils.getDescription(ev);
        if (labeltext == null || labeltext.isEmpty()) {
            labeltext = ((Event) context).getName();
        }
        String msg = ev.getMessage() != null ? "\nMessage: " + ev.getMessage() : "";
        String problabel = "";
        if (isASharedEvent(ev)) {
            labeltext = "Dependent event: " + labeltext;
        } else if (ev == ft.getRoot()) {
            // mark probability with star if shared events are involved
            if (FaultTreeUtils.hasSharedEvents(ft)) {
                problabel = " (incl. dependent event probabilities)";
            }
        }
        if (hazardDescription == null) {
            return String.format("%1$s%4$s\nOccurrence probability %2$s%3$s", labeltext, getProbability(ev), problabel, msg);
        } else {
            return String.format("%1$s\n%3$s%5$s\nOccurrence probability %2$s%4$s", labeltext, getProbability(ev), "Hazard: " + hazardDescription, problabel, msg);
        }
    }
    return "";
}
Also used : FaultTree(org.osate.aadl2.errormodel.FaultTree.FaultTree) Event(org.osate.aadl2.errormodel.FaultTree.Event) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent)

Example 28 with Context

use of org.osate.aadl2.Context in project osate2 by osate.

the class FaultTreeUtils method getDescriptionAndProbability.

public static String getDescriptionAndProbability(EObject context) {
    if (context instanceof Event) {
        Event ev = (Event) context;
        FaultTree ft = (FaultTree) ev.eContainer();
        String labeltext = ft.getFaultTreeType().equals(FaultTreeType.MINIMAL_CUT_SET) ? FaultTreeUtils.getCutsetLabel(ev) : FaultTreeUtils.getInstanceDescription(ev);
        if (labeltext == null || labeltext.isEmpty()) {
            labeltext = ev.getName();
        }
        String emv2label = FaultTreeUtils.getEMV2ElementDescription(ev);
        String ftmsg = ft.getMessage();
        if (ftmsg != null) {
            return "ERROR: " + ftmsg + "\n" + labeltext;
        }
        // String msg = ev.getMessage() != null ? "NOTE: " + ev.getMessage() : " ";
        // String fullText = String.format("%1$s\n%2$s\n%4$s(%3$.3E)", labeltext, emv2label, val, msg);
        String fullText = String.format("%1$s \n%2$s \n%3$s", labeltext, emv2label, getProbability(ev));
        if (ev == ft.getRoot()) {
            // mark probability with star if shared events are involved
            if (FaultTreeUtils.hasSharedEvents(ft)) {
                return fullText + "*";
            } else {
                return fullText;
            }
        } else if (isASharedEvent(ev)) {
            return "*" + fullText;
        } else {
            return fullText;
        }
    }
    return "";
}
Also used : FaultTree(org.osate.aadl2.errormodel.FaultTree.FaultTree) Event(org.osate.aadl2.errormodel.FaultTree.Event) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent)

Example 29 with Context

use of org.osate.aadl2.Context 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 30 with Context

use of org.osate.aadl2.Context in project osate2 by osate.

the class AbstractPropertiesSemanticSequencer method sequence.

@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
    EPackage epackage = semanticObject.eClass().getEPackage();
    ParserRule rule = context.getParserRule();
    Action action = context.getAssignedAction();
    Set<Parameter> parameters = context.getEnabledBooleanParameters();
    if (epackage == Aadl2Package.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case Aadl2Package.ARRAY_RANGE:
                sequence_ArrayRange(context, (ArrayRange) semanticObject);
                return;
            case Aadl2Package.BASIC_PROPERTY_ASSOCIATION:
                sequence_FieldPropertyAssociation(context, (BasicPropertyAssociation) semanticObject);
                return;
            case Aadl2Package.BOOLEAN_LITERAL:
                sequence_BooleanLiteral(context, (BooleanLiteral) semanticObject);
                return;
            case Aadl2Package.CLASSIFIER_VALUE:
                sequence_ComponentClassifierTerm(context, (ClassifierValue) semanticObject);
                return;
            case Aadl2Package.COMPUTED_VALUE:
                sequence_ComputedTerm(context, (ComputedValue) semanticObject);
                return;
            case Aadl2Package.CONTAINED_NAMED_ELEMENT:
                sequence_ContainmentPath(context, (ContainedNamedElement) semanticObject);
                return;
            case Aadl2Package.CONTAINMENT_PATH_ELEMENT:
                sequence_ContainmentPathElement(context, (ContainmentPathElement) semanticObject);
                return;
            case Aadl2Package.INTEGER_LITERAL:
                sequence_IntegerTerm(context, (IntegerLiteral) semanticObject);
                return;
            case Aadl2Package.LIST_VALUE:
                sequence_ListTerm(context, (ListValue) semanticObject);
                return;
            case Aadl2Package.MODAL_PROPERTY_VALUE:
                if (rule == grammarAccess.getModalPropertyValueRule()) {
                    sequence_ModalPropertyValue(context, (ModalPropertyValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getOptionalModalPropertyValueRule()) {
                    sequence_OptionalModalPropertyValue(context, (ModalPropertyValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyValueRule()) {
                    sequence_PropertyValue(context, (ModalPropertyValue) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.NAMED_VALUE:
                if (rule == grammarAccess.getConstantValueRule() || rule == grammarAccess.getNumAltRule()) {
                    sequence_ConstantValue(context, (NamedValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyExpressionRule() || rule == grammarAccess.getLiteralorReferenceTermRule()) {
                    sequence_LiteralorReferenceTerm(context, (NamedValue) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.OPERATION:
                sequence_SignedConstant(context, (Operation) semanticObject);
                return;
            case Aadl2Package.PROPERTY_ASSOCIATION:
                if (rule == grammarAccess.getBasicPropertyAssociationRule()) {
                    sequence_BasicPropertyAssociation(context, (PropertyAssociation) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPModelRule() || rule == grammarAccess.getContainedPropertyAssociationRule()) {
                    sequence_ContainedPropertyAssociation(context, (PropertyAssociation) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyAssociationRule()) {
                    sequence_PropertyAssociation(context, (PropertyAssociation) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.RANGE_VALUE:
                sequence_NumericRangeTerm(context, (RangeValue) semanticObject);
                return;
            case Aadl2Package.REAL_LITERAL:
                sequence_RealTerm(context, (RealLiteral) semanticObject);
                return;
            case Aadl2Package.RECORD_VALUE:
                if (rule == grammarAccess.getOldRecordTermRule()) {
                    sequence_OldRecordTerm(context, (RecordValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyExpressionRule() || rule == grammarAccess.getRecordTermRule()) {
                    sequence_RecordTerm(context, (RecordValue) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.REFERENCE_VALUE:
                sequence_ReferenceTerm(context, (ReferenceValue) semanticObject);
                return;
            case Aadl2Package.STRING_LITERAL:
                sequence_StringTerm(context, (StringLiteral) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) ComputedValue(org.osate.aadl2.ComputedValue) Action(org.eclipse.xtext.Action) ClassifierValue(org.osate.aadl2.ClassifierValue) ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) BooleanLiteral(org.osate.aadl2.BooleanLiteral) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ReferenceValue(org.osate.aadl2.ReferenceValue) ListValue(org.osate.aadl2.ListValue) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) RecordValue(org.osate.aadl2.RecordValue) ArrayRange(org.osate.aadl2.ArrayRange) NamedValue(org.osate.aadl2.NamedValue) Operation(org.osate.aadl2.Operation) RangeValue(org.osate.aadl2.RangeValue) EPackage(org.eclipse.emf.ecore.EPackage) RealLiteral(org.osate.aadl2.RealLiteral) StringLiteral(org.osate.aadl2.StringLiteral) Parameter(org.eclipse.xtext.Parameter) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) IntegerLiteral(org.osate.aadl2.IntegerLiteral)

Aggregations

Context (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context)58 Context (com.microsoft.z3.Context)39 CoreException (org.eclipse.core.runtime.CoreException)36 NamedElement (org.osate.aadl2.NamedElement)32 Context (org.osate.aadl2.Context)31 ArrayList (java.util.ArrayList)28 Subcomponent (org.osate.aadl2.Subcomponent)26 BoolExpr (com.microsoft.z3.BoolExpr)25 List (java.util.List)24 Feature (org.osate.aadl2.Feature)24 EObject (org.eclipse.emf.ecore.EObject)22 HashMap (java.util.HashMap)19 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)19 ServerInstance (org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance)17 Classifier (org.osate.aadl2.Classifier)17 Map (java.util.Map)16 Test (org.junit.Test)16 ComponentClassifier (org.osate.aadl2.ComponentClassifier)16 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)15 Property (org.osate.aadl2.Property)15