tuwien.auto.calimero.process
Class ProcessCommunicatorImpl

java.lang.Object
  extended by tuwien.auto.calimero.process.ProcessCommunicatorImpl
All Implemented Interfaces:
ProcessCommunicator

public class ProcessCommunicatorImpl
extends java.lang.Object
implements ProcessCommunicator

This implementation of the process communicator uses in any case the DPT translators DPTXlatorBoolean, DPTXlator3BitControlled, DPTXlator8BitUnsigned, DPTXlator2ByteFloat, DPTXlatorString. Other translator types are loaded through TranslatorTypes.


Field Summary
 
Fields inherited from interface tuwien.auto.calimero.process.ProcessCommunicator
ANGLE, BOOL_DECREASE, BOOL_DOWN, BOOL_INCREASE, BOOL_OFF, BOOL_ON, BOOL_START, BOOL_STOP, BOOL_UP, SCALING, UNSCALED
 
Constructor Summary
ProcessCommunicatorImpl(KNXNetworkLink link)
          Creates a new process communicator attached to the supplied KNX network link.
 
Method Summary
 void addProcessListener(ProcessListener l)
          Adds the specified event listener l to receive events from this process communicator.
 KNXNetworkLink detach()
          Detaches the network link from this process communicator.
 Priority getPriority()
          Returns the current used KNX message priority for KNX messages.
 int getResponseTimeout()
          Returns the response timeout used when waiting for a KNX response message to arrive.
 java.lang.String read(Datapoint dp)
          Reads a datapoint value from a group destination.
 boolean readBool(GroupAddress dst)
          Reads a boolean datapoint value from a group destination.
 byte readControl(GroupAddress dst)
          Reads a 3 Bit controlled datapoint value from a group destination.
 float readFloat(GroupAddress dst)
          Reads a 2 byte KNX float datapoint value from a group destination.
 java.lang.String readString(GroupAddress dst)
          Reads a string datapoint value from a group destination.
 short readUnsigned(GroupAddress dst, java.lang.String scale)
          Reads an unsigned 8 bit datapoint value from a group destination.
 void removeProcessListener(ProcessListener l)
          Removes the specified event listener l, so it does no longer receive events from this process communicator.
 void setPriority(Priority p)
          Sets the KNX message priority for KNX messages to send.
 void setResponseTimeout(int timeout)
          Sets the response timeout to wait for a KNX response message to arrive to complete a message exchange.
 void write(Datapoint dp, java.lang.String value)
          Writes a datapoint value to a group destination.
 void write(GroupAddress dst, boolean value)
          Writes a boolean datapoint value to a group destination.
 void write(GroupAddress dst, boolean control, byte stepcode)
          Writes a 3 bit controlled datapoint value to a group destination.
 void write(GroupAddress dst, float value)
          Writes a 2 byte KNX float datapoint value to a group destination.
 void write(GroupAddress dst, int value, java.lang.String scale)
          Writes a 8 bit unsigned datapoint value to a group destination.
 void write(GroupAddress dst, java.lang.String value)
          Writes a string datapoint value to a group destination.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProcessCommunicatorImpl

public ProcessCommunicatorImpl(KNXNetworkLink link)
                        throws KNXLinkClosedException
Creates a new process communicator attached to the supplied KNX network link.

The log service used by this process communicator is named "process " + link.getName().

Parameters:
link - network link used for communication with a KNX network
Throws:
KNXLinkClosedException - if the network link is closed
Method Detail

addProcessListener

public void addProcessListener(ProcessListener l)
Description copied from interface: ProcessCommunicator
Adds the specified event listener l to receive events from this process communicator.

If l was already added as listener, no action is performed.

Specified by:
addProcessListener in interface ProcessCommunicator
Parameters:
l - the listener to add

detach

public KNXNetworkLink detach()
Description copied from interface: ProcessCommunicator
Detaches the network link from this process communicator.

If no network link is attached, no action is performed.

Note that a detach does not trigger a close of the used network link.

Specified by:
detach in interface ProcessCommunicator
Returns:
the formerly attached KNX network link, or null if already detached

getPriority

public Priority getPriority()
Description copied from interface: ProcessCommunicator
Returns the current used KNX message priority for KNX messages.

Specified by:
getPriority in interface ProcessCommunicator
Returns:
message Priority

getResponseTimeout

public int getResponseTimeout()
Description copied from interface: ProcessCommunicator
Returns the response timeout used when waiting for a KNX response message to arrive.

Specified by:
getResponseTimeout in interface ProcessCommunicator
Returns:
timeout in seconds

read

public java.lang.String read(Datapoint dp)
                      throws KNXException
Description copied from interface: ProcessCommunicator
Reads a datapoint value from a group destination.

