tuwien.auto.calimero.dptxlator
Class DPTXlatorBoolean

java.lang.Object
  extended by tuwien.auto.calimero.dptxlator.DPTXlator
      extended by tuwien.auto.calimero.dptxlator.DPTXlatorBoolean

public class DPTXlatorBoolean
extends DPTXlator

Translator for KNX DPTs with main number 1, type Boolean.

The KNX data type width is the lowest bit of 1 byte.
The default return value after creation is 0, i.e. false for DPT Boolean for example.


Field Summary
static DPT DPT_ACK
          DPT ID 1.016, Acknowledge; values no action (dummy), acknowledge (trigger).
static DPT DPT_ALARM
          DPT ID 1.005, Alarm; values no alarm, alarm.
static DPT DPT_BINARYVALUE
          DPT ID 1.006, Binary value; values low, high.
static DPT DPT_BOOL
          DPT ID 1.002, Boolean; values false, true.
static DPT DPT_DIMSENDSTYLE
          DPT ID 1.013, DimSendStyle; values start/stop, cyclic.
static DPT DPT_ENABLE
          DPT ID 1.003, Enable; values enable, disable.
static DPT DPT_INPUTSOURCE
          DPT ID 1.014, Input source; values fixed, calculated.
static DPT DPT_INVERT
          DPT ID 1.012, Invert; values not inverted, inverted.
static DPT DPT_LOGICAL_FUNCTION
          DPT ID 1.021, Logical function; values OR, AND.
static DPT DPT_OCCUPANCY
          DPT ID 1.018, Occupancy; values not occupied, occupied.
static DPT DPT_OPENCLOSE
          DPT ID 1.009, Open/Close; values open, close.
static DPT DPT_RAMP
          DPT ID 1.004, Ramp; values no ramp, ramp.
static DPT DPT_RESET
          DPT ID 1.015, Reset; values no action (dummy), reset (trigger).
static DPT DPT_SCENE_AB
          DPT ID 1.022, Scene A/B; values scene A, scene B.
static DPT DPT_SHUTTER_BLINDS_MODE
          DPT ID 1.023, Shutter/Blinds mode; values only move up/down mode (shutter), move up/down + step-stop mode (blind).
static DPT DPT_START
          DPT ID 1.010, Start; values stop, start.
static DPT DPT_STATE
          DPT ID 1.011, State; values inactive, active.
static DPT DPT_STEP
          DPT ID 1.007, Step; values decrease, increase.
static DPT DPT_SWITCH
          DPT ID 1.001, Switch; values off, on.
static DPT DPT_TRIGGER
          DPT ID 1.017, Trigger; values trigger, trigger.
static DPT DPT_UPDOWN
          DPT ID 1.008, Up/Down; values up, down.
static DPT DPT_WINDOW_DOOR
          DPT ID 1.019, Window/Door; values closed, open.
 
Fields inherited from class tuwien.auto.calimero.dptxlator.DPTXlator
appendUnit, data, dpt, LOG_SERVICE, logger, typeSize
 
Constructor Summary
DPTXlatorBoolean(DPT dpt)
          Creates a translator for the given datapoint type.
