public class InspcVariable
extends java.lang.Object
InspcTargetAccessor
. It mirrors a variable in the target.
VariableContainer_ifc#getVariable(String)
which is provided with the InspcMng
to access an already existing
variable or create a new one mirror for a variable. The String parameter should be the access path to the target.
The access path can start with alias:...path...
: InspcMng#complete_ReplaceAlias_ifc(org.vishia.util.ReplaceAlias_ifc)
.
target:...path...
InspcMng.InspcMng(String, java.util.Map, int, boolean, org.vishia.inspcPC.InspcPlugUser_ifc)
.
requestValue()
or requestValue(long, Runnable)
to request the communication with the target.
This is done for example for graphical representation in org.vishia.gral.base.GralWidget#requestNewValueForVariable(long)
InspcMng.procComm()
routine checks all variables via #isRequestedValue(boolean)
.
That call sets an internal flag isRequested
to prevent more as one request to the target.
It sends the request to the target in the routine requestValueFromTarget(long, boolean)
either via InspcTargetAccessor.cmdGetValueByPath(String, InspcAccessExecRxOrder_ifc)
or InspcTargetAccessor.cmdGetValueByHandle(int, InspcAccessExecRxOrder_ifc)
with more variable in one datagram and all requests in up to 10 datagrams.
InspcMng.procComm()
. The answer was expected in another thread (communication thread) but the answer datagrams are stored in the
InspcTargetAccessor.TelgData
instance to evaluate in the procComm. The answer sets the timeRefreshed
.
getLastRefreshTime()
. With them it is possible
to set fields to show the value to gray if the variable was not refreshed a longer time.
getFloat()
etc. returns the stored value independently whether it was refreshed or not.
Modifier and Type | Class and Description |
---|---|
(package private) class |
InspcVariable.ActionRxByHandle
This class supplies the method to set the variable value from a received info block.
|
(package private) static class |
InspcVariable.ModeHandleVariable |
(package private) class |
InspcVariable.VariableRxAction
This class supplies the method to set the variable value from a received info block.
|
Modifier and Type | Field and Description |
---|---|
private InspcVariable.ActionRxByHandle |
actionRxByHandle |
(package private) char |
cType
The type depends from the type in the target device.
|
InspcTargetAccessData |
ds |
(package private) int |
handleTarget
If >=0 then it is the handle of the variable in the target device.
|
(package private) boolean |
isRequested
If true this variable is requested already by the
InspcMng . |
private InspcStruct |
itsStruct
It is is a structure, it maybe not null if it is requested.
|
protected static int |
kIdTargetDisabled
Special designations as value of
#idTarget |
protected static int |
kIdTargetUndefined
Special designations as value of
#idTarget |
protected static int |
kIdTargetUsePerPath
Special designations as value of
#idTarget |
(package private) InspcVariable.ModeHandleVariable |
modeTarget |
InspcVariable |
parent
The structure were this variable is member of.
|
private <any> |
runOnRecv |
(package private) InspcVariable.VariableRxAction |
rxAction |
(package private) java.lang.String |
sValueToTarget
The value of the variable was set from
VariableAccess_ifc . |
(package private) long |
timeRefreshed |
(package private) long |
timeRequested
Timestamp in milliseconds after 1970 when the variable was requested.
|
(package private) short |
typeTarget
The type information which is returned from the target by registerHandle.
|
(package private) float |
valueF
The value from the target device.
|
(package private) int |
valueI
The value from the target device.
|
(package private) java.lang.String |
valueS
The value from the target device.
|
(package private) InspcMng |
varMng |
static int |
version
Version, history and license.
|
Constructor and Description |
---|
InspcVariable(InspcMng mng,
InspcVariable parent,
InspcTargetAccessData data)
Creates a variable.
|
Modifier and Type | Method and Description |
---|---|
int |
getDimension(int dimension) |
double |
getDouble() |
double |
getDouble(int... ixArray) |
float |
getFloat() |
float |
getFloat(int... ixArray) |
int |
getInt() |
int |
getInt(int... ixArray) |
long |
getLastRefreshTime() |
long |
getLong() |
long |
getLong(int... ixArray) |
InspcStruct |
getOrCreateStructForNonLeafVariables()
Creates an
InspcStruct if it is not created till now, returns it. |
java.lang.String |
getString() |
java.lang.String |
getString(int... ixArray) |
InspcStruct |
getStruct()
Gets the struct for a node (non leafe variable).
|
char |
getType() |
boolean |
isRefreshed() |
boolean |
isRequestedValue(long timeEarlyRequested,
boolean retryFaultyVariables) |
void |
requestValue()
Request with the current time.
|
void |
requestValue(long time) |
void |
requestValue(long time,
java.lang.Runnable run) |
(package private) boolean |
requestValueFromTarget(long timeCurrent,
boolean retryDisabledVariable)
Notes the request for this variable in the request telegram to the target.
|
double |
setDouble(double value) |
double |
setDouble(double value,
int... ixArray) |
float |
setFloat(float value) |
float |
setFloat(float value,
int... ixArray) |
int |
setInt(int value) |
int |
setInt(int value,
int... ixArray) |
long |
setLong(long value) |
long |
setLong(long value,
int... ixArray) |
void |
setRefreshed(long time) |
java.lang.String |
setString(java.lang.String value) |
java.lang.String |
setString(java.lang.String value,
int... ixArray) |
private void |
setValueFormAnswerTelgByHandle(InspcDataExchangeAccess.Inspcitem accAnswerItem,
long time) |
java.lang.String |
toString() |
public static final int version
isRequested
to prevent request twice, in experience.
sValueToTarget
is set on setString(String)
. Then the new content
is sent to target to change it there. It is done in the requestValueFromTarget(long, boolean)
because this routine is called if the field is shown. Only if it is shown the change can be done.
itsStruct
InspcVariable.VariableRxAction
: Answer from target with info.cmd = InspcDataExchangeAccess.Inspcitem#kFailedPath
disables this variable from data communication. TODO enable with user action if the target was changed (recompiled, restarted etc).
InspcVariable.VariableRxAction
: Answer from target with variable type designation = InspcDataExchangeAccess.kInvalidHandle
The requester should remove that index. Then a new InspcTargetAccessor.cmdRegisterHandle(String, InspcAccessExecRxOrder_ifc)
is forced to get a valid index.
#requestValueFromTarget(long)
: If the path starts with '#', it is not requested.
#requestValueFromTarget(long)
because
the telegram is full, the same variable should be requested repeatedly in the next telegram. It was forgotten.
getLong(int...)
and setLong(long, int...)
not implemented, only formal
requestValue(long)
etc. from VariableAccess_ifc
.
InspcMng.version
.
final InspcMng varMng
private final InspcVariable.ActionRxByHandle actionRxByHandle
public final InspcVariable parent
final InspcVariable.VariableRxAction rxAction
public final InspcTargetAccessData ds
private InspcStruct itsStruct
getOrCreateStructForNonLeafVariables()
. It creates.protected static final int kIdTargetUndefined
#idTarget
protected static final int kIdTargetDisabled
#idTarget
protected static final int kIdTargetUsePerPath
#idTarget
InspcVariable.ModeHandleVariable modeTarget
int handleTarget
kIdTargetDisabled
etc.
The the value can be gotten calling getValueByHandle().short typeTarget
long timeRequested
boolean isRequested
InspcMng
. The answer should be awaited.long timeRefreshed
private final <any> runOnRecv
float valueF
int valueI
java.lang.String valueS
char cType
java.lang.String sValueToTarget
VariableAccess_ifc
. It means it should be sent to target.InspcVariable(InspcMng mng, InspcVariable parent, InspcTargetAccessData data)
mng
- sPathInTarget
- The access path.boolean requestValueFromTarget(long timeCurrent, boolean retryDisabledVariable)
retryDisabledVariable
- true then retry a disabled variable, see kIdTargetDisabled
public double getDouble()
public float getFloat()
public int getInt()
public long getLong()
public java.lang.String getString()
public double setDouble(double value)
public float setFloat(float value)
public int setInt(int value)
public long setLong(long value)
public java.lang.String setString(java.lang.String value)
public char getType()
public InspcStruct getOrCreateStructForNonLeafVariables()
InspcStruct
if it is not created till now, returns it.
This method should only be called for variable which are not leaf variables in the target device.
If it is created for a leaf variable, the filling of the struct fails so that the structure has no fields.public InspcStruct getStruct()
getOrCreateStructForNonLeafVariables()
.public void setRefreshed(long time)
public long getLastRefreshTime()
public void requestValue()
public void requestValue(long time)
public void requestValue(long time, java.lang.Runnable run)
public boolean isRequestedValue(long timeEarlyRequested, boolean retryFaultyVariables)
public boolean isRefreshed()
public java.lang.String toString()
toString
in class java.lang.Object
public int getInt(int... ixArray)
public int setInt(int value, int... ixArray)
public long getLong(int... ixArray)
public long setLong(long value, int... ixArray)
public float getFloat(int... ixArray)
public float setFloat(float value, int... ixArray)
public double getDouble(int... ixArray)
public double setDouble(double value, int... ixArray)
public java.lang.String getString(int... ixArray)
public java.lang.String setString(java.lang.String value, int... ixArray)
public int getDimension(int dimension)
private void setValueFormAnswerTelgByHandle(InspcDataExchangeAccess.Inspcitem accAnswerItem, long time)