The used KNX message priority is according the supplied datapoint priority.

Specified by:
read in interface ProcessCommunicator
Parameters:
dp - the datapoint for read
Returns:
the read value in textual representation according the datapoint its type
Throws:
KNXTimeoutException - on a timeout during send or no read response was received
KNXInvalidResponseException - on invalid read response message
KNXLinkClosedException - if network link to KNX network is closed
KNXFormatException - on translation problem of the response data
KNXException - if no appropriate DPT translator for the datapoint type is available

readBool

public boolean readBool(GroupAddress dst)
                 throws KNXTimeoutException,
                        KNXRemoteException,
                        KNXLinkClosedException,
                        KNXFormatException
Description copied from interface: ProcessCommunicator
Reads a boolean datapoint value from a group destination.

Specified by:
readBool in interface ProcessCommunicator
Parameters:
dst - group destination to read from
Returns:
the read value of type boolean
Throws:
KNXTimeoutException - on a timeout during send or no read response was received
KNXInvalidResponseException - on invalid read response message
KNXLinkClosedException - if network link to KNX network is closed
KNXFormatException - on translation problem of the response data
KNXRemoteException

readControl

public byte readControl(GroupAddress dst)
                 throws KNXTimeoutException,
                        KNXRemoteException,
                        KNXLinkClosedException,
                        KNXFormatException
Description copied from interface: ProcessCommunicator
Reads a 3 Bit controlled datapoint value from a group destination.

The returned value is either positive or negative according to the read control information. For control bit orientation, the DPT Dimming (DPT ID 3.007) is used (i.e. control bit type Step). A control value of "decrease" results in a negative value return, a control value of "increase" results in a positive value return. The possible value range is -7 (decrease 7) to +7 (increase 7).

Specified by:
readControl in interface ProcessCommunicator
Parameters:
dst - group destination to read from
Returns:
the read value of type 3 Bit controlled
Throws:
KNXTimeoutException - on a timeout during send or no read response was received
KNXInvalidResponseException - on invalid read response message
KNXLinkClosedException - if network link to KNX network is closed
KNXFormatException - on translation problem of the response data
KNXRemoteException

readFloat

public float readFloat(GroupAddress dst)
                throws KNXTimeoutException,
                       KNXRemoteException,
                       KNXLinkClosedException,
                       KNXFormatException
Description copied from interface: ProcessCommunicator
Reads a 2 byte KNX float datapoint value from a group destination.

Specified by:
readFloat in interface ProcessCommunicator
Parameters:
dst - group destination to read from
Returns:
the read value of type float
Throws:
KNXTimeoutException - on a timeout during send or no read response was received
KNXInvalidResponseException - on invalid read response message
KNXLinkClosedException - if network link to KNX network is closed
KNXFormatException - on translation problem of the response data
KNXRemoteException

readString

public java.lang.String readString(GroupAddress dst)
                            throws KNXTimeoutException,
                                   KNXRemoteException,
                                   KNXLinkClosedException,
                                   KNXFormatException
Description copied from interface: ProcessCommunicator
Reads a string datapoint value from a group destination.

The supported character set covers at least ISO-8859-1 (Latin 1), with an allowed string length of 14 characters.

Specified by:
readString in interface ProcessCommunicator
Parameters:
dst - group destination to read from
Returns:
the read value of type string
Throws:
KNXTimeoutException - on a timeout during send or no read response was received
KNXInvalidResponseException - on invalid read response message
KNXLinkClosedException - if network link to KNX network is closed
KNXFormatException - on translation problem of the response data
KNXRemoteException

readUnsigned

public short readUnsigned(GroupAddress dst,
                          java.lang.String scale)
                   throws KNXTimeoutException,
                          KNXRemoteException,
                          KNXLinkClosedException,
                          KNXFormatException
Description copied from interface: ProcessCommunicator
Reads an unsigned 8 bit datapoint value from a group destination.

The predefined scaling format constants are equal to DPT identifiers of the 8 Bit DPT translator, any other suiting IDs of that type might be specified as well.

Specified by:
readUnsigned in interface ProcessCommunicator
Parameters:
dst - group destination to read from
scale - scaling of the read value before return, one of ProcessCommunicator.SCALING, ProcessCommunicator.UNSCALED, ProcessCommunicator.ANGLE
Returns:
the read value of type unsigned byte
Throws:
KNXTimeoutException - on a timeout during send or no read response was received
KNXInvalidResponseException - on invalid read response message
KNXLinkClosedException - if network link to KNX network is closed
KNXFormatException - on translation problem of the response data
KNXRemoteException

removeProcessListener

public void removeProcessListener(ProcessListener l)
Description copied from interface: ProcessCommunicator
Removes the specified event listener l, so it does no longer receive events from this process communicator.

