|
|||||||||
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.DPTXlatorDate
public class DPTXlatorDate
Translator for KNX DPTs with main number 11, type date.
The KNX data type width is 3 bytes.
The type contains the date information year, month, and day of month.
Where required in time calculation, the used calendar is based on the current time in
the default time zone with the default locale. All time information behaves in
non-lenient mode, i.e. no value overflow is allowed and values are not normalized or
adjusted using the next, larger field.
The default return value after creation is 2000-01-01
.
Field Summary | |
---|---|
static DPT |
DPT_DATE
DPT ID 11.001, Date; values from 1990-01-01 to 2089-12-31. |
Fields inherited from class tuwien.auto.calimero.dptxlator.DPTXlator |
---|
appendUnit, data, dpt, LOG_SERVICE, logger, typeSize |
Constructor Summary | |
---|---|
DPTXlatorDate(DPT dpt)
Creates a translator for the given datapoint type. |
|
DPTXlatorDate(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 . |
byte |
getDay()
Returns the day information. |
byte |
getMonth()
Returns the month information. |
java.util.Map |
getSubTypes()
Returns all available, implemented subtypes for the translator. |
protected static java.util.Map |
getSubTypesStatic()
|
long |
getValueMilliseconds()
Returns the date information in UTC milliseconds, using the translator default calendar. |
short |
getYear()
Returns the year information. |
void |
setData(byte[] data,
int offset)
Sets the data array with KNX datapoint type items for translation. |
void |
setValue(int year,
int month,
int day)
Sets the year, month, and day of month for the first date item. |
void |
setValue(long milliseconds)
Sets the date for the first item using UTC millisecond information. |
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 . |
static void |
useValueFormat(java.lang.String pattern)
Sets a user defined date value format used by all instances of this class. |
Methods inherited from class tuwien.auto.calimero.dptxlator.DPTXlator |
---|
getData, getItems, getType, getTypeSize, getValue, 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_DATE
Constructor Detail |
---|
public DPTXlatorDate(DPT dpt) throws KNXFormatException
dpt
- the requested datapoint type
KNXFormatException
- on not supported or not available DPTpublic DPTXlatorDate(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 byte getDay()
public final byte getMonth()
public 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 final long getValueMilliseconds() throws KNXFormatException
The method uses year, month and day information for calculation. Any finer time
granularity defaults to 0.
Calendar
KNXFormatException
- on invalid calendar datepublic final short getYear()
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 year, int month, int day)
Any other items in the translator are discarded on successful set.
year
- year value, 1990 <= year <= 2089month
- month value, 1 <= month <= 12day
- day value, 1 <= day <= 31public final void setValue(long milliseconds)
The milliseconds
is interpreted with the translator default
calendar.
milliseconds
- time value in milliseconds, as used in Calendar
protected 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
typepublic static final void useValueFormat(java.lang.String pattern)
The pattern is specified according to SimpleDateFormat
. Subsequent date
information, supplied and returned in textual representation, will use a layout
formatted according this pattern.
Note, the format will rely on calendar default time symbols (i.e. language for
example).
If requesting a textual date representation, and using this value format leads to
errors due to an invalid calendar date, a short error message string will be
returned.
pattern
- the new pattern specifying the value date format, null
to reset to default value format
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |