public class ModbusTCPMaster extends AbstractModbusMaster
| Constructor and Description |
|---|
ModbusTCPMaster(String addr)
Constructs a new master facade instance for communication
with a given slave.
|
ModbusTCPMaster(String addr,
boolean useRtuOverTcp)
Constructs a new master facade instance for communication
with a given slave.
|
ModbusTCPMaster(String addr,
int port)
Constructs a new master facade instance for communication
with a given slave.
|
ModbusTCPMaster(String addr,
int port,
boolean useRtuOverTcp)
Constructs a new master facade instance for communication
with a given slave.
|
ModbusTCPMaster(String addr,
int port,
int timeout,
boolean reconnect)
Constructs a new master facade instance for communication
with a given slave.
|
ModbusTCPMaster(String addr,
int port,
int timeout,
boolean reconnect,
boolean useRtuOverTcp)
Constructs a new master facade instance for communication
with a given slave.
|
ModbusTCPMaster(String addr,
int port,
int timeout,
boolean reconnect,
boolean useRtuOverTcp,
Proxy proxy)
Constructs a new master facade instance for communication
with a given slave.
|
ModbusTCPMaster(String addr,
int port,
Proxy proxy)
Constructs a new master facade instance for communication
with a given slave.
|
ModbusTCPMaster(String addr,
Proxy proxy)
Constructs a new master facade instance for communication
with a given slave.
|
| Modifier and Type | Method and Description |
|---|---|
void |
connect()
Connects this ModbusTCPMaster with the slave.
|
void |
disconnect()
Disconnects this ModbusTCPMaster from the slave.
|
boolean |
equals(Object obj)
A
ModbusTCPMaster is equal if the underlying TCPMasterConnection is equal. |
AbstractModbusTransport |
getTransport()
Returns the transport being used by the
|
int |
hashCode()
The unique value of the
ModbusTCPMaster is calculated from the unique value of the TCPMasterConnection |
boolean |
isConnected()
Returns true if the master is connected
|
boolean |
isReconnecting()
Tests if a constant connection is maintained or if a new
connection is established for every transaction.
|
void |
setReconnecting(boolean b)
Sets the flag that specifies whether to maintain a
constant connection or reconnect for every transaction.
|
void |
setTimeout(int timeout)
Sets the receive timeout
|
getTimeout, maskWriteRegister, maskWriteRegister, readCoils, readCoils, readInputDiscretes, readInputDiscretes, readInputRegisters, readInputRegisters, readMultipleRegisters, readMultipleRegisters, setCheckingValidity, setRetries, writeCoil, writeCoil, writeMultipleCoils, writeMultipleCoils, writeMultipleRegisters, writeMultipleRegisters, writeSingleRegister, writeSingleRegisterpublic ModbusTCPMaster(String addr)
addr - an internet address as resolvable IP name or IP number,
specifying the slave to communicate with.public ModbusTCPMaster(String addr, Proxy proxy)
addr - an internet address as resolvable IP name or IP number,
specifying the slave to communicate with.proxy - a proxy to use on the underlying tcp socketpublic ModbusTCPMaster(String addr, boolean useRtuOverTcp)
addr - an internet address as resolvable IP name or IP number,
specifying the slave to communicate with.useRtuOverTcp - True if the RTU protocol should be used over TCPpublic ModbusTCPMaster(String addr, int port)
addr - an internet address as resolvable IP name or IP number,
specifying the slave to communicate with.port - the port the slave is listening to.public ModbusTCPMaster(String addr, int port, Proxy proxy)
addr - an internet address as resolvable IP name or IP number,
specifying the slave to communicate with.port - the port the slave is listening to.proxy - a proxy to use on the underlying tcp socketpublic ModbusTCPMaster(String addr, int port, boolean useRtuOverTcp)
addr - an internet address as resolvable IP name or IP number,
specifying the slave to communicate with.port - the port the slave is listening to.useRtuOverTcp - True if the RTU protocol should be used over TCPpublic ModbusTCPMaster(String addr, int port, int timeout, boolean reconnect)
addr - an internet address as resolvable IP name or IP number,
specifying the slave to communicate with.port - the port the slave is listening to.timeout - Socket timeout in millisecondsreconnect - true if a new connection should be established for each
transaction, false otherwise.public ModbusTCPMaster(String addr, int port, int timeout, boolean reconnect, boolean useRtuOverTcp)
addr - an internet address as resolvable IP name or IP number,
specifying the slave to communicate with.port - the port the slave is listening to.timeout - Socket timeout in millisecondsreconnect - true if a new connection should be established for each
transaction, false otherwise.useRtuOverTcp - True if the RTU protocol should be used over TCPpublic ModbusTCPMaster(String addr, int port, int timeout, boolean reconnect, boolean useRtuOverTcp, Proxy proxy)
addr - an internet address as resolvable IP name or IP number,
specifying the slave to communicate with.port - the port the slave is listening to.timeout - Socket timeout in millisecondsreconnect - true if a new connection should be established for each
transaction, false otherwise.useRtuOverTcp - True if the RTU protocol should be used over TCPproxy - proxy to use on the underlying tcp socketpublic void connect()
throws Exception
connect in class AbstractModbusMasterException - if the connection cannot be established.public void disconnect()
disconnect in class AbstractModbusMasterpublic boolean isReconnecting()
public void setReconnecting(boolean b)
b - true if a new connection should be established for each
transaction, false otherwise.public void setTimeout(int timeout)
AbstractModbusMastersetTimeout in class AbstractModbusMastertimeout - Timeout in millisecondspublic AbstractModbusTransport getTransport()
AbstractModbusMastergetTransport in class AbstractModbusMasterpublic boolean isConnected()
AbstractModbusMasterisConnected in class AbstractModbusMasterpublic boolean equals(Object obj)
ModbusTCPMaster is equal if the underlying TCPMasterConnection is equal. There can't be 2
un-identical ModbusTCPMasters with the same connection at the same time. One of the two, will raise a
SocketException if you start both at the same time, since the socket is only usable by exactly on entitypublic int hashCode()
ModbusTCPMaster is calculated from the unique value of the TCPMasterConnectionCopyright © 2025. All Rights Reserved.