Class GpioControl
java.lang.Object
net.solarnetwork.service.support.BasicIdentifiable
net.solarnetwork.node.service.support.BaseIdentifiable
net.solarnetwork.node.io.serial.support.SerialDeviceSupport
net.solarnetwork.node.control.numato.usbgpio.GpioControl
- All Implemented Interfaces:
net.solarnetwork.node.reactor.InstructionHandler,net.solarnetwork.node.service.NodeControlProvider,net.solarnetwork.service.Identifiable,net.solarnetwork.settings.SettingsChangeObserver,net.solarnetwork.settings.SettingSpecifierProvider
public class GpioControl
extends net.solarnetwork.node.io.serial.support.SerialDeviceSupport
implements net.solarnetwork.settings.SettingSpecifierProvider, net.solarnetwork.node.service.NodeControlProvider, net.solarnetwork.node.reactor.InstructionHandler, net.solarnetwork.settings.SettingsChangeObserver
NodeControlProvider for the Numato USB GPIO module.- Version:
- 1.0
- Author:
- matt
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceAPI for interacting with the GpioService. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThegpioLockTimeoutSecsproperty default value.static final StringTheserialNetworkUidproperty default value.Fields inherited from class net.solarnetwork.node.io.serial.support.SerialDeviceSupport
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
ConstructorsConstructorDescriptionGpioControl(net.solarnetwork.service.OptionalService.OptionalFilterableService<net.solarnetwork.node.io.serial.SerialNetwork> serialNetwork) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidconfigurationChanged(Map<String, Object> properties) net.solarnetwork.domain.NodeControlInfogetCurrentControlInfo(String controlId) intGet the maximum number of seconds to wait to acquire the GPIO lock.Get the property configurations.intGet the number of configuredpropConfigselements.Function<net.solarnetwork.node.io.serial.SerialConnection,GpioService> Get theGpioServiceprovider.List<net.solarnetwork.settings.SettingSpecifier>booleanhandlesTopic(String topic) protected <T> TperformAction(net.solarnetwork.node.io.serial.SerialConnectionAction<T> action) net.solarnetwork.node.reactor.InstructionStatusprocessInstruction(net.solarnetwork.node.reactor.Instruction instruction) readDeviceInfo(net.solarnetwork.node.io.serial.SerialConnection conn) voidsetGpioLockTimeoutSecs(int gpioLockTimeoutSecs) Set the maximum number of seconds to wait to acquire the GPIO lock.voidsetPropConfigs(GpioPropertyConfig[] propConfigs) Get the property configurations to use.voidsetPropConfigsCount(int count) Adjust the number of configuredpropConfigselements.voidsetSerialNetwork(net.solarnetwork.service.OptionalService.OptionalFilterableService<net.solarnetwork.node.io.serial.SerialNetwork> serialDevice) voidsetServiceProvider(Function<net.solarnetwork.node.io.serial.SerialConnection, GpioService> serviceProvider) Set aGpioServiceprovider.voidshutdown()Call when no longer needed.voidstartup()Call once after properties configured.Methods inherited from class net.solarnetwork.node.io.serial.support.SerialDeviceSupport
getDeviceInfo, getDeviceInfoMap, getDeviceInfoMessage, getEventAdmin, getSerialNetwork, getSerialNetworkUid, postEvent, serialNetworkSettings, setDeviceInfoMap, setEventAdmin, setSerialNetworkUidMethods 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, getUidMethods inherited from interface net.solarnetwork.settings.SettingSpecifierProvider
getDisplayName, getMessageSource
-
Field Details
-
DEFAULT_SERIAL_NETWORK_UID
TheserialNetworkUidproperty default value.- See Also:
-
DEFAULT_GPIO_LOCK_TIMEOUT_SECS
public static final int DEFAULT_GPIO_LOCK_TIMEOUT_SECSThegpioLockTimeoutSecsproperty default value.- See Also:
-
-
Constructor Details
-
GpioControl
public GpioControl(net.solarnetwork.service.OptionalService.OptionalFilterableService<net.solarnetwork.node.io.serial.SerialNetwork> serialNetwork) Constructor.- Parameters:
serialNetwork- the network to use
-
-
Method Details
-
startup
public void startup()Call once after properties configured. -
shutdown
public void shutdown()Call when no longer needed. -
configurationChanged
- Specified by:
configurationChangedin interfacenet.solarnetwork.settings.SettingsChangeObserver
-
setSerialNetwork
public void setSerialNetwork(net.solarnetwork.service.OptionalService.OptionalFilterableService<net.solarnetwork.node.io.serial.SerialNetwork> serialDevice) - Overrides:
setSerialNetworkin classnet.solarnetwork.node.io.serial.support.SerialDeviceSupport
-
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
-
performAction
protected <T> T performAction(net.solarnetwork.node.io.serial.SerialConnectionAction<T> action) throws IOException - Overrides:
performActionin classnet.solarnetwork.node.io.serial.support.SerialDeviceSupport- Throws:
IOException
-
readDeviceInfo
protected Map<String,Object> readDeviceInfo(net.solarnetwork.node.io.serial.SerialConnection conn) throws IOException - Specified by:
readDeviceInfoin classnet.solarnetwork.node.io.serial.support.SerialDeviceSupport- Throws:
IOException
-
getAvailableControlIds
- Specified by:
getAvailableControlIdsin interfacenet.solarnetwork.node.service.NodeControlProvider
-
getCurrentControlInfo
- Specified by:
getCurrentControlInfoin interfacenet.solarnetwork.node.service.NodeControlProvider
-
getSettingUid
- Specified by:
getSettingUidin interfacenet.solarnetwork.settings.SettingSpecifierProvider
-
getSettingSpecifiers
- Specified by:
getSettingSpecifiersin interfacenet.solarnetwork.settings.SettingSpecifierProvider
-
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
GpioPropertyConfiginstances.- Parameters:
count- The desired number ofpropConfigselements.
-
getServiceProvider
Get theGpioServiceprovider.- Returns:
- the provider; defaults to
UsbGpioService::new
-
setServiceProvider
public void setServiceProvider(Function<net.solarnetwork.node.io.serial.SerialConnection, GpioService> serviceProvider) Set aGpioServiceprovider.- Parameters:
serviceProvider- the provider to set; if null thenUsbGpioService::newwill be used
-
getGpioLockTimeoutSecs
public int getGpioLockTimeoutSecs()Get the maximum number of seconds to wait to acquire the GPIO lock.- Returns:
- the maximum number of seconds; defaults to
DEFAULT_GPIO_LOCK_TIMEOUT_SECS
-
setGpioLockTimeoutSecs
public void setGpioLockTimeoutSecs(int gpioLockTimeoutSecs) Set the maximum number of seconds to wait to acquire the GPIO lock.- Parameters:
gpioLockTimeoutSecs- the maximum number of seconds
-