use of org.osate.aadl2.RecordValue in project osate2 by osate.
the class Aadl2LabelProvider method text.
String text(ModalPropertyValue ele) {
EList<Mode> ml = ele.getInModes();
String label = "";
if (ml.isEmpty()) {
label = "Non-Modal Value";
// OsateDebug.osateDebug("non modal value" + ele.getOwnedValue());
if ((ele.getOwnedValue() != null) && (!(ele.getOwnedValue() instanceof RangeValue)) && (!(ele.getOwnedValue() instanceof RecordValue)) && (!(ele.getOwnedValue() instanceof ListValue))) {
label += " " + text(ele.getOwnedValue());
}
} else {
String modes = "";
for (Mode m : ml) {
modes = modes + " " + m.getName();
}
label = "Modal property value (" + modes + ")";
}
return label;
}
use of org.osate.aadl2.RecordValue 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;
}
use of org.osate.aadl2.RecordValue in project osate2 by osate.
the class EMV2Properties method getOccurrenceValue.
/**
* Retrieve the value associated with a containment path
* See RDB action to see how it is used.
*
* @param PA value get from getOccurenceDistributionProperty
*/
public static double getOccurrenceValue(final EMV2PropertyAssociation PA) {
double result;
result = 0;
if (PA == null) {
return 0;
}
PropertyExpression val = getPropertyValue(PA);
if (val instanceof RecordValue) {
RecordValue rv = (RecordValue) val;
EList<BasicPropertyAssociation> fields = rv.getOwnedFieldValues();
// for all error types/aliases in type set or the element identified in the containment clause
for (BasicPropertyAssociation bpa : fields) {
if (bpa.getProperty().getName().equalsIgnoreCase("probabilityvalue")) {
PropertyExpression bva = getPropertyValue(bpa);
if (bva instanceof RealLiteral) {
RealLiteral rl = (RealLiteral) bva;
result = rl.getScaledValue();
}
}
}
}
return result;
}
use of org.osate.aadl2.RecordValue in project osate2 by osate.
the class ModelReference method toPropertyExpression.
@Override
public RecordValue toPropertyExpression(ResourceSet resourceSet) {
if (!modelType.isPresent() && !kind.isPresent() && !filename.isPresent() && !artifact.isPresent()) {
throw new IllegalStateException("Record must have at least one field set.");
}
RecordValue recordValue = Aadl2Factory.eINSTANCE.createRecordValue();
modelType.ifPresent(field -> {
BasicPropertyAssociation fieldAssociation = recordValue.createOwnedFieldValue();
fieldAssociation.setProperty(loadField(resourceSet, MODEL_TYPE__URI, MODEL_TYPE__NAME));
fieldAssociation.setOwnedValue(field.toPropertyExpression(resourceSet));
});
kind.ifPresent(field -> {
BasicPropertyAssociation fieldAssociation = recordValue.createOwnedFieldValue();
fieldAssociation.setProperty(loadField(resourceSet, KIND__URI, KIND__NAME));
fieldAssociation.setOwnedValue(field.toPropertyExpression(resourceSet));
});
filename.ifPresent(field -> {
BasicPropertyAssociation fieldAssociation = recordValue.createOwnedFieldValue();
fieldAssociation.setProperty(loadField(resourceSet, FILENAME__URI, FILENAME__NAME));
fieldAssociation.setOwnedValue(CodeGenUtil.toPropertyExpression(field));
});
artifact.ifPresent(field -> {
BasicPropertyAssociation fieldAssociation = recordValue.createOwnedFieldValue();
fieldAssociation.setProperty(loadField(resourceSet, ARTIFACT__URI, ARTIFACT__NAME));
fieldAssociation.setOwnedValue(CodeGenUtil.toPropertyExpression(field));
});
return recordValue;
}
use of org.osate.aadl2.RecordValue in project osate2 by osate.
the class GetProperties method getMinimumTransmissionTimePerByte.
public static double getMinimumTransmissionTimePerByte(final NamedElement bus) {
RecordValue rv;
RangeValue bpa;
NumberValue nv;
rv = GetProperties.getTransmissionTime(bus);
if (rv == null) {
return 0;
}
bpa = (RangeValue) PropertyUtils.getRecordFieldValue(rv, "PerByte");
if (bpa != null) {
nv = bpa.getMinimumValue();
return nv.getScaledValue(GetProperties.getMSUnitLiteral(bus));
}
return 0;
}
Aggregations