Interface DeviceFactoryInterface

    • Method Detail

      • start

        default void start()
        Lifecycle method to start this device factory
      • 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 the AbstractDeviceFactory 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.
      • 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 number
        address - 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 number
        chipSelect - 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