Class DeviceService

All Implemented Interfaces:
CtxEventListener, ContextHandleAware, HandleAware, Ready, ReadyListener

public class DeviceService extends AbstractService
Track device changes and send notifications.
Since:
1.0
Version:
2023-11-13
  • Constructor Details

    • DeviceService

      public DeviceService()
  • Method Details

    • onBeanReady

      public boolean onBeanReady()
      Description copied from class: ReadyBean
      Override in subclasses to be notified when all dependencies are ready. Return true to indicate that this bean is also ready. If the bean needs to call setReady() later due to some async processing, return false to prevent setReady() from being called automatically.

      It is recommended to override this method rather than onDependenciesReady() as a majority of the time it requires calling super.onDependneciesReady() or explicitly calling setReady() which defaults to a failure mode.

      Overrides:
      onBeanReady in class ReadyBean
      Returns:
    • setDevice

      public void setDevice(Device<?> device)
      Set the device. This is called internally to set the device to an instance of AssemblyDevice , but can be called from the system app to use a different Device implementation.
    • getSerialNumberProvider

      public SerialNumberProvider getSerialNumberProvider()
      Get the serial number provider. The serial number should be set / fetched via DeviceService which verifies that the provider is installed and ready. However, in cases where a provider may take some time to be ready, such as when using critical data, it can be convenient to fetch the provider directly and use whenReady() . This allows application code to know when the provider is ready for use. This can be used to avoid calling getSerialNumber() when the provider isn't ready as it will simply throw an exception.
    • setSerialNumberProvider

      public void setSerialNumberProvider(SerialNumberProvider provider)
      Set the serial number provider. This is how the device determines the serial number. The provider implements Ready and the serial number will not be available until the provider becomes ready. Depending on the provider, this may take some time or may, under some conditions, never become ready. In this case the device effectively has no serial number.

      If this is called more than once, only the last provider will be used.

    • getSerialNumber

      public String getSerialNumber() throws Exception
      Return the device serial number.
      Throws:
      Exception
    • setSerialNumber

      public void setSerialNumber(String serialNum) throws Exception
      Set the device serial number. This will be stored using the associated SerialNumberProvider . It is up to the provider to persist the serial number in some way to survive reboots and board swaps.
      Throws:
      Exception
    • notifyListeners

      public void notifyListeners()
      Called from the device when it changes.
    • getDevice

      public Device<?> getDevice()