Class ModbusWritePropertyConfig
- Version:
- 2.1
- Author:
- matt
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default value for theaddressproperty.static final net.solarnetwork.domain.NodeControlPropertyTypeThe default value for thecontrolPropertyTypeproperty.static final net.solarnetwork.node.io.modbus.ModbusDataTypeThedataTypeproperty default valuestatic final intThedecimalScaleproperty default value.static final net.solarnetwork.node.io.modbus.ModbusWriteFunctionThefunctionproperty default valuestatic final BigDecimalTheunitMultiplierproperty default value.static final intThewordLengthproperty default value.static final PatternA setting type pattern for a property configuration element. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.ModbusWritePropertyConfig(String controlId, net.solarnetwork.domain.NodeControlPropertyType controlPropertyType, net.solarnetwork.node.io.modbus.ModbusDataType dataType, int address) Construct with values.ModbusWritePropertyConfig(String controlId, net.solarnetwork.domain.NodeControlPropertyType controlPropertyType, net.solarnetwork.node.io.modbus.ModbusDataType dataType, int address, int wordLength, BigDecimal unitMultiplier, int decimalScale) Construct with values.ModbusWritePropertyConfig(String controlId, net.solarnetwork.domain.NodeControlPropertyType controlPropertyType, net.solarnetwork.node.io.modbus.ModbusDataType dataType, int address, BigDecimal unitMultiplier) Construct with values.ModbusWritePropertyConfig(String controlId, net.solarnetwork.domain.NodeControlPropertyType controlPropertyType, net.solarnetwork.node.io.modbus.ModbusDataType dataType, int address, BigDecimal unitMultiplier, int decimalScale) Construct with values. -
Method Summary
Modifier and TypeMethodDescriptionGet the register address to start writing data to.Get the control ID.net.solarnetwork.domain.NodeControlPropertyTypeGet the control data type.Get the control property type key.net.solarnetwork.node.io.modbus.ModbusDataTypeGet the data type.Get the data type as a key value.Get the decimal scale to round decimal numbers to.net.solarnetwork.node.io.modbus.ModbusWriteFunctionGet the Modbus function to use.Get the Modbus function code to use as a string.Get the unit multiplier.Get the number of Modbus registers to read.booleanisEmpty()Test if this configuration is empty.booleanisValid()Test if this instance has a valid configuration.static booleanpopulateFromSetting(ModbusControlConfig config, net.solarnetwork.node.domain.Setting setting) Populate a setting as a property configuration value, if possible.voidsetAddress(Integer address) Set the register address to start writing data to.voidsetControlId(String controlId) Set the control ID.voidsetControlPropertyType(net.solarnetwork.domain.NodeControlPropertyType controlPropertyType) Set the control property type.voidSet the datum property type via a key value.voidsetDataType(net.solarnetwork.node.io.modbus.ModbusDataType dataType) Set the data type.voidsetDataTypeKey(String key) Set the data type as a string value.voidsetDecimalScale(Integer decimalScale) Set the decimal scale to round decimal numbers to.voidsetFunction(net.solarnetwork.node.io.modbus.ModbusWriteFunction function) Set the Modbus function to use.voidsetFunctionCode(String function) Set the Modbus function to use as a string.static List<net.solarnetwork.settings.SettingSpecifier>Get the settings to configure an instance of this class.voidsetUnitMultiplier(BigDecimal unitMultiplier) Set the unit multiplier.voidsetWordLength(Integer wordLength) Set the number of Modbus registers to read.List<net.solarnetwork.node.settings.SettingValueBean>toSettingValues(String providerId, String instanceId, int i) Generate a list of setting values.toString()
-
Field Details
-
DEFAULT_ADDRESS
public static final int DEFAULT_ADDRESSThe default value for theaddressproperty.- See Also:
-
DEFAULT_CONTROL_PROPERTY_TYPE
public static final net.solarnetwork.domain.NodeControlPropertyType DEFAULT_CONTROL_PROPERTY_TYPEThe default value for thecontrolPropertyTypeproperty. -
DEFAULT_DATA_TYPE
public static final net.solarnetwork.node.io.modbus.ModbusDataType DEFAULT_DATA_TYPEThedataTypeproperty default value -
DEFAULT_FUNCTION
public static final net.solarnetwork.node.io.modbus.ModbusWriteFunction DEFAULT_FUNCTIONThefunctionproperty default value -
DEFAULT_UNIT_MULTIPLIER
TheunitMultiplierproperty default value. -
DEFAULT_WORD_LENGTH
public static final int DEFAULT_WORD_LENGTHThewordLengthproperty default value.- See Also:
-
DEFAULT_DECIMAL_SCALE
public static final int DEFAULT_DECIMAL_SCALEThedecimalScaleproperty default value.- See Also:
-
PROP_SETTING_PATTERN
A setting type pattern for a property configuration element.The pattern has two capture groups: the property configuration index and the property setting name.
- Since:
- 2.1
-
-
Constructor Details
-
ModbusWritePropertyConfig
public ModbusWritePropertyConfig()Default constructor. -
ModbusWritePropertyConfig
public ModbusWritePropertyConfig(String controlId, net.solarnetwork.domain.NodeControlPropertyType controlPropertyType, net.solarnetwork.node.io.modbus.ModbusDataType dataType, int address) Construct with values.- Parameters:
controlId- the control ID to usecontrolPropertyType- the control property typedataType- the modbus data typeaddress- the modbus register address
-
ModbusWritePropertyConfig
public ModbusWritePropertyConfig(String controlId, net.solarnetwork.domain.NodeControlPropertyType controlPropertyType, net.solarnetwork.node.io.modbus.ModbusDataType dataType, int address, BigDecimal unitMultiplier) Construct with values.- Parameters:
controlId- the control ID to usecontrolPropertyType- the control property typedataType- the modbus data typeaddress- the modbus register addressunitMultiplier- the unit multiplier
-
ModbusWritePropertyConfig
public ModbusWritePropertyConfig(String controlId, net.solarnetwork.domain.NodeControlPropertyType controlPropertyType, net.solarnetwork.node.io.modbus.ModbusDataType dataType, int address, BigDecimal unitMultiplier, int decimalScale) Construct with values.- Parameters:
controlId- the control ID to usecontrolPropertyType- the control property typedataType- the modbus data typeaddress- the modbus register addressunitMultiplier- the unit multiplierdecimalScale- for numbers, the maximum decimal scale to support, or -1 for no limit
-
ModbusWritePropertyConfig
public ModbusWritePropertyConfig(String controlId, net.solarnetwork.domain.NodeControlPropertyType controlPropertyType, net.solarnetwork.node.io.modbus.ModbusDataType dataType, int address, int wordLength, BigDecimal unitMultiplier, int decimalScale) Construct with values.- Parameters:
controlId- the control ID to usecontrolPropertyType- the control property typedataType- the modbus data typeaddress- the modbus register addresswordLength- the modbus word length to readunitMultiplier- the unit multiplierdecimalScale- for numbers, the maximum decimal scale to support, or -1 for no limit
-
-
Method Details
-
isEmpty
public boolean isEmpty()Test if this configuration is empty.- Returns:
- true if all properties are null
- Since:
- 2.1
-
isValid
public boolean isValid()Test if this instance has a valid configuration.This method simply verifies the minimum level of configuration is available for the control to be used.
- Returns:
- true if this configuration is valid for use
-
toString
-
toSettingValues
public List<net.solarnetwork.node.settings.SettingValueBean> toSettingValues(String providerId, String instanceId, int i) Generate a list of setting values.- Parameters:
providerId- the setting provider IDinstanceId- the factory instance IDi- the property index- Returns:
- the settings
- Since:
- 2.1
-
populateFromSetting
public static boolean populateFromSetting(ModbusControlConfig config, net.solarnetwork.node.domain.Setting setting) Populate a setting as a property configuration value, if possible.- Parameters:
config- the overall configurationsetting- the setting to try to handle- Returns:
- true if the setting was handled as a property configuration value
- Since:
- 2.1
-
settings
Get the settings to configure an instance of this class.- Parameters:
prefix- the settings prefix to use- Returns:
- the settings
-
getControlId
Get the control ID.- Returns:
- the control ID
-
setControlId
Set the control ID.- Parameters:
controlId- the control ID to set
-
getControlPropertyType
public net.solarnetwork.domain.NodeControlPropertyType getControlPropertyType()Get the control data type.- Returns:
- the control property type
-
setControlPropertyType
public void setControlPropertyType(net.solarnetwork.domain.NodeControlPropertyType controlPropertyType) Set the control property type.- Parameters:
controlPropertyType- the control property type
-
getControlPropertyTypeKey
Get the control property type key.This returns the configured
getControlPropertyType()NodeControlPropertyType.getKey()value as a string.- Returns:
- the property type key
-
setControlPropertyTypeKey
Set the datum property type via a key value.This uses the first character of
keyas aNodeControlPropertyTypekey value to callsetControlPropertyType(NodeControlPropertyType). Ifkeyis not recognized, thenDEFAULT_CONTROL_PROPERTY_TYPEwill be set instead.- Parameters:
key- the datum property type key to set
-
getFunction
public net.solarnetwork.node.io.modbus.ModbusWriteFunction getFunction()Get the Modbus function to use.- Returns:
- the Modbus function
-
setFunction
public void setFunction(net.solarnetwork.node.io.modbus.ModbusWriteFunction function) Set the Modbus function to use.- Parameters:
function- the Modbus function
-
getFunctionCode
Get the Modbus function code to use as a string.- Returns:
- the Modbus function code as a string
-
setFunctionCode
Set the Modbus function to use as a string.- Parameters:
function- the Modbus function
-
getDataType
public net.solarnetwork.node.io.modbus.ModbusDataType getDataType()Get the data type.- Returns:
- the type
-
setDataType
public void setDataType(net.solarnetwork.node.io.modbus.ModbusDataType dataType) Set the data type.- Parameters:
dataType- the type to set
-
getDataTypeKey
Get the data type as a key value.- Returns:
- the type as a key
-
setDataTypeKey
Set the data type as a string value.- Parameters:
key- the type to set
-
getWordLength
Get the number of Modbus registers to read.This is only used for data types of unknown length, like strings.
- Returns:
- the register count to read
-
setWordLength
Set the number of Modbus registers to read.This is only used for data types of unknown length, like strings.
- Parameters:
wordLength- the register count to read
-
getAddress
Get the register address to start writing data to.- Returns:
- the register address
-
setAddress
Set the register address to start writing data to.- Parameters:
address- the register address to set
-
getUnitMultiplier
Get the unit multiplier.- Returns:
- the multiplier
-
setUnitMultiplier
Set the unit multiplier.This value represents a multiplication factor to apply to values collected for this property so that a standardized unit is captured. For example, a power meter might report power as killowatts, in which case
multipliercan be configured as .001 to convert the value to watts.- Parameters:
unitMultiplier- the mutliplier to set
-
getDecimalScale
Get the decimal scale to round decimal numbers to.- Returns:
- the decimal scale
-
setDecimalScale
Set the decimal scale to round decimal numbers to.This is a maximum scale value that decimal values should be rounded to. This is applied after any
unitMultiplieris applied. A scale of 0 would round all decimals to integer values.- Parameters:
decimalScale- the scale to set, or -1 to disable rounding completely
-