Search in sources :

Example 1 with PropertyLookupException

use of org.osate.aadl2.properties.PropertyLookupException in project osate2 by osate.

the class PropertyUtils method getScaledRangeDelta.

/**
 * Return the delta value of a non-modal range property value scaled to a
 * given unit. Returns a given default value if no property value exists.
 * Throws an exception if an error occurs.
 *
 * @param ph The property holder from which to retrieve the property value.
 * @param pd The property to retrieve.
 * @param unit The unit to scale the value to.
 * @param defaultVal The value to return if the property has no value.
 * @return The delta of the range value scaled to the given unit.
 */
public static double getScaledRangeDelta(final NamedElement ph, final Property pd, final UnitLiteral unit, final double defaultVal) {
    try {
        final PropertyExpression pv = checkUnitsAndGetSimplePropertyValue(ph, pd, unit);
        final RangeValue rv = (RangeValue) pv;
        return rv.getDeltaValue().getScaledValue(unit);
    } catch (PropertyLookupException e) {
        return defaultVal;
    }
}
Also used : PropertyExpression(org.osate.aadl2.PropertyExpression) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException) RangeValue(org.osate.aadl2.RangeValue)

Example 2 with PropertyLookupException

use of org.osate.aadl2.properties.PropertyLookupException in project osate2 by osate.

the class GetProperties method getAllowedDispatchProtocol.

public static List<EnumerationLiteral> getAllowedDispatchProtocol(NamedElement ne) {
    try {
        List<EnumerationLiteral> res = new ArrayList<>();
        Property allowedDispatchProtocol = lookupPropertyDefinition(ne, DeploymentProperties._NAME, DeploymentProperties.ALLOWED_DISPATCH_PROTOCOL);
        List<? extends PropertyExpression> propertyValues = ne.getPropertyValueList(allowedDispatchProtocol);
        for (PropertyExpression propertyExpression : propertyValues) {
            res.add((EnumerationLiteral) ((NamedValue) propertyExpression).getNamedValue());
        }
        return res;
    } catch (PropertyLookupException e) {
        return Collections.emptyList();
    }
}
Also used : ArrayList(java.util.ArrayList) PropertyExpression(org.osate.aadl2.PropertyExpression) NamedValue(org.osate.aadl2.NamedValue) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException)

Example 3 with PropertyLookupException

use of org.osate.aadl2.properties.PropertyLookupException in project osate2 by osate.

the class GetProperties method getSourceLanguage.

public static List<String> getSourceLanguage(final NamedElement ne) {
    try {
        List<String> res = new ArrayList<String>();
        Property sourceLanguage = lookupPropertyDefinition(ne, ProgrammingProperties._NAME, ProgrammingProperties.SOURCE_LANGUAGE);
        List<? extends PropertyExpression> propertyValues = ne.getPropertyValueList(sourceLanguage);
        for (PropertyExpression propertyExpression : propertyValues) {
            String v = ((EnumerationLiteral) ((NamedValue) propertyExpression).getNamedValue()).getName();
            res.add(v);
        }
        return res;
    } catch (PropertyLookupException e) {
        return null;
    }
}
Also used : ArrayList(java.util.ArrayList) PropertyExpression(org.osate.aadl2.PropertyExpression) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException)

Example 4 with PropertyLookupException

use of org.osate.aadl2.properties.PropertyLookupException in project osate2 by osate.

the class GetProperties method getModelReferences.

public static List<? extends PropertyExpression> getModelReferences(final NamedElement ne) {
    try {
        Property modelReferences = lookupPropertyDefinition(ne, SEI._NAME, SEI.MODEL_REFERENCES);
        List<? extends PropertyExpression> values = ne.getPropertyValueList(modelReferences);
        return values;
    } catch (PropertyLookupException e) {
        return null;
    }
}
Also used : BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException)

Example 5 with PropertyLookupException

use of org.osate.aadl2.properties.PropertyLookupException in project osate2 by osate.

the class GetProperties method getSourceText.

public static List<String> getSourceText(final NamedElement ne) {
    List<String> res;
    res = new ArrayList<String>();
    try {
        Property st = lookupPropertyDefinition(ne, ProgrammingProperties._NAME, ProgrammingProperties.SOURCE_TEXT);
        List<? extends PropertyExpression> propertyValues = ne.getPropertyValueList(st);
        for (PropertyExpression propertyExpression : propertyValues) {
            // System.out.println("pe=" + propertyExpression);
            StringLiteral sl = (StringLiteral) propertyExpression;
            res.add(sl.getValue());
        }
        return res;
    } catch (PropertyLookupException e) {
        return null;
    }
}
Also used : StringLiteral(org.osate.aadl2.StringLiteral) PropertyExpression(org.osate.aadl2.PropertyExpression) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException)

Aggregations

PropertyLookupException (org.osate.aadl2.properties.PropertyLookupException)23 PropertyExpression (org.osate.aadl2.PropertyExpression)19 Property (org.osate.aadl2.Property)16 BasicProperty (org.osate.aadl2.BasicProperty)12 EnumerationLiteral (org.osate.aadl2.EnumerationLiteral)8 ArrayList (java.util.ArrayList)6 StringLiteral (org.osate.aadl2.StringLiteral)4 NamedValue (org.osate.aadl2.NamedValue)3 RangeValue (org.osate.aadl2.RangeValue)3 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)3 InstanceReferenceValue (org.osate.aadl2.instance.InstanceReferenceValue)3 IntegerLiteral (org.osate.aadl2.IntegerLiteral)2 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)2 UnitLiteral (org.osate.aadl2.UnitLiteral)2 PropertyAcc (org.osate.aadl2.properties.PropertyAcc)2 BooleanLiteral (org.osate.aadl2.BooleanLiteral)1 Classifier (org.osate.aadl2.Classifier)1 ComponentClassifier (org.osate.aadl2.ComponentClassifier)1 ComponentType (org.osate.aadl2.ComponentType)1 NumberValue (org.osate.aadl2.NumberValue)1