tuwien.auto.calimero.process
Class ProcessListenerEx

java.lang.Object
  extended by tuwien.auto.calimero.process.ProcessListenerEx
All Implemented Interfaces:
java.util.EventListener, ProcessListener

public abstract class ProcessListenerEx
extends java.lang.Object
implements ProcessListener

Extended process listener interface with additional group read event handler methods, as well as basic ASDU type translation capabilities.

This listener contains predefined methods equal to the ones in the ProcessCommunicator interface to convert received ASDUs into common java data types.
Usage example for group reads from datapoints with DPT main number 1:

 public void groupWrite(ProcessEvent e)
 {
     // the member variable model (of type DatapointModel, declared by the user)
     // contains datapoints of light switch objects in the KNX network (boolean type)
     if (model.contains(e.getDestination()))
         try {
             final boolean switch = asBool(e);
             System.out.println(model.get(e.getDestination()).getName()
                 + " state = " + switch);
             if (switch) {
                 // light switch is in position on
                 // do some visual feedback for the user ...
             }
         }
         catch (KNXFormatException kfe) { /* DPT not found ... *<!-- -->/ }
 }
 

See Also:
ProcessCommunicator

Constructor Summary
ProcessListenerEx()
           
 
Method Summary
 boolean asBool(ProcessEvent e)
          Returns the ASDU of the received process event as boolean datapoint value.
 byte asControl(ProcessEvent e)
          Returns the ASDU of the received process event as 3 Bit controlled datapoint value.
 float asFloat(ProcessEvent e)
          Returns the ASDU of the received process event as 2 byte KNX float datapoint value.
 java.lang.String asString(ProcessEvent e)
          Returns the ASDU of the received process event as string datapoint value.
 java.lang.String asString(ProcessEvent e, int dptMainNumber, java.lang.String dptID)
          Returns the ASDU of the received process event as datapoint value of the requested DPT in String representation.
 short asUnsigned(ProcessEvent e, java.lang.String scale)
          Returns the ASDU of the received process event as unsigned 8 Bit datapoint value.
abstract  void groupReadRequest(ProcessEvent e)
          Indicates that a KNX group read request message was received from the KNX network.
abstract  void groupReadResponse(ProcessEvent e)
          Indicates that a KNX group read response message was received from the KNX network.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface tuwien.auto.calimero.process.ProcessListener
detached, groupWrite
 

Constructor Detail

ProcessListenerEx

public ProcessListenerEx()
Method Detail

asBool

public boolean asBool(ProcessEvent e)
               throws KNXFormatException
Returns the ASDU of the received process event as boolean datapoint value.

This method has to be invoked manually by the user (either in groupReadResponse(ProcessEvent) or ProcessListener.groupWrite(ProcessEvent)), depending on the received datapoint type.

Parameters:
e - the process event with the ASDU to translate
Returns:
the received value of type boolean
Throws:
KNXFormatException - on not supported or not available boolean DPT

asControl

public byte asControl(ProcessEvent e)
               throws KNXFormatException
Returns the ASDU of the received process event as 3 Bit controlled datapoint value.

This method has to be invoked manually by the user (either in groupReadResponse(ProcessEvent) or ProcessListener.groupWrite(ProcessEvent)), depending on the received datapoint type.

Parameters:
e - the process event with the ASDU to translate
Returns:
the received value of type 3 Bit controlled
Throws:
KNXFormatException - on not supported or not available 3 Bit controlled DPT

asFloat

public float asFloat(ProcessEvent e)
              throws KNXFormatException
Returns the ASDU of the received process event as 2 byte KNX float datapoint value.

This method has to be invoked manually by the user (either in groupReadResponse(ProcessEvent) or ProcessListener.groupWrite(ProcessEvent)), depending on the received datapoint type.

Parameters:
e - the process event with the ASDU to translate
Returns:
the received value of type float
Throws:
KNXFormatException - on not supported or not available float DPT

asString

public java.lang.String asString(ProcessEvent e)
                          throws KNXFormatException
Returns the ASDU of the received process event as string datapoint value.

The used character set is ISO-8859-1 (Latin 1), with an allowed string length of 14 characters.

This method has to be invoked manually by the user (either in groupReadResponse(ProcessEvent) or ProcessListener.groupWrite(ProcessEvent)), depending on the received datapoint type.

Parameters:
e - the process event with the ASDU to translate
Returns:
the received value of type String
Throws:
KNXFormatException - on not supported or not available ISO-8859-1 DPT

asString

public java.lang.String asString(ProcessEvent e,
                                 int dptMainNumber,
                                 java.lang.String dptID)
                          throws KNXException
Returns the ASDU of the received process event as datapoint value of the requested DPT in String representation.

This method has to be invoked manually by the user (either in groupReadResponse(ProcessEvent) or ProcessListener.groupWrite(ProcessEvent)), depending on the received datapoint type.

Parameters:
e - the process event with the ASDU to translate
dptMainNumber - datapoint type main number, number >= 0; use 0 to infer translator type from dptID argument only
dptID - datapoint type ID for selecting a particular kind of value translation
Returns:
the received value of the requested type as String representation
Throws:
KNXException - on not supported or not available DPT
See Also:
TranslatorTypes.createTranslator(int, String)

asUnsigned

public short asUnsigned(ProcessEvent e,
                        java.lang.String scale)
                 throws KNXFormatException
Returns the ASDU of the received process event as unsigned 8 Bit datapoint value.

This method has to be invoked manually by the user (either in groupReadResponse(ProcessEvent) or ProcessListener.groupWrite(ProcessEvent)), depending on the received datapoint type.

Parameters:
e - the process event with the ASDU to translate
scale - see ProcessCommunicator.readUnsigned( tuwien.auto.calimero.GroupAddress, String)
Returns:
the received value of type 8 Bit unsigned
Throws:
KNXFormatException - on not supported or not available 8 Bit unsigned DPT

groupReadRequest

public abstract void groupReadRequest(ProcessEvent e)
Indicates that a KNX group read request message was received from the KNX network.

Parameters:
e - process event object

groupReadResponse

public abstract void groupReadResponse(ProcessEvent e)
Indicates that a KNX group read response message was received from the KNX network.

Parameters:
e - process event object