public interface DataModel
The data model might need to used mutex locks in order to protect its internal data store. However there are a few requirements in the terms of locking the implementation has to fulfill.
The data model must not call listeners or complete futures holding a lock. The simplest way to achieve this is to push all events to an executor while holding the lock.
The following methods itself must not be synchronized:
read(ASDUAddress, InformationObjectAddress)
#readAll(ASDUAddress, DataListener)
Modifier and Type | Method and Description |
---|---|
BackgroundIterator |
createBackgroundIterator()
Create a new background iterator
If the implementation does not support background transmissions, null may be returned. |
void |
forAllAsdu(java.util.function.Consumer<ASDUAddress> function,
Runnable ifNoneFound)
A method that will call the provided function for each known ASDU
address
|
default void |
forAllAsdu(com.google.common.base.Function<ASDUAddress,Void> function,
Runnable ifNoneFound)
A wrapper method for
forAllAsdu(Function, Runnable) using the
Google Guava Function interface |
com.google.common.util.concurrent.ListenableFuture<Value<?>> |
read(ASDUAddress asduAddress,
InformationObjectAddress address)
Read a specific value
The future will be called with the result of the read operation. |
com.google.common.util.concurrent.ListenableFuture<Void> |
readAll(ASDUAddress asduAddress,
Runnable prepare,
DataListener listener)
Read all values from the internal structures
The data will not be returned by the future, but pushed to the DataListener . |
void |
start() |
Stopping |
stop() |
Subscription |
subscribe(DataListener listener) |
void |
writeCommand(ASDUHeader header,
InformationObjectAddress informationObjectAddress,
boolean state,
byte type,
MirrorCommand mirrorCommand,
boolean execute) |
void |
writeFloatValue(ASDUHeader header,
InformationObjectAddress informationObjectAddress,
float value,
byte type,
MirrorCommand mirrorCommand,
boolean execute) |
void |
writeScaledValue(ASDUHeader header,
InformationObjectAddress informationObjectAddress,
short value,
byte type,
MirrorCommand mirrorCommand,
boolean execute) |
Subscription subscribe(DataListener listener)
com.google.common.util.concurrent.ListenableFuture<Value<?>> read(ASDUAddress asduAddress, InformationObjectAddress address)
null
.address
- the address to readnull
if the data model
instantly decide that the value cannot be readcom.google.common.util.concurrent.ListenableFuture<Void> readAll(ASDUAddress asduAddress, Runnable prepare, DataListener listener)
DataListener
.asduAddress
- the ASDU common addressprepare
- a runnable that will be called before the actual processing,
from the same thread the listener will be called. But only
when the request actually can be processed. If the runnable
was called, the method must not return null
.listener
- the data receivernull
if the ASDU address was unknown.BackgroundIterator createBackgroundIterator()
null
may be returned. null
void forAllAsdu(java.util.function.Consumer<ASDUAddress> function, Runnable ifNoneFound)
Note that the ASDUs must not change until each function call has been completed.
The function call can be performed asynchronously.
function
- the function to call for each known ASDU addressifNoneFound
- will be called if there are no known common ASDU addresses,
may be null
default void forAllAsdu(com.google.common.base.Function<ASDUAddress,Void> function, Runnable ifNoneFound)
forAllAsdu(Function, Runnable)
using the
Google Guava Function interface
void writeCommand(ASDUHeader header, InformationObjectAddress informationObjectAddress, boolean state, byte type, MirrorCommand mirrorCommand, boolean execute)
void writeFloatValue(ASDUHeader header, InformationObjectAddress informationObjectAddress, float value, byte type, MirrorCommand mirrorCommand, boolean execute)
void writeScaledValue(ASDUHeader header, InformationObjectAddress informationObjectAddress, short value, byte type, MirrorCommand mirrorCommand, boolean execute)
void start()
Stopping stop()