tuwien.auto.calimero.cemi
Class CEMIDevMgmt

java.lang.Object
  extended by tuwien.auto.calimero.cemi.CEMIDevMgmt
All Implemented Interfaces:
CEMI

public class CEMIDevMgmt
extends java.lang.Object
implements CEMI

A cEMI device management message.

Function properties are not supported for the time being.

Objects of this type are immutable.


Field Summary
static short MC_PROPINFO_IND
          Message code for property info indication, code = 247.
static short MC_PROPREAD_CON
          Message code for property read confirmation, code = 251.
static short MC_PROPREAD_REQ
          Message code for property read request, code = 252.
static short MC_PROPWRITE_CON
          Message code for property write confirmation, code = 245.
static short MC_PROPWRITE_REQ
          Message code for property write request, code = 246.
static short MC_RESET_IND
          Message code for property reset indication, code = 240.
static short MC_RESET_REQ
          Message code for property reset request, code = 241.
 
Constructor Summary
CEMIDevMgmt(byte[] data, int offset, int length)
          Creates a new device management message from a byte stream.
CEMIDevMgmt(int msgCode)
          Creates a new device management message with the given message code.
CEMIDevMgmt(int msgCode, int objType, int objInstance, int propID, int startIndex, int elements)
          Creates a new device management message.
CEMIDevMgmt(int msgCode, int objType, int objInstance, int propID, int startIndex, int elements, byte[] data)
          Creates a new device management message.
 
Method Summary
 byte getElementCount()
          Returns the number of elements field from the message.
 java.lang.String getErrorMessage()
          Returns a descriptive error message on a negative response, as determined by isNegativeResponse().
 short getMessageCode()
          Returns the cEMI message code.
 short getObjectInstance()
          Returns the object instance field from the message.
 int getObjectType()
          Returns the interface object type.
 byte[] getPayload()
          Returns the data part, i.e. the property data or error information following the start index in the message structure.
 short getPID()
          Returns the property identifier used in the message.
 short getStartIndex()
          Returns the start index in the data array of the property.
 short getStructLength()
          Returns the length of this cEMI message frame.
 boolean isNegativeResponse()
          Returns if the message contains a negative response.
 byte[] toByteArray()
          Returns the byte representation of the whole cEMI message structure.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MC_PROPINFO_IND

public static final short MC_PROPINFO_IND
Message code for property info indication, code = 247.

See Also:
Constant Field Values

MC_PROPREAD_CON

public static final short MC_PROPREAD_CON
Message code for property read confirmation, code = 251.

See Also:
Constant Field Values

MC_PROPREAD_REQ

public static final short MC_PROPREAD_REQ
Message code for property read request, code = 252.

See Also:
Constant Field Values

MC_PROPWRITE_CON

public static final short MC_PROPWRITE_CON
Message code for property write confirmation, code = 245.

See Also:
Constant Field Values

MC_PROPWRITE_REQ

public static final short MC_PROPWRITE_REQ
Message code for property write request, code = 246.

See Also:
Constant Field Values

MC_RESET_IND

public static final short MC_RESET_IND
Message code for property reset indication, code = 240.

See Also:
Constant Field Values

MC_RESET_REQ

public static final short MC_RESET_REQ
Message code for property reset request, code = 241.

See Also:
Constant Field Values
Constructor Detail

CEMIDevMgmt

public CEMIDevMgmt(byte[] data,
                   int offset,
                   int length)
            throws KNXFormatException
Creates a new device management message from a byte stream.

Parameters:
data - byte stream containing a cEMI device management message
offset - start offset of cEMI frame in data
length - length in bytes of the whole device management message
Throws:
KNXFormatException - if no device management frame found or invalid frame structure

CEMIDevMgmt

public CEMIDevMgmt(int msgCode)
Creates a new device management message with the given message code.

The message structure (and resulting frame) will only consist of the message code field. All other device management methods are not used (and will consequently return 0 or empty fields by default).

Used for reset messages.

Parameters:
msgCode - a message code value specified by this class

CEMIDevMgmt

public CEMIDevMgmt(int msgCode,
                   int objType,
                   int objInstance,
                   int propID,
                   int startIndex,
                   int elements)
Creates a new device management message.

Used for messages without a data (or error information) part in the message structure (like read request).

Parameters:
msgCode - a message code constant declared by this class
objType - interface object type, value in the range 0 <= value <= 0xFFFF
objInstance - object instance, value in the range 1 <= value <= 0xFF
propID - property identifier (PID), in the range 0 <= PID <= 0xFF
startIndex - start index into the property array, first element value has index 1, index 0 in the property contains the current number of valid elements (read only)
elements - number of elements in the array of the property, in the range 1 <= elements <= 0xFF;

CEMIDevMgmt

public CEMIDevMgmt(int msgCode,
                   int objType,
                   int objInstance,
                   int propID,
                   int startIndex,
                   int elements,
                   byte[] data)
Creates a new device management message.

Used for messages containing a data (or error information) part in the message structure (like read confirmation).

Parameters:
msgCode - a message code constant declared by this class
objType - interface object type, value in the range 0 <= value <= 0xFFFF
objInstance - object instance, value in the range 1 <= value <= 0xFF
propID - property identifier (PID), in the range 0 <= PID <= 0xFF
startIndex - start index in the property, first element has index 1, index 0 in the property contains the current number of valid elements (read only)
elements - number of elements in the array of the property, in the range 0 <= elements <= 0xFF; the number 0 is used to indicate a negative response
data - contains the data (or the error information, if numElems = 0) as byte array
Method Detail

getElementCount

public final byte getElementCount()
Returns the number of elements field from the message.

An element count in the range 1 to 15 indicates the presence of element data. A value of 0 indicates a negative response.
If the message structure does not contain this field, 0 is returned.

Returns:
number of elements as unsigned 4 bit value

getErrorMessage

public java.lang.String getErrorMessage()
Returns a descriptive error message on a negative response, as determined by isNegativeResponse().

A negative response contains an error information code, which is used to find the associated message.
If invoked on positive response, "no error" will be returned.

Returns:
error status message as string

getMessageCode

public final short getMessageCode()
Description copied from interface: CEMI
Returns the cEMI message code.

The codes of the different cEMI message types can be looked up in the according subtype implementations.

Specified by:
getMessageCode in interface CEMI
Returns:
the message code byte

getObjectInstance

public final short getObjectInstance()
Returns the object instance field from the message.

The instance value is in the range 1 to 0xFF.
If the message structure does not contain this field, 0 is returned.

Returns:
the object instance

getObjectType

public final int getObjectType()
Returns the interface object type.

For example,

Returns:
the object type as 16 bit identifier

getPayload

public final byte[] getPayload()
Returns the data part, i.e. the property data or error information following the start index in the message structure.

The property content depends on the property data type, and in case of an array structured property value also on the accessed number of array elements.

In case of a message carrying a negative response, the payload holds error information. To determine whether the returned array contains error information, use isNegativeResponse().
If the message does not contain any data (or error information), a byte array with length 0 is returned.

Specified by:
getPayload in interface CEMI
Returns:
a copy of the data part in the message structure as byte array

getPID

public final short getPID()
Returns the property identifier used in the message.

If the message structure does not contain this field, 0 is returned.

Returns:
the PID

getStartIndex

public final short getStartIndex()
Returns the start index in the data array of the property.

If the message structure does not contain this field, 0 is returned.

Returns:
start index as 12 bit value

getStructLength

public final short getStructLength()
Description copied from interface: CEMI
Returns the length of this cEMI message frame.

Specified by:
getStructLength in interface CEMI
Returns:
the message length in bytes

isNegativeResponse

public final boolean isNegativeResponse()
Returns if the message contains a negative response.

A message contains a negative response, iff the message code equals MC_PROPREAD_CON or MC_PROPWRITE_CON and number of elements is 0.

Returns:
response state as boolean

toByteArray

public byte[] toByteArray()
Description copied from interface: CEMI
Returns the byte representation of the whole cEMI message structure.

Specified by:
toByteArray in interface CEMI
Returns:
frame as byte array

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object