|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttuwien.auto.calimero.dptxlator.DPTXlator
tuwien.auto.calimero.dptxlator.DPTXlator8BitUnsigned
public class DPTXlator8BitUnsigned
Translator for KNX DPTs with main number 5, type 8 Bit unsigned value.
The KNX data type width is 1 byte.
The default return value after creation is 0.
Note, that DPT_SCALING
and DPT_ANGLE
are scaled representations,
which means the DPT's value ranges [0..100] respectively [0..360] are mapped to the 8
Bit KNX value range [0..255], with mapped values rounded to the next nearest integer
value.
In value methods expecting string items, the item might be formatted using decimal, hexadecimal, and octal numbers, distinguished by using these prefixes:
0x
, 0X
or #
for hexadecimal
0
for octal numeral
Field Summary | |
---|---|
static DPT |
DPT_ANGLE
DPT ID 5.003, Angle; values from 0 to 360 ° (degree). |
static DPT |
DPT_DECIMALFACTOR
DPT ID 5.005, Decimal factor; values from 0 to 255 ratio. |
static DPT |
DPT_PERCENT_U8
DPT ID 5.004, Percent 8 Bit; values from 0 to 255 %. |
static DPT |
DPT_SCALING
DPT ID 5.001, Scaling; values from 0 to 100 %. |
static DPT |
DPT_VALUE_1_UCOUNT
DPT ID 5.010, Value 1 unsigned count; values from 0 to 255 counter pulses. |
Fields inherited from class tuwien.auto.calimero.dptxlator.DPTXlator |
---|
appendUnit, data, dpt, LOG_SERVICE, logger, typeSize |
Constructor Summary | |
---|---|
DPTXlator8BitUnsigned(DPT dpt)
Creates a translator for the given datapoint type. |
|
DPTXlator8BitUnsigned(java.lang.String dptID)
Creates a translator for the given datapoint type ID. |
Method Summary | |
---|---|
java.lang.String[] |
getAllValues()
Returns all translation items as strings currently contained in this translator. |
byte[] |
getData(byte[] dst,
int offset)
Copies KNX DPT value items stored by this translator into dst ,
starting at offset . |
java.util.Map |
getSubTypes()
Returns all available, implemented subtypes for the translator. |
protected static java.util.Map |
getSubTypesStatic()
|
java.lang.String |
getValue()
Returns the first value stored by this translator formatted into a string, according to the subtype ID. |
short |
getValueUnscaled()
Returns the first translation item without any scaling. |
short |
getValueUnsigned()
Returns the first translation item, the value scaled conforming to the range of the set DPT. |
void |
setData(byte[] data,
int offset)
Sets the data array with KNX datapoint type items for translation. |
void |
setValue(int scaled)
Sets one new translation item from a scaled unsigned value, replacing any old items. |
void |
setValueUnscaled(int unscaled)
Sets one new translation item from an unsigned unscaled value, replacing any old items. |
protected void |
toDPT(java.lang.String value,
short[] dst,
int index)
Translates a string value representation into KNX data type according the current DPT and stores the result into dst . |
Methods inherited from class tuwien.auto.calimero.dptxlator.DPTXlator |
---|
getData, getItems, getType, getTypeSize, setAppendUnit, setData, setTypeID, setValue, setValues, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final DPT DPT_ANGLE
public static final DPT DPT_DECIMALFACTOR
This is a preliminary datapoint type, still in state "to be defined".
public static final DPT DPT_PERCENT_U8
public static final DPT DPT_SCALING
public static final DPT DPT_VALUE_1_UCOUNT
Constructor Detail |
---|
public DPTXlator8BitUnsigned(DPT dpt) throws KNXFormatException
dpt
- the requested datapoint type
KNXFormatException
- on not supported or not available DPTpublic DPTXlator8BitUnsigned(java.lang.String dptID) throws KNXFormatException
dptID
- available implemented datapoint type ID
KNXFormatException
- on wrong formatted or not expected (available)
dptID
Method Detail |
---|
public java.lang.String[] getAllValues()
DPTXlator
The items are ordered the same way handed to the translator in the first place (FIFO, increasing byte index).
getAllValues
in class DPTXlator
DPTXlator.getValue()
public byte[] getData(byte[] dst, int offset)
DPTXlator
dst
,
starting at offset
.
The number of items copied depends on the usable dst
range, i.e. how
much items completely fit into dst.length - offset
. If the usable
range is too short, no item is copied at all, and dst
is not
modified.
Datapoint types shorter than 1 bytes only change the affected lower bit positions,
leaving the upper (high) bits of dst
bytes untouched.
getData
in class DPTXlator
dst
- byte array for storing DPT valuesoffset
- offset into dst
from where to start, 0 <= offset
< dst.length
dst
public final java.util.Map getSubTypes()
DPTXlator
A subtype, identified through a sub number, specifies the available dimension,
consisting of range and unit attributes. Together with the main type information
this uniquely defines a datapoint type.
The datapoint type information is contained in a DPT
object.
New or modified DPT information can be made available to the translator by adding
entries to the map, likewise map entries might be removed. In other words, the map
returned is the same used by the translators of one main type for DPT lookup.
Changes to the map influence all translators of the same main type.
Changes of the DPT currently used by the translator take effect on the next new
translator created using that DPT.
The map itself is not synchronized.
getSubTypes
in class DPTXlator
Map
, key is the subtype ID of type string, value of
type DPT
protected static java.util.Map getSubTypesStatic()
DPTXlator.getSubTypesStatic()
public java.lang.String getValue()
DPTXlator
If the subtype has a unit of measurement, it is appended after the value according
to DPTXlator.setAppendUnit(boolean)
.
getValue
in class DPTXlator
DPTXlator.getType()
public final short getValueUnscaled()
The returned value is the raw KNX data value (0..255), not adjusted to the value range of the set DPT.
public final short getValueUnsigned()
DPTXlator.getType()
public void setData(byte[] data, int offset)
DPTXlator
The data
array contains at least one DPT item, the new item(s) will
replace any other items set in the translator before.
The number of items (KNX data values) for translation in data
is
inferred from the length of the usable data
range:
items = (data.length - offset) / (length of KNX data type)
In general, the KNX data type width is implicitly known in the context where a
translator is invoked (e.g. by appropriate DP configuration), therefore
data.length
will satisfy the minimum acceptable length. If this is
not the case, KNXIllegalArgumentException
has to be caught and handled in
the caller's context.
setData
in class DPTXlator
data
- byte array containing KNX DPT item(s)offset
- offset into data
from where to start, 0 <= offset
< data.length
public final void setValue(int scaled) throws KNXFormatException
The scale of the input value is according to the current DPT.
scaled
- scaled unsigned value, the dimension is determined by the set DPT, 0
<= scaled value <= defined maximum of DPT
KNXFormatException
- on wrong scaled value, if input doesn't conform to
subtype dimensionDPTXlator.getType()
public final void setValueUnscaled(int unscaled)
No scaling is performed during translation, the value is equal to the raw KNX data.
unscaled
- unscaled unsigned value, 0 <= unscaled
<= 255,
the higher bytes are ignoredprotected void toDPT(java.lang.String value, short[] dst, int index) throws KNXFormatException
DPTXlator
dst
. The index parameter specifies
the item index of the value. The translated KNX data is stored at the corresponding
array offset in dst
. Calculation of offset:
offset = index * KNX data type size
.
toDPT
in class DPTXlator
value
- value to translatedst
- destination array for resulting KNX dataindex
- item index in destination array
KNXFormatException
- if value
can't be translated due to wrong
formatted content, or if value
doesn't fit into KNX data
type
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |