|
|||||||||
| 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.DPTXlator2ByteUnsigned
public class DPTXlator2ByteUnsigned
Translator for KNX DPTs with main number 7, type 2 byte unsigned value.
The KNX data type width is 2 bytes.
The default return value after creation is 0.
Supplied string value items 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_BRIGHTNESS
DPT ID 7.013, Brightness (Lux); values from 0 to 65535 lx. |
static DPT |
DPT_ELECTRICAL_CURRENT
DPT ID 7.012, Electrical current; values from 0 to 65535 mA. |
static DPT |
DPT_PROP_DATATYPE
DPT ID 7.010, Interface object property ID; values from 0 to 65535. |
static DPT |
DPT_TIMEPERIOD
DPT ID 7.002, Time period in ms; values from 0 to 65535 ms. |
static DPT |
DPT_TIMEPERIOD_10
DPT ID 7.003, Time period (resolution 10 ms); values from 0 to 655350 ms. |
static DPT |
DPT_TIMEPERIOD_100
DPT ID 7.004, Time period (resolution 100 ms); values from 0 to 6553500 ms. |
static DPT |
DPT_TIMEPERIOD_HOURS
DPT ID 7.007, Time period in hours; values from 0 to 65535 h (~7,4 years). |
static DPT |
DPT_TIMEPERIOD_MIN
DPT ID 7.006, Time period in minutes; values from 0 to 65535 min (~45,5 days). |
static DPT |
DPT_TIMEPERIOD_SEC
DPT ID 7.005, Time period in seconds; values from 0 to 65535 s (~18,2 hours). |
static DPT |
DPT_VALUE_2_UCOUNT
DPT ID 7.001, Unsigned count; values from 0 to 65535 pulses. |
| Fields inherited from class tuwien.auto.calimero.dptxlator.DPTXlator |
|---|
appendUnit, data, dpt, LOG_SERVICE, logger, typeSize |
| Constructor Summary | |
|---|---|
DPTXlator2ByteUnsigned(DPT dpt)
Creates a translator for the given datapoint type. |
|
DPTXlator2ByteUnsigned(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. |
int |
getValueUnsigned()
Returns the first translation item as unsigned value. |
void |
setData(byte[] data,
int offset)
Sets the data array with KNX datapoint type items for translation. |
void |
setTimePeriod(long milliseconds)
Sets the first translation item value from input of unit millisecond. |
void |
setValue(int value)
Sets the value of the first translation item. |
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_BRIGHTNESS
Note: the unit of measure symbol used here is "lx", and not "Lux" as originally proposed for this DPT.
public static final DPT DPT_ELECTRICAL_CURRENT
A value of 0 indicates no bus power supply functionality available, 1 to 65535 is the current in mA.
public static final DPT DPT_PROP_DATATYPE
public static final DPT DPT_TIMEPERIOD
public static final DPT DPT_TIMEPERIOD_10
public static final DPT DPT_TIMEPERIOD_100
public static final DPT DPT_TIMEPERIOD_HOURS
public static final DPT DPT_TIMEPERIOD_MIN
public static final DPT DPT_TIMEPERIOD_SEC
public static final DPT DPT_VALUE_2_UCOUNT
| Constructor Detail |
|---|
public DPTXlator2ByteUnsigned(DPT dpt)
throws KNXFormatException
dpt - the requested datapoint type
KNXFormatException - on not supported or not available DPT
public DPTXlator2ByteUnsigned(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()
DPTXlatorThe items are ordered the same way handed to the translator in the first place (FIFO, increasing byte index).
getAllValues in class DPTXlatorDPTXlator.getValue()
public byte[] getData(byte[] dst,
int offset)
DPTXlatordst,
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 DPTXlatordst - byte array for storing DPT valuesoffset - offset into dst from where to start, 0 <= offset
< dst.length
dstpublic 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 DPTXlatorMap, key is the subtype ID of type string, value of
type DPTprotected 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 DPTXlatorDPTXlator.getType()public final int getValueUnsigned()
A value of DPT DPT_TIMEPERIOD_10 or DPT_TIMEPERIOD_100 is
returned in unit millisecond, i.e. a KNX DPT_TIMEPERIOD_10 data value is multiplied
with 10, DPT_TIMEPERIOD_100 with 100.
On any other DPT the value is returned according to its unit.
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 DPTXlatordata - byte array containing KNX DPT item(s)offset - offset into data from where to start, 0 <= offset
< data.length
public final void setTimePeriod(long milliseconds)
throws KNXFormatException
The method is for DPTs dealing with periods of time, in particular
DPT_TIMEPERIOD, DPT_TIMEPERIOD_10, DPT_TIMEPERIOD_100
DPT_TIMEPERIOD_SEC, DPT_TIMEPERIOD_MIN and
DPT_TIMEPERIOD_HOURS. The milliseconds are converted to the unit of the
set DPT, with the result rounded to the nearest representable value (with 0.5
rounded up).
On any other DPT, the input is treated equal to setValue(int).
milliseconds - the value in milliseconds, 0 <= milliseconds
KNXFormatException - on milliseconds out of range for DPT
public final void setValue(int value)
throws KNXFormatException
A value of DPT DPT_TIMEPERIOD_10 or DPT_TIMEPERIOD_100 is
expected in unit millisecond, i.e. a value of DPT_TIMEPERIOD_10 gets divided by 10,
a value of DPT_TIMEPERIOD_100 by 100. The result is rounded to the nearest
representable value (with 0.5 rounded up). On any other DPT the value is expected
according to its unit.
value - unsigned value, 0 <= value <= max, with
DPT_TIMEPERIOD_10DPT_TIMEPERIOD_100KNXFormatException - on input value out of range for DPTDPTXlator.getType()
protected void toDPT(java.lang.String value,
short[] dst,
int index)
throws KNXFormatException
DPTXlatordst. 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 DPTXlatorvalue - 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 valuedoesn't fit into KNX data
type
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||