Search in sources :

Example 66 with NumberValue

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

the class UnitLiteralImpl method basicSetFactor.

/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetFactor(NumberValue newFactor, NotificationChain msgs) {
    NumberValue oldFactor = factor;
    factor = newFactor;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Aadl2Package.UNIT_LITERAL__FACTOR, oldFactor, newFactor);
        if (msgs == null) {
            msgs = notification;
        } else {
            msgs.add(notification);
        }
    }
    return msgs;
}
Also used : NumberValue(org.osate.aadl2.NumberValue) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 67 with NumberValue

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

the class GetProperties method getMinDataRate.

public static double getMinDataRate(RecordValue rate) {
    BasicPropertyAssociation vr = GetProperties.getRecordField(rate.getOwnedFieldValues(), "Value_Range");
    if (vr == null) {
        return 0;
    }
    RangeValue rv = (RangeValue) vr.getOwnedValue();
    PropertyExpression minimum = rv.getMinimum().evaluate(null, 0).first().getValue();
    return ((NumberValue) minimum).getScaledValue();
}
Also used : NumberValue(org.osate.aadl2.NumberValue) PropertyExpression(org.osate.aadl2.PropertyExpression) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) RangeValue(org.osate.aadl2.RangeValue)

Example 68 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. 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 maximum of the range value scaled to the given unit.
 */
public static double getScaledRangeMaximum(final NamedElement ne, final Property pd, final UnitLiteral unit, final double defaultVal) {
    try {
        final PropertyExpression pv = checkUnitsAndGetSimplePropertyValue(ne, pd, unit);
        final RangeValue rv = (RangeValue) pv;
        PropertyExpression maximum = rv.getMaximum().evaluate(null, 0).first().getValue();
        if (maximum instanceof NumberValue) {
            return ((NumberValue) maximum).getScaledValue(unit);
        } else {
            return defaultVal;
        }
    } catch (PropertyLookupException e) {
        return defaultVal;
    }
}
Also used : NumberValue(org.osate.aadl2.NumberValue) PropertyExpression(org.osate.aadl2.PropertyExpression) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException) 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