public class ByteDataSymbolicAccess extends java.lang.Object implements VariableContainer_ifc
ByteDataSymbolicAccess.Variable
contains a name, a data path (full name),
the type and the position of the bytes for the variable in the whole raw byte area.
The class ByteDataSymbolicAccessReadConfig
contained in the
javaSrc_Zbnf component extends this class with a routine, which reads the information
for all variable from a script file. Therewith the ZBNF-Parser org.vishia.zbnf
is used.
The variable may be given with Java-written instantiation too.
The data are given calling #assignData(byte[])
, #assignData(byte[], int, int)
from any source. New data can be updated outside, for example by a communication via network receive,
and update in the data buffer by calling copyNewData(byte[], int, int, long)
.
Thereby a timestamp of updating is provided. It supports the method VariableAccess_ifc.getLastRefreshTime()
.Modifier and Type | Class and Description |
---|---|
class |
ByteDataSymbolicAccess.Variable
An instance can be created and filled from ZBNF-parser using reflection
or also programmatically created using .
|
Modifier and Type | Field and Description |
---|---|
private byte[] |
data |
ByteDataAccessSimple |
dataAccess
The basically access to data.
|
private java.util.Map<java.lang.String,VariableAccess_ifc> |
indexVariable
The access to variables, index of variables used internally.
|
private int |
ixStartData |
private int |
nrofData |
private ConcurrentLinkedQueue<java.lang.Runnable> |
runOnRecv |
protected long |
timeRequestNewValue |
protected long |
timeSetNewValue
The last refresh time.
|
protected int[] |
timeShortRefresh
The time of last refresh of the data set. see
VariableAccess_ifc.getLastRefreshTimeShort() . |
static int |
versionStamp
Version, history and license.
|
version
Constructor and Description |
---|
ByteDataSymbolicAccess()
Creates with its own internal (not visible)
ByteDataAccessSimple access operations. |
ByteDataSymbolicAccess(ByteDataAccessSimple dataAccess)
Works with a given ByteDataAccess which can be additional touched with the
ByteDataAccessBase or ByteDataAccessSimple operations. |
ByteDataSymbolicAccess(java.util.Map<java.lang.String,VariableAccess_ifc> idxVariables) |
Modifier and Type | Method and Description |
---|---|
void |
addVariable(java.lang.String name,
ByteDataSymbolicAccess.Variable variable) |
void |
assignData(byte[] dataP,
int length,
int from,
long time)
Assigns new data which are filled with byte before, often from a received socket telegram
|
void |
assignData(byte[] dataP,
long time) |
void |
copyNewData(byte[] src,
int srcpos,
int srclen,
long time)
Replace the data bytes in the buffer.
|
VariableAccess_ifc |
getVariable(java.lang.String name)
Searches a variable by name and returns it.
|
VariableAccess_ifc |
getVariableAssert(java.lang.String name)
Searches a variable by name and returns it.
|
long |
isRequestedNewData()
Returns the time stamp (seconds after 1970) of the last call of
VariableAccess_ifc.requestValue(long)
for any variable of this container. |
int |
lengthData() |
static java.lang.String |
separateIndex(java.lang.String sPathValue,
int[] ix)
Separates an string-given index from a path.
|
void |
setCallbackOnReceivedData(java.lang.Runnable callback)
see
VariableContainer_ifc.setCallbackOnReceivedData(Runnable)
It is not implemented here. |
void |
setTimeShort(int timeShort,
int timeShortAdd)
Sets the timestamp not as absolute but as relative time for this sample.
|
public static final int versionStamp
indexVariable
is now not only private, it can be shared with a global index
using the ctor ByteDataSymbolicAccess(Map)
as done in org.vishia.guiViewCfg.OamShowValues.
In conclusion the members cannot have the specialized type ByteDataSymbolicAccess.Variable
,
instead the abstract common type VariableAccess_ifc
.
VariableAccessArray_ifc
,
and that should be test. If an array access is done (index found in string), then the downcasting should be done.
It should be able to do, elsewhere the index access cannot be done.
This is partially refactored for the necessary operations.
setTimeShort(int, int)
and ByteDataSymbolicAccess.Variable.getLastRefreshTimeShort()
as support for data from a controller which has a relative timeShort.
copyNewData(byte[], int, int, long)
assignData(byte[], long)
with timestamp required. Usages should updated.
A timestamp is a substantial propertiy of dynamic data. Use System.currentTimeMillis()
.
ByteDataSymbolicAccess.Variable.getLong(int...)
and ByteDataSymbolicAccess.Variable.setLong(long, int...)
ByteDataSymbolicAccess.Variable.nrofBytes
is necessary for ZBNF parse result.
But it isn't used yet.
VariableAccess_ifc
new ByteDataSymbolicAccess.Variable.getType()
and ByteDataSymbolicAccess.Variable.getDimension(int)
.
#syntaxSymbolicDescrFile
.
private final java.util.Map<java.lang.String,VariableAccess_ifc> indexVariable
private byte[] data
private int ixStartData
private int nrofData
protected long timeRequestNewValue
protected int[] timeShortRefresh
VariableAccess_ifc.getLastRefreshTimeShort()
.private final ConcurrentLinkedQueue<java.lang.Runnable> runOnRecv
protected long timeSetNewValue
public final ByteDataAccessSimple dataAccess
public ByteDataSymbolicAccess()
ByteDataAccessSimple
access operations.public ByteDataSymbolicAccess(java.util.Map<java.lang.String,VariableAccess_ifc> idxVariables)
public ByteDataSymbolicAccess(ByteDataAccessSimple dataAccess)
ByteDataAccessBase
or ByteDataAccessSimple
operations.
with that concept only a part of the whole data may be used for the symbolic access.dataAccess
- public final void addVariable(java.lang.String name, ByteDataSymbolicAccess.Variable variable)
public void assignData(byte[] dataP, long time)
public void assignData(byte[] dataP, int length, int from, long time)
dataP
- length
- valid number of bytes, the length + from should not exceed the dataP length.from
- byte position where the data for the internal variables starts. This is usual start of the payload, or after themtime
- The timestamp of the received data helpfull for some time relation operations.public void copyNewData(byte[] src, int srcpos, int srclen, long time)
src
- sourcesrcpos
- maybe any position in the source buffersrclen
- number of bytes in source buffer. It should be the same like number of bytes in this.data,
but it may be lesser or more. Lesser: Only a part of data are replaces.time
- timestamp of receive.public void setTimeShort(int timeShort, int timeShortAdd)
Timeshort
.
This operation does not regard any absolute time stamp. An absolute time stamp can be organized outside.
See for example org.vishia.gral.base.GralCurveView
, there either the system time is used as absolute time,
but also the controller can store an absolute time. The absolute time should be associated at point{0,0} of this timestamp.timeShort
- The internal currently relative time, maybe wrapping. Set to 0 to mark, not used.timeShortAdd
- An additional part to adjust with a given absolute time.public int lengthData()
public long isRequestedNewData()
VariableAccess_ifc.requestValue(long)
for any variable of this container.#assignData(byte[])
or
#assignData(byte[], int, int)
.public VariableAccess_ifc getVariable(java.lang.String name)
VariableContainer_ifc.getVariable(String)
getVariable
in interface VariableContainer_ifc
name
- The namepublic VariableAccess_ifc getVariableAssert(java.lang.String name) throws java.lang.NoSuchFieldException
name
- The namejava.lang.NoSuchFieldException
public static java.lang.String separateIndex(java.lang.String sPathValue, int[] ix)
sPathValue
- The path, it can contain "[ix]" on its wnd where ix is the numerical index.ix
- An array with the necessary number of element to store the index. It may be null
or shorter then the number of indices. Then the indeces are not stored.public void setCallbackOnReceivedData(java.lang.Runnable callback)
VariableContainer_ifc.setCallbackOnReceivedData(Runnable)
It is not implemented here.setCallbackOnReceivedData
in interface VariableContainer_ifc