If l was not added in the first place, no action is performed.

Specified by:
removeProcessListener in interface ProcessCommunicator
Parameters:
l - the listener to remove

setPriority

public void setPriority(Priority p)
Description copied from interface: ProcessCommunicator
Sets the KNX message priority for KNX messages to send.

Specified by:
setPriority in interface ProcessCommunicator
Parameters:
p - new priority to use

setResponseTimeout

public void setResponseTimeout(int timeout)
Description copied from interface: ProcessCommunicator
Sets the response timeout to wait for a KNX response message to arrive to complete a message exchange.

Specified by:
setResponseTimeout in interface ProcessCommunicator
Parameters:
timeout - time in seconds

write

public void write(Datapoint dp,
                  java.lang.String value)
           throws KNXException
Description copied from interface: ProcessCommunicator
Writes a datapoint value to a group destination.

The used KNX message priority is according the supplied datapoint priority.

Specified by:
write in interface ProcessCommunicator
Parameters:
dp - the datapoint for write
value - datapoint value in textual representation according the datapoint its type
Throws:
KNXTimeoutException - on a timeout during send
KNXFormatException - on translation problem of the supplied datapoint value
KNXLinkClosedException - if network link to KNX network is closed
KNXException - if no appropriate DPT translator for the datapoint type is available

write

public void write(GroupAddress dst,
                  boolean value)
           throws KNXTimeoutException,
                  KNXLinkClosedException
Description copied from interface: ProcessCommunicator
Writes a boolean datapoint value to a group destination.

Specified by:
write in interface ProcessCommunicator
Parameters:
dst - group destination to write to
value - boolean value to write, consider the predefined BOOL_* constants (e.g. ProcessCommunicator.BOOL_ON)
Throws:
KNXTimeoutException - on a timeout during send
KNXLinkClosedException - if network link to KNX network is closed

write

public void write(GroupAddress dst,
                  boolean control,
                  byte stepcode)
           throws KNXTimeoutException,
                  KNXFormatException,
                  KNXLinkClosedException
Description copied from interface: ProcessCommunicator
Writes a 3 bit controlled datapoint value to a group destination.

Specified by:
write in interface ProcessCommunicator
Parameters:
dst - group destination to write to
control - control information, one of the predefined BOOL_* constants of DPT Step and DPT Up/Down
stepcode - stepcode value, 0 <= value <= 7
Throws:
KNXTimeoutException - on a timeout during send
KNXFormatException - on translation problem of the supplied datapoint value
KNXLinkClosedException - if network link to KNX network is closed

write

public void write(GroupAddress dst,
                  float value)
           throws KNXTimeoutException,
                  KNXFormatException,
                  KNXLinkClosedException
Description copied from interface: ProcessCommunicator
Writes a 2 byte KNX float datapoint value to a group destination.

Specified by:
write in interface ProcessCommunicator
Parameters:
dst - group destination to write to
value - float value to write
Throws:
KNXTimeoutException - on a timeout during send
KNXFormatException - on translation problem of the supplied datapoint value
KNXLinkClosedException - if network link to KNX network is closed

write

public void write(GroupAddress dst,
                  int value,
                  java.lang.String scale)
           throws KNXTimeoutException,
                  KNXFormatException,
                  KNXLinkClosedException
Description copied from interface: ProcessCommunicator
Writes a 8 bit unsigned datapoint value to a group destination.

The predefined scaling format constants are equal to DPT identifiers of the 8 Bit DPT translator, any other suiting IDs of that type might be specified as well.

Specified by:
write in interface ProcessCommunicator
Parameters:
dst - group destination to write to
value - unsigned scaled value to write, 0 <= value <= scale format specific upper value
scale - scaling of the read value before return, one of ProcessCommunicator.SCALING, ProcessCommunicator.UNSCALED, ProcessCommunicator.ANGLE
Throws:
KNXTimeoutException - on a timeout during send
KNXFormatException - on translation problem of the supplied datapoint value
KNXLinkClosedException - if network link to KNX network is closed

write

public void write(GroupAddress dst,
                  java.lang.String value)
           throws KNXTimeoutException,
                  KNXFormatException,
                  KNXLinkClosedException
Description copied from interface: ProcessCommunicator
Writes a string datapoint value to a group destination.

The supported character set covers at least ISO-8859-1 (Latin 1), with an allowed string length of 14 characters.

Specified by:
write in interface ProcessCommunicator
Parameters:
dst - group destination to write to
value - string value to write
Throws:
KNXTimeoutException - on a timeout during send
KNXFormatException - on translation problem of the supplied datapoint value
KNXLinkClosedException - if network link to KNX network is closed