me.martiii.modbustcpjava.ModbusMaster Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of modbus-tcp-java Show documentation
Show all versions of modbus-tcp-java Show documentation
Modbus-TCP protocol for java.
The newest version!
package me.martiii.modbustcpjava;
import me.martiii.modbustcpjava.net.Callback;
import me.martiii.modbustcpjava.net.NetHandler;
import me.martiii.modbustcpjava.net.Task;
import me.martiii.modbustcpjava.protocol.ModbusHeader;
import me.martiii.modbustcpjava.protocol.ModbusRequest;
public class ModbusMaster {
private NetHandler netHandler;
public ModbusMaster() {
netHandler = new NetHandler();
}
public void setSlaveAddress(String address) {
netHandler.setSlaveAddress(address);
}
public void setSlavePort(int port) {
netHandler.setSlavePort(port);
}
public void request(ModbusHeader header, ModbusRequest request, Callback callback) {
request(header, request, callback, 1000);
}
public void request(ModbusHeader header, ModbusRequest request, Callback callback, int retryTimeout) {
netHandler.executeTask(new Task(header, request, callback), retryTimeout);
}
public void cancelPendingRequests() {
netHandler.cancelPendingRequests();
}
public void close(boolean force) {
netHandler.close(force);
}
}