tuwien.auto.calimero.mgmt
Class KnIPDeviceMgmtAdapter

java.lang.Object
  extended by tuwien.auto.calimero.mgmt.KnIPDeviceMgmtAdapter
All Implemented Interfaces:
PropertyAdapter

public class KnIPDeviceMgmtAdapter
extends java.lang.Object
implements PropertyAdapter

Property adapter for KNXnet/IP local device management.

This adapter is based on a KNXnetIPDevMgmt connection.
The object instance used is always the first one, i.e. object instance 1.


Constructor Summary
KnIPDeviceMgmtAdapter(java.net.InetSocketAddress localEP, java.net.InetSocketAddress serverCtrlEP, boolean useNAT, PropertyAdapterListener l, boolean queryWriteEnable)
          Creates a new property adapter for local device management.
 
Method Summary
 void close()
          Closes the adapter.
 byte[] getDescription(int objIndex, int pid, int propIndex)
          Reads the description of a property of an interface object.
 java.lang.String getName()
          Returns the name for identifying this adapter and its destination.
 byte[] getProperty(int objIndex, int pid, int start, int elements)
          Gets property value elements in an interface object property.
 boolean isOpen()
          Returns whether this adapter can be used for property access and is not closed.
 void setProperty(int objIndex, int pid, int start, int elements, byte[] data)
          Sets property value elements in an interface object property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KnIPDeviceMgmtAdapter

public KnIPDeviceMgmtAdapter(java.net.InetSocketAddress localEP,
                             java.net.InetSocketAddress serverCtrlEP,
                             boolean useNAT,
                             PropertyAdapterListener l,
                             boolean queryWriteEnable)
                      throws KNXException
Creates a new property adapter for local device management.

The server to do management for is specified with the server control endpoint.

A note on write enabled / read only properties:
The check whether a property is read only or write enabled, is done by issuing a write request for that property. Due to the memory layout, write cycles of a memory location and similar, this might not always be desired. To enable or skip this check, the queryWriteEnable option has to be set appropriately. Currently, the write enabled check is only of interest when getting a property description getDescription(int, int, int).

Parameters:
localEP - the local endpoint of the connection, use null for assigning the default local host and an unused (ephemeral) port
serverCtrlEP - the remote server control endpoint used for connect request
useNAT - true to use a network address translation aware communication mechanism, false to use the default way
l - property adapter listener to get notified about adapter events, use null for no listener
queryWriteEnable - true to check whether a property is write enabled or read only, false to skip the check
Throws:
KNXException - on failure establishing local device management connection or failure while initializing property adapter
Method Detail

close

public void close()
Description copied from interface: PropertyAdapter
Closes the adapter.

Depending on the adapter, necessary steps to terminate a connection might be done and owned resources will be freed.
A closed adapter can't be used for property access anymore.
Currently, this method does not invoke PropertyAdapterListener.adapterClosed(tuwien.auto.calimero.CloseEvent).

Specified by:
close in interface PropertyAdapter

getDescription

public byte[] getDescription(int objIndex,
                             int pid,
                             int propIndex)
                      throws KNXTimeoutException,
                             KNXConnectionClosedException,
                             KNXRemoteException
Description copied from interface: PropertyAdapter
Reads the description of a property of an interface object.

The property description layout is according the application layer property description service.

Specified by:
getDescription in interface PropertyAdapter
Parameters:
objIndex - interface object index
pid - property identifier, specify 0 to use the property index
propIndex - property index, starts with index 0 for the first property
Returns:
byte array containing the property description, starting with the property object index
Throws:
KNXTimeoutException
KNXConnectionClosedException
KNXRemoteException

getName

public java.lang.String getName()
Returns the name for identifying this adapter and its destination.

The name for this adapter starts with "local DM " + KNXnet/IP server control endpoint, allowing easier distinction of adapter types.

Specified by:
getName in interface PropertyAdapter
Returns:
adapter name as string

getProperty

public byte[] getProperty(int objIndex,
                          int pid,
                          int start,
                          int elements)
                   throws KNXTimeoutException,
                          KNXRemoteException,
                          KNXConnectionClosedException
Description copied from interface: PropertyAdapter
Gets property value elements in an interface object property.

Specified by:
getProperty in interface PropertyAdapter
Parameters:
objIndex - interface object index
pid - property identifier
start - start index in the property value to start reading from
elements - number of elements to get
Returns:
byte array containing the property value data
Throws:
KNXTimeoutException
KNXRemoteException
KNXConnectionClosedException

isOpen

public boolean isOpen()
Description copied from interface: PropertyAdapter
Returns whether this adapter can be used for property access and is not closed.

Specified by:
isOpen in interface PropertyAdapter
Returns:
true if adapter open, false if closed

setProperty

public void setProperty(int objIndex,
                        int pid,
                        int start,
                        int elements,
                        byte[] data)
                 throws KNXTimeoutException,
                        KNXRemoteException,
                        KNXConnectionClosedException
Description copied from interface: PropertyAdapter
Sets property value elements in an interface object property.

Specified by:
setProperty in interface PropertyAdapter
Parameters:
objIndex - interface object index
pid - property identifier
start - start index in the property value to start writing to
elements - number of elements to set
data - byte array containing the property value data
Throws:
KNXTimeoutException
KNXRemoteException
KNXConnectionClosedException