All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.martiii.modbustcpjava.ModbusMaster Maven / Gradle / Ivy

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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy