tuwien.auto.eicl.struct.cemi

Class EIB_Address


public class EIB_Address
extends java.lang.Object

This class represents a KNX TP1 individual or group address. Such an address consists of a 16-bit value plus one type bit (individual/group). Instances of this class are immutable. They can be created from and exported as strings, byte arrays and XML DOM nodes. Access to the value sub-fields (e.g. zone, line, device) is available as well. Both two- and three-level group addresses are supported.

Field Summary

static boolean
GROUP
static boolean
INDIVIDUAL
static String
XML_EIB_ADDRESS
The XML document node value.

Constructor Summary

EIB_Address()
Default (dummy) constructor.
EIB_Address(Node _XMLNODE)
Use this constructor to initialise an EIB_Address object from an XML node.
EIB_Address(String _AddressString)
This constructor is able to initialise the address object from its string representation.
EIB_Address(byte[] _Body, boolean _IsGroupAddress)
This constructor initializes a new EIB_Address object from the first two bytes of a byte array, plus a Boolean value for its kind.
EIB_Address(int address, boolean _IsGroupAddress)
This constructor initializes a new EIB_Address object from a raw 16-bit value.

Method Summary

short
getDevice()
Returns the device number.
byte
getLine()
Returns the line number.
byte
getMainGroup()
Returns the main group value.
byte
getMiddleGroup()
Returns the middle group value (for the three-level group address notation).
int
getRawAddress()
Returns the raw address value as an int (16 bit representation).
short
getSubGroup11()
Returns the sub group value (for the two-level group address notation).
short
getSubGroup8()
Returns the sub group value (for the three-level group address notation).
byte
getZone()
Returns the zone number.
boolean
isGroupAddress()
The returned boolean indicates whether this object is a group or individual address.
byte[]
toByteArray()
Returns the raw address value as a (new) byte array.
String
toString()
Returns the address as a string.
Node
toXML(Document doc)
This method converts the EIB address object into XML representation.

Field Details

GROUP

public static final boolean GROUP
Field Value:
true

INDIVIDUAL

public static final boolean INDIVIDUAL
Field Value:
false

XML_EIB_ADDRESS

public static final String XML_EIB_ADDRESS
The XML document node value.

Constructor Details

EIB_Address

public EIB_Address()
Default (dummy) constructor. Initializes an EIB address instance of 0.0.0 (reserved individual address).

EIB_Address

public EIB_Address(Node _XMLNODE)
            throws EICLException
Use this constructor to initialise an EIB_Address object from an XML node. The node must have exactly 2 children and must be named "eib_address".
Parameters:
_XMLNODE - the XML node
Throws:
EICLException - If the XML node has the wrong format then this exception is thrown.

EIB_Address

public EIB_Address(String _AddressString)
            throws EICLException
This constructor is able to initialise the address object from its string representation. The supported formats are:
  • zone.line.device (individual address, 4-4-8 bits)
  • main/middle/sub (3-level group address, 5-3-8 bits)
  • main/sub (2-level group address, 5-11 bits)
No range checking is performed.
Parameters:
_AddressString - the address in string representation
Throws:
EICLException - if another separator than "/" or "." is used or the number of elements (levels) is wrong

EIB_Address

public EIB_Address(byte[] _Body,
                   boolean _IsGroupAddress)
This constructor initializes a new EIB_Address object from the first two bytes of a byte array, plus a Boolean value for its kind.
Parameters:
_Body - the byte array
_IsGroupAddress - indicates whether the address object is to be an individual (false, EIB_Address.INDIVIDUAL) or group address (true, EIB_Address.GROUP).

EIB_Address

public EIB_Address(int address,
                   boolean _IsGroupAddress)
This constructor initializes a new EIB_Address object from a raw 16-bit value. Although it would be possible to pass this value as a parameter of type short, this would be cumbersome since all Java types are signed. Therefore, this parameter is passed as an int.
Parameters:
address - the raw address value
_IsGroupAddress - indicates whether the address object is to be an individual (false, EIB_Address.INDIVIDUAL) or group address (true, EIB_Address.GROUP).

Method Details

getDevice

public short getDevice()
Returns the device number.
Returns:
the line number (address low byte)

getLine

public byte getLine()
Returns the line number.
Returns:
the line number (low nibble of the address high byte)

getMainGroup

public byte getMainGroup()
Returns the main group value. This is the same for both the two- and three-level group address notations. The most significant bit is actually reserved, but is not specially handled in this class.
Returns:
the main group (5 most significant address bits)

getMiddleGroup

public byte getMiddleGroup()
Returns the middle group value (for the three-level group address notation).
Returns:
the middle group (3 least significant bits of the address high byte)

getRawAddress

public int getRawAddress()
Returns the raw address value as an int (16 bit representation).
Returns:
The address value. The address type is not included.

getSubGroup11

public short getSubGroup11()
Returns the sub group value (for the two-level group address notation).
Returns:
the sub group (11 least significant bits of the 16-bit address)

getSubGroup8

public short getSubGroup8()
Returns the sub group value (for the three-level group address notation).
Returns:
the sub group (address low byte)

getZone

public byte getZone()
Returns the zone number.
Returns:
the zone number (high nibble of the address high byte)

isGroupAddress

public boolean isGroupAddress()
The returned boolean indicates whether this object is a group or individual address.
Returns:
false if this instance is an individual address, true otherwise.

toByteArray

public byte[] toByteArray()
Returns the raw address value as a (new) byte array.
Returns:
The address value. The high byte of the address is placed at index 0. The address type is not included.

toString

public String toString()
Returns the address as a string. Depending on the address type the "." or "/" (3-level) notation is used.
Returns:
the address string

toXML

public Node toXML(Document doc)
This method converts the EIB address object into XML representation.
Parameters:
doc - a document object
Returns:
the eib_address node object