Search in sources :

Example 16 with PropertyLookupException

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

the class GetProperties method getPlatform.

public static String getPlatform(final NamedElement ne) {
    try {
        Property sn = lookupPropertyDefinition(ne, SEI._NAME, SEI.PLATFORM);
        PropertyAcc pacc = ne.getPropertyValue(sn);
        if (pacc.getAssociations().size() > 0) {
            ModalPropertyValue mdv = pacc.getAssociations().get(0).getOwnedValues().get(0);
            PropertyExpression pe = mdv.getOwnedValue();
            StringLiteral sl = (StringLiteral) pe;
            return sl.getValue();
        }
        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 17 with PropertyLookupException

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

the class GetProperties method getModuleSchedule.

/**
 * Get the module schedule for a processor
 *
 * @param ne
 *            - the processor component
 * @return - a list with all the module schedule. An empty list if not
 *         defined.
 */
public static List<ARINC653ScheduleWindow> getModuleSchedule(final ComponentInstance io) {
    Property moduleScheduleProperty;
    List<ARINC653ScheduleWindow> windows;
    List<? extends PropertyExpression> propertyValues;
    RecordValue window;
    IntegerLiteral windowTime;
    InstanceReferenceValue windowPartition;
    ARINC653ScheduleWindow scheduleWindow;
    boolean startProcessing;
    ComponentInstance part;
    double time;
    Property period;
    UnitLiteral milliseconds;
    period = lookupPropertyDefinition(io, TimingProperties._NAME, TimingProperties.PERIOD);
    milliseconds = findUnitLiteral(period, AadlProject.MS_LITERAL);
    time = 0;
    part = null;
    startProcessing = true;
    moduleScheduleProperty = lookupPropertyDefinition(io, ARINC653Properties._NAME, ARINC653Properties.MODULE_SCHEDULE);
    windows = new ArrayList<ARINC653ScheduleWindow>();
    try {
        propertyValues = io.getPropertyValueList(moduleScheduleProperty);
        for (PropertyExpression propertyExpression : propertyValues) {
            if (propertyExpression != null) {
                window = (RecordValue) propertyExpression;
                windowTime = (IntegerLiteral) PropertyUtils.getRecordFieldValue(window, "duration");
                windowPartition = (InstanceReferenceValue) PropertyUtils.getRecordFieldValue(window, "partition");
                if (windowPartition != null) {
                    part = (ComponentInstance) windowPartition.getReferencedInstanceObject();
                }
                if (windowTime == null) {
                    time = 0;
                } else {
                    time = ((NumberValue) windowTime).getScaledValue(milliseconds);
                }
                if (part != null) {
                    scheduleWindow = new ARINC653ScheduleWindow(part, time, startProcessing);
                    windows.add(scheduleWindow);
                }
            }
        }
    } catch (PropertyLookupException e) {
        return windows;
    }
    return windows;
}
Also used : RecordValue(org.osate.aadl2.RecordValue) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) PropertyExpression(org.osate.aadl2.PropertyExpression) UnitLiteral(org.osate.aadl2.UnitLiteral) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) IntegerLiteral(org.osate.aadl2.IntegerLiteral)

Example 18 with PropertyLookupException

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

the class GetProperties method getRequiredConnectionQualityOfService.

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

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

the class PropertyUtils method getClassifierReference.

public static Classifier getClassifierReference(final NamedElement ph, final Property pd) {
    if (ph == null) {
        return null;
    }
    try {
        final PropertyExpression pv = ph.getSimplePropertyValue(pd);
        final Classifier ref = ((ClassifierValueImpl) pv).getClassifier();
        return ref;
    } catch (PropertyLookupException e) {
        return null;
    }
}
Also used : ClassifierValueImpl(org.osate.aadl2.impl.ClassifierValueImpl) PropertyExpression(org.osate.aadl2.PropertyExpression) Classifier(org.osate.aadl2.Classifier) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException)

Example 20 with PropertyLookupException

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

the class PropertyUtils method getScaledRangeMinimum.

// TODO-LW: treat minimum same as maximum
/**
 * Return the minimum 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 minimum of the range value scaled to the given unit.
 */
public static double getScaledRangeMinimum(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.getMinimumValue().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)

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