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_ifc
and 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_ifc
getDouble
in interface VariableAccess_ifc
public float getFloat()
VariableAccess_ifc
getFloat
in interface VariableAccess_ifc
public java.lang.String getString()
VariableAccess_ifc
getString
in interface VariableAccess_ifc
public void setRefreshed(long time)
setRefreshed
in interface VariableAccess_ifc
public long getLastRefreshTime()
VariableAccess_ifc
getLastRefreshTime
in interface VariableAccess_ifc
public int[] getLastRefreshTimeShort()
VariableAccess_ifc
Timeshort
)
of the last refresh time if timeAbs is not available
or the necessary resolution should be finer than 1 ms.getLastRefreshTimeShort
in interface VariableAccess_ifc
public char getType()
VariableAccess_ifc
getType
in interface VariableAccess_ifc
public int getInt()
getInt
in interface VariableAccess_ifc
public long getLong()
getLong
in interface VariableAccess_ifc
public VariableAccess_ifc getVariable()
public float setFloat(float value)
setFloat(float, int...)
. The index may be stored here.setFloat
in interface VariableAccess_ifc
value
- public void setFloat(float value, int... ix)
value
- ix
- public java.lang.String setString(java.lang.String src)
VariableAccess_ifc
setString
in interface VariableAccess_ifc
src
- The value given as String.public void requestValue(long timeRequested)
VariableAccess_ifc
requestValue
in interface VariableAccess_ifc
timeRequested
- the current time, used to mark the request.public void requestValue()
VariableAccess_ifc
System.currentTimeMillis()
requestValue
in interface VariableAccess_ifc
public void requestValue(long timeRequested, java.lang.Runnable run)
VariableAccess_ifc
requestValue
in interface VariableAccess_ifc
timeRequested
- the current timerun
- method which should be invoked if the request is resolved, optional operation.public boolean isRequestedValue(long timeEarlyRequested, boolean retryFaultyVariables)
VariableAccess_ifc
isRequestedValue
in interface VariableAccess_ifc
timeEarlyRequested
- 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_ifc
isRefreshed
in interface VariableAccess_ifc
public double setDouble(double value)
VariableAccess_ifc
setDouble
in interface VariableAccess_ifc
public int setInt(int value)
VariableAccess_ifc
setInt
in interface VariableAccess_ifc
value
- The value given as int.public long setLong(long value)
VariableAccess_ifc
setLong
in interface VariableAccess_ifc
value
- The value given as int.