use of org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation 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));
}
}
}
}
}
}
use of org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation in project osate2 by osate.
the class ErrorModelValidator method checkBranches.
private void checkBranches(ErrorBehaviorTransition ebt) {
EList<TransitionBranch> branches = ebt.getDestinationBranches();
boolean foundsteady = false;
boolean foundothers = false;
BigDecimal prob = new BigDecimal(0.0, MathContext.UNLIMITED);
if (branches.isEmpty()) {
return;
}
for (TransitionBranch transitionBranch : branches) {
if (transitionBranch.isSteadyState()) {
if (foundsteady) {
error(ebt, "More than one same state branch");
} else {
foundsteady = true;
}
}
if (transitionBranch.getValue().isOthers()) {
if (foundothers) {
error(ebt, "More than one other branch");
} else {
foundothers = true;
}
}
String bv = EMV2Util.stripUnderScore(transitionBranch.getValue().getRealvalue());
Property sl = transitionBranch.getValue().getSymboliclabel();
if (bv != null) {
prob = prob.add(new BigDecimal(bv, MathContext.UNLIMITED));
} else if (sl != null) {
Classifier cl = EMV2Util.getAssociatedClassifier(ebt);
List<EMV2PropertyAssociation> pa = EMV2Properties.getProperty(sl.getQualifiedName(), cl, ebt, null);
for (EMV2PropertyAssociation emv2PropertyAssociation : pa) {
prob = prob.add(new BigDecimal(EMV2Properties.getRealValue(emv2PropertyAssociation), MathContext.UNLIMITED));
}
}
}
if (!foundothers && prob.compareTo(new BigDecimal(1.0)) != 0) {
error(ebt, "Sum of branch probabilities must be 1");
}
if (foundothers && prob.compareTo(new BigDecimal(1.0)) >= 0) {
error(ebt, "Sum of branch probabilities must be less than 1 due to 'others'");
}
}
use of org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation in project osate2 by osate.
the class EMV2Properties method getHazardDescription.
public static String getHazardDescription(NamedElement element, NamedElement relatedComponent, ErrorTypes ts) {
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, "description");
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, "description");
if (xref != null) {
PropertyExpression peVal = getPropertyValue(xref);
if (peVal instanceof StringLiteral) {
return ((StringLiteral) peVal).getValue();
}
}
}
}
}
return null;
}
use of org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation in project osate2 by osate.
the class EMV2Properties method getPropertyInClassifier.
/**
* retrieve an error model property (such as Hazard) attached to an error model element based on contained property associations
* in the annex subclause properties section of the classifier.
* @param propertyName name of property we are looking for
* @param ci component instance whose EM element has the property
* @param target the error model element (which is optionally followed by a type that is contained in the typeset ts
* @param ts the type set
* @return Containmentpath of the PA that matches the parameters.
* we return the path because the PA applies to more than element
*/
public static List<EMV2PropertyAssociation> getPropertyInClassifier(String propertyName, Classifier cl, NamedElement target, Stack<NamedElement> ciStack, ErrorTypes ts) {
if (cl != null) {
// deals with inherited properties by walking subclause inheritance
EList<ErrorModelSubclause> emslist = EMV2Util.getAllContainingClassifierEMV2Subclauses(cl);
for (ErrorModelSubclause ems : emslist) {
List<EMV2PropertyAssociation> props = ems.getProperties();
List<EMV2PropertyAssociation> result = getMatchingPropertiesInList(props, propertyName, target, ciStack, ts);
if (!result.isEmpty()) {
return result;
}
}
}
return Collections.emptyList();
}
use of org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation in project osate2 by osate.
the class EMV2Properties method getProbability.
/**
* retrieve the probability
* @param ci component instance, subcomponent, or classifier
* @param ne named element for which we retrieve the probability
* @param ts type set
* @return
*/
public static double getProbability(NamedElement ci, NamedElement ne, ErrorTypes ts) {
List<EMV2PropertyAssociation> PA = EMV2Properties.getOccurrenceDistributionProperty(ci, ne, ts);
double prob = 0;
for (EMV2PropertyAssociation emv2PropertyAssociation : PA) {
prob += EMV2Properties.getOccurrenceValue(emv2PropertyAssociation);
}
return prob;
}
Aggregations