1
0

read and write Field done. pushToField to do

This commit is contained in:
Nils Ritler
2023-05-23 16:02:16 +02:00
parent 88efeaf31a
commit c3f15804b6
6 changed files with 143 additions and 33 deletions

View File

@@ -4,31 +4,33 @@ import ch.hevs.isi.core.DataPoint;
import ch.hevs.isi.core.DataPointListener;
import ch.hevs.isi.core.FloatDataPoint;
import java.util.Timer;
public class FieldConnector implements DataPointListener {
private static FieldConnector mySelf = null;
private FieldConnector(){
}
public static FieldConnector getMySelf(){
if (mySelf == null){
mySelf = new FieldConnector();
}
return mySelf;
}
public void initialize(String host, int port){
ModbusAccessor mbA = ModbusAccessor.getMySelf();
mbA.connect(host, port);
}
private void pushToField(DataPoint dp){
System.out.println(dp.toString() + " -> Field");
}
@Override
public void onNewValue(DataPoint dp) {
pushToField(dp);
ModbusRegister mr = ModbusRegister.getRegisterFromDatapoint(dp);
mr.write();
}
public void periodicalPolling(){
Timer pollTimer = new Timer();
PollTask pollTask = new PollTask();
pollTimer.scheduleAtFixedRate(pollTask,0,2000);
}
}