tuwien.auto.calimero.cemi
Class CEMILDataEx

java.lang.Object
  extended by tuwien.auto.calimero.cemi.CEMILData
      extended by tuwien.auto.calimero.cemi.CEMILDataEx
All Implemented Interfaces:
java.lang.Cloneable, CEMI

public class CEMILDataEx
extends CEMILData
implements java.lang.Cloneable

A cEMI link layer data message (L-Data).

Extended frame formats are supported, with a transport layer protocol data unit of 255 bytes maximum. Additional information might be specified.

Objects of this L-Data type are not immutable.


Nested Class Summary
static class CEMILDataEx.AddInfo
          Holds an additional info type with corresponding information data.
 
Field Summary
static int ADDINFO_BIBAT
          Additional information type for BiBat information.
static int ADDINFO_PLMEDIUM
          Additional information type for PL medium information.
static int ADDINFO_RFMEDIUM
          Additional information type for RF medium information.
static int ADDINFO_TIMEDELAY
          Additional information type for time delay until sending information.
static int ADDINFO_TIMESTAMP
          Additional information type for relative timestamp information.
static int ADDINFO_TIMESTAMP_EXT
          Additional information type for extended relative timestamp information.
 
Fields inherited from class tuwien.auto.calimero.cemi.CEMILData
ctrl1, ctrl2, mc, MC_LDATA_CON, MC_LDATA_IND, MC_LDATA_REQ
 
Constructor Summary
CEMILDataEx(byte[] data, int offset)
          Creates a new L-Data message from a byte stream.
CEMILDataEx(int msgCode, IndividualAddress src, KNXAddress dst, byte[] tpdu, Priority p)
          Creates a L-Data message with most control information set to default values.
CEMILDataEx(int msgCode, IndividualAddress src, KNXAddress dst, byte[] tpdu, Priority p, boolean confirm)
          Creates a L-Data message, mainly for confirmation.
CEMILDataEx(int msgCode, IndividualAddress src, KNXAddress dst, byte[] tpdu, Priority p, boolean repeat, boolean broadcast, boolean ack, int hopCount)
          Creates a L-Data message with full customization for control information.
CEMILDataEx(int msgCode, IndividualAddress src, KNXAddress dst, byte[] tpdu, Priority p, boolean repeat, int hopCount)
          Creates a L-Data message, mainly for TP1 media.
 
Method Summary
 void addAdditionalInfo(int infoType, byte[] info)
          Adds additional information to the message.
 java.lang.Object clone()
           
 java.util.List getAdditionalInfo()
          Returns all additional information currently set.
 byte[] getAdditionalInfo(int infoType)
          Returns additional information data corresponding to the supplied type ID, if it is contained in the message.
 short getStructLength()
          Returns the length of this cEMI message frame.
 boolean isDomainBroadcast()
          Returns the kind of broadcast set for this message.
 boolean isExtendedFrame()
          Returns whether the message assembles an extended frame format.
 void removeAdditionalInfo(int infoType)
          Removes the additional information with the supplied type ID.
 void setBroadcast(boolean domainOnly)
          Specifies the kind of broadcast to use for sending.
 void setHopCount(int hobbes)
           
 void setPriority(Priority p)
           
 byte[] toByteArray()
          Returns the byte representation of the whole cEMI message structure.
 java.lang.String toString()
           
 
Methods inherited from class tuwien.auto.calimero.cemi.CEMILData
getDestination, getHopCount, getMessageCode, getPayload, getPriority, getSource, isAckRequested, isPositiveConfirmation, isRepetition
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ADDINFO_BIBAT

public static final int ADDINFO_BIBAT
Additional information type for BiBat information.

See Also:
Constant Field Values

ADDINFO_PLMEDIUM

public static final int ADDINFO_PLMEDIUM
Additional information type for PL medium information.

See Also:
Constant Field Values

ADDINFO_RFMEDIUM

public static final int ADDINFO_RFMEDIUM
Additional information type for RF medium information.

See Also:
Constant Field Values

ADDINFO_TIMEDELAY

public static final int ADDINFO_TIMEDELAY
Additional information type for time delay until sending information.

See Also:
Constant Field Values

ADDINFO_TIMESTAMP

public static final int ADDINFO_TIMESTAMP
Additional information type for relative timestamp information.

See Also:
Constant Field Values

ADDINFO_TIMESTAMP_EXT

public static final int ADDINFO_TIMESTAMP_EXT
Additional information type for extended relative timestamp information.

See Also:
Constant Field Values
Constructor Detail

CEMILDataEx

public CEMILDataEx(byte[] data,
                   int offset)
            throws KNXFormatException
Creates a new L-Data message from a byte stream.

Parameters:
data - byte stream containing a cEMI L-Data message
offset - start offset of cEMI frame in data
Throws:
KNXFormatException - if no (valid) frame was found

CEMILDataEx

public CEMILDataEx(int msgCode,
                   IndividualAddress src,
                   KNXAddress dst,
                   byte[] tpdu,
                   Priority p)
Creates a L-Data message with most control information set to default values.

The initialized message has send repetitions according to default medium behavior (for indication message this equals "not repeated frame"), broadcast is "don't care", acknowledge request is default medium behavior, hop count is 6 and confirmation request is "don't care" in the control field.

Parameters:
msgCode - a message code value specified in the L-Data type
src - individual address of source
dst - destination address
tpdu - data array, starting with the TPCI / APCI (transport / application layer protocol control information), i.e. the NPDU without the length field, tpdu.length <= 255
p - message priority, priority set in the control field

CEMILDataEx

public CEMILDataEx(int msgCode,
                   IndividualAddress src,
                   KNXAddress dst,
                   byte[] tpdu,
                   Priority p,
                   boolean confirm)
Creates a L-Data message, mainly for confirmation.

The message hop count is set to 6, send repetitions according to default medium behavior, broadcast and acknowledge request are set to "don't care" in the control field.

Parameters:
msgCode - a message code value specified in the L-Data type
src - individual address of source
dst - destination address
tpdu - data array, starting with the TPCI / APCI (transport / application layer protocol control information); i.e. the NPDU without the length field, tpdu.length <= 255
p - message priority, priority set in the control field
confirm - confirm flag in the control field, true to set error, false for no error

CEMILDataEx

public CEMILDataEx(int msgCode,
                   IndividualAddress src,
                   KNXAddress dst,
                   byte[] tpdu,
                   Priority p,
                   boolean repeat,
                   boolean broadcast,
                   boolean ack,
                   int hopCount)
Creates a L-Data message with full customization for control information.

The confirmation flag of the control field is left out, since it is mutual exclusive with the rest of the control information and set to "don't care" (refer to CEMILDataEx(int, IndividualAddress, KNXAddress, byte[], Priority, boolean)).

Parameters:
msgCode - a message code value specified in the L-Data type
src - individual address of source
dst - destination address
tpdu - data array, starting with the TPCI / APCI (transport / application layer protocol control information), i.e. the NPDU without the length field, tpdu.length <= 255
p - message priority, priority set in the control field
repeat - for request messages send repetitions on the medium - false for do not repeat if error, true for default repeat behavior;
meaning of default behavior on media:
  • TP0, PL132, RF: no repetitions
  • TP1, PL110: repetitions allowed
for indication message - true if is repeated frame, false otherwise
broadcast - system / domain broadcast behavior, applicable on open media only: false for system broadcast, true for broadcast; on closed media set true for "don't care"
ack - acknowledge request, true if acknowledge is requested, false for default behavior;
meaning of default behavior on media:
  • TP0, PL132: no acknowledge requested
  • TP1, PL110: acknowledge requested
hopCount - hop count starting value set in control field, in the range 0 <= value <= 7

CEMILDataEx

public CEMILDataEx(int msgCode,
                   IndividualAddress src,
                   KNXAddress dst,
                   byte[] tpdu,
                   Priority p,
                   boolean repeat,
                   int hopCount)
Creates a L-Data message, mainly for TP1 media.

Parameters:
msgCode - a message code value specified in the L-Data type
src - individual address of source
dst - destination address
tpdu - data array, starting with the TPCI / APCI (transport / application layer protocol control information), i.e. the NPDU without the length field, tpdu.length <= 255
p - message priority, priority set in the control field
repeat - for request message, send repetitions on the medium - false for do not repeat if error, true for default repeat behavior;
meaning of default behavior on media:
  • TP0, PL132, RF: no repetitions
  • TP1, PL110: repetitions allowed
for indication message - true if is repeated frame, false otherwise
hopCount - hop count starting value set in control field, in the range 0 <= value <= 7
Method Detail

addAdditionalInfo

public void addAdditionalInfo(int infoType,
                              byte[] info)
Adds additional information to the message.

It replaces additional information of the same type, if any was previously added.

Parameters:
infoType - type ID of additional information
info - additional information data

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

getAdditionalInfo

public java.util.List getAdditionalInfo()
Returns all additional information currently set.

Returns:
a List with CEMILDataEx.AddInfo objects

getAdditionalInfo

public byte[] getAdditionalInfo(int infoType)
Returns additional information data corresponding to the supplied type ID, if it is contained in the message.

Parameters:
infoType - type ID of the request additional information
Returns:
additional information data or null if no such information is available

getStructLength

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

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

isDomainBroadcast

public boolean isDomainBroadcast()
Returns the kind of broadcast set for this message.

By default, true is returned, indicating "domain-only" broadcast on open media or "don't care" on closed media.

Returns:
true if broadcast only within domain or "don't care" mode, false for system broadcast

isExtendedFrame

public boolean isExtendedFrame()
Returns whether the message assembles an extended frame format.

Returns:
true if this is an extended frame, false otherwise

removeAdditionalInfo

public void removeAdditionalInfo(int infoType)
Removes the additional information with the supplied type ID.

Parameters:
infoType - type ID of additional information to remove

setBroadcast

public void setBroadcast(boolean domainOnly)
Specifies the kind of broadcast to use for sending.

Parameters:
domainOnly - true for doing a broadcast only within the domain, false for a system broadcast

setHopCount

public final void setHopCount(int hobbes)

setPriority

public final void setPriority(Priority p)

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
Overrides:
toByteArray in class CEMILData
Returns:
frame as byte array

toString

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