Class ModbusWritePropertyConfig

java.lang.Object
net.solarnetwork.node.control.modbus.ModbusWritePropertyConfig

public class ModbusWritePropertyConfig extends Object
Configuration for a single control property to be set via Modbus.
Version:
2.1
Author:
matt
  • Field Details

    • DEFAULT_ADDRESS

      public static final int DEFAULT_ADDRESS
      The default value for the address property.
      See Also:
    • DEFAULT_CONTROL_PROPERTY_TYPE

      public static final net.solarnetwork.domain.NodeControlPropertyType DEFAULT_CONTROL_PROPERTY_TYPE
      The default value for the controlPropertyType property.
    • DEFAULT_DATA_TYPE

      public static final net.solarnetwork.node.io.modbus.ModbusDataType DEFAULT_DATA_TYPE
      The dataType property default value
    • DEFAULT_FUNCTION

      public static final net.solarnetwork.node.io.modbus.ModbusWriteFunction DEFAULT_FUNCTION
      The function property default value
    • DEFAULT_UNIT_MULTIPLIER

      public static final BigDecimal DEFAULT_UNIT_MULTIPLIER
      The unitMultiplier property default value.
    • DEFAULT_WORD_LENGTH

      public static final int DEFAULT_WORD_LENGTH
      The wordLength property default value.
      See Also:
    • DEFAULT_DECIMAL_SCALE

      public static final int DEFAULT_DECIMAL_SCALE
      The decimalScale property default value.
      See Also:
    • PROP_SETTING_PATTERN

      public static final Pattern 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 use
      controlPropertyType - the control property type
      dataType - the modbus data type
      address - 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 use
      controlPropertyType - the control property type
      dataType - the modbus data type
      address - the modbus register address
      unitMultiplier - 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 use
      controlPropertyType - the control property type
      dataType - the modbus data type
      address - the modbus register address
      unitMultiplier - the unit multiplier
      decimalScale - 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 use
      controlPropertyType - the control property type
      dataType - the modbus data type
      address - the modbus register address
      wordLength - the modbus word length to read
      unitMultiplier - the unit multiplier
      decimalScale - 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

      public String toString()
      Overrides:
      toString in class Object
    • 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 ID
      instanceId - the factory instance ID
      i - 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 configuration
      setting - the setting to try to handle
      Returns:
      true if the setting was handled as a property configuration value
      Since:
      2.1
    • settings

      public static List<net.solarnetwork.settings.SettingSpecifier> settings(String prefix)
      Get the settings to configure an instance of this class.
      Parameters:
      prefix - the settings prefix to use
      Returns:
      the settings
    • getControlId

      public String getControlId()
      Get the control ID.
      Returns:
      the control ID
    • setControlId

      public void setControlId(String controlId)
      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

      public String getControlPropertyTypeKey()
      Get the control property type key.

      This returns the configured getControlPropertyType() NodeControlPropertyType.getKey() value as a string.

      Returns:
      the property type key
    • setControlPropertyTypeKey

      public void setControlPropertyTypeKey(String key)
      Set the datum property type via a key value.

      This uses the first character of key as a NodeControlPropertyType key value to call setControlPropertyType(NodeControlPropertyType). If key is not recognized, then DEFAULT_CONTROL_PROPERTY_TYPE will 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

      public String getFunctionCode()
      Get the Modbus function code to use as a string.
      Returns:
      the Modbus function code as a string
    • setFunctionCode

      public void setFunctionCode(String function)
      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

      public String getDataTypeKey()
      Get the data type as a key value.
      Returns:
      the type as a key
    • setDataTypeKey

      public void setDataTypeKey(String key)
      Set the data type as a string value.
      Parameters:
      key - the type to set
    • getWordLength

      public Integer 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

      public void setWordLength(Integer wordLength)
      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

      public Integer getAddress()
      Get the register address to start writing data to.
      Returns:
      the register address
    • setAddress

      public void setAddress(Integer address)
      Set the register address to start writing data to.
      Parameters:
      address - the register address to set
    • getUnitMultiplier

      public BigDecimal getUnitMultiplier()
      Get the unit multiplier.
      Returns:
      the multiplier
    • setUnitMultiplier

      public void setUnitMultiplier(BigDecimal unitMultiplier)
      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 multiplier can be configured as .001 to convert the value to watts.

      Parameters:
      unitMultiplier - the mutliplier to set
    • getDecimalScale

      public Integer getDecimalScale()
      Get the decimal scale to round decimal numbers to.
      Returns:
      the decimal scale
    • setDecimalScale

      public void setDecimalScale(Integer decimalScale)
      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 unitMultiplier is applied. A scale of 0 would round all decimals to integer values.

      Parameters:
      decimalScale - the scale to set, or -1 to disable rounding completely