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);
}
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 "";
}
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 "";
}
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);
}
}
}
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));
}
Aggregations