Search in sources :

Example 6 with RecordValue

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;
}
Also used : Mode(org.osate.aadl2.Mode) ListValue(org.osate.aadl2.ListValue) RecordValue(org.osate.aadl2.RecordValue) RangeValue(org.osate.aadl2.RangeValue)

Example 7 with RecordValue

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;
}
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 8 with RecordValue

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;
}
Also used : RealLiteral(org.osate.aadl2.RealLiteral) RecordValue(org.osate.aadl2.RecordValue) PropertyExpression(org.osate.aadl2.PropertyExpression) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation)

Example 9 with RecordValue

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;
}
Also used : RecordValue(org.osate.aadl2.RecordValue) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation)

Example 10 with 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;
}
Also used : NumberValue(org.osate.aadl2.NumberValue) RecordValue(org.osate.aadl2.RecordValue) RangeValue(org.osate.aadl2.RangeValue)

Aggregations

RecordValue (org.osate.aadl2.RecordValue)46 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)37 ListValue (org.osate.aadl2.ListValue)22 PropertyExpression (org.osate.aadl2.PropertyExpression)20 RangeValue (org.osate.aadl2.RangeValue)19 ClassifierValue (org.osate.aadl2.ClassifierValue)13 IntegerLiteral (org.osate.aadl2.IntegerLiteral)13 StringLiteral (org.osate.aadl2.StringLiteral)13 RealLiteral (org.osate.aadl2.RealLiteral)12 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)11 NamedValue (org.osate.aadl2.NamedValue)11 BooleanLiteral (org.osate.aadl2.BooleanLiteral)10 ReferenceValue (org.osate.aadl2.ReferenceValue)10 ComputedValue (org.osate.aadl2.ComputedValue)8 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)8 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)8 NamedElement (org.osate.aadl2.NamedElement)8 PropertyAssociation (org.osate.aadl2.PropertyAssociation)8 ArrayRange (org.osate.aadl2.ArrayRange)7 Operation (org.osate.aadl2.Operation)7