Class CriticalDataSerialNumberProvider

java.lang.Object
com.tccc.kos.commons.util.ready.ReadyBean
com.tccc.kos.core.service.device.serialnum.criticaldata.CriticalDataSerialNumberProvider
All Implemented Interfaces:
Ready, ReadyListener, CriticalDataListener, SerialNumberProvider

public class CriticalDataSerialNumberProvider extends ReadyBean implements SerialNumberProvider, CriticalDataListener
Wrapper class for critical data. Critical data is stored as a byte array where the first four bytes is a CRC32 of the remaining bytes. This class verifies the CRC when created using a byte array and will add the CRC when setting the value from json. This means that getBytes() returns the byte array that can be written back to a CriticalDataSource.
Version:
2024-06-24
  • Constructor Details

    • CriticalDataSerialNumberProvider

      public CriticalDataSerialNumberProvider()
  • 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:
    • getSerialNumber

      public String getSerialNumber() throws Exception
      Description copied from interface: SerialNumberProvider
      Return the serial number of the device.
      Specified by:
      getSerialNumber in interface SerialNumberProvider
      Throws:
      Exception
    • setSerialNumber

      public void setSerialNumber(String serialNumber) throws Exception
      Description copied from interface: SerialNumberProvider
      Set the serial number of the device.
      Specified by:
      setSerialNumber in interface SerialNumberProvider
      Parameters:
      serialNumber - the new device serial number
      Throws:
      Exception
    • onCriticalDataAvailable

      public void onCriticalDataAvailable(CriticalDataService service)
      Description copied from interface: CriticalDataListener
      Notify the listener that we have consensus on our critical data. This is called at most one time once we figure out our critical data. It's possible this is never called because no critical data is found in any of the sources.
      Specified by:
      onCriticalDataAvailable in interface CriticalDataListener
      Parameters:
      service - the critical data service
    • onCriticalDataUnavailable

      public void onCriticalDataUnavailable()
      Description copied from interface: CriticalDataListener
      Notify the listener that there is no critical data available. This is called at most one time if we can't find any valid sources of critical data. This is the result of enough sources registering that a choice must be made, but no source has valid critical data.
      Specified by:
      onCriticalDataUnavailable in interface CriticalDataListener
    • onCriticalDataChanged

      public void onCriticalDataChanged(CriticalDataService service, String name, Object data)
      Description copied from interface: CriticalDataListener
      Notify the listener that the critical data just changed. This is called any time setCriticalData()) is called. If setAllCriticalData() is called, name will be CriticalData.ALL_DATA and data will be JsonNode representing all the critical data. param service the critical data service
      Specified by:
      onCriticalDataChanged in interface CriticalDataListener
      name - the name of the modified critical data
      data - the object used to set the data