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
FieldsModifier and TypeFieldDescriptionstatic final intThe default value for theaddressproperty.static final StringThe default value for thecontrolIdproperty.static final intThemaxReadWordCountproperty default value.static final longThe default value for thesampleCacheMsproperty.static final net.solarnetwork.node.io.modbus.ModbusWordOrderThewordOrderproperty default value.static final StringThe 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, logFields inherited from interface net.solarnetwork.service.Identifiable
GROUP_UID_PROPERTY, UID_PROPERTYFields 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_CONFIGUREFields inherited from interface net.solarnetwork.node.service.NodeControlProvider
EVENT_TOPIC_CONTROL_INFO_CAPTURED, EVENT_TOPIC_CONTROL_INFO_CHANGED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionnet.solarnetwork.domain.NodeControlInfogetCurrentControlInfo(String controlId) net.solarnetwork.service.OptionalService<org.osgi.service.event.EventAdmin>Get the event admin service.intGet 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.intGet the number of configuredpropConfigselements.longGet the sample cache maximum age, in milliseconds.List<net.solarnetwork.settings.SettingSpecifier>net.solarnetwork.node.io.modbus.ModbusWordOrderGet the word order.charGet the word order as a key value.booleanhandlesTopic(String topic) net.solarnetwork.node.reactor.InstructionStatusprocessInstruction(net.solarnetwork.node.reactor.Instruction instruction) readDeviceInfo(net.solarnetwork.node.io.modbus.ModbusConnection conn) voidsetEventAdmin(net.solarnetwork.service.OptionalService<org.osgi.service.event.EventAdmin> eventAdmin) Set the event admin sevice.voidsetMaxReadWordCount(int maxReadWordCount) Set the maximum number of Modbus registers to read in any single read operation.voidsetPropConfigs(ModbusWritePropertyConfig[] propConfigs) Get the property configurations to use.voidsetPropConfigsCount(int count) Adjust the number of configuredpropConfigselements.voidsetSampleCacheMs(long sampleCacheMs) Set the sample cache maximum age, in milliseconds.voidsetWordOrder(net.solarnetwork.node.io.modbus.ModbusWordOrder wordOrder) Set the word order.voidsetWordOrderKey(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, setUnitIdMethods 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, 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
getGroupUid, getUidMethods inherited from interface net.solarnetwork.settings.SettingSpecifierProvider
getMessageSource
-
Field Details
-
DEFAULT_ADDRESS
public static final int DEFAULT_ADDRESSThe default value for theaddressproperty.- See Also:
-
DEFAULT_CONTROL_ID
The default value for thecontrolIdproperty.- See Also:
-
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_COUNTThemaxReadWordCountproperty default value.- Since:
- 3.2
- See Also:
-
DEFAULT_WORD_ORDER
public static final net.solarnetwork.node.io.modbus.ModbusWordOrder DEFAULT_WORD_ORDERThewordOrderproperty default value.- Since:
- 3.4
-
DEFAULT_SAMPLE_CACHE_MS
public static final long DEFAULT_SAMPLE_CACHE_MSThe default value for thesampleCacheMsproperty.- Since:
- 3.4
- See Also:
-
-
Constructor Details
-
ModbusControl
public ModbusControl()Constructor.
-
-
Method Details
-
readDeviceInfo
- Specified by:
readDeviceInfoin classnet.solarnetwork.node.io.modbus.support.ModbusDeviceSupport
-
getAvailableControlIds
- Specified by:
getAvailableControlIdsin interfacenet.solarnetwork.node.service.NodeControlProvider
-
getCurrentControlInfo
- Specified by:
getCurrentControlInfoin interfacenet.solarnetwork.node.service.NodeControlProvider
-
handlesTopic
- Specified by:
handlesTopicin interfacenet.solarnetwork.node.reactor.InstructionHandler
-
processInstruction
public net.solarnetwork.node.reactor.InstructionStatus processInstruction(net.solarnetwork.node.reactor.Instruction instruction) - Specified by:
processInstructionin interfacenet.solarnetwork.node.reactor.InstructionHandler
-
getSettingUid
- Specified by:
getSettingUidin interfacenet.solarnetwork.settings.SettingSpecifierProvider
-
getDisplayName
- Specified by:
getDisplayNamein interfacenet.solarnetwork.service.Identifiable- Specified by:
getDisplayNamein interfacenet.solarnetwork.settings.SettingSpecifierProvider- Overrides:
getDisplayNamein classnet.solarnetwork.service.support.BasicIdentifiable
-
getModbusNetworkSettingSpecifiers
Get setting specifiers for the unitId and modbusNetwork.propertyFilters['uid'] properties.- Returns:
- list of setting specifiers
- Since:
- 1.1
-
getSettingSpecifiers
- Specified by:
getSettingSpecifiersin interfacenet.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
Get the property configurations.- Returns:
- the property configurations
-
setPropConfigs
Get the property configurations to use.- Parameters:
propConfigs- the configs to use
-
getPropConfigsCount
public int getPropConfigsCount()Get the number of configuredpropConfigselements.- Returns:
- the number of
propConfigselements
-
setPropConfigsCount
public void setPropConfigsCount(int count) Adjust the number of configuredpropConfigselements.Any newly added element values will be set to new
ModbusWritePropertyConfiginstances.- Parameters:
count- The desired number ofpropConfigselements.
-
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 thenModbusWordOrder.MostToLeastSignificantwill 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; ifkeyis not valid thenModbusWordOrder.MostToLeastSignificantwill 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
-