|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttuwien.auto.calimero.mgmt.TransportLayerImpl
public class TransportLayerImpl
Implementation of the transport layer protocol.
All sending is done blocking on the attached network link, so an eventual confirmation response is implicit by return of a send method, there are no explicit confirmation notifications.
Once this transport layer has been TransportLayer.detach()
ed, it can't be used
for any further layer 4 communication, and it can't be attached to a new network link.
All methods invoked after a detach of the network link used for communication are
allowed to throw KNXIllegalStateException
.
Constructor Summary | |
---|---|
TransportLayerImpl(KNXNetworkLink link)
Creates a new transport layer attached to the supplied KNX network link. |
Method Summary | |
---|---|
void |
addTransportListener(TransportListener l)
Adds the specified event listener l to receive events from this
transport layer. |
void |
broadcast(boolean system,
Priority p,
byte[] tsdu)
Broadcasts data in the KNX network. |
void |
connect(Destination d)
Connects to the destination. |
Destination |
createDestination(IndividualAddress remote,
boolean connectionOriented)
Creates a new destination using the remote KNX address for doing transport layer communication. |
Destination |
createDestination(IndividualAddress remote,
boolean connectionOriented,
boolean keepAlive,
boolean verifyMode)
Creates a new destination using the remote KNX address and connection settings for doing transport layer communication. |
void |
destroyDestination(Destination d)
Destroys the given destination and removes it from being maintained by this transport layer. |
KNXNetworkLink |
detach()
Detaches the network link from this transport layer and terminates all layer 4 communication. |
void |
disconnect(Destination d)
Disconnects from the destination. |
java.lang.String |
getName()
Returns the name of this transport layer, a short textual representation to identify this layer. |
void |
removeTransportListener(TransportListener l)
Removes the specified event listener l , so it does no longer
receive events from this transport layer. |
void |
sendData(Destination d,
Priority p,
byte[] tsdu)
Sends data to the given destination using connection oriented mode. |
void |
sendData(KNXAddress addr,
Priority p,
byte[] tsdu)
Sends data to the given KNX address using connectionless mode. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TransportLayerImpl(KNXNetworkLink link) throws KNXLinkClosedException
link
- network link used for communication with a KNX network
KNXLinkClosedException
- if the network link is closedMethod Detail |
---|
public void addTransportListener(TransportListener l)
TransportLayer
l
to receive events from this
transport layer.
If l
was already added as listener, no action is performed.
addTransportListener
in interface TransportLayer
l
- the listener to addpublic void broadcast(boolean system, Priority p, byte[] tsdu) throws KNXTimeoutException, KNXLinkClosedException
TransportLayer
The broadcast mode for KNX messages also depends on the used KNX medium, and might differ from the mode specified here.
broadcast
in interface TransportLayer
system
- true
for system broadcast, false
for
default (domain) broadcastp
- KNX message prioritytsdu
- transport layer service data unit to send
KNXTimeoutException
- on a timeout during send
KNXLinkClosedException
- if sending on a closed KNX network linkpublic void connect(Destination d) throws KNXTimeoutException, KNXLinkClosedException
TransportLayer
If the supplied destination is not configured in connection oriented mode or is not
in disconnected state, no action is performed.
On return of this method, the destination is in connected state.
connect
in interface TransportLayer
d
- destination to connect
KNXTimeoutException
- on timeout during connect
KNXLinkClosedException
- if sending on a closed KNX network linkpublic Destination createDestination(IndividualAddress remote, boolean connectionOriented)
The destination is owned and maintained by this transport layer, it is also
responsible for doing all layer 4 communication with that destination. The returned
destination connection state for a new destination is disconnected.
If a destination with the remote address is already available, behavior is
implementation dependent. Only one destination can be created per remote address. If a
destination with the supplied remote address already exists for this transport
layer, a KNXIllegalArgumentException
is thrown.
A transport layer can only handle one connection per destination, because it can't
distinguish incoming messages between more than one connection.
createDestination
in interface TransportLayer
remote
- destination KNX individual addressconnectionOriented
- true
for connection oriented mode,
false
for connectionless mode
Destination
public Destination createDestination(IndividualAddress remote, boolean connectionOriented, boolean keepAlive, boolean verifyMode)
The destination is owned and maintained by this transport layer, it is also
responsible for doing all layer 4 communication with that destination. The returned
destination connection state for a new destination is disconnected.
If a destination with the remote address is already available, behavior is
implementation dependent. Only one destination can be created per remote address. If a
destination with the supplied remote address already exists for this transport
layer, a KNXIllegalArgumentException
is thrown.
A transport layer can only handle one connection per destination, because it can't
distinguish incoming messages between more than one connection.
createDestination
in interface TransportLayer
remote
- destination KNX individual addressconnectionOriented
- true
for connection oriented mode,
false
for connectionless modekeepAlive
- true
to prevent a timing out of the logical
connection in connection oriented mode, false
to use default
connection timeoutverifyMode
- true
to indicate the destination has verify mode
enabled, false
otherwise
Destination
public void destroyDestination(Destination d)
TransportLayer
All necessary steps (like disconnecting) are done according to the transport layer
protocol before destroying the destination.
The transport layer does not own the destination any longer.
If the destination is not owned by this transport layer, no action is performed.
destroyDestination
in interface TransportLayer
d
- destination to destroypublic KNXNetworkLink detach()
TransportLayer
All owned destinations will get destroyed (equally to
TransportLayer.destroyDestination(Destination)
), other transport layer resources are
freed and all registered event listeners get notified with
TransportListener.detached(tuwien.auto.calimero.DetachEvent)
.
If no network link is attached, no action is performed.
Note that a detach does not trigger a close of the used network link.
detach
in interface TransportLayer
null
if already
detachedpublic void disconnect(Destination d) throws KNXLinkClosedException
TransportLayer
If the supplied destination is in connected state, it will be in disconnected state
on return of this method.
If the destination is already in disconnected state or destroyed, no action is
performed.
disconnect
in interface TransportLayer
d
- destination to disconnect from
KNXLinkClosedException
- if sending on a closed KNX network linkpublic java.lang.String getName()
The name should at least be unique for transport layers attached to different
links.
The returned name is used by this layer as the name of its log service. Supply
TransportLayer.getName()
for LogManager.getLogService(String)
for example to get
the associated log service.
By default, the name starts with "TL " + the name of the attached network link.
After detach of the transport layer the name might get reset to some default name. If detach()
was invoked for this layer, "TL (detached)" is
returned.
getName
in interface TransportLayer
public void removeTransportListener(TransportListener l)
TransportLayer
l
, so it does no longer
receive events from this transport layer.
If l
was not added in the first place, no action is performed.
removeTransportListener
in interface TransportLayer
l
- the listener to removepublic void sendData(Destination d, Priority p, byte[] tsdu) throws KNXDisconnectException, KNXLinkClosedException
TransportLayer
A destination has to be set in connected state before sending. All necessary timeouts are observed and send repetition are done according to the transport layer protocol. The method blocks for the corresponding layer 4 acknowledge before returning. If no acknowledge is received, the destination is disconnected.
sendData
in interface TransportLayer
d
- send destination in the KNX networkp
- KNX message prioritytsdu
- transport layer service data unit to send
KNXDisconnectException
- if destination state is disconnected or a disconnect
occurs during send
KNXLinkClosedException
- if sending on a closed KNX network linkpublic void sendData(KNXAddress addr, Priority p, byte[] tsdu) throws KNXTimeoutException, KNXLinkClosedException
TransportLayer
Depending on the supplied type of KNX address, sending on the KNX network is unicast or multicast.
sendData
in interface TransportLayer
addr
- send destination in the KNX network, address of type
IndividualAddress
for unicast, GroupAddress
for multicastp
- KNX message prioritytsdu
- transport layer service data unit to send
KNXTimeoutException
- on a timeout during send
KNXLinkClosedException
- if sending on a closed KNX network link
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |