1
0

fix everything for merge Field

This commit is contained in:
2023-06-07 13:42:14 +02:00
parent d88329a50b
commit 5878750109
7 changed files with 31 additions and 13 deletions

View File

@@ -8,6 +8,8 @@ import java.util.HashMap;
public class FloatRegister extends ModbusRegister{
private Float value;
private FloatDataPoint fdp;
private int range;
private int offset;
/**
* public constructor of the Float Register
@@ -18,14 +20,22 @@ public class FloatRegister extends ModbusRegister{
* @param range range of the datapoint value
* @param offset offset of the datapoint value
*/
public FloatRegister(String label, boolean isOutPut, int address, float range, float offset) {
public FloatRegister(String label, boolean isOutPut, int address, int range, int offset) {
this.fdp = new FloatDataPoint(label, isOutPut); //create an empty datapoint for the NullPointerException
updateMapOfRegisters(label,address); //add the address to the map
this.range = range;
this.offset = offset;
}
@Override
public void read() {
fdp.setValue(ModbusAccessor.getMySelf().readFloat(this.getAddress())); //read the value
if(fdp.isOutput()){
return; //if it is an output datapoint, it is not read
}
Float value = ModbusAccessor.getMySelf().readFloat(this.getAddress()); //read the value
value = value * range;
value = value + offset;
fdp.setValue(value);
}
@Override