public class VariableAccessWithIdx extends java.lang.Object implements VariableAccess_ifc
| Modifier and Type | Field and Description |
|---|---|
protected int |
bit
The position of the last significant bit if the value of the variable is placed in some bits
or specially in only one bit, a boolean value. 0 per default.
|
protected int[] |
ixArray
Array of indices to access if the variable has more as one dimension.
|
protected int |
mask
The mask to access to some bits.
|
protected VariableAccessArray_ifc |
variable
The entity of a variable.
|
static int |
version
Version, history and license
2012-09-24 Hartmut new
#getLong(int...) |
| Constructor and Description |
|---|
VariableAccessWithIdx(VariableAccessArray_ifc variable) |
VariableAccessWithIdx(VariableAccessArray_ifc variable,
int[] idx) |
VariableAccessWithIdx(VariableAccessArray_ifc variable,
int[] idx,
int bit,
int mask) |
VariableAccessWithIdx(VariableAccessArray_ifc variable,
int bit,
int mask) |
| Modifier and Type | Method and Description |
|---|---|
double |
getDouble()
Gets the value from this variable.
|
float |
getFloat()
Gets the value from this variable.
|
int |
getInt()
Returns the integer representation of the value of the variable.
|
long |
getLastRefreshTime()
Gets the time stamp when this variable was refreshed lastly.
|
int[] |
getLastRefreshTimeShort()
Returns a pair of timeShort and timeShortAdd (see
Timeshort)
of the last refresh time if timeAbs is not available
or the necessary resolution should be finer than 1 ms. |
long |
getLong()
Returns the integer representation of the value of the variable.
|
java.lang.String |
getString()
Gets the value from this variable.
|
char |
getType()
Returns the type of the variable:
|
VariableAccess_ifc |
getVariable() |
boolean |
isRefreshed()
Returns true if the variable was refreshed after it was requested.
|
boolean |
isRequestedValue(long timeEarlyRequested,
boolean retryFaultyVariables)
Returns true if the request is newer than the last refresh.
|
void |
requestValue()
Requests a new value from the target device with the
System.currentTimeMillis() |
void |
requestValue(long timeRequested)
Requests a new value from the target device.
|
void |
requestValue(long timeRequested,
java.lang.Runnable run)
Requests a new value from the target device.
|
double |
setDouble(double value)
Sets the value from this variable.
|
float |
setFloat(float value)
Sets a float to the variable.
|
void |
setFloat(float value,
int... ix)
Sets a value to the variable which is an array variable.
|
int |
setInt(int value)
Sets the value into the variable.
|
long |
setLong(long value)
Sets the value into the variable.
|
void |
setRefreshed(long time) |
java.lang.String |
setString(java.lang.String src)
Sets the value into the variable
|
public static final int version
#getLong(int...)
setFloat(float, int...) Access a variable with an index
if this describes the non-indexed variable. It is only implmented yet for the setFloat. TODO: for all others too.
org.vishia.gral.base.GralWidget
has accessed a variable via VariableAccess_ifcand the necessary index #idx for an arry variable
was contained in the GralWidget. Secondary the possibility of mask of some bits was impossible.
The access to a array or bitfield variable is not a problem of the widget in a GUI,
it is a problem of access to the variable. Therefore this class was created.
VariableAccess_ifc should not contain this details of access
A variable accessed via VariableAccess_ifc is an entity of access to a whole data element.
This class controls the access to details of a variable.
protected final VariableAccessArray_ifc variable
protected final int[] ixArray
protected final int mask
protected final int bit
public VariableAccessWithIdx(VariableAccessArray_ifc variable, int[] idx, int bit, int mask)
public VariableAccessWithIdx(VariableAccessArray_ifc variable, int[] idx)
public VariableAccessWithIdx(VariableAccessArray_ifc variable)
public VariableAccessWithIdx(VariableAccessArray_ifc variable, int bit, int mask)
public double getDouble()
VariableAccess_ifcgetDouble in interface VariableAccess_ifcpublic float getFloat()
VariableAccess_ifcgetFloat in interface VariableAccess_ifcpublic java.lang.String getString()
VariableAccess_ifcgetString in interface VariableAccess_ifcpublic void setRefreshed(long time)
setRefreshed in interface VariableAccess_ifcpublic long getLastRefreshTime()
VariableAccess_ifcgetLastRefreshTime in interface VariableAccess_ifcpublic int[] getLastRefreshTimeShort()
VariableAccess_ifcTimeshort)
of the last refresh time if timeAbs is not available
or the necessary resolution should be finer than 1 ms.getLastRefreshTimeShort in interface VariableAccess_ifcpublic char getType()
VariableAccess_ifcgetType in interface VariableAccess_ifcpublic int getInt()
getInt in interface VariableAccess_ifcpublic long getLong()
getLong in interface VariableAccess_ifcpublic VariableAccess_ifc getVariable()
public float setFloat(float value)
setFloat(float, int...). The index may be stored here.setFloat in interface VariableAccess_ifcvalue - public void setFloat(float value,
int... ix)
value - ix - public java.lang.String setString(java.lang.String src)
VariableAccess_ifcsetString in interface VariableAccess_ifcsrc - The value given as String.public void requestValue(long timeRequested)
VariableAccess_ifcrequestValue in interface VariableAccess_ifctimeRequested - the current time, used to mark the request.public void requestValue()
VariableAccess_ifcSystem.currentTimeMillis()requestValue in interface VariableAccess_ifcpublic void requestValue(long timeRequested,
java.lang.Runnable run)
VariableAccess_ifcrequestValue in interface VariableAccess_ifctimeRequested - the current timerun - method which should be invoked if the request is resolved, optional operation.public boolean isRequestedValue(long timeEarlyRequested,
boolean retryFaultyVariables)
VariableAccess_ifcisRequestedValue in interface VariableAccess_ifctimeEarlyRequested - The earliest time where the variable is requested. If the request time is more early, it is not regarded.
This is since 2016-01. An old request should be ignored but the time stamp of the request should be visible for debug or view the state.retryFaultyVariables - A variable which is set to invalid is requested though.public boolean isRefreshed()
VariableAccess_ifcisRefreshed in interface VariableAccess_ifcpublic double setDouble(double value)
VariableAccess_ifcsetDouble in interface VariableAccess_ifcpublic int setInt(int value)
VariableAccess_ifcsetInt in interface VariableAccess_ifcvalue - The value given as int.public long setLong(long value)
VariableAccess_ifcsetLong in interface VariableAccess_ifcvalue - The value given as int.