Search in sources :

Example 6 with NumberValue

use of com.google.api.ads.admanager.jaxws.v202205.NumberValue in project osate2 by osate.

the class GetProperties method getMaximumTransmissionTimeFixed.

public static double getMaximumTransmissionTimeFixed(final NamedElement bus) {
    RecordValue rv;
    RangeValue bpa;
    NumberValue nv;
    rv = GetProperties.getTransmissionTime(bus);
    if (rv == null) {
        return 0;
    }
    bpa = (RangeValue) PropertyUtils.getRecordFieldValue(rv, "Fixed");
    if (bpa != null) {
        nv = bpa.getMaximumValue();
        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)

Example 7 with NumberValue

use of com.google.api.ads.admanager.jaxws.v202205.NumberValue in project osate2 by osate.

the class GetProperties method getMaximumTransmissionTimePerByte.

public static double getMaximumTransmissionTimePerByte(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.getMaximumValue();
        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)

Example 8 with NumberValue

use of com.google.api.ads.admanager.jaxws.v202205.NumberValue in project osate2 by osate.

the class GetProperties method getMinimumTransmissionTimeFixed.

public static double getMinimumTransmissionTimeFixed(final NamedElement bus) {
    RecordValue rv;
    RangeValue bpa;
    NumberValue nv;
    rv = GetProperties.getTransmissionTime(bus);
    if (rv == null) {
        return 0;
    }
    bpa = (RangeValue) PropertyUtils.getRecordFieldValue(rv, "Fixed");
    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)

Example 9 with NumberValue

use of com.google.api.ads.admanager.jaxws.v202205.NumberValue in project osate2 by osate.

the class PropertyUtils method getScaledRangeMaximum.

/**
 * Return the maximum value of a non-modal range property value scaled to a
 * given unit. Throws an exception if no property value exists or 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.
 * @return The maximum of the range value scaled to the given unit.
 * @throws InvalidModelException Thrown if the property value cannot be
 *             retrieved because the model is incomplete or otherwise
 *             invalid.
 * @throws PropertyNotPresentException Thrown if the property is undefined
 *             for ph.
 * @throws PropertyIsModalException Thrown if ph is modal and declarative.
 * @throws IllegalStateException Thrown if the lookup encounters a cycle of
 *             property reference dependencies.
 * @throws IllegalArgumentException Thrown if the given unit literal is not
 *             from the property's unit type or if ph, pd, or unit is null.
 * @throws PropertyDoesNotApplyToHolderException Thrown if pd does not apply
 *             to ph.
 * @throws PropertyIsListException Thrown if the property is not scalar.
 * @throws ClassCastException Thrown if the retrieved value is not a range
 *             value.
 */
public static double getScaledRangeMaximum(final NamedElement ph, final Property pd, final UnitLiteral unit) throws InvalidModelException, PropertyNotPresentException, PropertyIsModalException, IllegalStateException, IllegalArgumentException, PropertyDoesNotApplyToHolderException, PropertyIsListException, ClassCastException {
    final PropertyExpression pv = checkUnitsAndGetSimplePropertyValue(ph, pd, unit);
    RangeValue rv = (RangeValue) pv;
    PropertyExpression maximum = rv.getMaximum().evaluate(null, 0).first().getValue();
    if (maximum instanceof NumberValue) {
        return ((NumberValue) maximum).getScaledValue(unit);
    }
    throw new InvalidModelException(maximum, "Cannot evaluate upper range limit");
}
Also used : InvalidModelException(org.osate.aadl2.properties.InvalidModelException) NumberValue(org.osate.aadl2.NumberValue) PropertyExpression(org.osate.aadl2.PropertyExpression) RangeValue(org.osate.aadl2.RangeValue)

Example 10 with NumberValue

use of com.google.api.ads.admanager.jaxws.v202205.NumberValue in project osate2 by osate.

the class AADLBus method getTransmissionTimePerByte.

private static double getTransmissionTimePerByte(final ComponentInstance proc) {
    RecordValue rv = GetProperties.getTransmissionTime(proc);
    if (rv == null) {
        return DEFAULT_TRANSMISSION_TIME;
    }
    RangeValue bpa = (RangeValue) PropertyUtils.getRecordFieldValue(rv, "PerByte");
    if (bpa != null) {
        NumberValue nv = bpa.getMaximumValue();
        return nv.getScaledValue(GetProperties.getSecUnitLiteral(proc));
    }
    return 0;
}
Also used : NumberValue(org.osate.aadl2.NumberValue) RecordValue(org.osate.aadl2.RecordValue) RangeValue(org.osate.aadl2.RangeValue)

Aggregations

LinkedHashSet (java.util.LinkedHashSet)30 NumberValue (org.osate.aadl2.NumberValue)24 RangeValue (org.osate.aadl2.RangeValue)13 PropertyExpression (org.osate.aadl2.PropertyExpression)12 ParseException (java.text.ParseException)10 Set (java.util.Set)10 Before (org.junit.Before)10 Test (org.junit.Test)10 RecordValue (org.osate.aadl2.RecordValue)6 NumberValue (com.google.api.ads.admanager.axis.v202108.NumberValue)5 NumberValue (com.google.api.ads.admanager.axis.v202111.NumberValue)5 BooleanValue (com.google.api.ads.admanager.axis.v202105.BooleanValue)4 DateTimeValue (com.google.api.ads.admanager.axis.v202105.DateTimeValue)4 DateValue (com.google.api.ads.admanager.axis.v202105.DateValue)4 NumberValue (com.google.api.ads.admanager.axis.v202105.NumberValue)4 SetValue (com.google.api.ads.admanager.axis.v202105.SetValue)4 TargetingValue (com.google.api.ads.admanager.axis.v202105.TargetingValue)4 TextValue (com.google.api.ads.admanager.axis.v202105.TextValue)4 BooleanValue (com.google.api.ads.admanager.axis.v202202.BooleanValue)4 BooleanValue (com.google.api.ads.admanager.jaxws.v202205.BooleanValue)4