diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml
new file mode 100644
index 0000000..f16775e
--- /dev/null
+++ b/.idea/libraries/lib.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..3d3ab27
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..576a9fb
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WeatherStation.iml b/WeatherStation.iml
new file mode 100644
index 0000000..4b7d4f3
--- /dev/null
+++ b/WeatherStation.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WeatherStation/.idea/.gitignore b/WeatherStation/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/WeatherStation/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/WeatherStation/.idea/libraries/lib.xml b/WeatherStation/.idea/libraries/lib.xml
new file mode 100644
index 0000000..216df84
--- /dev/null
+++ b/WeatherStation/.idea/libraries/lib.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WeatherStation/.idea/misc.xml b/WeatherStation/.idea/misc.xml
new file mode 100644
index 0000000..a346fd7
--- /dev/null
+++ b/WeatherStation/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WeatherStation/.idea/modules.xml b/WeatherStation/.idea/modules.xml
new file mode 100644
index 0000000..576a9fb
--- /dev/null
+++ b/WeatherStation/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WeatherStation/.idea/uiDesigner.xml b/WeatherStation/.idea/uiDesigner.xml
new file mode 100644
index 0000000..2b63946
--- /dev/null
+++ b/WeatherStation/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/WeatherStation/WeatherStation.iml b/WeatherStation/WeatherStation.iml
new file mode 100644
index 0000000..f85ca6b
--- /dev/null
+++ b/WeatherStation/WeatherStation.iml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WeatherStation/out/production/WeatherStation/launch/Launch.class b/WeatherStation/out/production/WeatherStation/launch/Launch.class
new file mode 100644
index 0000000..87850ec
Binary files /dev/null and b/WeatherStation/out/production/WeatherStation/launch/Launch.class differ
diff --git a/WeatherStation/out/production/WeatherStation/modele/Capteur.class b/WeatherStation/out/production/WeatherStation/modele/Capteur.class
new file mode 100644
index 0000000..adffc53
Binary files /dev/null and b/WeatherStation/out/production/WeatherStation/modele/Capteur.class differ
diff --git a/WeatherStation/out/production/WeatherStation/views/WeatherController.class b/WeatherStation/out/production/WeatherStation/views/WeatherController.class
new file mode 100644
index 0000000..0ac0ddc
Binary files /dev/null and b/WeatherStation/out/production/WeatherStation/views/WeatherController.class differ
diff --git a/WeatherStation/resources/FXML/WeatherStation.fxml b/WeatherStation/resources/FXML/WeatherStation.fxml
new file mode 100644
index 0000000..b2d63fd
--- /dev/null
+++ b/WeatherStation/resources/FXML/WeatherStation.fxml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WeatherStation/resources/images/void.webp b/WeatherStation/resources/images/void.webp
new file mode 100644
index 0000000..607c516
Binary files /dev/null and b/WeatherStation/resources/images/void.webp differ
diff --git a/WeatherStation/src/launch/Launch.java b/WeatherStation/src/launch/Launch.java
new file mode 100644
index 0000000..278eb17
--- /dev/null
+++ b/WeatherStation/src/launch/Launch.java
@@ -0,0 +1,28 @@
+package launch;
+
+import javafx.application.Application;
+import javafx.stage.Stage;
+import modele.ConcreteSensor;
+import modele.Sensor;
+import modele.VirtualSensor;
+import views.WeatherController;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Launch extends Application {
+ @Override
+ public void start(Stage primaryStage) throws Exception {
+ //Create captors here
+ List sensorsList = new ArrayList<>();
+ VirtualSensor virtualSensor = new VirtualSensor(new ArrayList<>(), 0, "testmachin", 54);
+ ConcreteSensor concreteSensor1 = new ConcreteSensor(3);
+ ConcreteSensor concreteSensor2 = new ConcreteSensor(78);
+ virtualSensor.addSensor(concreteSensor1,concreteSensor1.getWeight());
+ virtualSensor.addSensor(concreteSensor2,concreteSensor2.getWeight());
+ sensorsList.add(virtualSensor);
+
+ WeatherController weatherController = new WeatherController(sensorsList,"FXML/WeatherStation.fxml","WeatherStation");
+
+ }
+}
diff --git a/WeatherStation/src/modele/ConcreteSensor.java b/WeatherStation/src/modele/ConcreteSensor.java
new file mode 100644
index 0000000..79a31cb
--- /dev/null
+++ b/WeatherStation/src/modele/ConcreteSensor.java
@@ -0,0 +1,23 @@
+package modele;
+
+public class ConcreteSensor extends Sensor {
+ private double weight;
+
+ public ConcreteSensor(double weight) {
+ this.weight = weight;
+ }
+
+ public double getWeight() {
+ return weight;
+ }
+
+ public void updateTemperature() {
+ }
+
+ @Override
+ public double generateTemperature() {
+ double min = -273.15;
+ double max = 1000;
+ return Math.floor(Math.random() * (max - min + 1) + min); }
+}
+
diff --git a/WeatherStation/src/modele/Sensor.java b/WeatherStation/src/modele/Sensor.java
new file mode 100644
index 0000000..3abeeaf
--- /dev/null
+++ b/WeatherStation/src/modele/Sensor.java
@@ -0,0 +1,28 @@
+package modele;
+
+import javafx.beans.property.*;
+
+public abstract class Sensor {
+ int id;
+ StringProperty name;
+ double weight;
+ private Property temp = new SimpleObjectProperty<>(0d);
+
+ public void setTemp(double tmp){
+ this.temp.setValue(tmp);
+ }
+
+ public double getTemp() {
+ return temp.getValue();
+ }
+ public StringProperty getName(){
+ return name;
+ }
+
+ public Property getTempProperty(){
+ return temp;
+ }
+
+ public abstract double generateTemperature();
+
+}
diff --git a/WeatherStation/src/modele/VirtualSensor.java b/WeatherStation/src/modele/VirtualSensor.java
new file mode 100644
index 0000000..6431fb2
--- /dev/null
+++ b/WeatherStation/src/modele/VirtualSensor.java
@@ -0,0 +1,49 @@
+package modele;
+
+import javafx.beans.property.SimpleStringProperty;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class VirtualSensor extends Sensor {
+ private List sensors =new ArrayList<>();
+ private Map weights = new HashMap<>();
+
+ public VirtualSensor(List sensorsList, int id, String name, int weight) {
+ this.name = new SimpleStringProperty(name);
+ this.id = id;
+ this.weight = weight;
+ }
+
+ public void addSensor(ConcreteSensor sensor, double weight) {
+ sensors.add(sensor);
+ weights.put(sensor, weight);
+ sensor.getTempProperty().addListener((observable, oldValue, newValue) -> updateTemperature());
+ }
+
+ public void updateTemperature() {
+ double tempSum = 0;
+ double weightSum = 0;
+ for (ConcreteSensor sensor : sensors) {
+ tempSum += sensor.getTemp() * weights.get(sensor);
+ weightSum += weights.get(sensor);
+ }
+ setTemp(tempSum / weightSum);
+ }
+
+ @Override
+ public double generateTemperature() {
+ double value = 0;
+ double count = 0;
+ for (Sensor sensor:
+ sensors) {
+ value += sensor.getTemp();
+ count += 1;
+ }
+ value = value/count;
+ return value;
+ }
+}
+
diff --git a/WeatherStation/src/views/FXMLWindow.java b/WeatherStation/src/views/FXMLWindow.java
new file mode 100644
index 0000000..762f8b6
--- /dev/null
+++ b/WeatherStation/src/views/FXMLWindow.java
@@ -0,0 +1,20 @@
+package views;
+
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Parent;
+import javafx.scene.Scene;
+import javafx.stage.Stage;
+
+import java.io.IOException;
+
+public class FXMLWindow extends Stage {
+
+ public FXMLWindow(String title, String url) throws IOException {
+ FXMLLoader fxmlLoader = new FXMLLoader(getClass().getClassLoader().getResource(url));
+ fxmlLoader.setController(this);
+ Parent group = fxmlLoader.load();
+ Scene scene = new Scene(group);
+ this.setScene(scene);
+ this.show();
+ }
+}
diff --git a/WeatherStation/src/views/WeatherController.java b/WeatherStation/src/views/WeatherController.java
new file mode 100644
index 0000000..2945c29
--- /dev/null
+++ b/WeatherStation/src/views/WeatherController.java
@@ -0,0 +1,74 @@
+package views;
+
+import javafx.fxml.FXML;
+import javafx.scene.control.*;
+import modele.ConcreteSensor;
+import modele.Sensor;
+import modele.VirtualSensor;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class WeatherController extends FXMLWindow {
+
+ Sensor sensor;
+ List sensorList;
+
+ @FXML
+ Spinner tempSpinner;
+
+ @FXML
+ TreeView tree;
+ public WeatherController(List sensorsList, String url, String title) throws IOException {
+ super(title, url);
+
+ TreeItem root = new TreeItem<>(sensorsList.get(0));
+ root.setExpanded(true);
+ tree.setRoot(root);
+ sensorList = sensorsList;
+
+ tree.setVisible(true);
+ for (Sensor sensor : sensorsList) {
+ TreeItem sensorItem = new TreeItem<>(sensor);
+ root.getChildren().add(sensorItem);
+ }
+
+
+
+ }
+
+ public void initialize(){
+ //------------------------------------------------------------------------------------------------------
+
+ sensor = new ConcreteSensor(56);
+
+ tree.setCellFactory(param -> new TreeCell() {
+ protected void updateItem(Sensor item, boolean empty) {
+ super.updateItem(item, empty);
+ if (empty) {
+ setText(null);
+ } else {
+ textProperty().bindBidirectional(item.getName());
+ }
+ }
+ });
+
+ //------------------------------------------------------------------------------------------------------
+ // SPINNER
+ tempSpinner.setVisible(true);
+
+ sensor.getTempProperty().addListener((observable, oldValue, newValue) -> {
+ System.out.println("La température a changé de " + oldValue + " à " + newValue);
+ });
+
+ SpinnerValueFactory spinnerValueFactory= new SpinnerValueFactory.DoubleSpinnerValueFactory(-273,10000, sensor.getTemp(), 0.5);
+ tempSpinner.setValueFactory(spinnerValueFactory);
+ tempSpinner.getValueFactory().valueProperty().bindBidirectional(sensor.getTempProperty());
+ sensor.setTemp(sensor.generateTemperature());
+ System.out.println("initialize spinner");
+ System.out.println(tempSpinner.getValueFactory().getValue());
+
+ };
+}
diff --git a/out/production/WeatherStation/FXML/WeatherStation.fxml b/out/production/WeatherStation/FXML/WeatherStation.fxml
new file mode 100644
index 0000000..b2d63fd
--- /dev/null
+++ b/out/production/WeatherStation/FXML/WeatherStation.fxml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/out/production/WeatherStation/images/void.webp b/out/production/WeatherStation/images/void.webp
new file mode 100644
index 0000000..607c516
Binary files /dev/null and b/out/production/WeatherStation/images/void.webp differ
diff --git a/out/production/WeatherStation/launch/Launch.class b/out/production/WeatherStation/launch/Launch.class
new file mode 100644
index 0000000..4c7dfe6
Binary files /dev/null and b/out/production/WeatherStation/launch/Launch.class differ
diff --git a/out/production/WeatherStation/modele/ConcreteSensor.class b/out/production/WeatherStation/modele/ConcreteSensor.class
new file mode 100644
index 0000000..cb528e1
Binary files /dev/null and b/out/production/WeatherStation/modele/ConcreteSensor.class differ
diff --git a/out/production/WeatherStation/modele/Sensor.class b/out/production/WeatherStation/modele/Sensor.class
new file mode 100644
index 0000000..de05671
Binary files /dev/null and b/out/production/WeatherStation/modele/Sensor.class differ
diff --git a/out/production/WeatherStation/modele/VirtualSensor.class b/out/production/WeatherStation/modele/VirtualSensor.class
new file mode 100644
index 0000000..bb285b6
Binary files /dev/null and b/out/production/WeatherStation/modele/VirtualSensor.class differ
diff --git a/out/production/WeatherStation/views/FXMLWindow.class b/out/production/WeatherStation/views/FXMLWindow.class
new file mode 100644
index 0000000..1475ac6
Binary files /dev/null and b/out/production/WeatherStation/views/FXMLWindow.class differ
diff --git a/out/production/WeatherStation/views/WeatherController$1.class b/out/production/WeatherStation/views/WeatherController$1.class
new file mode 100644
index 0000000..4778053
Binary files /dev/null and b/out/production/WeatherStation/views/WeatherController$1.class differ
diff --git a/out/production/WeatherStation/views/WeatherController.class b/out/production/WeatherStation/views/WeatherController.class
new file mode 100644
index 0000000..ffbd92f
Binary files /dev/null and b/out/production/WeatherStation/views/WeatherController.class differ