Class ModbusControl

java.lang.Object
net.solarnetwork.service.support.BasicIdentifiable
net.solarnetwork.node.service.support.BaseIdentifiable
net.solarnetwork.node.io.modbus.support.ModbusDeviceSupport
net.solarnetwork.node.control.modbus.ModbusControl
All Implemented Interfaces:
net.solarnetwork.node.reactor.InstructionHandler, net.solarnetwork.node.service.NodeControlProvider, net.solarnetwork.service.Identifiable, net.solarnetwork.settings.SettingSpecifierProvider

public class ModbusControl extends net.solarnetwork.node.io.modbus.support.ModbusDeviceSupport implements net.solarnetwork.settings.SettingSpecifierProvider, net.solarnetwork.node.service.NodeControlProvider, net.solarnetwork.node.reactor.InstructionHandler
Read and write a Modbus "coil" or "holding" type register.
Version:
3.4
Author:
matt
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The default value for the address property.
    static final String
    The default value for the controlId property.
    static final int
    The maxReadWordCount property default value.
    static final long
    The default value for the sampleCacheMs property.
    static final net.solarnetwork.node.io.modbus.ModbusWordOrder
    The wordOrder property default value.
    static final String
    The setting UID used by this service.

    Fields inherited from class net.solarnetwork.node.io.modbus.support.ModbusDeviceSupport

    DEFAULT_NETWORK_UID, DEFAULT_UNIT_ID, INFO_KEY_DEVICE_MANUFACTURE_DATE, log

    Fields inherited from interface net.solarnetwork.service.Identifiable

    GROUP_UID_PROPERTY, UID_PROPERTY

    Fields inherited from interface net.solarnetwork.node.reactor.InstructionHandler

    PARAM_MESSAGE, PARAM_SERVICE, PARAM_SERVICE_ARGUMENT, PARAM_SERVICE_RESULT, PARAM_STATUS_CODE, TOPIC_DEMAND_BALANCE, TOPIC_SET_CONTROL_PARAMETER, TOPIC_SET_OPERATING_STATE, TOPIC_SHED_LOAD, TOPIC_SIGNAL, TOPIC_SYSTEM_CONFIGURE

    Fields inherited from interface net.solarnetwork.node.service.NodeControlProvider

    EVENT_TOPIC_CONTROL_INFO_CAPTURED, EVENT_TOPIC_CONTROL_INFO_CHANGED
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    net.solarnetwork.domain.NodeControlInfo
     
     
    net.solarnetwork.service.OptionalService<org.osgi.service.event.EventAdmin>
    Get the event admin service.
    int
    Get the maximum number of Modbus registers to read in any single read operation.
    protected List<net.solarnetwork.settings.SettingSpecifier>
    Get setting specifiers for the unitId and modbusNetwork.propertyFilters['uid'] properties.
    Get the property configurations.
    int
    Get the number of configured propConfigs elements.
    long
    Get the sample cache maximum age, in milliseconds.
    List<net.solarnetwork.settings.SettingSpecifier>
     
     
    net.solarnetwork.node.io.modbus.ModbusWordOrder
    Get the word order.
    char
    Get the word order as a key value.
    boolean
     
    net.solarnetwork.node.reactor.InstructionStatus
    processInstruction(net.solarnetwork.node.reactor.Instruction instruction)
     
    protected Map<String,Object>
    readDeviceInfo(net.solarnetwork.node.io.modbus.ModbusConnection conn)
     
    void
    setEventAdmin(net.solarnetwork.service.OptionalService<org.osgi.service.event.EventAdmin> eventAdmin)
    Set the event admin sevice.
    void
    setMaxReadWordCount(int maxReadWordCount)
    Set the maximum number of Modbus registers to read in any single read operation.
    void
    Get the property configurations to use.
    void
    Adjust the number of configured propConfigs elements.
    void
    setSampleCacheMs(long sampleCacheMs)
    Set the sample cache maximum age, in milliseconds.
    void
    setWordOrder(net.solarnetwork.node.io.modbus.ModbusWordOrder wordOrder)
    Set the word order.
    void
    setWordOrderKey(char key)
    Set the word order as a key value.

    Methods inherited from class net.solarnetwork.node.io.modbus.support.ModbusDeviceSupport

    getDeviceInfo, getDeviceInfoMap, getDeviceInfoMessage, getModbusNetwork, getUnitId, modbusDeviceName, modbusNetwork, modbusNetworkSettings, performAction, setDeviceInfoMap, setModbusNetwork, setUnitId

    Methods inherited from class net.solarnetwork.node.service.support.BaseIdentifiable

    baseIdentifiableSettings, baseIdentifiableSettings, getExpressionServices, getPlaceholderService, populateExpressionDatumProperties, resolvePlaceholders, resolvePlaceholders, setExpressionServices, setPlaceholderService

    Methods inherited from class net.solarnetwork.service.support.BasicIdentifiable

    basicIdentifiableMetadataSettings, basicIdentifiableSettings, basicIdentifiableSettings, basicIdentifiableSettings, doubleMetadataValue, getGroupUid, getGroupUID, getMessageSource, getMetadata, getMetadataCount, getUid, getUID, integerMetadataValue, metadataValue, numberMetadataValue, saveMetadataValue, saveMetadataValue, setDisplayName, setGroupUid, setGroupUID, setMessageSource, setMetadata, setMetadataCount, setUid, setUID, smartMetadataValue

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.solarnetwork.service.Identifiable

    getGroupUid, getUid

    Methods inherited from interface net.solarnetwork.settings.SettingSpecifierProvider

    getMessageSource
  • Field Details

    • DEFAULT_ADDRESS

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

      public static final String DEFAULT_CONTROL_ID
      The default value for the controlId property.
      See Also:
    • SETTING_UID

      public static final String SETTING_UID
      The setting UID used by this service.
      Since:
      3.1
      See Also:
    • DEFAULT_MAX_READ_WORD_COUNT

      public static final int DEFAULT_MAX_READ_WORD_COUNT
      The maxReadWordCount property default value.
      Since:
      3.2
      See Also:
    • DEFAULT_WORD_ORDER

      public static final net.solarnetwork.node.io.modbus.ModbusWordOrder DEFAULT_WORD_ORDER
      The wordOrder property default value.
      Since:
      3.4
    • DEFAULT_SAMPLE_CACHE_MS

      public static final long DEFAULT_SAMPLE_CACHE_MS
      The default value for the sampleCacheMs property.
      Since:
      3.4
      See Also:
  • Constructor Details

    • ModbusControl

      public ModbusControl()
      Constructor.
  • Method Details

    • readDeviceInfo

      protected Map<String,Object> readDeviceInfo(net.solarnetwork.node.io.modbus.ModbusConnection conn)
      Specified by:
      readDeviceInfo in class net.solarnetwork.node.io.modbus.support.ModbusDeviceSupport
    • getAvailableControlIds

      public List<String> getAvailableControlIds()
      Specified by:
      getAvailableControlIds in interface net.solarnetwork.node.service.NodeControlProvider
    • getCurrentControlInfo

      public net.solarnetwork.domain.NodeControlInfo getCurrentControlInfo(String controlId)
      Specified by:
      getCurrentControlInfo in interface net.solarnetwork.node.service.NodeControlProvider
    • handlesTopic

      public boolean handlesTopic(String topic)
      Specified by:
      handlesTopic in interface net.solarnetwork.node.reactor.InstructionHandler
    • processInstruction

      public net.solarnetwork.node.reactor.InstructionStatus processInstruction(net.solarnetwork.node.reactor.Instruction instruction)
      Specified by:
      processInstruction in interface net.solarnetwork.node.reactor.InstructionHandler
    • getSettingUid

      public String getSettingUid()
      Specified by:
      getSettingUid in interface net.solarnetwork.settings.SettingSpecifierProvider
    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in interface net.solarnetwork.service.Identifiable
      Specified by:
      getDisplayName in interface net.solarnetwork.settings.SettingSpecifierProvider
      Overrides:
      getDisplayName in class net.solarnetwork.service.support.BasicIdentifiable
    • getModbusNetworkSettingSpecifiers

      protected List<net.solarnetwork.settings.SettingSpecifier> getModbusNetworkSettingSpecifiers()
      Get setting specifiers for the unitId and modbusNetwork.propertyFilters['uid'] properties.
      Returns:
      list of setting specifiers
      Since:
      1.1
    • getSettingSpecifiers

      public List<net.solarnetwork.settings.SettingSpecifier> getSettingSpecifiers()
      Specified by:
      getSettingSpecifiers in interface net.solarnetwork.settings.SettingSpecifierProvider
    • getEventAdmin

      public net.solarnetwork.service.OptionalService<org.osgi.service.event.EventAdmin> getEventAdmin()
      Get the event admin service.
      Returns:
      the event admin
    • setEventAdmin

      public void setEventAdmin(net.solarnetwork.service.OptionalService<org.osgi.service.event.EventAdmin> eventAdmin)
      Set the event admin sevice.
      Parameters:
      eventAdmin - the service to set
    • getPropConfigs

      public ModbusWritePropertyConfig[] getPropConfigs()
      Get the property configurations.
      Returns:
      the property configurations
    • setPropConfigs

      public void setPropConfigs(ModbusWritePropertyConfig[] propConfigs)
      Get the property configurations to use.
      Parameters:
      propConfigs - the configs to use
    • getPropConfigsCount

      public int getPropConfigsCount()
      Get the number of configured propConfigs elements.
      Returns:
      the number of propConfigs elements
    • setPropConfigsCount

      public void setPropConfigsCount(int count)
      Adjust the number of configured propConfigs elements.

      Any newly added element values will be set to new ModbusWritePropertyConfig instances.

      Parameters:
      count - The desired number of propConfigs elements.
    • getMaxReadWordCount

      public int getMaxReadWordCount()
      Get the maximum number of Modbus registers to read in any single read operation.
      Returns:
      the max read word count; defaults to DEFAULT_MAX_READ_WORD_COUNT
      Since:
      3.2
    • setMaxReadWordCount

      public void setMaxReadWordCount(int maxReadWordCount)
      Set the maximum number of Modbus registers to read in any single read operation.

      Some modbus devices do not handle large read ranges. This setting can be used to limit the number of registers read at one time.

      Parameters:
      maxReadWordCount - the maximum word count
      Since:
      3.2
    • getWordOrder

      public net.solarnetwork.node.io.modbus.ModbusWordOrder getWordOrder()
      Get the word order.
      Returns:
      the word order
      Since:
      3.4
    • setWordOrder

      public void setWordOrder(net.solarnetwork.node.io.modbus.ModbusWordOrder wordOrder)
      Set the word order.
      Parameters:
      wordOrder - the order to set; null will be ignored
      Since:
      3.4
    • getWordOrderKey

      public char getWordOrderKey()
      Get the word order as a key value.
      Returns:
      the word order as a key; if getWordOrder() is null then ModbusWordOrder.MostToLeastSignificant will be returned
      Since:
      3.4
    • setWordOrderKey

      public void setWordOrderKey(char key)
      Set the word order as a key value.
      Parameters:
      key - the word order key to set; if key is not valid then ModbusWordOrder.MostToLeastSignificant will be set
      Since:
      3.4
    • getSampleCacheMs

      public long getSampleCacheMs()
      Get the sample cache maximum age, in milliseconds.
      Returns:
      the cache milliseconds
      Since:
      3.4
    • setSampleCacheMs

      public void setSampleCacheMs(long sampleCacheMs)
      Set the sample cache maximum age, in milliseconds.
      Parameters:
      sampleCacheMs - the cache milliseconds
      Since:
      3.4