Merge branch 'smart' into main
This commit is contained in:
@@ -13,11 +13,8 @@ public class FieldConnector implements DataPointListener {
|
||||
private static FieldConnector mySelf = null;
|
||||
private FieldConnector(){
|
||||
|
||||
initialize("LocalHost",1502, "C:/Nils/Hesso/4_Semester/SIN/Minecraft_Electrical_Age_Project/ModbusMap.csv");
|
||||
|
||||
// Subscribe to the update of DataPoints
|
||||
DataPointListener.subscribeUpdate(this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,9 +76,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);
|
||||
createRegister(pathToFile);
|
||||
startPeriodicalPolling();
|
||||
|
||||
ModbusAccessor.getMySelf().connect(host,port); //connect with Modbus
|
||||
createRegister(pathToFile); //read the csv file of the modbus registers
|
||||
startPeriodicalPolling(); //start periodical reading of the float values
|
||||
|
||||
}
|
||||
private void pushToField(String label, String value){
|
||||
System.out.println("Field: " + label + " " + value);
|
||||
@@ -100,6 +99,7 @@ public class FieldConnector implements DataPointListener {
|
||||
public void startPeriodicalPolling(){
|
||||
Timer pollTimer = new Timer();
|
||||
PollTask pollTask = new PollTask();
|
||||
pollTimer.scheduleAtFixedRate(pollTask,0,100);
|
||||
|
||||
pollTimer.scheduleAtFixedRate(pollTask,0,2000);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user