1
0

changed the field component, made some test and added some comments

This commit is contained in:
Nils Ritler
2023-06-06 17:50:17 +02:00
parent 55fa80c4d4
commit c478c0a7bf
8 changed files with 111 additions and 57 deletions

View File

@@ -7,18 +7,26 @@ public class BooleanRegister extends ModbusRegister{
private boolean value;
private BooleanDataPoint bdp;
/**
* public constructor of the booleanRegister
*
* @param label label of the datapoint
* @param isOutput true if it is an output datapoint
* @param address modbus address of the datapoint
*/
public BooleanRegister(String label, boolean isOutput, int address){
this.bdp = new BooleanDataPoint(label, isOutput);
value = bdp.getValue();
updateMapOfRegisters(bdp, address);
this.bdp = new BooleanDataPoint(label, isOutput); //create an empty datapoint for the NullPointerException
updateMapOfRegisters(label, address); //add the address to the map
}
@Override
public void read() {
bdp.setValue(ModbusAccessor.getMySelf().readBoolean(this.getAddress()));
bdp.setValue(ModbusAccessor.getMySelf().readBoolean(this.getAddress())); //read the value
}
@Override
public void write() {
ModbusAccessor.getMySelf().writeBoolean(this.getAddress(), bdp.getValue());
public void write(DataPoint dp) {
bdp = (BooleanDataPoint) dp; //make the empty datapoint to the desired datapoint, which is to be written on the address
value = bdp.getValue(); //store the value of the datapoint
ModbusAccessor.getMySelf().writeBoolean(this.getAddress(),bdp.getValue()); //write the desired value on the modbus address
}
}