use of com.ghgande.j2mod.modbus.msg.WriteCoilResponse in project SmartApplianceEnabler by camueller.
the class WriteCoilExecutor method execute.
@Override
public void execute(TCPMasterConnection con, int slaveAddress) throws ModbusException {
WriteCoilRequest req = new WriteCoilRequest(Integer.parseInt(registerAddress, 16), coil);
req.setUnitID(slaveAddress);
ModbusTCPTransaction trans = new ModbusTCPTransaction(con);
trans.setRequest(req);
trans.execute();
WriteCoilResponse res = (WriteCoilResponse) trans.getResponse();
if (res != null) {
result = res.getCoil();
logger.debug("{}: Write coil register={} coil={} result={}", applianceId, registerAddress, coil, result);
} else {
logger.error("{}: No response received.", applianceId);
}
}
use of com.ghgande.j2mod.modbus.msg.WriteCoilResponse in project SmartApplianceEnabler by camueller.
the class WriteCoilExecutorImpl method execute.
@Override
public void execute(TCPMasterConnection con, int slaveAddress) throws ModbusException {
WriteCoilRequest req = new WriteCoilRequest(getAddress(), value);
req.setUnitID(slaveAddress);
ModbusTCPTransaction trans = new ModbusTCPTransaction(con);
trans.setRequest(req);
trans.execute();
WriteCoilResponse res = (WriteCoilResponse) trans.getResponse();
if (res != null) {
result = res.getCoil();
logger.debug("{}: Write coil register={} coil={} confirmedValue={}", getApplianceId(), getAddress(), value, result);
} else {
logger.error("{}: No response received.", getApplianceId());
}
}
Aggregations