public class InspcTargetAccessor extends java.lang.Object implements InspcAccess_ifc
InterProcessComm
from its InspcCommPort
aggregate.
The InspcCommPort has created a receiving thread.InspcMng
knows one or more InspcTargetAccessor-instances, indicated by its name.
The name of the target access is the first part of the data path to a target: "name:path.in.target"
InspcCommPort
.
InterProcessComm
interface which is implemented by the InterProcessComm_SocketImpl
or maybe for a serial communication or Dual-Port-RAM or other. It means the communication connection to a target can be done
in several ways independent of the mission of this class.
InspcMng
.
isOrSetReady(long)
is invoked to see whether a communication task is pending yet.
isOrSetReady(long)
clears the communication to this target and returns true
if the given timeout is expired: It is possible to unplug a target - it does not answer - and plug again later.
The target does not repeat the lost answers. But it is ready for new communication. The timeout should be a proper time for the target.
If it is to less, the target may prepare the answer yet in the moment and it is disturbed hectically. The timeout should be acceptable
for usage. About 5 seconds may be a proper value.
isOrSetReady(long)
returns true.
InspcAccess_ifc
cmdGet/Set
....
With them one or more datagrams are prepared.
InspcAccessExecRxOrder_ifc
.
Thats InspcAccessExecRxOrder_ifc.execInspcRxOrder(org.vishia.communication.InspcDataExchangeAccess.Inspcitem, long, LogMessage, int)
is executed if the response item is received. With the order-number-concept
see InspcDataExchangeAccess.Inspcitem#getOrder()
the request and the response are associated together.
cmdFinit()
should be invoked. That completes the one or last datagram and forces sending to the target.
InspcMng this txAccess commPort ipc | | | | ~ ~ ~ ~ +procComm(): | | | +--isOrSetReady(...)------>| | | | +--cmdGetSet...----------->|--->addChild--------->| | | +--isOrSetReady(...)------>| | | | +--cmdGetSet...----------->|--->addChild--------->| | | +--cmdGetSet...----------->|--->addChild--------->| | | + |--completeDatagram()->| | | +--cmdGetSet...----------->|--->addChild--------->| | | +--cmdGetSet...----------->|--->addChild--------->| | | + | | | | +-->cmdFinit()------------>|--completeDatagram()->| | | | [bTaskPending = true] | | | |---send(txBuffer)--------------->|--send----->| | | | | ~ ~ ~ ~Therewith up to 10 datagrams are assembled. Only the first datagram is sent yet. The target may answer:
_tdata
InspcTargetAccessor.TelgData.rxDatagram
. This is done in evaluateRxTelg(byte[], int)
.
InspcTargetAccessor.TelgData.rxBitsAnswerNr
.
An datagram which is received twice is ignored as twice.
InspcDataExchangeAccess.InspcDatagram#lastAnswer()
, a special bit.
With them is can be recognized that all datagrams are completely received.
this commPort ipc | | ! ~ ~ ~<<== | ! ! " ! !<..receive..! " [rxDatagram]!<---evaluateRxTelg(datagram)-----! ! " [rxDatagram]!<---evaluateRxTelg(datagram)-----! ! " ! ! ! " ~ ~ ~ "
InspcMng.procComm()
invokes evaluateRxTelgInspcThread()
cyclically. This routine checks
whether all datagrams of one request datagram are received. It invokes
evaluateOneDatagram(org.vishia.communication.InspcDataExchangeAccess.InspcDatagram, InspcAccessExecRxOrder_ifc, long, LogMessage, int, DebugTxRx, int)
internally for each of the received datagrams.
InspcDataExchangeAccess.Inspcitem
for each item.
That is derived from ByteDataAccessBase
which converts the byte data in the datagram to user specifics.
InspcDataExchangeAccess.Inspcitem#getOrder()
is read.
With them and the stored InspcAccessExecRxOrder_ifc
is searched in the ordersExpected
index.
InspcAccessExecRxOrder_ifc.execInspcRxOrder(org.vishia.communication.InspcDataExchangeAccess.Inspcitem, long, LogMessage, int)
is invoked with the received datagram item. That is the callback to the users level with the received information.
evaluateRxTelgInspcThread()
looks whether a next datagram with assembled requests
are given furthermore. Then it sends is to the target.
send()
this sequence is repeated.
InspcMng this "
| | "
~ ~ "
+procComm(): | "
+-evaluateRxTelgInspcThread()
-->|[rxDatagram] "
+ |-evaluateOneDatagram()-+ Requestor "
+ +<----------------------+ | "
+ +----execInspcRxOrder(datagramitem, ...)-->| "
+ +----execInspcRxOrder(datagramitem, ...)-->| "
+ +----execInspcRxOrder(datagramitem, ...)-->| "
+ +----execInspcRxOrder(datagramitem, ...)-->| "
+ + | "
+ + "
+ + commPort ipc "
+ + | | "
+ +---send(txBuffer)--------------->|...........>| "
+<.......................................+ | | "
| | | | "
| | | | "
~ ~ ~ ~====
The communication is still pending yet. Next requests from user level are deferred till this repetition
of send()
and evaluateRxTelgInspcThread()
is currently.
InspcMng this " | | " ~ ~ ~ ~ | |[on last datagram: ] | |[bTaskPending = false;] | | ~ ~ |--isOrSetReady(...)------>| //the next communication cycle |The cmdGetSet routines are:
cmdGetFields(String, InspcAccessExecRxOrder_ifc)
cmdGetValueByPath(String, InspcAccessExecRxOrder_ifc)
cmdRegisterHandle(String, InspcAccessExecRxOrder_ifc)
cmdGetValueByHandle(int, InspcAccessExecRxOrder_ifc)
cmdGetAddressByPath(String, InspcAccessExecRxOrder_ifc)
#cmdSetValueByPath(String, double, InspcAccessExecRxOrder_ifc)
#cmdSetValueByPath(String, float, InspcAccessExecRxOrder_ifc)
#cmdSetValueByPath(String, int, InspcAccessExecRxOrder_ifc)
cmdSetValueByPath(String, long, int, InspcAccessExecRxOrder_ifc)
InspcTargetAccessor.TxBuffer
.
cmdFinit()
. That command completes the only one or the last datagram
and sends the first datagram to the target. With this invocation the #isReady(long)
returns false
because the variable bTaskPending
is set to true.
commPort
(InspcCommPort
) gets the received telegram.
On comparison of the sender address in the datagram or on comparison of the entrant in the
datagram's head InspcDataExchangeAccess.InspcDatagram#getEntrant()
.
The answer from target can consist of more as one datagram. Any correct answer telegram invokes
evaluateRxTelg(byte[], int)
.
The answer contains some InspcDataExchangeAccess.Inspcitem
. All of them has its order number.
With the order number the associated #execInspcRxOrder(org.vishia.communication.InspcDataExchangeAccess.Inspcitem, long, LogMessage, int)
is invoked as callback in the users space. This is organized in the aggregated #rxEval
instance.
bTaskPending
is set to false, a next #isReady(long)
returns true
for the next task of requests.
commPort
(InspcCommPort
) gets the received telegram.
On comparison of the sender address in the datagram or on comparison of the entrant in the
datagram's head InspcDataExchangeAccess.InspcDatagram#getEntrant()
.
cmdGetValueByPath(String, InspcAccessExecRxOrder_ifc)
etc. are not threadsafe.
That is because the organization of a datagram content should be controlled by one hand. Typically this
only one thread runs cyclically because it requests currently data.
ConcurrentLinkedQueue
and
regarded on next cyclic call.
#execInspcRxOrder(org.vishia.communication.InspcDataExchangeAccess.Inspcitem, long, LogMessage, int)
is invoked by the receiver's thread called back in the user's space. This routines can be used to notify
any waiting thread or any short action can be done in the callback, especially request of some more cmd...Modifier and Type | Class and Description |
---|---|
(package private) static class |
InspcTargetAccessor.Cmd |
private static class |
InspcTargetAccessor.DebugTxRx |
(package private) class |
InspcTargetAccessor.Ev |
private static class |
InspcTargetAccessor.GetFieldsData |
private static class |
InspcTargetAccessor.OrderWithTime |
(package private) class |
InspcTargetAccessor.States |
private static class |
InspcTargetAccessor.TelgData |
private class |
InspcTargetAccessor.TxBuffer
This class contains all data for one datagram to send.
|
Modifier and Type | Field and Description |
---|---|
(package private) InspcTargetAccessor.TelgData |
_tdata |
private ByteDataAccessBase |
accInfoDataGetValueByIdent
Managing instance of
ByteDataAccessBase for dataInfoDataGetValueByIdent . |
(package private) int |
accLevels
Return value from CheckPwd_Inspc#check(int). it is 0..4 in bit 7..0 for change and 0..4 in bit 3..0 for access.
|
(package private) InspcAccessExecRxOrder_ifc |
actionPwdRx
This class handles a received access level for a new password.
|
private InspcAccessExecRxOrder_ifc[] |
actionRx4GetValueByHandle |
(package private) java.lang.Runnable |
addCmdAccessCheck
Adds a telegram for password-check.
|
private boolean |
bFillTelg
If true, then a TelgHead is prepared already and some more info can be taken into the telegram.
|
private boolean |
bIsSentTelg
True if a second datagram is prepared and sent yet.
|
private boolean |
bRequestWhileTaskPending |
(package private) boolean |
bRunInRxThread
Set to true while a telegram is evaluating in the received thread.
|
private boolean |
bShouldSend
If true then the current prepared tx telegram should be send.
|
private java.util.concurrent.atomic.AtomicBoolean |
bTaskPending
Set if the
cmdFinit() is given. set false on last received answer for the task. |
(package private) boolean |
bWriteDebugSystemOut |
java.util.Map<java.lang.Integer,java.lang.Runnable> |
callbacksOnAnswer
Reused instance to evaluate any info blocks.
|
private InspcCommPort |
commPort |
float[] |
cycle_timeout |
private byte[] |
dataInfoDataGetValueByIdent
A info element to get values by ident It contains a
InspcDataExchangeAccess.Inspcitem head
and then 4-byte-idents for data. |
(package private) java.lang.String |
dbgNameStopTx
Free String to write, for debug stop.
|
(package private) long |
dtimeReceive |
(package private) long |
dtimeWeakup |
(package private) InspcTargetAccessor.Ev |
evFill |
(package private) InspcTargetAccessor.Ev |
evLastAnswer |
(package private) InspcTargetAccessor.Ev |
evSend |
(package private) InspcTargetAccessor.GetFieldsData |
getFieldsData |
(package private) int |
identLogTelg |
private int |
ixIdent5GetValueByIdent |
(package private) java.util.Deque<InspcTargetAccessor.OrderWithTime> |
listTimedOrders |
(package private) LogMessage |
logTelg
If true then writes a log of all send and received telegrams.
|
java.lang.String |
name
Identifier especially for debugging.
|
(package private) int |
nEncryptionAcc |
(package private) int |
nEncryptionAccNew |
(package private) int |
nEncryptionChg |
(package private) int |
nEntrant
The entrant is the sub-consumer of a telegram on the device with given IP.
|
private InspcAccessGenerateOrder |
orderGenerator |
protected java.util.Map<java.lang.Integer,InspcTargetAccessor.OrderWithTime> |
ordersExpected
Map of all orders which are send as request.
|
(package private) char |
state |
private StateSimple |
stateIdle |
(package private) InspcTargetAccessor.States |
states |
private StateSimple |
stateWaitAnswer |
(package private) Address_InterProcessComm |
targetAddr |
(package private) long |
timeReceive |
(package private) long |
timeSend |
private InspcDataExchangeAccess.InspcDatagram |
txAccess |
private java.util.concurrent.ConcurrentLinkedQueue<java.lang.Runnable> |
userTxOrders
Some orders from any application which should be run in the
#inspcThread . |
(package private) static java.lang.String |
version
The version history and license of this class.
|
(package private) InspcAccessExecRxOrder_ifc |
XXXactionRx4ValueByIdent |
(package private) java.util.Map<java.lang.Integer,InspcVariable> |
XXXvariablesByHandle
Map of all Variables which are gotten by handle.
|
private static int |
zIdent4GetValueByIdent
Number of idents to get values per ident.
|
idLogFailedSeq, idLogGetAddress, idLogGetFields, idLogGetOther, idLogGetValueByIdent, idLogGetValueByPath, idLogRcvGetAddress, idLogRcvGetFields, idLogRcvGetOther, idLogRcvGetValueByIdent, idLogRcvGetValueByPath, idLogRcvRegisterByPath, idLogRcvSetValueByPath, idLogRegisterByPath, idLogRx, idLogRxError, idLogRxItem, idLogRxLast, idLogRxNotlast, idLogRxRepeat, idLogSetValueByPath, idLogTx, sVersion
Constructor and Description |
---|
InspcTargetAccessor(java.lang.String name,
InspcCommPort commPort,
Address_InterProcessComm targetAddr,
float period,
float timeout,
EventTimerThread threadEvents) |
Modifier and Type | Method and Description |
---|---|
void |
addUserTxOrder(java.lang.Runnable order)
Adds any program snippet which is executed while preparing the telegram for data request from target.
|
InspcDataExchangeAccess.InspcDatagram[] |
awaitAnswer(int timeout)
Deprecated.
The communication handles several requests. It is not proper that one await is programmed.
The answer will be gotten for any information unit in the telegrams.
See
InspcAccessExecRxOrder_ifc -argument of any cmdGetValueByPath(String, InspcAccessExecRxOrder_ifc) ...
routine. |
int |
checkAndRemoveOldOrders(long timeOld)
Clean up the order list.
|
void |
checkExecuteSendUserOrder()
This routine checks whether the communication is in its tx request gathering state:
isOrSetReady(long)
returns true. |
boolean |
checkIsSent()
Returns true if enough information blocks are given, so that a telegram was sent already.
|
private int |
cmdAccessCheck()
Adds the info block to send 'get fields by path'
|
boolean |
cmdFinit()
This routine have to be called after the last cmd in one thread.
|
boolean |
cmdGetAddressByPath(java.lang.String sPathInTarget,
InspcAccessExecRxOrder_ifc actionOnRx)
Adds the info block to send 'get address by path'
|
int |
cmdGetFields(java.lang.String sPathInTarget,
InspcAccessExecRxOrder_ifc actionOnRx)
Adds the info block to send 'get fields by path'
|
boolean |
cmdGetValueByHandle(int ident,
InspcAccessExecRxOrder_ifc action)
Adds the info block to send 'get value by ident'
|
int |
cmdGetValueByPath(java.lang.String sPathInTarget,
InspcAccessExecRxOrder_ifc actionOnRx)
Adds the info block to send 'get value by path'
|
int |
cmdRegisterHandle(java.lang.String sPathInTarget,
InspcAccessExecRxOrder_ifc actionOnRx)
Adds the info block to send 'register by path'
|
void |
cmdSetDoubleByPath(java.lang.String sPathInTarget,
double value,
InspcAccessExecRxOrder_ifc actionOnRx)
Adds the info block to send 'set value by path'
|
void |
cmdSetFloatByPath(java.lang.String sPathInTarget,
float value,
InspcAccessExecRxOrder_ifc actionOnRx)
Adds the info block to send 'set value by path'
|
void |
cmdSetInt32ByPath(java.lang.String sPathInTarget,
int value,
InspcAccessExecRxOrder_ifc actionOnRx)
Adds the info block to send 'set value by path'
|
void |
cmdSetStringByPath(VariableAccessArray_ifc var,
java.lang.String value)
Adds the info block to send 'set value by path'
|
int |
cmdSetValueByPath(java.lang.String sPathInTarget,
int value)
Adds the info block to send 'set value by path'
|
void |
cmdSetValueByPath(java.lang.String sPathInTarget,
long value,
int typeofValue,
InspcAccessExecRxOrder_ifc actionOnRx)
Adds the info block to send 'get value by path'
|
private void |
completeDatagram(boolean lastTelg)
Completes this datagram with all head information.
|
void |
evaluateOneDatagram(InspcDataExchangeAccess.InspcDatagram telgHead,
InspcAccessExecRxOrder_ifc executer,
long time,
LogMessage log,
int identLog,
InspcTargetAccessor.DebugTxRx dbgRx,
int dbgixAnswer)
Evaluates a received telegram.
|
void |
evaluateRxTelg(byte[] rxBuffer,
int rxLength)
This routine is called from the received thread if a telegram with the sender of this target
was received.
|
void |
evaluateRxTelgInspcThread()
This routine is invoked cyclically in the inspector thread.
|
(package private) void |
execRx4ValueByHandle(InspcDataExchangeAccess.Inspcitem inspcitem,
long time,
LogMessage log,
int identLog) |
static short |
getInspcTypeFromRxValue(InspcDataExchangeAccess.Inspcitem info)
Gets the reflection type of the received information.
|
int |
getStateInfo() |
InspcTargetAccessData |
getTargetAccessFromPath(java.lang.String sDataPath,
boolean strict)
Splits a given full data path with device:datapath maybe with alias:datapath in the device, path, name and returns a struct.
|
static char |
getTypeFromInspcType(int type)
Gets the type of the received information.
|
boolean |
isFilledTxTelg()
Returns whether a tx telegram is filled with any info blocks.
|
boolean |
isOrSetReady(long timeCurrent)
Checks readiness of communication cycle.
|
(package private) void |
lastTelg()
Executes after the last answer telegram of this sequence was received.
|
(package private) InspcTelgInfoSet |
newTxitem() |
private boolean |
prepareTelg(int lengthNewInfo,
int nEncryption)
Checks whether the head of the datagram should be created and the telegram has place for the current data.
|
void |
requestFields(InspcTargetAccessData data,
InspcAccessExecRxOrder_ifc rxActionGetFields,
java.lang.Runnable runOnReceive)
Set the request for all fields of the given variable.
|
private void |
send()
Sends the prepared telegram.
|
boolean |
sendAndPrepareCmdSetValueByPath(java.lang.String sPathInTarget,
long value,
int typeofValue,
InspcAccessExecRxOrder_ifc exec)
Deprecated.
|
void |
setExpectedOrder(int order,
InspcAccessExecRxOrder_ifc actionOnRx)
Sets an expected order in the index of orders and registers a callback after all telegrams was received if given.
|
void |
setLog(LogMessage log,
int ident)
Switch on or off the log functionality.
|
void |
setPwdCycle(java.lang.String pwdAccess,
float timeCycle,
float timeout)
Set information from the GUI
|
void |
setReady()
Sets the communication cycle of ready (idle) state,
called either inside
isOrSetReady(long) on time expired or if the last rx telegram was processed successfully. |
void |
setStateToUser(InspcPlugUser_ifc user) |
void |
setTargetAddr(java.lang.String sTargetIpAddr)
Deprecated.
|
boolean |
shouldSend()
Returns true if any cmd..() call doesn't fit in the current telegram, therefore the tx telegram
should be send firstly.
|
(package private) void |
stop() |
java.lang.String |
toString() |
(package private) boolean |
txCmdGetValueByIdent() |
static float |
valueFloatFromRxValue(InspcDataExchangeAccess.Inspcitem info,
int type) |
static int |
valueIntFromRxValue(InspcDataExchangeAccess.Inspcitem info,
int type) |
static java.lang.String |
valueStringFromRxValue(InspcDataExchangeAccess.Inspcitem info,
int nBytesString) |
static final java.lang.String version
addCmdAccessCheck
#setPwdCycle(String, String, float, float)
from Gui,
setReady()
is public because called from Gui. Better for single-step-debug in target with timeout = 0.
InspcTargetAccessor(String, InspcCommPort, Address_InterProcessComm, float, float, EventTimerThread)
with arguments for timeout and perdiod.
isOrSetReady(long)
regards timeout = 0: don't invoke setReady()
.
cmdSetStringByPath(VariableAccessArray_ifc, String)
: Up to now float values should be sent as double
because the old target systems from 2010, 2011 does not regard float.
isOrSetReady(long)
now checks the timeout by its own cycle_timeout
.
The last one can be changed in the setStateToUser(InspcPlugUser_ifc)
which acts with the graphical user interface.
Therewith the timeout can be changed in the GUI especially for debugging situations.
InspcTargetAccessor.GetFieldsData.bGetFieldsPending
and prohibits further telegrams
via isOrSetReady(long)
false-return: Reason: The target does not regard a new telegram
for further get-value requests if the telegram has less free space. The target crashes instead.
On getFields more as one answer telegram is regarded. But the rest of the telegram for getValueByPath does not work.
An older non fixed target should be accepted because it runs in field - no update possibility!
addUserTxOrder(Runnable)
not only for the whole InspcMng
.
InspcTelgInfoSet.lengthCmdSetValueByPath(int)
. For all commands.
InspcTargetAccessor.DebugTxRx
, data in sub classes
#requestFields(InspcStruct, Runnable)
redesigned
#cmdSetValueByPath(String, int, InspcAccessExecRxOrder_ifc)
,
valueStringFromRxValue(org.vishia.communication.InspcDataExchangeAccess.Inspcitem, int)
to test telegram traffic
sendAndPrepareCmdSetValueByPath(String, long, int, InspcAccessExecRxOrder_ifc)
.
The concept is: provide the InspcAccessExecRxOrder_ifc
with the send request.
It should be implement for all requests in this form. But the awaiting of answer doesn't may the best way.
Problem evaluating the answer telg in the rx thread or in the tx thread. TODO documentation.
shouldSend()
and isFilledTxTelg()
able to call outside.
It improves the handling with info blocks in a telegram.
InspcTargetAccessor.TelgData _tdata
InspcTargetAccessor.GetFieldsData getFieldsData
public final java.lang.String name
java.lang.String dbgNameStopTx
LogMessage logTelg
boolean bWriteDebugSystemOut
int identLogTelg
private final InspcAccessGenerateOrder orderGenerator
protected final java.util.Map<java.lang.Integer,InspcTargetAccessor.OrderWithTime> ordersExpected
final java.util.Deque<InspcTargetAccessor.OrderWithTime> listTimedOrders
private final java.util.concurrent.ConcurrentLinkedQueue<java.lang.Runnable> userTxOrders
#inspcThread
.final java.util.Map<java.lang.Integer,InspcVariable> XXXvariablesByHandle
public final java.util.Map<java.lang.Integer,java.lang.Runnable> callbacksOnAnswer
char state
final InspcTargetAccessor.States states
private final StateSimple stateIdle
private final StateSimple stateWaitAnswer
InspcTargetAccessor.Ev evFill
InspcTargetAccessor.Ev evSend
InspcTargetAccessor.Ev evLastAnswer
private boolean bFillTelg
private boolean bShouldSend
private boolean bIsSentTelg
private final java.util.concurrent.atomic.AtomicBoolean bTaskPending
cmdFinit()
is given. set false on last received answer for the task.private boolean bRequestWhileTaskPending
long timeSend
long timeReceive
long dtimeReceive
long dtimeWeakup
boolean bRunInRxThread
isOrSetReady(long)
returns false though the time is expired.
This is a helper for debugging firstly. Don't send new telegrams while debugging.private InspcDataExchangeAccess.InspcDatagram txAccess
private static final int zIdent4GetValueByIdent
dataInfoDataGetValueByIdent
. An info block has to be no longer than a UDP-telegram.private int ixIdent5GetValueByIdent
private final byte[] dataInfoDataGetValueByIdent
InspcDataExchangeAccess.Inspcitem
head
and then 4-byte-idents for data. The same order of data are given in the arrayprivate final ByteDataAccessBase accInfoDataGetValueByIdent
ByteDataAccessBase
for dataInfoDataGetValueByIdent
.private final InspcAccessExecRxOrder_ifc[] actionRx4GetValueByHandle
int nEntrant
final Address_InterProcessComm targetAddr
int nEncryptionAcc
int nEncryptionChg
int nEncryptionAccNew
int accLevels
private final InspcCommPort commPort
public final float[] cycle_timeout
InspcAccessExecRxOrder_ifc XXXactionRx4ValueByIdent
java.lang.Runnable addCmdAccessCheck
actionPwdRx
InspcAccessExecRxOrder_ifc actionPwdRx
setPwdCycle(String, float, float)
.public InspcTargetAccessor(java.lang.String name, InspcCommPort commPort, Address_InterProcessComm targetAddr, float period, float timeout, EventTimerThread threadEvents)
@Deprecated public void setTargetAddr(java.lang.String sTargetIpAddr)
sTargetIpAddr
- public void setLog(LogMessage log, int ident)
logP
- The log output. null then switch of the log.ident
- The ident number in log for send, next number for receive.public final void setPwdCycle(java.lang.String pwdAccess, float timeCycle, float timeout)
pwdAccess
- should be "" if no changepwdChange
- should be "" if no changetimeCycle
- timeout
- public void addUserTxOrder(java.lang.Runnable order)
addUserTxOrder
in interface InspcAccess_ifc
order
- the program snippet.private boolean prepareTelg(int lengthNewInfo, int nEncryption)
bFillTelg
, able to query with isFilledTxTelg()
.
bShouldSend
able to query with shouldSend()
if the info doesn't fit in the telegram.
zBytesInfo
- Number of bytes to add to the telegram.public boolean checkIsSent()
public boolean isOrSetReady(long timeCurrent)
InspcTargetAccessor.States.StateIdle
or InspcTargetAccessor.States.StateFilling
Returns false if not all answer telegrams were received from the last request.
It is in all other states of InspcTargetAccessor.States
.
If the time of the last send request was before timeLastTxWaitFor
then it is assumed that the communication was faulty. Therefore all older pending requests are removed.isOrSetReady
in interface InspcAccess_ifc
timeCurrent
- The current time. It is compared with the time of the last transmit telegram which's answer is expected,
and the timeout. If the timeout is expired, older requests are removed and this routine returns true.public void setReady()
isOrSetReady(long)
on time expired or if the last rx telegram was processed successfully.public void setExpectedOrder(int order, InspcAccessExecRxOrder_ifc actionOnRx)
order
- The unique order number.exec
- The execution for the answer.public void requestFields(InspcTargetAccessData data, InspcAccessExecRxOrder_ifc rxActionGetFields, java.lang.Runnable runOnReceive)
cmdGetFields(String, InspcAccessExecRxOrder_ifc)
in the inspector thread.requestFields
in interface InspcAccess_ifc
data
- The variablerxActionGetFields
- Action on gotten fieldsrunOnReceive
- Action should be run if all fields are received, if all datagrams are received for that communication cycle.InspcTelgInfoSet newTxitem()
private int cmdAccessCheck()
sPathInTarget
- The path in the target with the target specific rules.actionOnRx
- this action will be executed on receiving the item.public int cmdGetFields(java.lang.String sPathInTarget, InspcAccessExecRxOrder_ifc actionOnRx)
cmdGetFields
in interface InspcAccess_ifc
sPathInTarget
- The path in the target with the target specific rules.actionOnRx
- this action will be executed on receiving the item.public int cmdGetValueByPath(java.lang.String sPathInTarget, InspcAccessExecRxOrder_ifc actionOnRx)
cmdGetValueByPath
in interface InspcAccess_ifc
sPathInTarget
- public int cmdRegisterHandle(java.lang.String sPathInTarget, InspcAccessExecRxOrder_ifc actionOnRx)
cmdRegisterHandle
in interface InspcAccess_ifc
sPathInTarget
- public boolean cmdGetValueByHandle(int ident, InspcAccessExecRxOrder_ifc action)
cmdGetValueByHandle
in interface InspcAccess_ifc
sPathInTarget
- boolean txCmdGetValueByIdent()
final void execRx4ValueByHandle(InspcDataExchangeAccess.Inspcitem inspcitem, long time, LogMessage log, int identLog)
public void cmdSetValueByPath(java.lang.String sPathInTarget, long value, int typeofValue, InspcAccessExecRxOrder_ifc actionOnRx)
cmdSetValueByPath
in interface InspcAccess_ifc
sPathInTarget
- value
- The value as long-image, it may be a double, float, int etc.typeofValue
- The type of the value, use InspcDataExchangeAccess.kScalarTypes
+ ClassJc.REFLECTION_double
etc.@Deprecated public boolean sendAndPrepareCmdSetValueByPath(java.lang.String sPathInTarget, long value, int typeofValue, InspcAccessExecRxOrder_ifc exec)
#sendAndAwaitAnswer()
have to be called
to send at least the last request.sPathInTarget
- value
- The value as long-image, it may be a double, float, int etc.typeofValue
- The type of the value, use InspcDataExchangeAccess.kScalarTypes
+ ClassJc.REFLECTION_double
etc.exec
- The routine to execute on answer.public void cmdSetStringByPath(VariableAccessArray_ifc var, java.lang.String value)
InspcAccess_ifc
cmdSetStringByPath
in interface InspcAccess_ifc
value
- The value as long-image, it may be a double, float, int etc.public int cmdSetValueByPath(java.lang.String sPathInTarget, int value)
sPathInTarget
- value
- The value as long-image, it may be a double, float, int etc.typeofValue
- The type of the value, use InspcDataExchangeAccess.kScalarTypes
+ ClassJc.REFLECTION_double
etc.public void cmdSetInt32ByPath(java.lang.String sPathInTarget, int value, InspcAccessExecRxOrder_ifc actionOnRx)
cmdSetInt32ByPath
in interface InspcAccess_ifc
sPathInTarget
- value
- The value as int value, 32 bittypeofValue
- The type of the value, use InspcDataExchangeAccess.kScalarTypes
+ ClassJc.REFLECTION_double
etc.public void cmdSetFloatByPath(java.lang.String sPathInTarget, float value, InspcAccessExecRxOrder_ifc actionOnRx)
cmdSetFloatByPath
in interface InspcAccess_ifc
sPathInTarget
- value
- The value as long-image, it may be a double, float, int etc.typeofValue
- The type of the value, use InspcDataExchangeAccess.kScalarTypes
+ ClassJc.REFLECTION_double
etc.public void cmdSetDoubleByPath(java.lang.String sPathInTarget, double value, InspcAccessExecRxOrder_ifc actionOnRx)
cmdSetDoubleByPath
in interface InspcAccess_ifc
sPathInTarget
- value
- The value as long-image, it may be a double, float, int etc.typeofValue
- The type of the value, use InspcDataExchangeAccess.kScalarTypes
+ ClassJc.REFLECTION_double
etc.public boolean cmdGetAddressByPath(java.lang.String sPathInTarget, InspcAccessExecRxOrder_ifc actionOnRx)
cmdGetAddressByPath
in interface InspcAccess_ifc
sPathInTarget
- actionOnRx
- it will be added to a list with its order. Executed in the receive thread.public boolean cmdFinit()
public void setStateToUser(InspcPlugUser_ifc user)
public boolean isFilledTxTelg()
public boolean shouldSend()
private void completeDatagram(boolean lastTelg)
private void send()
public void evaluateRxTelg(byte[] rxBuffer, int rxLength)
bTaskPending
is set to false
and the #isReady(long)
method will return true.
#isReady(long)
returns false till the given timeout has expired.rxBuffer
- rxLength
- public void evaluateRxTelgInspcThread()
public void checkExecuteSendUserOrder()
isOrSetReady(long)
returns true. Then given addUserTxOrder(Runnable)
are invoked, which fills the tx telegram usual.
This routine is only invoked in the org.vishia.inspcPV.mng.InspcMng#procComm()
routine cyclically for any target.
It is not intent to invoke by an application.@Deprecated public InspcDataExchangeAccess.InspcDatagram[] awaitAnswer(int timeout)
InspcAccessExecRxOrder_ifc
-argument of any cmdGetValueByPath(String, InspcAccessExecRxOrder_ifc)
...
routine.timeout
- for waiting.public int checkAndRemoveOldOrders(long timeOld)
timeOld
- The time before that the orders are old.public void evaluateOneDatagram(InspcDataExchangeAccess.InspcDatagram telgHead, InspcAccessExecRxOrder_ifc executer, long time, LogMessage log, int identLog, InspcTargetAccessor.DebugTxRx dbgRx, int dbgixAnswer)
telgHead
- The telegramexecuter
- if given, than the InspcAccessExecRxOrder_ifc#execInspcRxOrder(org.vishia.communication.InspcDataExchangeAccess.Inspcitem)
-method is called for any info block.setExpectedOrder(int, InspcAccessExecRxOrder_ifc)
and that special routine is executed.public static float valueFloatFromRxValue(InspcDataExchangeAccess.Inspcitem info, int type)
public static int valueIntFromRxValue(InspcDataExchangeAccess.Inspcitem info, int type)
public static java.lang.String valueStringFromRxValue(InspcDataExchangeAccess.Inspcitem info, int nBytesString)
public static short getInspcTypeFromRxValue(InspcDataExchangeAccess.Inspcitem info)
info
- public static char getTypeFromInspcType(int type)
info
- public int getStateInfo()
void lastTelg()
callbacksOnAnswer
and executes it.public java.lang.String toString()
toString
in class java.lang.Object
public InspcTargetAccessData getTargetAccessFromPath(java.lang.String sDataPath, boolean strict)
InspcAccess_ifc
#indexTargetAccessor
to get the target accessor instance.
It uses #idxAllStruct
to get the existing InspcStruct
for the variablegetTargetAccessFromPath
in interface InspcAccess_ifc
sDataPath
- The user given data path maybe with alias, necessary with target.
An alias is written in form "alias:rest.of.path". A device is written "device:rest.of.path".
The distinction between alias and device is done with checking whether the charsequence before :
is detected as alias.strict
- true then throws an error on faulty device, if false then returns null if faulty.void stop()