Search in sources :

Example 6 with PropertyLookupException

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

the class GetProperties method getProvidedConnectionQualityOfService.

public static List<EnumerationLiteral> getProvidedConnectionQualityOfService(NamedElement ne) {
    try {
        List<EnumerationLiteral> res = new ArrayList<>();
        Property providedConnQos = lookupPropertyDefinition(ne, DeploymentProperties._NAME, DeploymentProperties.PROVIDED_CONNECTION_QUALITY_OF_SERVICE);
        List<? extends PropertyExpression> propertyValues = ne.getPropertyValueList(providedConnQos);
        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 7 with PropertyLookupException

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

the class GetProperties method getSourceName.

public static String getSourceName(final NamedElement ne) {
    try {
        Property sn = lookupPropertyDefinition(ne, ProgrammingProperties._NAME, ProgrammingProperties.SOURCE_NAME);
        PropertyAcc pacc = ne.getPropertyValue(sn);
        if (pacc.getAssociations().size() > 0) {
            ModalPropertyValue mdv = pacc.getAssociations().get(0).getOwnedValues().get(0);
            PropertyExpression pe = mdv.getOwnedValue();
            // System.out.println("pe=" + pe);
            StringLiteral sl = (StringLiteral) pe;
            return sl.getValue();
        }
        // System.out.println("pacc" + pacc.getAssociations().get(0).getOwnedValues().get(0));
        return null;
    } catch (PropertyLookupException e) {
        return null;
    }
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) StringLiteral(org.osate.aadl2.StringLiteral) PropertyAcc(org.osate.aadl2.properties.PropertyAcc) PropertyExpression(org.osate.aadl2.PropertyExpression) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException)

Example 8 with PropertyLookupException

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

the class GetProperties method getConcurrencyControlProtocol.

public static String getConcurrencyControlProtocol(final NamedElement ne) {
    try {
        Property concurrencyControlProtocol = lookupPropertyDefinition(ne, ThreadProperties._NAME, DeploymentProperties.CONCURRENCY_CONTROL_PROTOCOL);
        List<? extends PropertyExpression> propertyValues = ne.getPropertyValueList(concurrencyControlProtocol);
        if (!propertyValues.isEmpty()) {
            return ((EnumerationLiteral) ((NamedValue) propertyValues.iterator().next()).getNamedValue()).getName();
        } else {
            return null;
        }
    } catch (PropertyLookupException e) {
        return null;
    }
}
Also used : BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException)

Example 9 with PropertyLookupException

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

the class PokProperties method getTimeSlotInMs.

public static List<Double> getTimeSlotInMs(final NamedElement ne) {
    List<Double> res;
    UnitLiteral milliseconds;
    res = new ArrayList<Double>();
    try {
        Property slots = GetProperties.lookupPropertyDefinition(ne, PokProperties._NAME, PokProperties._SLOTS);
        milliseconds = GetProperties.getMSUnitLiteral(slots);
        List<? extends PropertyExpression> propertyValues = ne.getPropertyValueList(slots);
        for (PropertyExpression propertyExpression : propertyValues) {
            double time = ((IntegerLiteral) propertyExpression).getScaledValue(milliseconds);
            res.add(time);
        }
        return res;
    } catch (PropertyLookupException e) {
        return null;
    }
}
Also used : PropertyExpression(org.osate.aadl2.PropertyExpression) UnitLiteral(org.osate.aadl2.UnitLiteral) Property(org.osate.aadl2.Property) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException) IntegerLiteral(org.osate.aadl2.IntegerLiteral)

Example 10 with PropertyLookupException

use of org.osate.aadl2.properties.PropertyLookupException in project osate-plugin by sireum.

the class HAMRPropertyProvider method getHWsFromElement.

public static List<HW> getHWsFromElement(NamedElement ne) {
    List<HW> r = new ArrayList<>();
    try {
        Property p = GetProperties.lookupPropertyDefinition(ne, PROP_HAMR__HW);
        List<? extends PropertyExpression> propertyValues = ne.getPropertyValueList(p);
        for (PropertyExpression pe : propertyValues) {
            String v = ((EnumerationLiteral) ((NamedValue) pe).getNamedValue()).getName();
            r.add(HW.valueOf(v));
        }
    } catch (PropertyLookupException e) {
    }
    return r;
}
Also used : ArrayList(java.util.ArrayList) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) 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