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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturn the serial number of the device.booleanOverride in subclasses to be notified when all dependencies are ready.voidNotify the listener that we have consensus on our critical data.voidonCriticalDataChanged(CriticalDataService service, String name, Object data) Notify the listener that the critical data just changed.voidNotify the listener that there is no critical data available.voidsetSerialNumber(String serialNumber) Set the serial number of the device.Methods inherited from class com.tccc.kos.commons.util.ready.ReadyBean
getReady, onDependenciesReadyMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.tccc.kos.commons.util.ready.ReadyListener
onDependenciesGroupReady
-
Constructor Details
-
CriticalDataSerialNumberProvider
public CriticalDataSerialNumberProvider()
-
-
Method Details
-
onBeanReady
public boolean onBeanReady()Description copied from class:ReadyBeanOverride 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 callsetReady()later due to some async processing, return false to preventsetReady()from being called automatically.It is recommended to override this method rather than
onDependenciesReady()as a majority of the time it requires callingsuper.onDependneciesReady()or explicitly callingsetReady()which defaults to a failure mode.- Overrides:
onBeanReadyin classReadyBean- Returns:
-
getSerialNumber
Description copied from interface:SerialNumberProviderReturn the serial number of the device.- Specified by:
getSerialNumberin interfaceSerialNumberProvider- Throws:
Exception
-
setSerialNumber
Description copied from interface:SerialNumberProviderSet the serial number of the device.- Specified by:
setSerialNumberin interfaceSerialNumberProvider- Parameters:
serialNumber- the new device serial number- Throws:
Exception
-
onCriticalDataAvailable
Description copied from interface:CriticalDataListenerNotify 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:
onCriticalDataAvailablein interfaceCriticalDataListener- Parameters:
service- the critical data service
-
onCriticalDataChanged
Description copied from interface:CriticalDataListenerNotify the listener that the critical data just changed. This is called any timesetCriticalData()) is called. IfsetAllCriticalData()is called, name will beCriticalData.ALL_DATAand data will beJsonNoderepresenting all the critical data. param service the critical data service- Specified by:
onCriticalDataChangedin interfaceCriticalDataListenername- the name of the modified critical datadata- the object used to set the data
-