Class ModbusDeviceDatumDataSourceSupport
- All Implemented Interfaces:
net.solarnetwork.service.Identifiable
- Direct Known Subclasses:
ModbusDataDatumDataSourceSupport
ModbusNetwork based
DatumDataSource implementations.- Version:
- 3.1
- Author:
- matt
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intTheunitIdproperty default value.Fields inherited from class net.solarnetwork.node.service.support.DatumDataSourceSupport
DEFAULT_PUBLISH_DEVICE_INFO_METADATA, DEFAULT_SUBSAMPLE_START_DELAY, SUB_SAMPLE_PROPSFields inherited from class net.solarnetwork.node.service.support.BaseIdentifiable
logFields inherited from interface net.solarnetwork.service.Identifiable
GROUP_UID_PROPERTY, UID_PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionnet.solarnetwork.domain.DeviceInfoGet device info.Get the device info data as a Map.Get direct access to the device info data.Return an informational message composed of general device info.net.solarnetwork.service.OptionalService<ModbusNetwork>Get the configuredModbusNetwork.protected List<net.solarnetwork.settings.SettingSpecifier>Get setting specifiers for the unitId and modbusNetwork.propertyFilters['uid'] properties.intGet the Modbus unit ID.Get the configured Modbus device name.protected final ModbusNetworkGet theModbusNetworkfrom the configuredmodbusNetworkservice, or null if not available or not configured.static List<net.solarnetwork.settings.SettingSpecifier>modbusNetworkSettingSpecifiers(String uid, int unitId) Get setting specifiers for the unitId and modbusNetwork.propertyFilters['uid'] properties.protected final <T> TperformAction(ModbusConnectionAction<T> action) Perform some work with a ModbusModbusConnection.Read general device info and return a map of the results.protected voidsetDeviceInfoMap(Map<String, Object> deviceInfo) Set the device info data.voidsetModbusNetwork(net.solarnetwork.service.OptionalService<ModbusNetwork> modbusDevice) Set theModbusNetworkto use.voidsetUnitId(int unitId) Set the Modbus unit ID.Methods inherited from class net.solarnetwork.node.service.support.DatumDataSourceSupport
addSourceMetadata, applyDatumFilter, canPublishDeviceInfo, clearSourceMetadataCache, getDatumFilterService, getDatumMetadataService, getDatumQueue, getDatumService, getDeviceInfoMetadataSettingSpecifiers, getExpressionConfigs, getExpressionConfigsCount, getIdentifiableSettingSpecifiers, getSubSampleFrequency, getSubSampleSettingSpecifiers, getSubSampleStartDelay, getTaskScheduler, isPublishDeviceInfoMetadata, isSubSampling, offerDatumCapturedEvent, populateExpressionDatumProperties, populateExpressionDatumProperties, readSubSampleDatum, saveMetadata, setDatumFilterService, setDatumMetadataService, setDatumQueue, setDatumService, setExpressionConfigs, setExpressionConfigsCount, setPublishDeviceInfoMetadata, setSubSampleFrequency, setSubSampleStartDelay, setTaskScheduler, startSubSampling, stopSubSamplingMethods inherited from class net.solarnetwork.node.service.support.BaseIdentifiable
baseIdentifiableSettings, baseIdentifiableSettings, getExpressionServices, getPlaceholderService, populateExpressionDatumProperties, resolvePlaceholders, resolvePlaceholders, setExpressionServices, setPlaceholderServiceMethods inherited from class net.solarnetwork.service.support.BasicIdentifiable
basicIdentifiableMetadataSettings, basicIdentifiableSettings, basicIdentifiableSettings, basicIdentifiableSettings, doubleMetadataValue, getDisplayName, getGroupUid, getGroupUID, getMessageSource, getMetadata, getMetadataCount, getUid, getUID, integerMetadataValue, metadataValue, numberMetadataValue, saveMetadataValue, saveMetadataValue, setDisplayName, setGroupUid, setGroupUID, setMessageSource, setMetadata, setMetadataCount, setUid, setUID, smartMetadataValueMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.solarnetwork.service.Identifiable
getDisplayName, getGroupUid, getUid
-
Field Details
-
DEFAULT_UNIT_ID
public static final int DEFAULT_UNIT_IDTheunitIdproperty default value.- See Also:
-
-
Constructor Details
-
ModbusDeviceDatumDataSourceSupport
public ModbusDeviceDatumDataSourceSupport()
-
-
Method Details
-
getModbusNetworkSettingSpecifiers
Get setting specifiers for the unitId and modbusNetwork.propertyFilters['uid'] properties.- Returns:
- list of setting specifiers
- Since:
- 1.1
-
modbusNetworkSettingSpecifiers
public static List<net.solarnetwork.settings.SettingSpecifier> modbusNetworkSettingSpecifiers(String uid, int unitId) Get setting specifiers for the unitId and modbusNetwork.propertyFilters['uid'] properties.- Parameters:
uid- the Modbus Network UID property filter default value to useunitId- the unit ID default value to use- Returns:
- list of setting specifiers
- Since:
- 3.1
-
modbusNetwork
Get theModbusNetworkfrom the configuredmodbusNetworkservice, or null if not available or not configured.- Returns:
- ModbusNetwork
-
readDeviceInfo
Read general device info and return a map of the results.See the various
INFO_KEY_*constants for information on the values returned in the result map.- Parameters:
conn- the connection to use- Returns:
- a map with general device information populated
- Throws:
IOException- if any communication error occurs
-
getDeviceInfoMessage
Return an informational message composed of general device info.This method will call
getDeviceInfo()and return a/(forward slash) delimited string of the resulting values, or null if that method returns null.- Returns:
- info message
-
getDeviceInfo
Get the device info data as a Map.This method will call
readDeviceInfo(ModbusConnection). The map is cached so subsequent calls will not attempt to read from the device. Note the returned map cannot be modified.- Returns:
- the device info, or null
- See Also:
-
performAction
Perform some work with a ModbusModbusConnection.This method attempts to obtain a
ModbusNetworkfrom the configuredmodbusNetworkservice, callingModbusNetwork.performAction(int, ModbusConnectionAction)if one can be obtained.- Type Parameters:
T- the result type- Parameters:
action- the connection action- Returns:
- the result of the callback, or null if the action is never invoked
- Throws:
IOException- if any IO error occurs
-
getDeviceInfoMap
Get direct access to the device info data.- Returns:
- the device info, or null
-
setDeviceInfoMap
Set the device info data.Setting the
deviceInfoto null will force the next call togetDeviceInfo()to read from the device to populate this data, and setting this to anything else will force all subsequent calls togetDeviceInfo()to simply return that map.- Parameters:
deviceInfo- the device info map to set
-
deviceInfo
public net.solarnetwork.domain.DeviceInfo deviceInfo()Get device info.- Returns:
- the device info based on calling the
getDeviceInfo()method - Since:
- 2.2
-
modbusDeviceName
Get the configured Modbus device name.- Returns:
- the modbus device name
- Since:
- 1.3
-
getModbusNetwork
Get the configuredModbusNetwork.- Returns:
- the modbus network
-
setModbusNetwork
Set theModbusNetworkto use.- Parameters:
modbusDevice- the modbus network
-
getUnitId
public int getUnitId()Get the Modbus unit ID.- Returns:
- the unit ID; defauts to
DEFAULT_UNIT_ID
-
setUnitId
public void setUnitId(int unitId) Set the Modbus unit ID.- Parameters:
unitId- the unit ID
-