Not all devices are sensors. In typical use case you will have many devices providing some state by measuring data using external sensors and we call them here sensors. However very often you will have some devices which need to react on changed state of other devices or react on user action - this we call executor devices.
To implement a new executor device you need to create a new implementation of a sensor (executor device is a sensor as well
as it reports it current state), which also implements IExecutorDevice
inteface:
public interface IExecutorDevice<T> { void setValue(T value); }
Note
In typical usage T
should implement IValue
interface.
This method will be automatically called if new state will be published for this device (new state will be published on a device state node).
If your device requires to listen to states published by other sensors then it needs to implement NodesObserver
with method getObserverdNodes()
which needs to return list of state node in which your device is interrested in.
Additionally you will have to implement following method:
@HandleEvent public void onValueChanged(ExtendedPubSubNodesManager.ValueChangedEvent event) { }
It will be called whenever new state/value will be published by any sensor or a device. You need to check source
variable of a ValueChangedEvent
to look for a node of a device in which state you are interested in.
In value
variable of a ValueChangedEvent
you will find newly published device state which node you will find in source
variable.