fix everything for merge Field
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user