changed the field component, made some test and added some comments
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user