Package com.diozero.internal.spi
Class AbstractDevice
- java.lang.Object
-
- com.diozero.internal.spi.AbstractDevice
-
- All Implemented Interfaces:
DeviceInterface
,InternalDeviceInterface
,AutoCloseable
- Direct Known Subclasses:
AbstractInputDevice
,DefaultNativeSerialDevice
,DefaultNativeSpiDevice
,MCP23xxxDigitalOutputDevice
,NativeGpioOutputDevice
,NativeI2CDeviceJavaRaf
,NativeI2CDeviceSMBus
,OdroidC2SysFsPwmOutputDevice
,PiconZero.PiconZeroAnalogOutputDevice
,PiconZero.PiconZeroDigitalInputDevice
,PiconZero.PiconZeroDigitalOutputDevice
,PiconZero.PiconZeroPwmOutputDevice
,PiconZero.PiconZeroServoDevice
,PwmServoDevice
,SoftwarePwmOutputDevice
,SysFsDigitalOutputDevice
,SysFsPwmOutputDevice
public abstract class AbstractDevice extends Object implements InternalDeviceInterface
-
-
Constructor Summary
Constructors Constructor Description AbstractDevice(String key, DeviceFactoryInterface deviceFactory)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
Close this deviceprotected abstract void
closeDevice()
protected DeviceFactoryInterface
getDeviceFactory()
String
getKey()
Get the unique device identifier for this deviceboolean
isChild()
Check if this is a child / wrapped device.boolean
isOpen()
Check if this device is open or closedvoid
setChild(boolean child)
-
-
-
Constructor Detail
-
AbstractDevice
public AbstractDevice(String key, DeviceFactoryInterface deviceFactory)
-
-
Method Detail
-
getKey
public final String getKey()
Description copied from interface:InternalDeviceInterface
Get the unique device identifier for this device- Specified by:
getKey
in interfaceInternalDeviceInterface
- Returns:
- unique device identifier
-
isOpen
public boolean isOpen()
Description copied from interface:InternalDeviceInterface
Check if this device is open or closed- Specified by:
isOpen
in interfaceInternalDeviceInterface
- Returns:
- true if this device is open
-
isChild
public boolean isChild()
Description copied from interface:InternalDeviceInterface
Check if this is a child / wrapped device. Child devices are assumed to be closed by the parent device. Key example is a software PWM output device that uses a digital output device.- Specified by:
isChild
in interfaceInternalDeviceInterface
- Returns:
- true if this a child / wrapped device
-
setChild
public void setChild(boolean child)
- Specified by:
setChild
in interfaceInternalDeviceInterface
-
close
public final void close()
Description copied from interface:DeviceInterface
Close this device- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceDeviceInterface
-
getDeviceFactory
protected DeviceFactoryInterface getDeviceFactory()
-
closeDevice
protected abstract void closeDevice() throws RuntimeIOException
- Throws:
RuntimeIOException
-
-