Package com.diozero.internal.spi
Interface DeviceFactoryInterface
-
- All Superinterfaces:
AutoCloseable
,Closeable
- 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 Closeable
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods 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 deviceFile)
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 Detail
-
start
default void start()
Lifecycle method to start this device factory
-
close
void close() throws RuntimeIOException
Close this device factory including all devices that have been provisioned by it.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- 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
boolean isDeviceOpened(String key)
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
void deviceOpened(InternalDeviceInterface device)
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
void deviceClosed(InternalDeviceInterface device)
diozero internal method to notify theAbstractDeviceFactory
that a device has been closed.
-
getName
String getName()
Get the name of this device factory- Returns:
- the name of this device factory
-
getBoardPinInfo
BoardPinInfo getBoardPinInfo()
Get information about pins that can be provisioned by this device factory.- Returns:
-
createPinKey
String createPinKey(PinInfo pinInfo)
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
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.- Parameters:
controller
- the I2C bus controller numberaddress
- the I2C device address- Returns:
- a unique I2C key
-
createSpiKey
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.- Parameters:
controller
- the SPI controller numberchipSelect
- the SPI chip select number- Returns:
- a unique SPI key
-
createSerialKey
String createSerialKey(String deviceFile)
diozero internal method to generate a unique key for the specified serial device.- Parameters:
deviceFile
- the serial device filename- Returns:
- a unique serial key
-
getDevice
<T extends InternalDeviceInterface> T getDevice(String key)
Get the already provisioned device for the specified key- Parameters:
key
- the unique device key- Returns:
- the device otherwise null if not found
-
-