Class UsbGpioService
java.lang.Object
net.solarnetwork.node.control.numato.usbgpio.UsbGpioService
- All Implemented Interfaces:
GpioService
Implementation of the
GpioService.- Version:
- 1.0
- Author:
- matt
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThegpioCountproperty default value.static final longThelistenWaitMsproperty default value. -
Constructor Summary
ConstructorsConstructorDescriptionUsbGpioService(net.solarnetwork.node.io.serial.SerialConnection conn) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidConfigure the GPIO direction of all GPIO addresses.voidconfigureWriteMask(BitSet set) Configure a bitmask to use on futureGpioService.configureIoDirection(BitSet)orGpioService.writeAll(BitSet)calls.Get the device version information.intGet the GPIO count.getId()Get the ID of the device.longGet the length of time to wait to read responses after writing a command, in milliseconds.booleanread(int address) Get the value of the GPIO address as a binary value.readAll()Read the value of all GPIO addresses.intreadAnalog(int address) Get the analog value of the GPIO address.voidset(int address, boolean value) Set the value of the GPIO address as a binary value.voidsetGpioCount(int gpioCount) Set the GPIO count.voidSet the ID of the device.voidsetListenWaitMs(long listenWaitMs) Set the length of time to wait to read responses after writing a command, in milliseconds.voidSet the value of all GPIO addresses on enabled/disabled based on aBitSet.
-
Field Details
-
DEFAULT_LISTEN_WAIT_MS
public static final long DEFAULT_LISTEN_WAIT_MSThelistenWaitMsproperty default value.- See Also:
-
DEFAULT_GPIO_COUNT
public static final int DEFAULT_GPIO_COUNTThegpioCountproperty default value.- See Also:
-
-
Constructor Details
-
UsbGpioService
public UsbGpioService(net.solarnetwork.node.io.serial.SerialConnection conn) Constructor.- Parameters:
conn- the serial connection to use- Throws:
IllegalArgumentException- if any argument is null
-
-
Method Details
-
getDeviceVersion
Description copied from interface:GpioServiceGet the device version information.- Specified by:
getDeviceVersionin interfaceGpioService- Returns:
- the device version
- Throws:
IOException- if a communication error occurs
-
getId
Description copied from interface:GpioServiceGet the ID of the device.- Specified by:
getIdin interfaceGpioService- Returns:
- the ID, an 8-character string
- Throws:
IOException- if a communication error occurs
-
setId
Description copied from interface:GpioServiceSet the ID of the device.- Specified by:
setIdin interfaceGpioService- Parameters:
id- the ID to set: an 8-character string- Throws:
IOException- if a communication error occurs
-
read
Description copied from interface:GpioServiceGet the value of the GPIO address as a binary value.- Specified by:
readin interfaceGpioService- Parameters:
address- the address, starting from 0, of the GPIO to get- Returns:
- true if the GPIO is on, otherwise false
- Throws:
IOException- if a communication error occurs
-
set
Description copied from interface:GpioServiceSet the value of the GPIO address as a binary value.- Specified by:
setin interfaceGpioService- Parameters:
address- the address, starting from 0, of the GPIO to getvalue- true if the GPIO is on, otherwise false- Throws:
IOException- if a communication error occurs
-
readAnalog
Description copied from interface:GpioServiceGet the analog value of the GPIO address.- Specified by:
readAnalogin interfaceGpioService- Parameters:
address- the address- Returns:
- the analog value
- Throws:
IOException- if a communication error occurs
-
readAll
Description copied from interface:GpioServiceRead the value of all GPIO addresses.- Specified by:
readAllin interfaceGpioService- Returns:
- the set of enabled GPIO addresses
- Throws:
IOException- if a communication error occurs
-
writeAll
Description copied from interface:GpioServiceSet the value of all GPIO addresses on enabled/disabled based on aBitSet.- Specified by:
writeAllin interfaceGpioService- Parameters:
values- the value to set, with bit positions representing GPIO addresses- Throws:
IOException- if a communication error occurs
-
configureWriteMask
Description copied from interface:GpioServiceConfigure a bitmask to use on futureGpioService.configureIoDirection(BitSet)orGpioService.writeAll(BitSet)calls.- Specified by:
configureWriteMaskin interfaceGpioService- Parameters:
set- the GPIO addresses to enable for future operations, using bit positions- Throws:
IOException- if a communication error occurs
-
configureIoDirection
Description copied from interface:GpioServiceConfigure the GPIO direction of all GPIO addresses.If a bit is enabled that means the coreponsing GPIO address should be configured as the input direction, otherwise as output.
- Specified by:
configureIoDirectionin interfaceGpioService- Parameters:
set- the GPIO addresses to configure as input, using bit positions- Throws:
IOException- if a communication error occurs
-
getListenWaitMs
public long getListenWaitMs()Get the length of time to wait to read responses after writing a command, in milliseconds.- Returns:
- the milliseconds to wait, or 0 to not wait at all;
defaults to
DEFAULT_LISTEN_WAIT_MS
-
setListenWaitMs
public void setListenWaitMs(long listenWaitMs) Set the length of time to wait to read responses after writing a command, in milliseconds.- Parameters:
listenWaitMs- the milliseconds to set, or 0 to not wait at all
-
getGpioCount
public int getGpioCount()Get the GPIO count.- Returns:
- the count; defaults to
DEFAULT_GPIO_COUNT
-
setGpioCount
public void setGpioCount(int gpioCount) Set the GPIO count.- Parameters:
gpioCount- the gpioCount to set- Throws:
IllegalArgumentException- ifgpioCountis less than 1
-