DPTXlatorBoolean(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.
 boolean getValueBoolean()
          Returns the first translation item formatted as boolean.
 void setData(byte[] data, int offset)
          Sets the data array with KNX datapoint type items for translation.
 void setValue(boolean value)
          Sets the translation value from a boolean.
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

DPT_ACK

public static final DPT DPT_ACK
DPT ID 1.016, Acknowledge; values no action (dummy), acknowledge (trigger).


DPT_ALARM

public static final DPT DPT_ALARM
DPT ID 1.005, Alarm; values no alarm, alarm.


DPT_BINARYVALUE

public static final DPT DPT_BINARYVALUE
DPT ID 1.006, Binary value; values low, high.


DPT_BOOL

public static final DPT DPT_BOOL
DPT ID 1.002, Boolean; values false, true.


DPT_DIMSENDSTYLE

public static final DPT DPT_DIMSENDSTYLE
DPT ID 1.013, DimSendStyle; values start/stop, cyclic.


DPT_ENABLE

public static final DPT DPT_ENABLE
DPT ID 1.003, Enable; values enable, disable.


DPT_INPUTSOURCE

public static final DPT DPT_INPUTSOURCE
DPT ID 1.014, Input source; values fixed, calculated.


DPT_INVERT

public static final DPT DPT_INVERT
DPT ID 1.012, Invert; values not inverted, inverted.


DPT_LOGICAL_FUNCTION

public static final DPT DPT_LOGICAL_FUNCTION
DPT ID 1.021, Logical function; values OR, AND.


DPT_OCCUPANCY

public static final DPT DPT_OCCUPANCY
DPT ID 1.018, Occupancy; values not occupied, occupied.


DPT_OPENCLOSE

public static final DPT DPT_OPENCLOSE
DPT ID 1.009, Open/Close; values open, close.


DPT_RAMP

public static final DPT DPT_RAMP
DPT ID 1.004, Ramp; values no ramp, ramp.


DPT_RESET

public static final DPT DPT_RESET
DPT ID 1.015, Reset; values no action (dummy), reset (trigger).


DPT_SCENE_AB

public static final DPT DPT_SCENE_AB
DPT ID 1.022, Scene A/B; values scene A, scene B.

Note, when displaying scene numbers, scene A is equal to number 1, scene B to number 2.


DPT_SHUTTER_BLINDS_MODE

public static final DPT DPT_SHUTTER_BLINDS_MODE
DPT ID 1.023, Shutter/Blinds mode; values only move up/down mode (shutter), move up/down + step-stop mode (blind).


DPT_START

public static final DPT DPT_START
DPT ID 1.010, Start; values stop, start.


DPT_STATE

public static final DPT DPT_STATE
DPT ID 1.011, State; values inactive, active.


DPT_STEP

public static final DPT DPT_STEP
DPT ID 1.007, Step; values decrease, increase.


DPT_SWITCH

public static final DPT DPT_SWITCH
DPT ID 1.001, Switch; values off, on.


DPT_TRIGGER

public static final DPT DPT_TRIGGER
DPT ID 1.017, Trigger; values trigger, trigger.


DPT_UPDOWN

public static final DPT DPT_UPDOWN
DPT ID 1.008, Up/Down; values up, down.


DPT_WINDOW_DOOR

public static final DPT DPT_WINDOW_DOOR
DPT ID 1.019, Window/Door; values closed, open.

Constructor Detail

DPTXlatorBoolean

public DPTXlatorBoolean(DPT dpt)
                 throws KNXFormatException
Creates a translator for the given datapoint type.

Parameters:
dpt - the requested datapoint type
Throws:
KNXFormatException - on not supported or not available DPT

DPTXlatorBoolean

public DPTXlatorBoolean(java.lang.String dptID)
                 throws KNXFormatException
Creates a translator for the given datapoint type ID.

Parameters:
dptID - available implemented datapoint type ID
Throws:
KNXFormatException - on wrong formatted or not expected (available) dptID
Method Detail

getAllValues

public java.lang.String[] getAllValues()
Description copied from class: DPTXlator
Returns all translation items as strings currently contained in this translator.

The items are ordered the same way handed to the translator in the first place (FIFO, increasing byte index).

Specified by:
getAllValues in class DPTXlator
Returns:
an array of strings with values represented as strings
See Also:
DPTXlator.getValue()

getData

public byte[] getData(byte[] dst,
                      int offset)
Description copied from class: DPTXlator
Copies KNX DPT value items stored by this translator into 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.

Specified by:
getData in class DPTXlator
Parameters:
dst - byte array for storing DPT values
offset - offset into dst from where to start, 0 <= offset < dst.length
Returns:
dst

getSubTypes

public final java.util.Map getSubTypes()
Description copied from class: DPTXlator
Returns all available, implemented subtypes for the translator.

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.

Specified by:
getSubTypes in class DPTXlator
Returns:
subtypes as Map, key is the subtype ID of type string, value of type DPT

getSubTypesStatic

protected static java.util.Map getSubTypesStatic()
Returns:
the subtypes of the boolean translator type
See Also:
DPTXlator.getSubTypesStatic()

getValue

public java.lang.String getValue()
Description copied from class: DPTXlator
Returns the first value stored by this translator formatted into a string, according to the subtype ID.

If the subtype has a unit of measurement, it is appended after the value according to DPTXlator.setAppendUnit(boolean).

Overrides:
getValue in class DPTXlator
Returns:
a string representation of the value
See Also:
DPTXlator.getType()

getValueBoolean

public final boolean getValueBoolean()
Returns the first translation item formatted as boolean.

Returns:
boolean representation

setData

public void setData(byte[] data,
                    int offset)
Description copied from class: DPTXlator
Sets the data array with KNX datapoint type items for translation.

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.

Specified by:
setData in class DPTXlator
Parameters:
data - byte array containing KNX DPT item(s)
offset - offset into data from where to start, 0 <= offset < data.length

setValue

public final void setValue(boolean value)
Sets the translation value from a boolean.

Any other items in the translator are discarded.

Parameters:
value - the boolean value

toDPT

protected void toDPT(java.lang.String value,
                     short[] dst,
                     int index)
              throws KNXFormatException
Description copied from class: DPTXlator
Translates a string value representation into KNX data type according the current DPT and stores the result into 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.

Specified by:
toDPT in class DPTXlator
Parameters:
value - value to translate
dst - destination array for resulting KNX data
index - item index in destination array
Throws:
KNXFormatException - if value can't be translated due to wrong formatted content, or if valuedoesn't fit into KNX data type