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 Classes
    Modifier and Type
    Class
    Description
    static interface 
    API for interacting with the GpioService.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The gpioLockTimeoutSecs property default value.
    static final String
    The serialNetworkUid property default value.

    Fields inherited from class net.solarnetwork.node.io.serial.support.SerialDeviceSupport

    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
    GpioControl(net.solarnetwork.service.OptionalService.OptionalFilterableService<net.solarnetwork.node.io.serial.SerialNetwork> serialNetwork)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
     
    net.solarnetwork.domain.NodeControlInfo
     
    int
    Get the maximum number of seconds to wait to acquire the GPIO lock.
    Get the property configurations.
    int
    Get the number of configured propConfigs elements.
    Function<net.solarnetwork.node.io.serial.SerialConnection,GpioService>
    Get the GpioService provider.
    List<net.solarnetwork.settings.SettingSpecifier>
     
     
    boolean
     
    protected <T> T
    performAction(net.solarnetwork.node.io.serial.SerialConnectionAction<T> action)
     
    net.solarnetwork.node.reactor.InstructionStatus
    processInstruction(net.solarnetwork.node.reactor.Instruction instruction)
     
    protected Map<String,Object>
    readDeviceInfo(net.solarnetwork.node.io.serial.SerialConnection conn)
     
    void
    setGpioLockTimeoutSecs(int gpioLockTimeoutSecs)
    Set the maximum number of seconds to wait to acquire the GPIO lock.
    void
    Get the property configurations to use.
    void
    Adjust the number of configured propConfigs elements.
    void
    setSerialNetwork(net.solarnetwork.service.OptionalService.OptionalFilterableService<net.solarnetwork.node.io.serial.SerialNetwork> serialDevice)
     
    void
    setServiceProvider(Function<net.solarnetwork.node.io.serial.SerialConnection,GpioService> serviceProvider)
    Set a GpioService provider.
    void
    Call when no longer needed.
    void
    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, setSerialNetworkUid

    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, getDisplayName, 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

    getDisplayName, getGroupUid, getUid

    Methods inherited from interface net.solarnetwork.settings.SettingSpecifierProvider

    getDisplayName, getMessageSource
  • Field Details

    • DEFAULT_SERIAL_NETWORK_UID

      public static final String DEFAULT_SERIAL_NETWORK_UID
      The serialNetworkUid property default value.
      See Also:
    • DEFAULT_GPIO_LOCK_TIMEOUT_SECS

      public static final int DEFAULT_GPIO_LOCK_TIMEOUT_SECS
      The gpioLockTimeoutSecs property 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

      public void configurationChanged(Map<String,Object> properties)
      Specified by:
      configurationChanged in interface net.solarnetwork.settings.SettingsChangeObserver
    • setSerialNetwork

      public void setSerialNetwork(net.solarnetwork.service.OptionalService.OptionalFilterableService<net.solarnetwork.node.io.serial.SerialNetwork> serialDevice)
      Overrides:
      setSerialNetwork in class net.solarnetwork.node.io.serial.support.SerialDeviceSupport
    • 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
    • performAction

      protected <T> T performAction(net.solarnetwork.node.io.serial.SerialConnectionAction<T> action) throws IOException
      Overrides:
      performAction in class net.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:
      readDeviceInfo in class net.solarnetwork.node.io.serial.support.SerialDeviceSupport
      Throws:
      IOException
    • 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
    • getSettingUid

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

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

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

      public void setPropConfigs(GpioPropertyConfig[] 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 GpioPropertyConfig instances.

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

      public Function<net.solarnetwork.node.io.serial.SerialConnection,GpioService> getServiceProvider()
      Get the GpioService provider.
      Returns:
      the provider; defaults to UsbGpioService::new
    • setServiceProvider

      public void setServiceProvider(Function<net.solarnetwork.node.io.serial.SerialConnection,GpioService> serviceProvider)
      Set a GpioService provider.
      Parameters:
      serviceProvider - the provider to set; if null then UsbGpioService::new will 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