tuwien.auto.calimero.link
Class KNXNetworkMonitorIP

java.lang.Object
  extended by tuwien.auto.calimero.link.KNXNetworkMonitorIP
All Implemented Interfaces:
KNXNetworkMonitor

public class KNXNetworkMonitorIP
extends java.lang.Object
implements KNXNetworkMonitor

Implementation of the KNX network monitor link based on the KNXnet/IP protocol, using a KNXnetIPConnection.

Once a monitor has been closed, it is not available for further link communication, i.e. it can't be reopened.

Pay attention to the IP address consideration stated in the documentation comments of class KNXNetworkLinkIP.


Constructor Summary
KNXNetworkMonitorIP(java.net.InetSocketAddress localEP, java.net.InetSocketAddress remoteEP, boolean useNAT, KNXMediumSettings settings)
          Creates a new network monitor based on the KNXnet/IP protocol for accessing the KNX network.
 
Method Summary
 void addMonitorListener(LinkListener l)
          Adds the specified event listener l to receive events from this network monitor.
 void close()
          Ends monitoring the KNX network and closes the network monitor.
 KNXMediumSettings getKNXMedium()
          Returns the KNX medium settings used by this monitor link.
 java.lang.String getName()
          Returns the name of the monitor, a short textual representation to identify a network monitor.
 boolean isOpen()
          Checks for open monitor link.
 void removeMonitorListener(LinkListener l)
          Removes the specified event listener l, so it does no longer receive events from this network monitor.
 void setDecodeRawFrames(boolean decode)
          Sets whether the monitor should decode the raw frame on medium contained in received KNX bus monitor messages.
 void setKNXMedium(KNXMediumSettings settings)
          Supplies medium information necessary for KNX communication.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KNXNetworkMonitorIP

public KNXNetworkMonitorIP(java.net.InetSocketAddress localEP,
                           java.net.InetSocketAddress remoteEP,
                           boolean useNAT,
                           KNXMediumSettings settings)
                    throws KNXException
Creates a new network monitor based on the KNXnet/IP protocol for accessing the KNX network.

Parameters:
localEP - the local endpoint to use for the link, this is the client control endpoint, use null for the default local host and an ephemeral port number
remoteEP - the remote endpoint of the link; this is the server control endpoint
useNAT - true to use network address translation in the KNXnet/IP protocol, false to use the default (non aware) mode
settings - medium settings defining the specific KNX medium needed for decoding raw frames received from the KNX network
Throws:
KNXException - on failure establishing the link
Method Detail

addMonitorListener

public void addMonitorListener(LinkListener l)
Description copied from interface: KNXNetworkMonitor
Adds the specified event listener l to receive events from this network monitor.

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

Specified by:
addMonitorListener in interface KNXNetworkMonitor
Parameters:
l - the listener to add

close

public void close()
Description copied from interface: KNXNetworkMonitor
Ends monitoring the KNX network and closes the network monitor.

All registered monitor listeners get notified.
If no communication access was established in the first place, no action is performed.

Specified by:
close in interface KNXNetworkMonitor

getKNXMedium

public KNXMediumSettings getKNXMedium()
Description copied from interface: KNXNetworkMonitor
Returns the KNX medium settings used by this monitor link.

The returned object is a reference to the one used by this link (not a copy).

Specified by:
getKNXMedium in interface KNXNetworkMonitor
Returns:
medium settings for KNX network

getName

public java.lang.String getName()
Returns the name of the monitor, a short textual representation to identify a network monitor.

The name is unique for monitors with different remote endpoints.
The returned name is used by the monitor for the name of its log service. Supply KNXNetworkMonitor.getName() for LogManager.getLogService(String) for example to get the associated log service.

By default, "monitor " + address/ID of the remote endpoint is returned.
After closing the monitor, the returned name might differ, e.g. get reset to some arbitrary default name.
The returned name is "monitor " + remote IP address of the control endpoint + ":" + remote port used by the monitor.

Specified by:
getName in interface KNXNetworkMonitor
Returns:
monitor name as string

isOpen

public boolean isOpen()
Description copied from interface: KNXNetworkMonitor
Checks for open monitor link.

After a call to KNXNetworkMonitor.close() or after the underlying protocol initiated the end of the communication, this method always returns false.

Specified by:
isOpen in interface KNXNetworkMonitor
Returns:
true if this network monitor is open, false on closed

removeMonitorListener

public void removeMonitorListener(LinkListener l)
Description copied from interface: KNXNetworkMonitor
Removes the specified event listener l, so it does no longer receive events from this network monitor.

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

Specified by:
removeMonitorListener in interface KNXNetworkMonitor
Parameters:
l - the listener to remove

setDecodeRawFrames

public void setDecodeRawFrames(boolean decode)
Description copied from interface: KNXNetworkMonitor
Sets whether the monitor should decode the raw frame on medium contained in received KNX bus monitor messages.

A decoded raw frame is of type RawFrame and can be retrieved using MonitorFrameEvent.getRawFrame() within a link listener registered for this monitor.

Specified by:
setDecodeRawFrames in interface KNXNetworkMonitor
Parameters:
decode - true to enable decoding, false to skip decoding

setKNXMedium

public void setKNXMedium(KNXMediumSettings settings)
Description copied from interface: KNXNetworkMonitor
Supplies medium information necessary for KNX communication.

These informations are differing between KNX media and depend on the KNX network this link is communicating with.
The settings medium type has to match the medium type supplied to the link in the first place.
The settings object is not copied internally to allow subsequent changes to medium settings by the user which should take effect immediately.

Specified by:
setKNXMedium in interface KNXNetworkMonitor
Parameters:
settings - medium settings to use, the expected subtype is according to the KNX network medium

toString

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