net.wimpi.modbus.net
Class TCPMasterConnection

java.lang.Object
  extended by net.wimpi.modbus.net.TCPMasterConnection

public class TCPMasterConnection
extends Object

Class that implements a TCPMasterConnection.

Version:
@version@ (@date@)
Author:
Dieter Wimberger

Constructor Summary
TCPMasterConnection(InetAddress adr)
          Constructs a TCPMasterConnection instance with a given destination address.
 
Method Summary
 void close()
          Closes this TCPMasterConnection.
 void connect()
          Opens this TCPMasterConnection.
 InetAddress getAddress()
          Returns the destination InetAddress of this TCPMasterConnection.
 ModbusTransport getModbusTransport()
          Returns the ModbusTransport associated with this TCPMasterConnection.
 int getPort()
          Returns the destination port of this TCPMasterConnection.
 int getTimeout()
          Returns the timeout for this TCPMasterConnection.
 boolean isConnected()
          Tests if this TCPMasterConnection is connected.
 void setAddress(InetAddress adr)
          Sets the destination InetAddress of this TCPMasterConnection.
 void setPort(int port)
          Sets the destination port of this TCPMasterConnection.
 void setTimeout(int timeout)
          Sets the timeout for this TCPMasterConnection.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TCPMasterConnection

public TCPMasterConnection(InetAddress adr)
Constructs a TCPMasterConnection instance with a given destination address.

Parameters:
adr - the destination InetAddress.
Method Detail

connect

public void connect()
             throws Exception
Opens this TCPMasterConnection.

Throws:
Exception - if there is a network failure.

close

public void close()
Closes this TCPMasterConnection.


getModbusTransport

public ModbusTransport getModbusTransport()
Returns the ModbusTransport associated with this TCPMasterConnection.

Returns:
the connection's ModbusTransport.

getTimeout

public int getTimeout()
Returns the timeout for this TCPMasterConnection.

Returns:
the timeout as int.

setTimeout

public void setTimeout(int timeout)
Sets the timeout for this TCPMasterConnection.

Parameters:
timeout - the timeout as int.

getPort

public int getPort()
Returns the destination port of this TCPMasterConnection.

Returns:
the port number as int.

setPort

public void setPort(int port)
Sets the destination port of this TCPMasterConnection. The default is defined as Modbus.DEFAULT_PORT.

Parameters:
port - the port number as int.

getAddress

public InetAddress getAddress()
Returns the destination InetAddress of this TCPMasterConnection.

Returns:
the destination address as InetAddress.

setAddress

public void setAddress(InetAddress adr)
Sets the destination InetAddress of this TCPMasterConnection.

Parameters:
adr - the destination address as InetAddress.

isConnected

public boolean isConnected()
Tests if this TCPMasterConnection is connected.

Returns:
true if connected, false otherwise.


Copyright © 2010. All Rights Reserved.