Package com.diozero.internal.spi
Interface DeviceFactoryInterface
- All Superinterfaces:
AutoCloseable
- All Known Subinterfaces:
AnalogInputDeviceFactoryInterface
,AnalogOutputDeviceFactoryInterface
,GpioDeviceFactoryInterface
,I2CDeviceFactoryInterface
,NativeDeviceFactoryInterface
,PwmOutputDeviceFactoryInterface
,SerialDeviceFactoryInterface
,SpiDeviceFactoryInterface
- All Known Implementing Classes:
AbstractDeviceFactory
,Ads112C04
,Ads1x15
,BaseNativeDeviceFactory
,DefaultDeviceFactory
,MCP23008
,MCP23017
,MCP23S17
,MCP23x08
,MCP23x17
,MCP23xxx
,McpAdc
,PCA9685
,PCF8574
,PCF8591
,PiconZero
public interface DeviceFactoryInterface extends AutoCloseable
-
Method Summary
Modifier and Type Method Description void
close()
Close this device factory including all devices that have been provisioned by it.String
createI2CKey(int controller, int address)
diozero internal method to generate a unique key for the I2C device at the specified address attached to the specified I2C bus controller.String
createPinKey(PinInfo pinInfo)
diozero internal method to generate a unique key for the specified pin.String
createSerialKey(String deviceFilename)
diozero internal method to generate a unique key for the specified serial device.String
createSpiKey(int controller, int chipSelect)
diozero internal method to generate a unique key for the SPI device attached to the specified SPI controller and chip select.void
deviceClosed(InternalDeviceInterface device)
diozero internal method to notify theAbstractDeviceFactory
that a device has been closed.void
deviceOpened(InternalDeviceInterface device)
diozero internal method to notify theAbstractDeviceFactory
that a device has been opened.BoardPinInfo
getBoardPinInfo()
Get information about pins that can be provisioned by this device factory.<T extends InternalDeviceInterface>
TgetDevice(String key)
Get the already provisioned device for the specified keyString
getName()
Get the name of this device factoryboolean
isClosed()
Check if this device factory is closed.boolean
isDeviceOpened(String key)
Check if the device with the given unique key is openedvoid
reopen()
Reopen this device factory.default void
start()
Lifecycle method to start this device factory
-
Method Details
-
getName
String getName()Get the name of this device factory- Returns:
- the name of this device factory
-
start
default void start()Lifecycle method to start this device factory -
close
Close this device factory including all devices that have been provisioned by it.- Specified by:
close
in interfaceAutoCloseable
- Throws:
RuntimeIOException
-
isClosed
boolean isClosed()Check if this device factory is closed.- Returns:
- true if this device factory is closed
-
reopen
void reopen()Reopen this device factory. -
isDeviceOpened
Check if the device with the given unique key is opened- Parameters:
key
- the unique key of the device- Returns:
- true if the device is opened
-
deviceOpened
diozero internal method to notify theAbstractDeviceFactory
that a device has been opened. Enables diozero to perform cleanup operations, for example closing a device factory closes all devices provisionined by that device factory. -
deviceClosed
diozero internal method to notify theAbstractDeviceFactory
that a device has been closed. -
getBoardPinInfo
BoardPinInfo getBoardPinInfo()Get information about pins that can be provisioned by this device factory.- Returns:
-
createPinKey
diozero internal method to generate a unique key for the specified pin. Used for maintaining the state of devices provisioned by this device factory.- Parameters:
pinInfo
- the pin to create the key for- Returns:
- a key that is unique to this pin
-
createI2CKey
diozero internal method to generate a unique key for the I2C device at the specified address attached to the specified I2C bus controller.- Parameters:
controller
- the I2C bus controller numberaddress
- the I2C device address- Returns:
- a unique I2C key
-
createSpiKey
diozero internal method to generate a unique key for the SPI device attached to the specified SPI controller and chip select.- Parameters:
controller
- the SPI controller numberchipSelect
- the SPI chip select number- Returns:
- a unique SPI key
-
createSerialKey
diozero internal method to generate a unique key for the specified serial device.- Parameters:
deviceFilename
- the serial device filename- Returns:
- a unique serial key
-
getDevice
Get the already provisioned device for the specified key- Parameters:
key
- the unique device key- Returns:
- the device otherwise null if not found
-