|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttuwien.auto.calimero.buffer.cache.CacheObject
tuwien.auto.calimero.buffer.LDataObject
tuwien.auto.calimero.buffer.LDataObjectQueue
public class LDataObjectQueue
A CacheObject
used for holding a list of CEMILData
frames.
A KNX address is specified on creation, which will be used to generate the cache object
key. A LDataObjectQueue is used for frames having all the same key like the one
supplied on creation of a new queue. For each frame inserted into the queue, its own
timestamp will get stored.
These different queue behaviors are available (optional):
A limit might be set for the maximum size of the queue. Reading of the queue can be
consuming, i.e. a frame and its timestamp is removed after reading the frame. With a
maximum queue size set, overwriting of old frames (according to insertion order) can be
enabled, to allow storing a new frame when the queue got filled up by removing the
oldest frames (i.e. a ring buffer).
Nested Class Summary | |
---|---|
static class |
LDataObjectQueue.QueueItem
Represents an item in the queue, holding one L-Data frame and its timestamp. |
static interface |
LDataObjectQueue.QueueListener
Listener for queue events. |
Field Summary |
---|
Fields inherited from class tuwien.auto.calimero.buffer.cache.CacheObject |
---|
value |
Constructor Summary | |
---|---|
LDataObjectQueue(GroupAddress addr)
Creates a new LDataObjectQueue for KNX address addr . |
|
LDataObjectQueue(GroupAddress addr,
boolean consumingRead)
Creates a new LDataObjectQueue for KNX address addr . |
|
LDataObjectQueue(GroupAddress addr,
boolean consumingRead,
int maxSize,
boolean overwrite,
LDataObjectQueue.QueueListener l)
Creates a new LDataObjectQueue for KNX address addr with a fixed
maximum queue size. |
Method Summary | |
---|---|
void |
clear()
Clears the frame and timestamp queue. |
CEMILData |
getFrame()
Returns a CEMILData frame contained in this cache object. |
CEMILData[] |
getFrames()
Returns all L-Data frames currently hold by the queue. |
LDataObjectQueue.QueueItem |
getItem()
Returns the next queued item in insertion order. |
int |
getSize()
Returns the number of frames currently in the queue. |
long[] |
getTimestamps()
Returns the timestamps of the frames hold by the queue. |
java.lang.Object |
getValue()
Gets the value entry hold by this cache object. |
boolean |
isConsuming()
Returns mode for consuming read behavior. |
boolean |
isOverwrite()
Returns mode for overwrite used for this queue. |
void |
setFrame(CEMILData frame)
Sets a new CEMILData frame for this cache object. |
Methods inherited from class tuwien.auto.calimero.buffer.cache.CacheObject |
---|
getCount, getKey, getTimestamp, getUsage, incCount, resetCount, resetTimestamp, setUsage |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LDataObjectQueue(GroupAddress addr)
addr
.
There is no limit on the queue size used.
addr
- KNX address to create the queue for, this address is used to generate
the cache object keypublic LDataObjectQueue(GroupAddress addr, boolean consumingRead)
addr
.
There is no limit on the queue size used.
addr
- KNX address to create the queue for, this address is used to generate
the cache object keyconsumingRead
- set true
to remove a frame from the queue the
first time it gets requested for read (i.e. returned by a frame getter
method), false
to leave it in the queuepublic LDataObjectQueue(GroupAddress addr, boolean consumingRead, int maxSize, boolean overwrite, LDataObjectQueue.QueueListener l)
addr
with a fixed
maximum queue size.
addr
- KNX address to create the queue for, this address is used to generate
the cache object keyconsumingRead
- set true
to remove a frame from the queue the
first time it gets requested for read (i.e. returned by a frame getter
method), false
to leave it in the queuemaxSize
- the maximum queue size, i.e. max. number of frames hold by the
queue, maxSize has to be > 0overwrite
- set true
if on full queue a new frame should
replace the oldest frame in the queue (i.e. ring buffer semantics),false
if on full queue new frames should be ignoredl
- sets a queue listener to receive events from this queue, use
null
if no notifications are requiredMethod Detail |
---|
public final void clear()
The queue will be empty on return.
public CEMILData getFrame()
CEMILData
frame contained in this cache object.
On no frame available, null
is returned. Frames are returned in insertion order. If consuming read behavior is
enabled, the frame will be removed from the queue before return.
getFrame
in class LDataObject
CEMILData
frame, or null
public final CEMILData[] getFrames()
The frames are returned in insertion order. If consuming read behavior is enabled,
the internal queue buffer is cleared before return.
Note that on consuming read the associated timestamps of the frames will be
cleared, too, before return of this method. In order to obtain the timestamps,
getTimestamps()
has to be called at first.
public LDataObjectQueue.QueueItem getItem()
The item consists of the L-Data frame and its associated timestamp. This method
behaves equal to getFrame()
with respect to queueing behavior.
If the queue is empty, an empty QueueItem is returned.
public final int getSize()
Since each frame has its associated timestamp, this is also the number of timestamps at the same time.
public final long[] getTimestamps()
The timestamps are returned in insertion order of the associated frames.
This means, if no setFrame(CEMILData)
is called in between,
getTimestamps()
[i] belongs to getFrames()
[i], where 0 <= i <
getSize()
getTimestamps()
.length == getFrames()
.lengthgetFrames()
).
CacheObject.getTimestamp()
public java.lang.Object getValue()
Note that the value is guaranteed to be always a non null
reference.
Note that the length of the returned buffer might be 0.
This method is equal to invoking getFrames()
.
getValue
in class CacheObject
public final boolean isConsuming()
true
if queued items get consumed on read,
false
if a read does not modify the queuepublic final boolean isOverwrite()
true
if overwrite is used, false
otherwisepublic void setFrame(CEMILData frame)
CEMILData
frame
for this cache object.
The key generated out of frame
(i.e. out of the KNX address of
frame
) has to be equal to the key of this LDataObject
,
as returned from CacheObject.getKey()
. Otherwise a
KNXIllegalArgumentException
will be thrown.
Note that on successful set the timestamp is renewed.
If a maximum size is set and the queue already reached maximum size, if
isOverwrite()
evaluates to
- true
, frame
will replace the oldest inserted frame
- false
,
frame
is ignored and not queued.
setFrame
in class LDataObject
frame
- the new CEMILData
frame to set
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |