1
0

Merge branch 'main' into improvement

This commit is contained in:
Rémi Heredero
2023-06-09 12:34:37 +02:00
committed by GitHub
2 changed files with 71 additions and 0 deletions

View File

@@ -15,6 +15,10 @@ public class FieldConnector implements DataPointListener {
private FieldConnector(){
initialize("LocalHost",1502, "src/main/resources/ModbusMap.csv");
// Subscribe to the update of DataPoints
DataPointListener.subscribeUpdate(this);
}
@@ -78,9 +82,11 @@ public class FieldConnector implements DataPointListener {
* @param pathToFile path to the file of all modbus registers (C:/.../ModbusMap.csv)
*/
public void initialize(String host, int port, String pathToFile){
ModbusAccessor.getMySelf().connect(host,port); //connect to the modbus server
createRegister(pathToFile); //create the all needed modbus registers and save them in a map
startPeriodicalPolling(); //start periodical reading of the values
}
private void pushToField(String label, String value){
System.out.println("Field: " + label + " " + value);
@@ -111,5 +117,6 @@ public class FieldConnector implements DataPointListener {
Timer pollTimer = new Timer(); //create a new timer,
PollTask pollTask = new PollTask(); //create a new task to do every period.
pollTimer.scheduleAtFixedRate(pollTask,0,100); //do the run-function of the polltask every period
}
}