public final class ClassContent extends java.lang.Object implements CmdConsumer_ifc
Modifier and Type | Field and Description |
---|---|
(package private) byte[] |
__TEST__ |
private AnswerComm_ifc |
answerComm
Association to produce the answer of a request.
|
private InspcDataExchangeAccess.Inspcitem |
answerItem
Access element for
ByteDataAccessBase to the answer Item. |
MemAccessArrayDebugJc |
debugRemoteAccess
Yet only a placeholder, used in the C-implementation.
|
(package private) InspcDataInfo[] |
handles
Array of registered data access info items.
|
private MemSegmJc |
rootAddr
For C usage: It can be in an extended memory area.
|
private ClassJc |
rootClass
The class to the rootAddr.
|
(package private) InspcDataInfo |
test
java2c=simpleRef.
|
private java.lang.StringBuilder |
uAnswer
Buffer to prepare the answer in the answer of a telegram.
|
private java.lang.StringBuilder |
uArray
Buffer to prepare a array information in the answer of a telegram.
|
private java.lang.StringBuilder |
uValue
Buffer to prepare the value in the answer of a telegram.
|
(package private) static java.lang.String |
version
Version, history and license.
|
private java.lang.Object |
XXXrootObj
The Object from which the user-given path starts to search.
|
Constructor and Description |
---|
ClassContent() |
Modifier and Type | Method and Description |
---|---|
private void |
addAnswerItemValueByHandle(InspcDataExchangeAccess.InspcDatagram answer,
InspcDataExchangeAccess.InspcAnswerValueByHandle answItem,
int sizeExpected) |
private int |
cmdGetAddressByPath(InspcDataExchangeAccess.Inspcitem cmd,
InspcDataExchangeAccess.InspcDatagram answer,
int maxNrofAnswerBytes) |
private int |
cmdGetFields(InspcDataExchangeAccess.Inspcitem cmd,
InspcDataExchangeAccess.InspcDatagram answer,
int maxNrofAnswerBytes) |
(package private) int |
cmdGetValueByHandle(InspcDataExchangeAccess.Inspcitem cmd,
InspcDataExchangeAccess.InspcDatagram answer,
int maxNrofAnswerBytes) |
private int |
cmdGetValueByPath(InspcDataExchangeAccess.Inspcitem cmd,
InspcDataExchangeAccess.InspcDatagram answer) |
(package private) int |
cmdRegisterRepeat(InspcDataExchangeAccess.Inspcitem cmd,
InspcDataExchangeAccess.InspcDatagram answer,
int maxNrofAnswerBytes) |
private int |
cmdSetValueByPath(InspcDataExchangeAccess.Inspcitem cmd,
InspcDataExchangeAccess.InspcDatagram answer) |
private void |
completeAnswerItemByHandle(InspcDataExchangeAccess.InspcAnswerValueByHandle answItem,
int indexTo,
int nOrderNr) |
private void |
evaluateFieldGetFields(InspcDataExchangeAccess.InspcDatagram answer,
FieldJc field,
int orderNr,
int maxNrofAnswerBytes) |
private void |
evaluateFieldGetFields(InspcDataExchangeAccess.InspcDatagram answer,
java.lang.String name,
ClassJc typeField,
int modifiers,
int staticArraySize,
int orderNr,
int maxNrofAnswerBytes) |
int |
executeMonitorCmd(InspcDataExchangeAccess.Inspcitem cmd,
InspcDataExchangeAccess.InspcDatagram answer,
int maxNrofAnswerBytes)
Executes a command, writes the answer in the answer datagram.
|
float |
getFloatValueByHandle(int handle)
Gets the value described by this handle as float value.
|
int |
getIntValueByHandle(int handle)
Gets the value described by this handle as int32 value.
|
private static short |
getSetValue(FieldJc theField,
int idx,
MemSegmJc theObject,
InspcDataExchangeAccess.InspcSetValue accSetValue,
InspcDataExchangeAccess.Inspcitem answerItem,
boolean bStoreTypeInAnswer)
Sets the value if accSetValue is not null, fills the
answerItem with the read value. |
void |
getSetValueByPath(int nOrderNr,
java.lang.String sVariablePath,
InspcDataExchangeAccess.InspcSetValue accSetValue,
InspcDataExchangeAccess.Inspcitem answerItem)
Gets or sets a value by given path of reflection.
|
static short |
getTypeFromField(FieldJc theField)
Converts the given Field of Reflection to the type byte.
|
private short |
getValueByHandle(int handle,
InspcDataExchangeAccess.InspcAnswerValueByHandle answItem,
InspcDataExchangeAccess.InspcDatagram answer,
int index,
int nOrderNr)
Gets a value which is registered before by
registerHandle(String, org.vishia.communication.InspcDataExchangeAccess.Inspcitem)
This is the core routine for cmdGetValueByHandle(org.vishia.communication.InspcDataExchangeAccess.Inspcitem, org.vishia.communication.InspcDataExchangeAccess.InspcDatagram, int)
which needs writing to the answer datagram. |
int |
registerHandle(java.lang.String sVariablePath,
InspcDataExchangeAccess.Inspcitem answerItem)
Registers a path for repeated access
|
void |
setAnswerComm(AnswerComm_ifc answerComm)
sets all aggregations which are unknown on constuctor.
|
void |
setRootObject(ClassJc rootClazz,
MemSegmJc rootAddr)
Sets the Object which is the root for all data.
|
void |
setRootObject(java.lang.Object rootObj)
Sets the Object which is the root for all data.
|
(package private) void |
stop() |
private void |
txAnswerAndPrepareNewTelg(InspcDataExchangeAccess.InspcDatagram answer)
The information doesn't fit in the datagram: Send the last one and clear it.
|
static final java.lang.String version
rootClass
, rootAddr
instead XXXrootObj
: In C it is possible to have a rootAddr outside the own code, in a target proxy.
In C it is possible to have a non-Object.based instance with separate reflection info (Class).
setRootObject(ClassJc, MemSegmJc)
SearchElement.searchObject(String, ClassJc, MemSegmJc, FieldJc[], int[])
with separated class and instance reference.
#getValueByHandle(int, org.vishia.communication.InspcDataExchangeAccess.Inspcitem)
etc.
to access data with path without a reflection item, directly in the same application.
evaluateFieldGetFields(org.vishia.communication.InspcDataExchangeAccess.InspcDatagram, String, ClassJc, int, int, int, int)
:
The incrAnswerNr() was called twice because it is called on CmdExecuter.txAnswer(int, boolean)
too.
FieldJc
and @link ClassJc.getSuperField()
.
evaluateFieldGetFields(org.vishia.communication.InspcDataExchangeAccess.InspcDatagram, FieldJc, int, int)
:
Problem with answer for long structures with second telegram. TODO: test it for C too!
InspcDataExchangeAccess.kInvalidHandle
is returned for this value.
The requester should remove that index. It is implemented in InspcVariable
.
#getSetValueByPath(org.vishia.communication.InspcDataExchangeAccess.Inspcitem, org.vishia.communication.InspcDataExchangeAccess.InspcSetValue, org.vishia.communication.InspcDataExchangeAccess.InspcDatagram, String, int)
,
It should be returned a message anyway. If nothing is returned, the calling doesn't know that problem
and the whole telegram may not be sent. It would cause a timeout.
final byte[] __TEST__
private java.lang.Object XXXrootObj
SearchElement#searchObject(String, Object, FieldJc[], int[])
.private ClassJc rootClass
private MemSegmJc rootAddr
private AnswerComm_ifc answerComm
public MemAccessArrayDebugJc debugRemoteAccess
private final InspcDataExchangeAccess.Inspcitem answerItem
ByteDataAccessBase
to the answer Item.
It is reused whenever an info item is to be added.private final java.lang.StringBuilder uArray
private final java.lang.StringBuilder uValue
private final java.lang.StringBuilder uAnswer
final InspcDataInfo test
final InspcDataInfo[] handles
public final void setRootObject(java.lang.Object rootObj)
rootObj
- public final void setRootObject(ClassJc rootClazz, MemSegmJc rootAddr)
rootObj
- public final void setAnswerComm(AnswerComm_ifc answerComm)
setAnswerComm
in interface CmdConsumer_ifc
public int executeMonitorCmd(InspcDataExchangeAccess.Inspcitem cmd, InspcDataExchangeAccess.InspcDatagram answer, int maxNrofAnswerBytes) throws java.lang.IllegalArgumentException, java.io.UnsupportedEncodingException
CmdConsumer_ifc
AnswerComm_ifc.txAnswer(int, boolean)
.
The user should add its InspcDataExchangeAccess.Inspcitem
-elements for the answer there.
Only if the datagram is full and a next info have to be add, the current datagram should be send.
Therefore the routine AnswerComm_ifc.txAnswer(int, boolean)
should be called
with the current number of bytes and false
as 2. parameter. A non-filled datagram
is not to be sent. It will be send after the last invocation of a command consumer from the
activator of this method. In this way more as one answer can be given in one ore more datagrams,
while the command datagram may contain more as one command too.executeMonitorCmd
in interface CmdConsumer_ifc
cmd
- The command. It is one information unit only, not a full datagram, because the command
is containing in a information unit. A datagram may contain more as one command.answer
- answer datagram with prepared head, maybe with already content.
The answer information units are to be add here. The datagram is to be send,
if it is full.maxNrofAnswerBytes
- The maximum of bytes inclusive head in the datagram.java.lang.IllegalArgumentException
java.io.UnsupportedEncodingException
private void txAnswerAndPrepareNewTelg(InspcDataExchangeAccess.InspcDatagram answer)
private final int cmdGetFields(InspcDataExchangeAccess.Inspcitem cmd, InspcDataExchangeAccess.InspcDatagram answer, int maxNrofAnswerBytes)
private final void evaluateFieldGetFields(InspcDataExchangeAccess.InspcDatagram answer, FieldJc field, int orderNr, int maxNrofAnswerBytes)
private final void evaluateFieldGetFields(InspcDataExchangeAccess.InspcDatagram answer, java.lang.String name, ClassJc typeField, int modifiers, int staticArraySize, int orderNr, int maxNrofAnswerBytes)
private final int cmdGetValueByPath(InspcDataExchangeAccess.Inspcitem cmd, InspcDataExchangeAccess.InspcDatagram answer) throws java.lang.IllegalArgumentException, java.io.UnsupportedEncodingException
java.lang.IllegalArgumentException
java.io.UnsupportedEncodingException
private final int cmdSetValueByPath(InspcDataExchangeAccess.Inspcitem cmd, InspcDataExchangeAccess.InspcDatagram answer) throws java.lang.IllegalArgumentException, java.io.UnsupportedEncodingException
java.lang.IllegalArgumentException
java.io.UnsupportedEncodingException
public final void getSetValueByPath(int nOrderNr, java.lang.String sVariablePath, InspcDataExchangeAccess.InspcSetValue accSetValue, InspcDataExchangeAccess.Inspcitem answerItem) throws java.lang.IllegalArgumentException, java.io.UnsupportedEncodingException
nOrderNr
- The order number for answer.sVariablePath
- variable-path like it is found in cmdaccSetValue
- if null then get, if not null, the value to set, It refers inside the request for the set value.answerItem
- response datagram item for answer. The item should be added already to a parent if necessary.java.lang.IllegalArgumentException
java.io.UnsupportedEncodingException
private static short getSetValue(FieldJc theField, int idx, MemSegmJc theObject, InspcDataExchangeAccess.InspcSetValue accSetValue, InspcDataExchangeAccess.Inspcitem answerItem, boolean bStoreTypeInAnswer) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException
answerItem
with the read value.
Fills with or without type byte.theField
- describes the field to accessidx
- with this indextheObject
- in this objectaccSetValue
- null or given to set a value.answerItem
- It writes the type with one byte if bStoreTypeInAnswer = true,
and than the value with ByteDataAccessBase#addChildInteger(int, long)
or such with the read value.bStoreTypeInAnswer
- true then stores the 1-byte-type information before the value. false then store the value only.java.lang.IllegalArgumentException
java.lang.IllegalAccessException
private final int cmdGetAddressByPath(InspcDataExchangeAccess.Inspcitem cmd, InspcDataExchangeAccess.InspcDatagram answer, int maxNrofAnswerBytes) throws java.lang.IllegalArgumentException, java.io.UnsupportedEncodingException
java.lang.IllegalArgumentException
java.io.UnsupportedEncodingException
int cmdRegisterRepeat(InspcDataExchangeAccess.Inspcitem cmd, InspcDataExchangeAccess.InspcDatagram answer, int maxNrofAnswerBytes) throws java.lang.IllegalArgumentException, java.io.UnsupportedEncodingException
java.lang.IllegalArgumentException
java.io.UnsupportedEncodingException
public int registerHandle(java.lang.String sVariablePath, InspcDataExchangeAccess.Inspcitem answerItem) throws java.lang.IllegalArgumentException
sVariablePath
- answerItem
- maybe null then not used, elsewhere the current value is added.java.lang.IllegalArgumentException
java.io.UnsupportedEncodingException
private void addAnswerItemValueByHandle(InspcDataExchangeAccess.InspcDatagram answer, InspcDataExchangeAccess.InspcAnswerValueByHandle answItem, int sizeExpected)
private void completeAnswerItemByHandle(InspcDataExchangeAccess.InspcAnswerValueByHandle answItem, int indexTo, int nOrderNr)
int cmdGetValueByHandle(InspcDataExchangeAccess.Inspcitem cmd, InspcDataExchangeAccess.InspcDatagram answer, int maxNrofAnswerBytes) throws java.lang.IllegalArgumentException, java.io.UnsupportedEncodingException
java.lang.IllegalArgumentException
java.io.UnsupportedEncodingException
private short getValueByHandle(int handle, InspcDataExchangeAccess.InspcAnswerValueByHandle answItem, InspcDataExchangeAccess.InspcDatagram answer, int index, int nOrderNr)
registerHandle(String, org.vishia.communication.InspcDataExchangeAccess.Inspcitem)
This is the core routine for cmdGetValueByHandle(org.vishia.communication.InspcDataExchangeAccess.Inspcitem, org.vishia.communication.InspcDataExchangeAccess.InspcDatagram, int)
which needs writing to the answer datagram. If this routine is used directly, inside this target, this routine can be used
with following pattern: byte[] answerBuffer = new byte[20]; //buffer for the answer InspcDataExchangeAccess.Inspcitem answItem = new InspcDataExchangeAccess.Inspcitem(); answItem.assignClear(answerBuffer); short type = inspector.classContent.getValueByHandle(handle, answItem); //The result is written to the answerBuffer, the answItem is the helper only. answItem.assign(answerBuffer); //assign newly but yet to read the content. int value = InspcDataExchangeAccess.getIntChild(type, answItem);See
getFloatValueByHandle(int)
, getIntValueByHandle(int)
which uses this routine.handle
- The returned ident from registrationanswItem
- destination jar for the value. The bytes of value will be appended as child only.
The number of bytes are able to evaluate by checking the length of the item respectively the
InspcDataExchangeAccess.nrofBytesForType(short)
with the returned type. That information was stored also
by executing of registerHandle(String, org.vishia.communication.InspcDataExchangeAccess.Inspcitem)
in the target system too.
Therefore the number of the bytes of the value and the type of value should be known, it is not transferred in the datagram.public float getFloatValueByHandle(int handle)
handle
- Return value of registerHandle(String, org.vishia.communication.InspcDataExchangeAccess.Inspcitem)
public int getIntValueByHandle(int handle)
handle
- Return value of registerHandle(String, org.vishia.communication.InspcDataExchangeAccess.Inspcitem)
public static short getTypeFromField(FieldJc theField)
theField
- describes the field to accessidx
- with this indexfinal void stop()