changed the field component, made some test and added some comments
This commit is contained in:
@@ -8,19 +8,30 @@ import java.util.HashMap;
|
||||
public class FloatRegister extends ModbusRegister{
|
||||
private Float value;
|
||||
private FloatDataPoint fdp;
|
||||
|
||||
/**
|
||||
* public constructor of the Float Register
|
||||
*
|
||||
* @param label label of the datapoint
|
||||
* @param isOutPut true if it is an output datapoint
|
||||
* @param address modbus address of the datapoint
|
||||
* @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) {
|
||||
this.fdp = new FloatDataPoint(label, isOutPut);
|
||||
value = fdp.getValue();
|
||||
updateMapOfRegisters(fdp,address);
|
||||
this.fdp = new FloatDataPoint(label, isOutPut); //create an empty datapoint for the NullPointerException
|
||||
updateMapOfRegisters(label,address); //add the address to the map
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read() {
|
||||
fdp.setValue(ModbusAccessor.getMySelf().readFloat(this.getAddress()));
|
||||
fdp.setValue(ModbusAccessor.getMySelf().readFloat(this.getAddress())); //read the value
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write() {
|
||||
ModbusAccessor.getMySelf().writeFloat(this.getAddress(), fdp.getValue());
|
||||
public void write(DataPoint dp) {
|
||||
fdp = (FloatDataPoint) dp; //make the empty datapoint to the desired datapoint, which is to be written on the address
|
||||
value = fdp.getValue(); //store the value of the datapoint
|
||||
ModbusAccessor.getMySelf().writeFloat(this.getAddress(), fdp.getValue()); //write the desired value on the modbus address
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user