Class Device<T extends BaseDeviceConfig>
- All Implemented Interfaces:
ConfigAware<T>,HandleAware,JsonDescriptorAware
System applications typically subclass Device and set the device into
KOS using setDevice(). The device typically contain all the data
required to bootstrap an external system such as an admin interface. This
object is typically accessed using the DeviceView json view, and many
core KOS objects are annotated accordingly.
There are various subclasses of Device which provide higher level
starting points for defining a device. Any of these can be extended to achieve
the desired definition of a device.
- Since:
- 1.0
- Version:
- 2023-11-13
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the current config bean so that it can be updated.Return the associated JsonDescriptor.Return the device type.Returns the handle for this bean.getName()Return the device name from the config bean.Return the nodeId of the node this is running on.Return the serial number of the device.voidloadDescriptor(File file) Load the descriptor from the specified file.voidLoad the descriptor from the specified input stream.voidCalled when the device has been changed and any listeners should be informed.voidSets the initial config bean.voidsetDescriptor(JsonDescriptor descriptor) voidSet the device name.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.tccc.kos.commons.core.service.config.ConfigAware
onConfigChanged, onConfigSetMethods inherited from interface com.tccc.kos.commons.core.service.handle.HandleAware
addHandleChild, getPath
-
Constructor Details
-
Device
public Device()
-
-
Method Details
-
getDeviceType
Return the device type. -
getName
Return the device name from the config bean.- Specified by:
getNamein interfaceHandleAware- Returns:
- this handle's name
-
setName
Set the device name. Shortcut for updating the config bean.- Parameters:
name- the new device name
-
getSerialNumber
Return the serial number of the device. -
getNodeId
Return the nodeId of the node this is running on. -
notifyListeners
public void notifyListeners()Called when the device has been changed and any listeners should be informed. This is called automatically when anAssemblyis added or removed. User code can call this any time listeners need to react to a change in the device.This typically results in external system rebuilding their state to match the new device data.
Deviceobjects should not be used to store state that can regularly change. It is reasonable to have the device return data that may contain runtime state as a means of establishing a baseline of data, but there should then be other data streams that allow external systems to remain in sync via deltas. -
loadDescriptor
Load the descriptor from the specified file.- Parameters:
file- the file containing the descriptor json- Throws:
IOException
-
loadDescriptor
Load the descriptor from the specified input stream.- Parameters:
is- the input stream containing the descriptor json- Throws:
IOException
-
getHandle
Description copied from interface:HandleAwareReturns the handle for this bean. This is used by the context to compute the opaque handle for the object.- Specified by:
getHandlein interfaceHandleAware- Returns:
- the handle node for the bean
-
getConfig
Description copied from interface:ConfigAwareGets the current config bean so that it can be updated.- Specified by:
getConfigin interfaceConfigAware<T extends BaseDeviceConfig>- Returns:
- the config bean
-
setConfig
Description copied from interface:ConfigAwareSets the initial config bean.- Specified by:
setConfigin interfaceConfigAware<T extends BaseDeviceConfig>
-
getDescriptor
Description copied from interface:JsonDescriptorAwareReturn the associated JsonDescriptor.- Specified by:
getDescriptorin interfaceJsonDescriptorAware
-
setDescriptor
-