Class NumberDatumSamplePropertyConfig<V>
DatumSamplePropertyConfig specifically designed to help
with number property values.
This class contains two pairs of linear equation property pairs that can be used to transform raw data values x into appropriate datum values y. ly just one pair needs to be used; sometimes it is more convenient to use one pair over the other.
First, the unitSlope M and unitIntercept B
properties are calculated using the equation y = M * (x + B).
Second, the slope m and intercept b properties
are used with an equation like y = (m * x) + b. If both are
specified, the overall equation is thus
y = (m * (M * (x + B))) + b.
- Since:
- 1.54
- Version:
- 2.0
- Author:
- matt
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default value for thedecimalScaleproperty.static final BigDecimalThe default value for theinterceptandunitInterceptproperties.static final DatumSamplesTypeThe default value for thepropertyTypeproperty.static final BigDecimalThe default value for theslopeandunitSlopeproperties. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.NumberDatumSamplePropertyConfig(String propertyKey, DatumSamplesType propertyType, V config) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionapplyTransformations(Number value) Apply the configured slope, intercept, unit slope, unit intercept, and decimal scale to a number value.intGet the decimal scale to round decimal numbers to.Get the y-intercept offset.getSlope()Get the slope multiplier.Get the unit y-intercept offset.Get the unit slope multiplier.static List<SettingSpecifier>numberTransformSettings(String prefix) Get the number transform settings for all transforms.voidsetDecimalScale(int decimalScale) Set the decimal scale to round decimal numbers to.voidsetIntercept(BigDecimal intercept) Set the y-intercept offset.voidsetSlope(BigDecimal slope) Set the slope multiplier.voidsetUnitIntercept(BigDecimal unitIntercept) Set the unit y-intercept offset.voidsetUnitSlope(BigDecimal unitSlope) Set the unit slope multiplier.Methods inherited from class net.solarnetwork.domain.datum.DatumSamplePropertyConfig
getConfig, getPropertyKey, getPropertyType, getPropertyTypeKey, setConfig, setPropertyKey, setPropertyType, setPropertyTypeKey, toString
-
Field Details
-
DEFAULT_PROPERTY_TYPE
The default value for thepropertyTypeproperty. -
DEFAULT_SLOPE
The default value for theslopeandunitSlopeproperties. -
DEFAULT_INTERCEPT
The default value for theinterceptandunitInterceptproperties. -
DEFAULT_DECIMAL_SCALE
public static final int DEFAULT_DECIMAL_SCALEThe default value for thedecimalScaleproperty.- See Also:
-
-
Constructor Details
-
NumberDatumSamplePropertyConfig
public NumberDatumSamplePropertyConfig()Default constructor. -
NumberDatumSamplePropertyConfig
Constructor.- Parameters:
propertyKey- the datum property name to assignpropertyType- the datum property typeconfig- the configuration value
-
-
Method Details
-
numberTransformSettings
Get the number transform settings for all transforms.- Parameters:
prefix- the optional prefix- Returns:
- the settings for unit intercept, unit slope, slope, and intercept
- Since:
- 2.0
-
applyTransformations
Apply the configured slope, intercept, unit slope, unit intercept, and decimal scale to a number value.This executes the equation y = (m * (M * (x + B))) + b and applys
getDecimalScale()to the result. The variables are:- x - the
valuepassed to this method - M - the
getUnitSlope()value - B - the
getUnitIntercept()value - m - the
getSlope()value - b - the
getIntercept()value
- Parameters:
value- the number to apply the transform properties to- Returns:
- the result, or null if
valueis null
- x - the
-
getSlope
Get the slope multiplier.This value represents m in the equation
y = mx + b. For example, a power meter might report power as killowatts, in which caseslopecan be configured as .001 to convert the value to watts.- Returns:
- the slope multiplier, never null; defaults to
DEFAULT_SLOPE
-
setSlope
Set the slope multiplier.- Parameters:
slope- the slope multiplier to set; if nullDEFAULT_SLOPEwill be used instead
-
getIntercept
Get the y-intercept offset.This value represents b in the equation
y = mx + b. For example, a sensor might report values in the range -10..10 which should be interpreted as values in the range 0..20, in which caseinterceptcan be configured as 10 to convert the value appropriately.- Returns:
- the y-intercept, never null; defaults to
DEFAULT_INTERCEPT
-
setIntercept
Set the y-intercept offset.- Parameters:
intercept- the intercept offset to set; if nullDEFAULT_INTERCEPTwill be used instead
-
getUnitSlope
Get the unit slope multiplier.This value represents m in the equation
y = m(x + b). For example, a power meter might report power as killowatts, in which caseslopecan be configured as .001 to convert the value to watts.- Returns:
- the unit slope multiplier, never null; defaults to
DEFAULT_SLOPE
-
setUnitSlope
Set the unit slope multiplier.- Parameters:
unitSlope- the unit slope multiplier to set; if nullDEFAULT_SLOPEwill be used instead
-
getUnitIntercept
Get the unit y-intercept offset.This value represents b in the equation
y = m(x + b). For example, a sensor might report values in the range -10..10 which should be interpreted as values in the range 0..20, in which caseinterceptcan be configured as 10 to convert the value appropriately.- Returns:
- the unit y-intercept, never null; defaults to
DEFAULT_INTERCEPT
-
setUnitIntercept
Set the unit y-intercept offset.- Parameters:
unitIntercept- the unit intercept offset to set; if nullDEFAULT_INTERCEPTwill be used instead
-
getDecimalScale
public int getDecimalScale()Get the decimal scale to round decimal numbers to.- Returns:
- the decimal scale; defaults to
DEFAULT_DECIMAL_SCALE
-
setDecimalScale
public void setDecimalScale(int decimalScale) Set the decimal scale to round decimal numbers to.This is a maximum scale value that decimal values should be rounded to. A scale of 0 would round all decimals to integer values.
- Parameters:
decimalScale- the maximum scale to set, or -1 to disable rounding completely
-