From 4b3a0bedd49b580226de447c541f9d1acd9806bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= <63239207+Klagarge@users.noreply.github.com> Date: Thu, 25 May 2023 21:17:11 +0200 Subject: [PATCH 1/9] Change update DataPoints by a subscription way --- src/main/java/ch/hevs/isi/core/DataPoint.java | 6 +++--- .../java/ch/hevs/isi/core/DataPointListener.java | 14 ++++++++++++++ .../java/ch/hevs/isi/db/DatabaseConnector.java | 3 +++ .../java/ch/hevs/isi/field/FieldConnector.java | 2 ++ src/main/java/ch/hevs/isi/web/WebConnector.java | 2 ++ src/test/java/Database.java | 4 ++++ 6 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/main/java/ch/hevs/isi/core/DataPoint.java b/src/main/java/ch/hevs/isi/core/DataPoint.java index 47f51e8..fc6287e 100644 --- a/src/main/java/ch/hevs/isi/core/DataPoint.java +++ b/src/main/java/ch/hevs/isi/core/DataPoint.java @@ -22,9 +22,9 @@ public abstract class DataPoint{ } else { dataPointMap.replace(this.label, this); } - DatabaseConnector.getMySelf().onNewValue(this); - WebConnector.getMySelf().onNewValue(this); - FieldConnector.getMySelf().onNewValue(this); + + // Update every connector + DataPointListener.listeners.forEach(listener -> listener.onNewValue(this)); } public static DataPoint getDataPointFromLabel(String label){ if( !dataPointMap.containsKey(label) ){ diff --git a/src/main/java/ch/hevs/isi/core/DataPointListener.java b/src/main/java/ch/hevs/isi/core/DataPointListener.java index d2164ee..fdeded5 100644 --- a/src/main/java/ch/hevs/isi/core/DataPointListener.java +++ b/src/main/java/ch/hevs/isi/core/DataPointListener.java @@ -1,6 +1,20 @@ package ch.hevs.isi.core; +import java.util.Vector; + public interface DataPointListener { + // Vector of listeners + Vector listeners = new Vector<>(); + void onNewValue(DataPoint dp); + + /** + * Subscribe to the update of the DataPoint + * @param listener the listener to subscribe + */ + static void subscribeUpdate(DataPointListener listener){ + // Call by final class for subscribe update + listeners.add(listener); + } } diff --git a/src/main/java/ch/hevs/isi/db/DatabaseConnector.java b/src/main/java/ch/hevs/isi/db/DatabaseConnector.java index e91edb6..0f094f6 100644 --- a/src/main/java/ch/hevs/isi/db/DatabaseConnector.java +++ b/src/main/java/ch/hevs/isi/db/DatabaseConnector.java @@ -56,6 +56,9 @@ public class DatabaseConnector implements DataPointListener { if (bucket == null){ bucket = properties.getProperty("BUCKET"); } + + // Subscribe to the update of DataPoints + DataPointListener.subscribeUpdate(this); } /** diff --git a/src/main/java/ch/hevs/isi/field/FieldConnector.java b/src/main/java/ch/hevs/isi/field/FieldConnector.java index 3180d21..a9c85ea 100644 --- a/src/main/java/ch/hevs/isi/field/FieldConnector.java +++ b/src/main/java/ch/hevs/isi/field/FieldConnector.java @@ -10,6 +10,8 @@ public class FieldConnector implements DataPointListener { private FieldConnector(){ + // Subscribe to the update of DataPoints + DataPointListener.subscribeUpdate(this); } public static FieldConnector getMySelf(){ diff --git a/src/main/java/ch/hevs/isi/web/WebConnector.java b/src/main/java/ch/hevs/isi/web/WebConnector.java index fd59f71..449e011 100644 --- a/src/main/java/ch/hevs/isi/web/WebConnector.java +++ b/src/main/java/ch/hevs/isi/web/WebConnector.java @@ -8,6 +8,8 @@ public class WebConnector implements DataPointListener { private WebConnector (){ + // Subscribe to the update of DataPoints + DataPointListener.subscribeUpdate(this); } public static WebConnector getMySelf(){ diff --git a/src/test/java/Database.java b/src/test/java/Database.java index 70815ef..9d9250a 100644 --- a/src/test/java/Database.java +++ b/src/test/java/Database.java @@ -3,6 +3,8 @@ import ch.hevs.isi.core.BooleanDataPoint; import ch.hevs.isi.core.DataPoint; import ch.hevs.isi.core.FloatDataPoint; import ch.hevs.isi.db.DatabaseConnector; +import ch.hevs.isi.field.FieldConnector; +import ch.hevs.isi.web.WebConnector; import java.io.FileInputStream; import java.io.InputStream; @@ -16,6 +18,8 @@ public class Database { BooleanDataPoint solarPanel = new BooleanDataPoint("REMOTE_SOLAR_SW", true); DatabaseConnector.getMySelf().initialize(null); + FieldConnector.getMySelf().initialize(null, 0); + WebConnector.getMySelf().initialize(null, 0); clock.setValue(0f); From c5a1e49e60c96121bb468667a061a4992c5fac24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= <63239207+Klagarge@users.noreply.github.com> Date: Thu, 25 May 2023 21:20:20 +0200 Subject: [PATCH 2/9] Remove unused import --- src/main/java/ch/hevs/isi/core/DataPoint.java | 4 ---- src/main/java/ch/hevs/isi/db/DatabaseConnector.java | 4 ++-- src/main/java/ch/hevs/isi/field/FieldConnector.java | 1 - src/test/java/Database.java | 5 ----- 4 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/main/java/ch/hevs/isi/core/DataPoint.java b/src/main/java/ch/hevs/isi/core/DataPoint.java index fc6287e..cfc5543 100644 --- a/src/main/java/ch/hevs/isi/core/DataPoint.java +++ b/src/main/java/ch/hevs/isi/core/DataPoint.java @@ -1,9 +1,5 @@ package ch.hevs.isi.core; -import ch.hevs.isi.db.DatabaseConnector; -import ch.hevs.isi.field.FieldConnector; -import ch.hevs.isi.web.WebConnector; - import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/ch/hevs/isi/db/DatabaseConnector.java b/src/main/java/ch/hevs/isi/db/DatabaseConnector.java index 0f094f6..0b17712 100644 --- a/src/main/java/ch/hevs/isi/db/DatabaseConnector.java +++ b/src/main/java/ch/hevs/isi/db/DatabaseConnector.java @@ -24,7 +24,7 @@ public class DatabaseConnector implements DataPointListener { private URL urlForWrite = null; // URL of the InfluxDB server private HttpURLConnection con = null; // Connection to the InfluxDB server private boolean initialized = false; // Boolean to know if the database connector is initialized - private TimeManager _timeManager = new TimeManager(3); // Time manager to manage the time of the data points + private final TimeManager _timeManager = new TimeManager(3); // Time manager to manage the time of the data points private long _timestamp = 0; // Timestamp of the data points String default_token = System.getenv("SECRET_TOKEN"); // Token to access the InfluxDB server public static String url = null; // URL of the InfluxDB server @@ -132,7 +132,7 @@ public class DatabaseConnector implements DataPointListener { */ private void pushToDatabase(DataPoint dp) { // Initialize the database connector if not already done - if(initialized == false){ + if(!initialized){ initialize(null); } diff --git a/src/main/java/ch/hevs/isi/field/FieldConnector.java b/src/main/java/ch/hevs/isi/field/FieldConnector.java index a9c85ea..2720929 100644 --- a/src/main/java/ch/hevs/isi/field/FieldConnector.java +++ b/src/main/java/ch/hevs/isi/field/FieldConnector.java @@ -2,7 +2,6 @@ package ch.hevs.isi.field; import ch.hevs.isi.core.DataPoint; import ch.hevs.isi.core.DataPointListener; -import ch.hevs.isi.core.FloatDataPoint; public class FieldConnector implements DataPointListener { diff --git a/src/test/java/Database.java b/src/test/java/Database.java index 9d9250a..3ea14f7 100644 --- a/src/test/java/Database.java +++ b/src/test/java/Database.java @@ -1,15 +1,10 @@ import ch.hevs.isi.MinecraftController; import ch.hevs.isi.core.BooleanDataPoint; -import ch.hevs.isi.core.DataPoint; import ch.hevs.isi.core.FloatDataPoint; import ch.hevs.isi.db.DatabaseConnector; import ch.hevs.isi.field.FieldConnector; import ch.hevs.isi.web.WebConnector; -import java.io.FileInputStream; -import java.io.InputStream; -import java.util.Properties; - public class Database { public static void main(String[] args) { MinecraftController.ERASE_PREVIOUS_DATA_INB_DB = true; From df941eea489514725f7f0e58b56ee0bf58c63660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= <63239207+Klagarge@users.noreply.github.com> Date: Thu, 25 May 2023 21:22:59 +0200 Subject: [PATCH 3/9] small polish --- src/main/java/ch/hevs/isi/core/DataPoint.java | 3 +-- src/main/java/ch/hevs/isi/db/DatabaseConnector.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/ch/hevs/isi/core/DataPoint.java b/src/main/java/ch/hevs/isi/core/DataPoint.java index cfc5543..4259189 100644 --- a/src/main/java/ch/hevs/isi/core/DataPoint.java +++ b/src/main/java/ch/hevs/isi/core/DataPoint.java @@ -26,8 +26,7 @@ public abstract class DataPoint{ if( !dataPointMap.containsKey(label) ){ return null; } else { - DataPoint dp = dataPointMap.get(label); - return dp; + return dataPointMap.get(label); } } diff --git a/src/main/java/ch/hevs/isi/db/DatabaseConnector.java b/src/main/java/ch/hevs/isi/db/DatabaseConnector.java index 0b17712..163d6d2 100644 --- a/src/main/java/ch/hevs/isi/db/DatabaseConnector.java +++ b/src/main/java/ch/hevs/isi/db/DatabaseConnector.java @@ -19,7 +19,7 @@ import java.util.Properties; public class DatabaseConnector implements DataPointListener { - private Properties properties = new Properties(); // Properties of the config.properties file + private final Properties properties = new Properties(); // Properties of the config.properties file private String fullURL = null; // Full URL of the InfluxDB server private URL urlForWrite = null; // URL of the InfluxDB server private HttpURLConnection con = null; // Connection to the InfluxDB server From be9c484001b245aab080b36421a94bcfee394545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Tue, 6 Jun 2023 13:38:49 +0200 Subject: [PATCH 4/9] add comment on Core --- .../ch/hevs/isi/core/BooleanDataPoint.java | 25 ++++++++++++---- src/main/java/ch/hevs/isi/core/DataPoint.java | 29 ++++++++++++++++--- .../java/ch/hevs/isi/core/FloatDataPoint.java | 25 ++++++++++++---- src/test/java/Database.java | 1 - src/test/java/Web.java | 8 ++--- 5 files changed, 69 insertions(+), 19 deletions(-) diff --git a/src/main/java/ch/hevs/isi/core/BooleanDataPoint.java b/src/main/java/ch/hevs/isi/core/BooleanDataPoint.java index d18131f..dc78181 100644 --- a/src/main/java/ch/hevs/isi/core/BooleanDataPoint.java +++ b/src/main/java/ch/hevs/isi/core/BooleanDataPoint.java @@ -1,27 +1,42 @@ package ch.hevs.isi.core; -import ch.hevs.isi.core.DataPointListener; -import ch.hevs.isi.db.DatabaseConnector; -import ch.hevs.isi.field.FieldConnector; -import ch.hevs.isi.web.WebConnector; public class BooleanDataPoint extends DataPoint{ private boolean value; + /** + * Create a new DataPoint with a label and if is an Output or not + * @param label the label of this DataPoint + * @param isOutput true if this is an Output, false if it's an Input + */ public BooleanDataPoint(String label, boolean isOutput) { super(label, isOutput); } + + /** + * Set the value of this DataPoint and create it if it doesn't exist via the update method + * @param value the value to set + */ public void setValue(boolean value){ this.value = value; - if (getDataPointFromLabel(this.getLabel()) == null){ + if (getDataPointOnListFromLabel(this.getLabel()) == null){ this.update(true); } else { this.update(false); } } + + /** + * Get the value of this DataPoint + * @return the value of this DataPoint + */ public boolean getValue(){ return this.value; } + /** + * Convert this DataPoint to a string + * @return the string representation of this DataPoint + */ public String toString(){ String s; s = this.getLabel(); diff --git a/src/main/java/ch/hevs/isi/core/DataPoint.java b/src/main/java/ch/hevs/isi/core/DataPoint.java index 22d211d..672a20a 100644 --- a/src/main/java/ch/hevs/isi/core/DataPoint.java +++ b/src/main/java/ch/hevs/isi/core/DataPoint.java @@ -4,13 +4,28 @@ import java.util.HashMap; import java.util.Map; public abstract class DataPoint{ - private static Map dataPointMap = new HashMap<>(); - private String label; - private boolean isOutput; + + + public static Map dataPointMap = new HashMap<>(); // Map of all DataPoints + private String label; // Label of this DataPoint + private boolean isOutput; // True if this DataPoint is an output, false if it's an input + + /** + * Constructor of DataPoint + * @param label label of this DataPoint + * @param isOutput true if this DataPoint is an output, false if it's an input + */ protected DataPoint(String label, boolean isOutput){ this.label = label; this.isOutput = isOutput; } + + + /** + * Update the value of this DataPoint and notify every connector + * If this is a new value (doesn't exist), add it to the dataPointMap + * @param isNewValue true if this is a new value, false if it's an update + */ protected void update(boolean isNewValue){ if(isNewValue){ @@ -22,7 +37,13 @@ public abstract class DataPoint{ // Update every connector DataPointListener.listeners.forEach(listener -> listener.onNewValue(this)); } - public static DataPoint getDataPointFromLabel(String label){ + + /** + * Get the DataPoint from the label + * @param label label of the DataPoint + * @return the DataPoint if it exists, null otherwise + */ + public static DataPoint getDataPointOnListFromLabel(String label){ if( !dataPointMap.containsKey(label) ){ return null; } else { diff --git a/src/main/java/ch/hevs/isi/core/FloatDataPoint.java b/src/main/java/ch/hevs/isi/core/FloatDataPoint.java index c168dd4..6941ff8 100644 --- a/src/main/java/ch/hevs/isi/core/FloatDataPoint.java +++ b/src/main/java/ch/hevs/isi/core/FloatDataPoint.java @@ -1,27 +1,42 @@ package ch.hevs.isi.core; -import ch.hevs.isi.db.DatabaseConnector; -import ch.hevs.isi.field.FieldConnector; -import ch.hevs.isi.web.WebConnector; - public class FloatDataPoint extends DataPoint{ private float value; + + /** + * Create a new DataPoint with a label and if is an Output or not + * @param label the label of this DataPoint + * @param isOutput true if this is an Output, false if it's an Input + */ public FloatDataPoint(String label, boolean isOutput) { super(label, isOutput); } + + /** + * Set the value of this DataPoint and create it if it doesn't exist via the update method + * @param value the value to set + */ public void setValue(float value){ this.value = value; - if (getDataPointFromLabel(this.getLabel()) == null){ + if (getDataPointOnListFromLabel(this.getLabel()) == null){ this.update(true); } else { this.update(false); } } + /** + * Get the value of this DataPoint + * @return the value of this DataPoint + */ public float getValue(){ return this.value; } + /** + * Convert this DataPoint to a string + * @return the string representation of this DataPoint + */ public String toString(){ String s; s = this.getLabel(); diff --git a/src/test/java/Database.java b/src/test/java/Database.java index 3ea14f7..f4f7553 100644 --- a/src/test/java/Database.java +++ b/src/test/java/Database.java @@ -13,7 +13,6 @@ public class Database { BooleanDataPoint solarPanel = new BooleanDataPoint("REMOTE_SOLAR_SW", true); DatabaseConnector.getMySelf().initialize(null); - FieldConnector.getMySelf().initialize(null, 0); WebConnector.getMySelf().initialize(null, 0); clock.setValue(0f); diff --git a/src/test/java/Web.java b/src/test/java/Web.java index f289052..ff0c5e6 100644 --- a/src/test/java/Web.java +++ b/src/test/java/Web.java @@ -24,16 +24,16 @@ public class Web { Thread.sleep(2000); if(WebConnector.getMySelf().wss.getConnections().size() > 0){ - FloatDataPoint rfSP = (FloatDataPoint) DataPoint.getDataPointFromLabel("REMOTE_FACTORY_SP"); + FloatDataPoint rfSP = (FloatDataPoint) DataPoint.getDataPointOnListFromLabel("REMOTE_FACTORY_SP"); if(rfSP != null) new FloatDataPoint("FACTORY_ST", true).setValue(rfSP.getValue()); - FloatDataPoint cfSP = (FloatDataPoint) DataPoint.getDataPointFromLabel("REMOTE_COAL_SP"); + FloatDataPoint cfSP = (FloatDataPoint) DataPoint.getDataPointOnListFromLabel("REMOTE_COAL_SP"); if(cfSP != null) new FloatDataPoint("COAL_ST", true).setValue(cfSP.getValue()); - BooleanDataPoint solar = (BooleanDataPoint) DataPoint.getDataPointFromLabel("REMOTE_SOLAR_SW"); + BooleanDataPoint solar = (BooleanDataPoint) DataPoint.getDataPointOnListFromLabel("REMOTE_SOLAR_SW"); if(solar != null) new BooleanDataPoint("SOLAR_CONNECT_ST", true).setValue(solar.getValue()); - BooleanDataPoint wind = (BooleanDataPoint) DataPoint.getDataPointFromLabel("REMOTE_WIND_SW"); + BooleanDataPoint wind = (BooleanDataPoint) DataPoint.getDataPointOnListFromLabel("REMOTE_WIND_SW"); if(wind != null) new BooleanDataPoint("WIND_CONNECT_ST", true).setValue(wind.getValue()); time += 0.1f; From fa54c5fbb372b480d52781b49a1292a46bcdfed0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Tue, 6 Jun 2023 13:51:28 +0200 Subject: [PATCH 5/9] add web on main --- src/config.properties | 8 ++++--- .../java/ch/hevs/isi/MinecraftController.java | 21 ++++++++++++++++--- .../ch/hevs/isi/db/DatabaseConnector.java | 8 +++---- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/config.properties b/src/config.properties index bba40f7..8f4c695 100644 --- a/src/config.properties +++ b/src/config.properties @@ -1,3 +1,5 @@ -URL = https://influx.sdi.hevs.ch -ORG = SIn15 -BUCKET = SIn15 \ No newline at end of file +DB.URL = https://influx.sdi.hevs.ch +DB.ORG = SIn15 +DB.BUCKET = SIn15 +WEB.URL = localhost +WEB.PORT = 8888 \ No newline at end of file diff --git a/src/main/java/ch/hevs/isi/MinecraftController.java b/src/main/java/ch/hevs/isi/MinecraftController.java index 6bc5059..2567af5 100644 --- a/src/main/java/ch/hevs/isi/MinecraftController.java +++ b/src/main/java/ch/hevs/isi/MinecraftController.java @@ -1,13 +1,17 @@ package ch.hevs.isi; -import ch.hevs.isi.core.BooleanDataPoint; -import ch.hevs.isi.core.FloatDataPoint; import ch.hevs.isi.db.DatabaseConnector; import ch.hevs.isi.utils.Utility; +import ch.hevs.isi.web.WebConnector; + +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.Properties; public class MinecraftController { public static boolean ERASE_PREVIOUS_DATA_INB_DB = false; + private static final Properties properties = new Properties(); // Properties of the config.properties file public static void usage() { System.out.println(); @@ -75,7 +79,12 @@ public class MinecraftController { // ------------------------------------ /DO NOT CHANGE THE FOLLOWING LINES ------------------------------------- - // Start coding here ... + // Read the config.properties file + try (InputStream input = new FileInputStream("src/config.properties")) { + properties.load(input); + } catch (Exception e) { + e.printStackTrace(); + } // Initialize the database connector if((dbProtocol != null) && (dbHostName != null)){ @@ -92,5 +101,11 @@ public class MinecraftController { // Initialize the Modbus TCP connector + // Initialize the web server + String host = properties.getProperty("WEB.URL"); + int port = Integer.parseInt(properties.getProperty("WEB.PORT")); + WebConnector.getMySelf().initialize(host, port); + + } } diff --git a/src/main/java/ch/hevs/isi/db/DatabaseConnector.java b/src/main/java/ch/hevs/isi/db/DatabaseConnector.java index 163d6d2..d87b584 100644 --- a/src/main/java/ch/hevs/isi/db/DatabaseConnector.java +++ b/src/main/java/ch/hevs/isi/db/DatabaseConnector.java @@ -48,13 +48,13 @@ public class DatabaseConnector implements DataPointListener { // Get the URL, the organization and the bucket from the config.properties file if their are null if (url == null){ - url = properties.getProperty("URL"); + url = properties.getProperty("DB.URL"); } if (org == null){ - org = properties.getProperty("ORG"); + org = properties.getProperty("DB.ORG"); } if (bucket == null){ - bucket = properties.getProperty("BUCKET"); + bucket = properties.getProperty("DB.BUCKET"); } // Subscribe to the update of DataPoints @@ -80,7 +80,7 @@ public class DatabaseConnector implements DataPointListener { try{ if(urlForWrite == null){ if(url == null){ - url = properties.getProperty("URL"); + url = properties.getProperty("DB.URL"); } fullURL = url + "/api/v2/write?org=" + org + "&bucket=" + bucket; Utility.pDebug("URL: " + fullURL); From 6f51ae034124181ffd7e380217cc62eb7b39ef54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Tue, 6 Jun 2023 13:54:53 +0200 Subject: [PATCH 6/9] fix some warnings --- src/main/java/ch/hevs/isi/core/DataPoint.java | 4 ++-- src/main/java/ch/hevs/isi/db/DatabaseConnector.java | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/ch/hevs/isi/core/DataPoint.java b/src/main/java/ch/hevs/isi/core/DataPoint.java index 672a20a..636ab60 100644 --- a/src/main/java/ch/hevs/isi/core/DataPoint.java +++ b/src/main/java/ch/hevs/isi/core/DataPoint.java @@ -7,8 +7,8 @@ public abstract class DataPoint{ public static Map dataPointMap = new HashMap<>(); // Map of all DataPoints - private String label; // Label of this DataPoint - private boolean isOutput; // True if this DataPoint is an output, false if it's an input + private final String label; // Label of this DataPoint + private final boolean isOutput; // True if this DataPoint is an output, false if it's an input /** * Constructor of DataPoint diff --git a/src/main/java/ch/hevs/isi/db/DatabaseConnector.java b/src/main/java/ch/hevs/isi/db/DatabaseConnector.java index d87b584..c6e5c5e 100644 --- a/src/main/java/ch/hevs/isi/db/DatabaseConnector.java +++ b/src/main/java/ch/hevs/isi/db/DatabaseConnector.java @@ -15,12 +15,13 @@ import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.ProtocolException; import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.Properties; public class DatabaseConnector implements DataPointListener { private final Properties properties = new Properties(); // Properties of the config.properties file - private String fullURL = null; // Full URL of the InfluxDB server private URL urlForWrite = null; // URL of the InfluxDB server private HttpURLConnection con = null; // Connection to the InfluxDB server private boolean initialized = false; // Boolean to know if the database connector is initialized @@ -40,7 +41,7 @@ public class DatabaseConnector implements DataPointListener { */ private DatabaseConnector (){ // Read the config.properties file - try (InputStream input = new FileInputStream("src/config.properties")) { + try (InputStream input = Files.newInputStream(Paths.get("src/config.properties"))) { properties.load(input); } catch (Exception e) { e.printStackTrace(); @@ -77,6 +78,8 @@ public class DatabaseConnector implements DataPointListener { * @param url URL of the database. If null take the URL from the config.properties file */ public void initialize(String url){ + // Full URL of the InfluxDB server + String fullURL = null; try{ if(urlForWrite == null){ if(url == null){ @@ -106,10 +109,6 @@ public class DatabaseConnector implements DataPointListener { con.setRequestProperty("Content-Type", "text/plain"); con.setRequestProperty("Accept", "application/json"); con.setDoOutput(true); - } catch (MalformedURLException e) { - throw new RuntimeException(e); - } catch (ProtocolException e) { - throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } @@ -122,7 +121,7 @@ public class DatabaseConnector implements DataPointListener { data += "}"; Utility.pDebug(data); sendDataToDatabase(data); - fullURL=null; // Reset the full URL + fullURL =null; // Reset the full URL } } From e973693faa13c0497aa15917ef7febc71fbdf05f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Tue, 6 Jun 2023 13:55:53 +0200 Subject: [PATCH 7/9] optimize imports --- src/main/java/ch/hevs/isi/db/DatabaseConnector.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/ch/hevs/isi/db/DatabaseConnector.java b/src/main/java/ch/hevs/isi/db/DatabaseConnector.java index c6e5c5e..cd66e31 100644 --- a/src/main/java/ch/hevs/isi/db/DatabaseConnector.java +++ b/src/main/java/ch/hevs/isi/db/DatabaseConnector.java @@ -7,13 +7,11 @@ import ch.hevs.isi.core.DataPointListener; import ch.hevs.isi.core.FloatDataPoint; import ch.hevs.isi.utils.Utility; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.net.HttpURLConnection; import java.net.MalformedURLException; -import java.net.ProtocolException; import java.net.URL; import java.nio.file.Files; import java.nio.file.Paths; From c478c0a7bf0b76166f11d55c1f1e76f2213da233 Mon Sep 17 00:00:00 2001 From: Nils Ritler <79571155+Slisls@users.noreply.github.com> Date: Tue, 6 Jun 2023 17:50:17 +0200 Subject: [PATCH 8/9] changed the field component, made some test and added some comments --- src/main/java/ch/hevs/isi/core/DataPoint.java | 4 +- .../ch/hevs/isi/field/BooleanRegister.java | 20 +++++++--- .../ch/hevs/isi/field/FieldConnector.java | 39 ++++++++++++------- .../java/ch/hevs/isi/field/FloatRegister.java | 23 ++++++++--- .../ch/hevs/isi/field/ModbusRegister.java | 23 ++++++----- src/main/java/ch/hevs/isi/field/PollTask.java | 2 + src/main/resources/ModbusMap.csv | 27 +++++++++++++ src/test/java/Field.java | 30 +++++--------- 8 files changed, 111 insertions(+), 57 deletions(-) create mode 100644 src/main/resources/ModbusMap.csv diff --git a/src/main/java/ch/hevs/isi/core/DataPoint.java b/src/main/java/ch/hevs/isi/core/DataPoint.java index 6923ae4..1a87291 100644 --- a/src/main/java/ch/hevs/isi/core/DataPoint.java +++ b/src/main/java/ch/hevs/isi/core/DataPoint.java @@ -22,8 +22,8 @@ public abstract class DataPoint{ } else { dataPointMap.replace(this.label, this); } - DatabaseConnector.getMySelf().onNewValue(this); - WebConnector.getMySelf().onNewValue(this); + //DatabaseConnector.getMySelf().onNewValue(this); + //WebConnector.getMySelf().onNewValue(this); FieldConnector.getMySelf().onNewValue(this); } public static DataPoint getDataPointFromLabel(String label){ diff --git a/src/main/java/ch/hevs/isi/field/BooleanRegister.java b/src/main/java/ch/hevs/isi/field/BooleanRegister.java index a71e5f0..71716a0 100644 --- a/src/main/java/ch/hevs/isi/field/BooleanRegister.java +++ b/src/main/java/ch/hevs/isi/field/BooleanRegister.java @@ -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 } } diff --git a/src/main/java/ch/hevs/isi/field/FieldConnector.java b/src/main/java/ch/hevs/isi/field/FieldConnector.java index 3d26045..2991a18 100644 --- a/src/main/java/ch/hevs/isi/field/FieldConnector.java +++ b/src/main/java/ch/hevs/isi/field/FieldConnector.java @@ -12,8 +12,9 @@ import java.util.Timer; 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"); + initialize("LocalHost",1502, "src/main/resources/ModbusMap.csv"); } /** @@ -48,14 +49,15 @@ public class FieldConnector implements DataPointListener { float range = new Float(splitLine[5]); // if it is a floatDatapoint, the fifth split is the range of the data float offset = new Float(splitLine[6]); // if it is a floatDatapoint, the sixth split is the offset of the data - /* - // create a float or a boolean register + + // create a float or a boolean register and put it in the map of registers if (splitLine[1].equals("B")){ BooleanRegister b = new BooleanRegister(label, isOutput, address); + b.updateMapOfRegisters(label, address); //save the register in map, the key is the label of the datapoint } else if(splitLine[1].equals("F")){ FloatRegister f = new FloatRegister(label, isOutput, address, range, offset); + f.updateMapOfRegisters(label, address); //save the register in map, the key is the label of the datapoint } - */ } } catch(FileNotFoundException e){ @@ -75,18 +77,29 @@ 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 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); } @Override public void onNewValue(DataPoint dp) { - ModbusRegister mR = ModbusRegister.getRegisterFromDatapoint(dp); - mR.write(); - pushToField(dp.getLabel(),dp.toString()); + ModbusRegister mR = ModbusRegister.getRegisterFromDatapoint(dp); //search the corresponding register to the datapoint + if(dp.isOutput()){ //write only on the datapoints, which are outputs + if(dp.getLabel().equals("REMOTE_SOLAR_SW") //write only boolean outputs + ||dp.getLabel().equals("REMOTE_WIND_SW") + ||dp.getLabel().equals("SOLAR_CONNECT_ST") + ||dp.getLabel().equals("WIND_CONNECT_ST")){ + BooleanRegister br = (BooleanRegister) ModbusRegister.getRegisterFromDatapoint(dp); //create a booleanregister, because they are only boolean datapoints + br.write(dp); //write with the correct dp value + }else{ //write only float outputs + FloatRegister fr = (FloatRegister) ModbusRegister.getRegisterFromDatapoint(dp); //create a floatregister, because they are only float datapoints + fr.write(dp); //write with the correct dp value + } + pushToField(dp.getLabel(),dp.toString()); + } } /** @@ -94,8 +107,8 @@ public class FieldConnector implements DataPointListener { * in our case it is the reading of the modbus registers */ public void startPeriodicalPolling(){ - Timer pollTimer = new Timer(); - PollTask pollTask = new PollTask(); - pollTimer.scheduleAtFixedRate(pollTask,0,100); + 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 } } diff --git a/src/main/java/ch/hevs/isi/field/FloatRegister.java b/src/main/java/ch/hevs/isi/field/FloatRegister.java index 214bcf0..cf27828 100644 --- a/src/main/java/ch/hevs/isi/field/FloatRegister.java +++ b/src/main/java/ch/hevs/isi/field/FloatRegister.java @@ -8,19 +8,30 @@ import java.util.HashMap; public class FloatRegister extends ModbusRegister{ private Float value; private FloatDataPoint fdp; + + /** + * public constructor of the Float Register + * + * @param label label of the datapoint + * @param isOutPut true if it is an output datapoint + * @param address modbus address of the datapoint + * @param range range of the datapoint value + * @param offset offset of the datapoint value + */ public FloatRegister(String label, boolean isOutPut, int address, float range, float offset) { - this.fdp = new FloatDataPoint(label, isOutPut); - value = fdp.getValue(); - updateMapOfRegisters(fdp,address); + this.fdp = new FloatDataPoint(label, isOutPut); //create an empty datapoint for the NullPointerException + updateMapOfRegisters(label,address); //add the address to the map } @Override public void read() { - fdp.setValue(ModbusAccessor.getMySelf().readFloat(this.getAddress())); + fdp.setValue(ModbusAccessor.getMySelf().readFloat(this.getAddress())); //read the value } @Override - public void write() { - ModbusAccessor.getMySelf().writeFloat(this.getAddress(), fdp.getValue()); + public void write(DataPoint dp) { + fdp = (FloatDataPoint) dp; //make the empty datapoint to the desired datapoint, which is to be written on the address + value = fdp.getValue(); //store the value of the datapoint + ModbusAccessor.getMySelf().writeFloat(this.getAddress(), fdp.getValue()); //write the desired value on the modbus address } } \ No newline at end of file diff --git a/src/main/java/ch/hevs/isi/field/ModbusRegister.java b/src/main/java/ch/hevs/isi/field/ModbusRegister.java index f963845..6c87cff 100644 --- a/src/main/java/ch/hevs/isi/field/ModbusRegister.java +++ b/src/main/java/ch/hevs/isi/field/ModbusRegister.java @@ -7,7 +7,6 @@ import java.util.HashMap; public abstract class ModbusRegister { private int address; - /** * get the address of the modbus register * @return address of the modbus register @@ -15,29 +14,35 @@ public abstract class ModbusRegister { public int getAddress() { return address; } - private final static HashMap mapOfRegisters = new HashMap<>(); + private final static HashMap mapOfRegisters = new HashMap<>(); /** * get the modbus register from the desired datapoint * @param dp the desired datapoint - * @return modbus register + * @return modbus adress of the datapoint */ public static ModbusRegister getRegisterFromDatapoint(DataPoint dp){ - return mapOfRegisters.get(dp); + return mapOfRegisters.get(dp.getLabel()); //search the modbus address of the datapoint-label } - public void updateMapOfRegisters(DataPoint dp, int address){ + + /** + * add an register to the map of the modbus addresses + * @param label label of the datapoint + * @param address modbus address of the datapoint + */ + public void updateMapOfRegisters(String label, int address){ this.address = address; - mapOfRegisters.put(dp,this); + mapOfRegisters.put(label,this); //add an address to the map with the corresponding datapoint-label } /** * read periodically each modbus register */ public static void poll(){ - for (ModbusRegister mr : mapOfRegisters.values()){ - mr.read(); //read all values (registers) of the map + for (ModbusRegister mr : mapOfRegisters.values()){ //read through all the values (modbus addresses) of the map + mr.read(); //read each datapoint, which address is stored in the map } } public abstract void read(); //abstract prototype of the method read - public abstract void write(); //abstract prototype of the method read + public abstract void write(DataPoint dp); //abstract prototype of the method read } diff --git a/src/main/java/ch/hevs/isi/field/PollTask.java b/src/main/java/ch/hevs/isi/field/PollTask.java index a01ccc2..8fe9204 100644 --- a/src/main/java/ch/hevs/isi/field/PollTask.java +++ b/src/main/java/ch/hevs/isi/field/PollTask.java @@ -1,5 +1,7 @@ package ch.hevs.isi.field; +import ch.hevs.isi.core.DataPoint; + import java.util.TimerTask; public class PollTask extends TimerTask { diff --git a/src/main/resources/ModbusMap.csv b/src/main/resources/ModbusMap.csv new file mode 100644 index 0000000..dc684e3 --- /dev/null +++ b/src/main/resources/ModbusMap.csv @@ -0,0 +1,27 @@ +Label;Type [FLOAT|Boolean];Input;Output;Address;Range;Offset +GRID_U_FLOAT;F;Y;N;89;1000;0 +BATT_P_FLOAT;F;Y;N;57;6000;-3000 +BATT_CHRG_FLOAT;F;Y;N;49;1;0 +SOLAR_P_FLOAT;F;Y;N;61;1500;0 +WIND_P_FLOAT;F;Y;N;53;1000;0 +COAL_P_FLOAT;F;Y;N;81;600;0 +COAL_AMOUNT;F;Y;N;65;1;0 +HOME_P_FLOAT;F;Y;N;101;1000;0 +PUBLIC_P_FLOAT;F;Y;N;97;500;0 +FACTORY_P_FLOAT;F;Y;N;105;2000;0 +BUNKER_P_FLOAT;F;Y;N;93;500;0 +WIND_FLOAT;F;Y;N;301;1;0 +WEATHER_FLOAT;F;Y;N;305;1;0 +WEATHER_FORECAST_FLOAT;F;Y;N;309;1;0 +WEATHER_COUNTDOWN_FLOAT;F;Y;;313;600;0 +CLOCK_FLOAT;F;Y;N;317;1;0 +REMOTE_COAL_SP;F;Y;Y;209;1;0 +REMOTE_FACTORY_SP;F;Y;Y;205;1;0 +REMOTE_SOLAR_SW;B;Y;Y;401;1;0 +REMOTE_WIND_SW;B;Y;Y;405;1;0 +FACTORY_ENERGY;F;Y;N;341;3600000;0 +SCORE;F;Y;N;345;3600000;0 +COAL_ST;F;Y;N;601;1;0 +FACTORY_ST;F;Y;N;605;1;0 +SOLAR_CONNECT_ST;B;Y;N;609;1;0 +WIND_CONNECT_ST;B;Y;N;613;1;0 diff --git a/src/test/java/Field.java b/src/test/java/Field.java index 7cd5802..fe282c5 100644 --- a/src/test/java/Field.java +++ b/src/test/java/Field.java @@ -7,28 +7,16 @@ import ch.hevs.isi.field.FloatRegister; public class Field { public static void main(String[] args) { + //create an FieldConnector + //reads the datapoint values and displays them in the consol + FieldConnector.getMySelf().initialize("LocalHost", 1502,"src/main/resources/ModbusMap.csv"); - //FloatRegister fRI = new FloatRegister("GRID_U_FLOAT",false,89); - BooleanRegister bRI = new BooleanRegister("SOLAR_CONNECT_ST", false ,609); - FieldConnector.getMySelf().startPeriodicalPolling(); + //create two datapoint to write a new value to them + BooleanDataPoint solarPanel = new BooleanDataPoint("REMOTE_SOLAR_SW", true); + FloatDataPoint remoteFactorySp = new FloatDataPoint("REMOTE_FACTORY_SP", true); - //FloatRegister fRO = new FloatRegister("REMOTE_FACTORY_SP",true,205); - BooleanRegister bRO = new BooleanRegister("REMOTE_SOLAR_SW", true ,401); - - /* - fRO.fdp.setValue(0.8F); - bRO.bdp.setValue(true); - */ - - while(true) - { - /* - float value = fRI.dataPoint.getValue()*1000; - System.out.println(value); - */ - /* - System.out.println(bRI.bdp.getValue()); - */ - } + //write to values + remoteFactorySp.setValue(0.74f); + solarPanel.setValue(true); } } From 58787501098a9b426f3493ca1509dbe0d0dfe658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Wed, 7 Jun 2023 13:42:14 +0200 Subject: [PATCH 9/9] fix everything for merge Field --- src/main/java/ch/hevs/isi/MinecraftController.java | 13 +++++++++---- .../java/ch/hevs/isi/db/DatabaseConnector.java | 2 +- .../java/ch/hevs/isi/field/BooleanRegister.java | 3 +++ .../java/ch/hevs/isi/field/FieldConnector.java | 7 ++++--- src/main/java/ch/hevs/isi/field/FloatRegister.java | 14 ++++++++++++-- src/main/resources/ModbusMap.csv | 2 +- src/test/java/Database.java | 3 +-- 7 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/main/java/ch/hevs/isi/MinecraftController.java b/src/main/java/ch/hevs/isi/MinecraftController.java index 2567af5..1e6b4ac 100644 --- a/src/main/java/ch/hevs/isi/MinecraftController.java +++ b/src/main/java/ch/hevs/isi/MinecraftController.java @@ -1,6 +1,7 @@ package ch.hevs.isi; import ch.hevs.isi.db.DatabaseConnector; +import ch.hevs.isi.field.FieldConnector; import ch.hevs.isi.utils.Utility; import ch.hevs.isi.web.WebConnector; @@ -87,18 +88,22 @@ public class MinecraftController { } // Initialize the database connector - if((dbProtocol != null) && (dbHostName != null)){ - DatabaseConnector.url = dbProtocol+ "://" + dbHostName; - DatabaseConnector.getMySelf().initialize(dbProtocol+ "://" + dbHostName); - } if(dbName != null){ DatabaseConnector.org = dbName; } if(dbUserName != null){ DatabaseConnector.bucket = dbUserName; } + if((dbProtocol != null) && (dbHostName != null)){ + DatabaseConnector.url = dbProtocol+ "://" + dbHostName; + Utility.pDebug("Database URL: " + DatabaseConnector.url); + Utility.pDebug("Config: " + properties.getProperty("DB.URL")); + DatabaseConnector.getMySelf().initialize(DatabaseConnector.url); + } // Initialize the Modbus TCP connector + FieldConnector.getMySelf().initialize(modbusTcpHost, modbusTcpPort,"src/main/resources/ModbusMap.csv"); + // Initialize the web server diff --git a/src/main/java/ch/hevs/isi/db/DatabaseConnector.java b/src/main/java/ch/hevs/isi/db/DatabaseConnector.java index cd66e31..63eb65a 100644 --- a/src/main/java/ch/hevs/isi/db/DatabaseConnector.java +++ b/src/main/java/ch/hevs/isi/db/DatabaseConnector.java @@ -178,7 +178,7 @@ public class DatabaseConnector implements DataPointListener { */ @Override public void onNewValue(DataPoint dp) { - if(dp.getLabel().equals("CLOAK_FLOAT")) { + if(dp.getLabel().equals("CLOCK_FLOAT")) { FloatDataPoint fdp = (FloatDataPoint) dp; _timeManager.setTimestamp(fdp.getValue()); _timestamp = _timeManager.getNanosForDB(); diff --git a/src/main/java/ch/hevs/isi/field/BooleanRegister.java b/src/main/java/ch/hevs/isi/field/BooleanRegister.java index 71716a0..205f596 100644 --- a/src/main/java/ch/hevs/isi/field/BooleanRegister.java +++ b/src/main/java/ch/hevs/isi/field/BooleanRegister.java @@ -20,6 +20,9 @@ public class BooleanRegister extends ModbusRegister{ } @Override public void read() { + if(bdp.isOutput()){ + return; //if it is an output datapoint, it is not read + } bdp.setValue(ModbusAccessor.getMySelf().readBoolean(this.getAddress())); //read the value } diff --git a/src/main/java/ch/hevs/isi/field/FieldConnector.java b/src/main/java/ch/hevs/isi/field/FieldConnector.java index 2991a18..411069f 100644 --- a/src/main/java/ch/hevs/isi/field/FieldConnector.java +++ b/src/main/java/ch/hevs/isi/field/FieldConnector.java @@ -15,6 +15,7 @@ public class FieldConnector implements DataPointListener { private FieldConnector(){ initialize("LocalHost",1502, "src/main/resources/ModbusMap.csv"); + DataPointListener.subscribeUpdate(this); } /** @@ -44,10 +45,10 @@ public class FieldConnector implements DataPointListener { String[] splitLine = line.split(";"); // split line between ";" String label = splitLine[0]; // first split is the label of the register - boolean isOutput = splitLine[3].equals("N"); // third split declares if it is an output + boolean isOutput = splitLine[3].equals("Y"); // third split declares if it is an output int address = new Integer((splitLine[4])); // fourth split is the address of the register - float range = new Float(splitLine[5]); // if it is a floatDatapoint, the fifth split is the range of the data - float offset = new Float(splitLine[6]); // if it is a floatDatapoint, the sixth split is the offset of the data + int range = new Integer(splitLine[5]); // if it is a floatDatapoint, the fifth split is the range of the data + int offset = new Integer(splitLine[6]); // if it is a floatDatapoint, the sixth split is the offset of the data // create a float or a boolean register and put it in the map of registers diff --git a/src/main/java/ch/hevs/isi/field/FloatRegister.java b/src/main/java/ch/hevs/isi/field/FloatRegister.java index cf27828..56f5e03 100644 --- a/src/main/java/ch/hevs/isi/field/FloatRegister.java +++ b/src/main/java/ch/hevs/isi/field/FloatRegister.java @@ -8,6 +8,8 @@ import java.util.HashMap; public class FloatRegister extends ModbusRegister{ private Float value; private FloatDataPoint fdp; + private int range; + private int offset; /** * public constructor of the Float Register @@ -18,14 +20,22 @@ public class FloatRegister extends ModbusRegister{ * @param range range of the datapoint value * @param offset offset of the datapoint value */ - public FloatRegister(String label, boolean isOutPut, int address, float range, float offset) { + public FloatRegister(String label, boolean isOutPut, int address, int range, int offset) { this.fdp = new FloatDataPoint(label, isOutPut); //create an empty datapoint for the NullPointerException updateMapOfRegisters(label,address); //add the address to the map + this.range = range; + this.offset = offset; } @Override public void read() { - fdp.setValue(ModbusAccessor.getMySelf().readFloat(this.getAddress())); //read the value + if(fdp.isOutput()){ + return; //if it is an output datapoint, it is not read + } + Float value = ModbusAccessor.getMySelf().readFloat(this.getAddress()); //read the value + value = value * range; + value = value + offset; + fdp.setValue(value); } @Override diff --git a/src/main/resources/ModbusMap.csv b/src/main/resources/ModbusMap.csv index dc684e3..0e6984d 100644 --- a/src/main/resources/ModbusMap.csv +++ b/src/main/resources/ModbusMap.csv @@ -13,7 +13,7 @@ BUNKER_P_FLOAT;F;Y;N;93;500;0 WIND_FLOAT;F;Y;N;301;1;0 WEATHER_FLOAT;F;Y;N;305;1;0 WEATHER_FORECAST_FLOAT;F;Y;N;309;1;0 -WEATHER_COUNTDOWN_FLOAT;F;Y;;313;600;0 +WEATHER_COUNTDOWN_FLOAT;F;Y;N;313;600;0 CLOCK_FLOAT;F;Y;N;317;1;0 REMOTE_COAL_SP;F;Y;Y;209;1;0 REMOTE_FACTORY_SP;F;Y;Y;205;1;0 diff --git a/src/test/java/Database.java b/src/test/java/Database.java index f4f7553..cae80de 100644 --- a/src/test/java/Database.java +++ b/src/test/java/Database.java @@ -8,12 +8,11 @@ import ch.hevs.isi.web.WebConnector; public class Database { public static void main(String[] args) { MinecraftController.ERASE_PREVIOUS_DATA_INB_DB = true; - FloatDataPoint clock = new FloatDataPoint("CLOAK_FLOAT", false); + FloatDataPoint clock = new FloatDataPoint("CLOCK_FLOAT", false); FloatDataPoint gridVoltage = new FloatDataPoint("GRID_U_FLOAT", true); BooleanDataPoint solarPanel = new BooleanDataPoint("REMOTE_SOLAR_SW", true); DatabaseConnector.getMySelf().initialize(null); - WebConnector.getMySelf().initialize(null, 0); clock.setValue(0f);