From 3b1d829bbf1a1da8cacd4d33fad627c55c775b15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Fri, 5 May 2023 16:25:15 +0200 Subject: [PATCH 1/2] fix dataPointMap --- src/main/java/ch/hevs/isi/core/DataPoint.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/ch/hevs/isi/core/DataPoint.java b/src/main/java/ch/hevs/isi/core/DataPoint.java index f589dd2..47f51e8 100644 --- a/src/main/java/ch/hevs/isi/core/DataPoint.java +++ b/src/main/java/ch/hevs/isi/core/DataPoint.java @@ -4,16 +4,14 @@ 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; public abstract class DataPoint{ - private static Map dataPointMap; + private static Map dataPointMap = new HashMap<>(); private String label; private boolean isOutput; protected DataPoint(String label, boolean isOutput){ - if(dataPointMap.containsKey(label)){ - - } this.label = label; this.isOutput = isOutput; } From 184303ffdb3f5104a7abf2c271c6dc49c92720c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Fri, 5 May 2023 16:26:16 +0200 Subject: [PATCH 2/2] some tests --- .gitignore | 3 +-- .../ch/hevs/isi/db/DatabaseConnector.java | 2 +- .../ch/hevs/isi/field/FieldConnector.java | 7 +------ .../java/ch/hevs/isi/web/WebConnector.java | 2 +- src/test/java/Core.java | 21 +++++++------------ 5 files changed, 12 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index aeb1bd4..a4e6cb4 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,4 @@ /.idea/jarRepositories.xml /.idea/codeStyles /.idea/*.xml -/target/ -# TODO: add your build folder here \ No newline at end of file +/target/ \ No newline at end of file diff --git a/src/main/java/ch/hevs/isi/db/DatabaseConnector.java b/src/main/java/ch/hevs/isi/db/DatabaseConnector.java index 0c9cc8a..3385bee 100644 --- a/src/main/java/ch/hevs/isi/db/DatabaseConnector.java +++ b/src/main/java/ch/hevs/isi/db/DatabaseConnector.java @@ -22,7 +22,7 @@ public class DatabaseConnector implements DataPointListener { } private void pushToDatabase(DataPoint dp){ - System.out.println("To Database: " + dp.toString()); + System.out.println(dp.toString() + " -> Database"); } @Override diff --git a/src/main/java/ch/hevs/isi/field/FieldConnector.java b/src/main/java/ch/hevs/isi/field/FieldConnector.java index 25352de..3180d21 100644 --- a/src/main/java/ch/hevs/isi/field/FieldConnector.java +++ b/src/main/java/ch/hevs/isi/field/FieldConnector.java @@ -23,13 +23,8 @@ public class FieldConnector implements DataPointListener { } - public void uselessTest(){ - FloatDataPoint dp = new FloatDataPoint("Voltage", false); - dp.setValue(5); - } - private void pushToField(DataPoint dp){ - System.out.println("To Field: " + dp.toString()); + System.out.println(dp.toString() + " -> Field"); } @Override diff --git a/src/main/java/ch/hevs/isi/web/WebConnector.java b/src/main/java/ch/hevs/isi/web/WebConnector.java index b484392..fd59f71 100644 --- a/src/main/java/ch/hevs/isi/web/WebConnector.java +++ b/src/main/java/ch/hevs/isi/web/WebConnector.java @@ -21,7 +21,7 @@ public class WebConnector implements DataPointListener { } private void pushToWeb(DataPoint dp){ - System.out.println("To Web: " + dp.toString()); + System.out.println(dp.toString() + " -> Web"); } @Override diff --git a/src/test/java/Core.java b/src/test/java/Core.java index 103c31b..567ac56 100644 --- a/src/test/java/Core.java +++ b/src/test/java/Core.java @@ -1,22 +1,17 @@ import ch.hevs.isi.core.BooleanDataPoint; import ch.hevs.isi.core.FloatDataPoint; -import ch.hevs.isi.field.FieldConnector; public class Core { public static void main(String[] args) { - /* - BooleanDataPoint bDp = new BooleanDataPoint("foo", true); - FloatDataPoint floatDp = new FloatDataPoint("bar", true); - System.out.println(bDp.toString()); - System.out.println(floatDp.toString()); - bDp.setValue(true);; - floatDp.setValue(42); - System.out.println(bDp.toString()); - System.out.println(floatDp.toString()); - */ - FieldConnector fc; - // TODO some test + BooleanDataPoint bDp = new BooleanDataPoint("foo", true); + new FloatDataPoint("bar", true).setValue(42); + bDp.setValue(true); + + + FloatDataPoint v = new FloatDataPoint("Voltage", false); + v.setValue(5); + v.setValue(3.3f); } }