use of com.ghgande.j2mod.modbus.msg.ReadInputDiscretesResponse in project SmartApplianceEnabler by camueller.
the class ReadDiscreteInputExecutorImpl method execute.
@Override
public void execute(TCPMasterConnection con, int slaveAddress) throws ModbusException {
logger.trace("{}: Reading discrete input register={}", getApplianceId(), getAddress());
ReadInputDiscretesRequest req = new ReadInputDiscretesRequest(getAddress(), 1);
req.setUnitID(slaveAddress);
ModbusTCPTransaction trans = new ModbusTCPTransaction(con);
trans.setRequest(req);
trans.execute();
ReadInputDiscretesResponse res = (ReadInputDiscretesResponse) trans.getResponse();
if (res != null) {
discrete = res.getDiscreteStatus(0);
logger.debug("{}: Discrete input register={} value={}", getApplianceId(), getAddress(), discrete);
} else {
logger.error("{}: No response received.", getApplianceId());
}
}
Aggregations