tuwien.auto.calimero.cemi
Class CEMIBusMon

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

public class CEMIBusMon
extends java.lang.Object
implements CEMI

A cEMI busmonitor indication message.

The data part of the busmonitor message structure contains the raw frame on medium (the data link layer PDU + FCS), it accepts up to 23 bytes in length.
So the raw frame consists of 22 byte LPDU + 1 byte FCS.

Objects of this type are immutable.


Field Summary
static short MC_BUSMON_IND
          Message code for busmonitor indication, code = 43.
static short TYPEID_STATUSINFO
          Additional information type ID for status info, ID = 3.
static short TYPEID_TIMESTAMP
          Additional information type ID for timestamp, ID = 4.
static short TYPEID_TIMESTAMP_EXT
          Additional information type ID for extended timestamp, ID = 6.
 
Constructor Summary
CEMIBusMon(boolean frameError, boolean bitError, boolean parityError, boolean lost, byte seqNumber, long timestamp, boolean extTimestamp, byte[] rawFrame)
          Creates a new busmonitor message.
CEMIBusMon(byte[] data, int offset, int length)
          Creates a new busmonitor message from a byte stream.
CEMIBusMon(byte seqNumber, long timestamp, boolean extTimestamp, byte[] rawFrame)
          Creates a new busmonitor message.
CEMIBusMon(int status, long timestamp, boolean extTimestamp, byte[] rawFrame)
          Creates a new busmonitor message.
 
Method Summary
 boolean getBitError()
          Returns the bit error flag state set in the status information.
 boolean getFrameError()
          Returns the frame error flag state set in the status information.
 boolean getLost()
          Returns the lost flag state set in the status information.
 short getMessageCode()
          Returns the cEMI message code.
 boolean getParityError()
          Returns the parity error flag state set in the status information.
 byte[] getPayload()
          Returns the raw frame on medium (the data link PDU inclusive FCS) contained in this busmonitor indication message.
 byte getSequenceNumber()
          Returns the sequence number set in the status information.
 short getStructLength()
          Returns the length of this cEMI message frame.
 long getTimestamp()
          Returns the timestamp value of the monitoring frame contained in the additional information.
 short getTimestampType()
          Returns the type of timestamp contained in the additional information.
 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_BUSMON_IND

public static final short MC_BUSMON_IND
Message code for busmonitor indication, code = 43.

See Also:
Constant Field Values

TYPEID_STATUSINFO

public static final short TYPEID_STATUSINFO
Additional information type ID for status info, ID = 3.

See Also:
Constant Field Values

TYPEID_TIMESTAMP

public static final short TYPEID_TIMESTAMP
Additional information type ID for timestamp, ID = 4.

See Also:
Constant Field Values

TYPEID_TIMESTAMP_EXT

public static final short TYPEID_TIMESTAMP_EXT
Additional information type ID for extended timestamp, ID = 6.

See Also:
Constant Field Values
Constructor Detail

CEMIBusMon

public CEMIBusMon(boolean frameError,
                  boolean bitError,
                  boolean parityError,
                  boolean lost,
                  byte seqNumber,
                  long timestamp,
                  boolean extTimestamp,
                  byte[] rawFrame)
Creates a new busmonitor message.

Allows to specify every status flag in detail.

Parameters:
frameError - true if a frame error was detected in the message, false otherwise
bitError - true if an invalid bit was detected in one or several of the frame characters, false otherwise
parityError - true if an invalid parity bit was detected, false otherwise
lost - true if at least one frame or frame piece was lost by the Data Link Layer, false otherwise
seqNumber - sequence number in the status field (bits 2..0), 0 <= seqNumber <= 7
timestamp - relative timestamp as specified by cEMI, it might either be a normal (2 byte range) timestamp for TYPEID_TIMESTAMP, or an extended (4 byte range) timestamp of type TYPEID_TIMESTAMP_EXT
extTimestamp - true if timestamp is an extended timestamp value, false otherwise
rawFrame - byte array holding the raw frame on the medium (inclusive FCS), also referred to as the data part in the message structure rawFrame.length <= 23

CEMIBusMon

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

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

CEMIBusMon

public CEMIBusMon(byte seqNumber,
                  long timestamp,
                  boolean extTimestamp,
                  byte[] rawFrame)
Creates a new busmonitor message.

In the status field of the additional information block, only the sequence number can be chosen, all other status flags remain 0 (i.e. indicating no error, no frame loss)

Parameters:
seqNumber - sequence number in the status field (bits 2..0), 0 <= seqNumber <= 7
timestamp - relative timestamp as specified by cEMI, it might either be a normal (2 byte range) timestamp for TYPEID_TIMESTAMP, or an extended (4 byte range) timestamp of type TYPEID_TIMESTAMP_EXT
extTimestamp - true if timestamp is an extended timestamp value, false otherwise
rawFrame - byte array holding the raw frame on the medium (inclusive FCS), also referred to as the data part in the message structure rawFrame.length <= 23

CEMIBusMon

public CEMIBusMon(int status,
                  long timestamp,
                  boolean extTimestamp,
                  byte[] rawFrame)
Creates a new busmonitor message.

Parameters:
status - the status information field (busmonitor error flags) as specified by cEMI, located in the additional information type TYPEID_STATUSINFO, 0 <= status <= 0xFF
timestamp - relative timestamp as specified by cEMI, it might either be a normal (2 byte range) timestamp for TYPEID_TIMESTAMP, or an extended (4 byte range) timestamp of type TYPEID_TIMESTAMP_EXT
extTimestamp - true if timestamp is an extended timestamp value, false otherwise
rawFrame - byte array holding the raw frame on the medium (inclusive FCS), also referred to as the data part in the message structure, rawFrame.length <= 23
Method Detail

getBitError

public final boolean getBitError()
Returns the bit error flag state set in the status information.

If true, an invalid bit was detected in one or several of the frame characters.

Returns:
bit error flag as boolean

getFrameError

public final boolean getFrameError()
Returns the frame error flag state set in the status information.

If true, a frame error was detected in the message.

Returns:
frame error flag as boolean

getLost

public final boolean getLost()
Returns the lost flag state set in the status information.

If true, at least one frame (piece) was lost by the Data Link Layer.

Returns:
lost flag as boolean

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

getParityError

public final boolean getParityError()
Returns the parity error flag state set in the status information.

If true, an invalid parity bit was detected in the frame bits.

Returns:
parity error flag as boolean

getPayload

public final byte[] getPayload()
Returns the raw frame on medium (the data link PDU inclusive FCS) contained in this busmonitor indication message.

Specified by:
getPayload in interface CEMI
Returns:
a copy of the raw frame on medium as byte array

getSequenceNumber

public final byte getSequenceNumber()
Returns the sequence number set in the status information.

Returns:
sequence in the range [0..7]

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

getTimestamp

public final long getTimestamp()
Returns the timestamp value of the monitoring frame contained in the additional information.

The type of timestamp returned is according to getTimestampType().

Returns:
the timestamp value as long

getTimestampType

public final short getTimestampType()
Returns the type of timestamp contained in the additional information.

Returns:
timestamp type ID

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