BatchRead<Integer> batch = new BatchRead<Integer>();
int add;
int reg;
int typ;
add = FEOHdb.intDB[1][3];
for (int m = 1 ; m < FEOHdb.tDev; m++){
add = FEOHdb.intDB[m][3];
for (int n = 1; n < FEOHdb.mapQty; n++ ){
reg =FEOHdb.mapInt[n][1];
typ =FEOHdb.mapInt[n][2];
batch.addLocator(n-1, BaseLocator.holdingRegister(add, reg, typ));
}
}
try {
master.init();
while (pool) {
batch.setContiguousRequests(false);
BatchResults<Integer> results = master.send(batch);
for (int n = 0; n < FEOHdb.mapQty; n++){
System.out.println("Value = " + (int) results.getValue(n));
}
Thread.sleep(500);
}
-
How to cast BatchResults getValue(n) property to int in ModBus TCP/IP
-
Try casting it to java.lang.Number instead
-
Thank you so much it works.