diff --git a/.drone.yml b/.drone.yml
index c8ca2cb..49fbde0 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -14,4 +14,3 @@ steps:
when:
branch:
- master
- depends_on: [ build ]
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..ea434d5
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index f361f06..3e35e9c 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,5 +1,10 @@
+
+
+
+
+
diff --git a/Source/out/production/ProjetJavaFX/fxml/MainPage.fxml b/Source/out/production/ProjetJavaFX/fxml/MainPage.fxml
index f32f5f5..af43f9b 100644
--- a/Source/out/production/ProjetJavaFX/fxml/MainPage.fxml
+++ b/Source/out/production/ProjetJavaFX/fxml/MainPage.fxml
@@ -4,7 +4,7 @@
-
+
@@ -21,6 +21,7 @@
-
+
+
diff --git a/Source/out/production/ProjetJavaFX/model/CPUTemp.class b/Source/out/production/ProjetJavaFX/model/CPUTemp.class
index 4b30bbb..5782d2e 100644
Binary files a/Source/out/production/ProjetJavaFX/model/CPUTemp.class and b/Source/out/production/ProjetJavaFX/model/CPUTemp.class differ
diff --git a/Source/out/production/ProjetJavaFX/model/CapteurVirtuel.class b/Source/out/production/ProjetJavaFX/model/CapteurVirtuel.class
index 613810c..ad17092 100644
Binary files a/Source/out/production/ProjetJavaFX/model/CapteurVirtuel.class and b/Source/out/production/ProjetJavaFX/model/CapteurVirtuel.class differ
diff --git a/Source/out/production/ProjetJavaFX/model/Captor.class b/Source/out/production/ProjetJavaFX/model/Captor.class
index 59e68f0..0f8ab3b 100644
Binary files a/Source/out/production/ProjetJavaFX/model/Captor.class and b/Source/out/production/ProjetJavaFX/model/Captor.class differ
diff --git a/Source/out/production/ProjetJavaFX/model/GenererTemperature.class b/Source/out/production/ProjetJavaFX/model/GenererTemperature.class
deleted file mode 100644
index 941b177..0000000
Binary files a/Source/out/production/ProjetJavaFX/model/GenererTemperature.class and /dev/null differ
diff --git a/Source/out/production/ProjetJavaFX/model/Observateur.class b/Source/out/production/ProjetJavaFX/model/Observateur.class
deleted file mode 100644
index 5966eab..0000000
Binary files a/Source/out/production/ProjetJavaFX/model/Observateur.class and /dev/null differ
diff --git a/Source/out/production/ProjetJavaFX/model/Sujet.class b/Source/out/production/ProjetJavaFX/model/Sujet.class
deleted file mode 100644
index 4f7903a..0000000
Binary files a/Source/out/production/ProjetJavaFX/model/Sujet.class and /dev/null differ
diff --git a/Source/out/production/ProjetJavaFX/view/Image.class b/Source/out/production/ProjetJavaFX/view/Image.class
deleted file mode 100644
index ae3a417..0000000
Binary files a/Source/out/production/ProjetJavaFX/view/Image.class and /dev/null differ
diff --git a/Source/out/production/ProjetJavaFX/view/ImageVue.class b/Source/out/production/ProjetJavaFX/view/ImageVue.class
new file mode 100644
index 0000000..a18a5cb
Binary files /dev/null and b/Source/out/production/ProjetJavaFX/view/ImageVue.class differ
diff --git a/Source/out/production/ProjetJavaFX/view/MainPage.class b/Source/out/production/ProjetJavaFX/view/MainPage.class
index 10f410f..102b3c9 100644
Binary files a/Source/out/production/ProjetJavaFX/view/MainPage.class and b/Source/out/production/ProjetJavaFX/view/MainPage.class differ
diff --git a/Source/out/production/ProjetJavaFX/view/Spinner.class b/Source/out/production/ProjetJavaFX/view/Spinner.class
index 58e2bda..eebc097 100644
Binary files a/Source/out/production/ProjetJavaFX/view/Spinner.class and b/Source/out/production/ProjetJavaFX/view/Spinner.class differ
diff --git a/Source/resource/fxml/MainPage.fxml b/Source/resource/fxml/MainPage.fxml
index f32f5f5..af43f9b 100644
--- a/Source/resource/fxml/MainPage.fxml
+++ b/Source/resource/fxml/MainPage.fxml
@@ -4,7 +4,7 @@
-
+
@@ -21,6 +21,7 @@
-
+
+
diff --git a/Source/resource/img/loading.jpg b/Source/resource/img/loading.jpg
new file mode 100644
index 0000000..0178c68
Binary files /dev/null and b/Source/resource/img/loading.jpg differ
diff --git a/Source/src/model/CPUTemp.java b/Source/src/model/CPUTemp.java
index aac8eea..6744846 100644
--- a/Source/src/model/CPUTemp.java
+++ b/Source/src/model/CPUTemp.java
@@ -6,7 +6,7 @@ import javafx.beans.property.SimpleDoubleProperty;
import java.io.*;
-public class CPUTemp implements GenererTemperature, Runnable {
+public class CPUTemp implements Runnable {
DoubleProperty temperature = new SimpleDoubleProperty(0.0);
@@ -16,7 +16,6 @@ public class CPUTemp implements GenererTemperature, Runnable {
this.name=nom;
genererTemperature();
}
- @Override
public void genererTemperature(){
try{
File temp = new File("/sys/devices/virtual/thermal/thermal_zone6/temp");
diff --git a/Source/src/model/CapteurVirtuel.java b/Source/src/model/CapteurVirtuel.java
index 6943432..cae218a 100644
--- a/Source/src/model/CapteurVirtuel.java
+++ b/Source/src/model/CapteurVirtuel.java
@@ -9,7 +9,7 @@ import javafx.beans.property.StringProperty;
import javafx.collections.*;
import java.util.*;
-public class CapteurVirtuel extends Sujet implements Runnable {
+public class CapteurVirtuel implements Runnable {
private final StringProperty nom;
private final DoubleProperty tempMoyenne = new SimpleDoubleProperty(0);
@@ -54,7 +54,7 @@ public class CapteurVirtuel extends Sujet implements Runnable {
while (true){
Platform.runLater(this::updateData);
try{
- Thread.sleep(1000);
+ Thread.sleep(2000);
}
catch (InterruptedException e){
break;
diff --git a/Source/src/model/GenererTemperature.java b/Source/src/model/GenererTemperature.java
deleted file mode 100644
index 03d0534..0000000
--- a/Source/src/model/GenererTemperature.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package model;
-
-import java.io.IOException;
-
-public interface GenererTemperature {
-
- abstract void genererTemperature() throws IOException;
-
-}
diff --git a/Source/src/model/Observateur.java b/Source/src/model/Observateur.java
deleted file mode 100644
index 58aed6d..0000000
--- a/Source/src/model/Observateur.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package model;
-
-public interface Observateur {
- void update();
-}
diff --git a/Source/src/model/Sujet.java b/Source/src/model/Sujet.java
deleted file mode 100644
index 9afbf05..0000000
--- a/Source/src/model/Sujet.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package model;
-
-import java.util.ArrayList;
-
-public abstract class Sujet {
-
- public ArrayList observateur = new ArrayList();
-
- public void attacher(Observateur o){
- this.observateur.add(o);
- }
-
- public void notifier(){
- for (Observateur o : observateur) {
- o.update();
- }
- }
-}
diff --git a/Source/src/view/Image.java b/Source/src/view/Image.java
deleted file mode 100644
index 94bae0a..0000000
--- a/Source/src/view/Image.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package view;
-
-import model.CapteurVirtuel;
-import model.Observateur;
-
-public class Image implements Observateur {
-
- public float temperature;
-
- /*
- public void __construct(float temperature){
- this.temperature = new Capteur("Test").getTemperature();
- }
- */
- public void initialize(){
-
- }
-
- public void update() {
-
- }
-}
diff --git a/Source/src/view/ImageVue.java b/Source/src/view/ImageVue.java
new file mode 100644
index 0000000..186093e
--- /dev/null
+++ b/Source/src/view/ImageVue.java
@@ -0,0 +1,128 @@
+package view;
+
+import javafx.beans.value.ObservableValue;
+import javafx.collections.*;
+import javafx.fxml.FXML;
+import javafx.scene.Scene;
+import javafx.scene.control.Button;
+import javafx.scene.control.Label;
+import javafx.scene.image.ImageView;
+import javafx.scene.layout.VBox;
+import javafx.scene.text.Font;
+import javafx.stage.Stage;
+import model.CapteurVirtuel;
+import model.Captor;
+import javafx.scene.image.Image;
+import static javafx.application.Platform.exit;
+
+public class ImageVue {
+
+ @FXML private ImageView img = new ImageView(new Image("https://media.istockphoto.com/id/1125717763/fr/vectoriel/ic%C3%B4ne-de-chargement-design-plat-de-vector-illustration.jpg?s=612x612&w=0&k=20&c=3bkStusySjnEyXtfik1gyjWJqKKd-xOhhMizNy9F-W8="));
+ @FXML private Label imgLabel = new Label();
+ @FXML private Button fermer = new Button("Fermer");
+
+ public void setDisplayWindowsCaptorVirtual(CapteurVirtuel cv){
+ setDisplayBothDisplay();
+
+ ObservableList VirtualCaptor = FXCollections.observableArrayList(
+ TrueCaptor->new ObservableValue[]{
+ TrueCaptor.getTempMoyenneProperty()
+ }
+ );
+
+ VirtualCaptor.addListener((ListChangeListener.Change extends CapteurVirtuel> c) ->{
+ while (c.next()){
+
+ if (c.wasUpdated()){
+
+ try {
+
+ Double temp = cv.getTempMoyenne();
+
+ if (temp < 0) {
+
+ img.setImage(new javafx.scene.image.Image("https://static.vecteezy.com/ti/vecteur-libre/p1/1555350-montagne-enneigee-paysage-d-hiver-avec-flocons-de-neige-gratuit-vectoriel.jpg"));
+
+ } else if (temp > 30) {
+
+ img.setImage(new javafx.scene.image.Image("https://png.pngtree.com/thumb_back/fw800/background/20220515/pngtree-cartoon-landscape-with-house-and-summer-nature-scene-image_1367386.jpg"));
+
+ } else {
+
+ img.setImage(new javafx.scene.image.Image("https://www.tunisienumerique.com/wp-content/uploads/2023/01/meteo-nuage-1-compressed-1.jpg"));
+
+ }
+ imgLabel.textProperty().set(Math.round(temp * 10.0) / 10.0 + "°C");
+ }catch (NullPointerException ignored){}
+ }
+ }
+ });
+
+ VirtualCaptor.add(cv);
+ }
+
+ public void setDisplayWindow(Captor cap){
+
+ setDisplayBothDisplay();
+
+ ObservableList CaptorObs = FXCollections.observableArrayList(
+ TrueCaptor->new ObservableValue[]{
+ TrueCaptor.getTemperatureProperty()
+ }
+ );
+
+ CaptorObs.addListener((ListChangeListener.Change extends Captor> c) ->{
+ while (c.next()){
+
+ if (c.wasUpdated()){
+
+ try {
+
+ Double temp = cap.getTemperature();
+
+ if (temp < 0) {
+
+ img.setImage(new javafx.scene.image.Image("https://static.vecteezy.com/ti/vecteur-libre/p1/1555350-montagne-enneigee-paysage-d-hiver-avec-flocons-de-neige-gratuit-vectoriel.jpg"));
+
+ } else if (temp > 30) {
+
+ img.setImage(new javafx.scene.image.Image("https://png.pngtree.com/thumb_back/fw800/background/20220515/pngtree-cartoon-landscape-with-house-and-summer-nature-scene-image_1367386.jpg"));
+
+ } else {
+
+ img.setImage(new javafx.scene.image.Image("https://www.tunisienumerique.com/wp-content/uploads/2023/01/meteo-nuage-1-compressed-1.jpg"));
+
+ }
+ imgLabel.textProperty().set(Math.round(temp * 10.0) / 10.0 + "°C");
+ }catch (NullPointerException ignored){}
+ }
+ }
+ });
+
+ CaptorObs.add(cap);
+ }
+
+ private void setDisplayBothDisplay() {
+ VBox vue = new VBox();
+ vue.setMinSize(600,400);
+
+ img.setFitWidth(600);
+ img.setFitHeight(400);
+
+ imgLabel.setFont(new Font("Arial", 25));
+
+ vue.getChildren().add(img);
+ vue.getChildren().add(imgLabel);
+ vue.getChildren().add(fermer);
+
+ fermer.setOnAction(e -> exit());
+
+ Scene SecondScene = new Scene(vue);
+
+ Stage Image = new Stage();
+ Image.setTitle("Image");
+ Image.setScene(SecondScene);
+ Image.show();
+ }
+}
+
diff --git a/Source/src/view/MainPage.java b/Source/src/view/MainPage.java
index f270188..5a2056f 100644
--- a/Source/src/view/MainPage.java
+++ b/Source/src/view/MainPage.java
@@ -10,9 +10,13 @@ import javafx.scene.image.ImageView;
import javafx.scene.layout.*;
import javafx.scene.text.Font;
import model.*;
+import java.util.Objects;
+import static java.lang.Integer.parseInt;
+import static java.lang.Integer.valueOf;
public class MainPage {
+ @FXML private Pane bottom;
@FXML private Button FirstButton;
@FXML private Button SecondButton;
@FXML private VBox vb1;
@@ -20,13 +24,19 @@ public class MainPage {
@FXML private ImageView open;
@FXML private final Button FirstCaptorButton = new Button();
@FXML private final Button SecondCaptorButton = new Button();
-
-
+ @FXML private final TextField coefCaptor1 = new TextField();
+ @FXML private final TextField coefCaptor2 = new TextField();
+ @FXML private final Button submitButton1 = new Button("Submit");
+ @FXML private final Button submitButton2 = new Button("Submit");
+ @FXML private final Label errorLabel = new Label("mich");
+ @FXML private final Button DetailsButtonVirtual = new Button("Détails");
+ @FXML private final Button DetailsButtonC1 = new Button("Détails");
+ @FXML private final Button DetailsButtonC2 = new Button("Détails");
CPUTemp cpuTemp = new CPUTemp("CPU Captor");
- CapteurVirtuel cV1 = new CapteurVirtuel("CaptVirt1");
- Captor c1 = new Captor("c1");
- Captor c2 = new Captor("c2");
+ static CapteurVirtuel cV1 = new CapteurVirtuel("CaptVirt1");
+ static Captor c1 = new Captor("c1");
+ static Captor c2 = new Captor("c2");
@FXML
public void initialize() {
@@ -40,6 +50,7 @@ public class MainPage {
FirstButton.setOnAction(e -> {
+ bottom.getChildren().clear();
vb1.getChildren().clear();
vb1.getChildren().add(setDisplayCPUCaptor());
@@ -47,16 +58,18 @@ public class MainPage {
SecondButton.setOnAction(e -> {
+ bottom.getChildren().clear();
+ vb1.getChildren().clear();
+ vb1.getChildren().add(setDisplayVirtualCaptor());
+ bottom.getChildren().add(DetailsButtonVirtual);
+
if (!vb2.getChildren().isEmpty()){
open.setImage(new Image("https://www.citypng.com/public/uploads/preview/download-black-right-triangle-png-31629764954y0662peplm.png"));
vb2.getChildren().clear();
- vb1.getChildren().clear();
}else{
- vb1.getChildren().clear();
- vb1.getChildren().add(setDisplayVirtualCaptor());
open.setImage(new Image("https://cdn-icons-png.flaticon.com/512/0/159.png"));
vb2.getChildren().add(setDisplayFirstCaptor());
vb2.getChildren().add(setDisplaySecondCaptor());
@@ -66,19 +79,78 @@ public class MainPage {
FirstCaptorButton.setOnAction(e -> {
+ bottom.getChildren().clear();
vb1.getChildren().clear();
+ errorLabel.textProperty().set("");
vb1.getChildren().add(setDisplayCaptor(c1));
+ bottom.getChildren().add(DetailsButtonC1);
+
});
SecondCaptorButton.setOnAction(e -> {
+ bottom.getChildren().clear();
vb1.getChildren().clear();
+ errorLabel.textProperty().set("");
vb1.getChildren().add(setDisplayCaptor(c2));
+ bottom.getChildren().add(DetailsButtonC2);
+
+ });
+
+
+ submitButton1.setOnAction(e -> {
+ try {
+ if (!(parseInt(coefCaptor1.getText()) >= 0 && parseInt(coefCaptor1.getText()) <= 10)) {
+ errorLabel.textProperty().set("Mettez un coef valide");
+ } else {
+ errorLabel.textProperty().set("Opération validée");
+ c1.setCoef(parseInt(coefCaptor1.getText()));
+ }
+ }
+ catch (NumberFormatException n){
+ errorLabel.textProperty().set("Mettez un coef valide");
+ }
+
+ });
+
+ submitButton2.setOnAction(e -> {
+ try{
+ if (!(parseInt(coefCaptor2.getText()) >= 0 && parseInt(coefCaptor2.getText()) <= 10)) {
+ errorLabel.textProperty().set(String.valueOf(valueOf(parseInt(coefCaptor2.getText()))));
+ }else {
+ errorLabel.textProperty().set("Opération validée");
+ c2.setCoef(parseInt(coefCaptor2.getText()));
+ }
+ }catch (NumberFormatException n){
+ errorLabel.textProperty().set("Mettez un coef valide");
+ }
+
+ });
+ DetailsButtonC1.setOnAction(e -> {
+
+ ImageVue display = new ImageVue();
+ display.setDisplayWindow(c1);
+
+ });
+
+ DetailsButtonC2.setOnAction(e -> {
+
+ ImageVue display = new ImageVue();
+ display.setDisplayWindow(c2);
+
+ });
+
+ DetailsButtonVirtual.setOnAction(e -> {
+ ImageVue display = new ImageVue();
+ display.setDisplayWindowsCaptorVirtual(cV1);
});
+
}
+
+
private VBox setDisplayCPUCaptor() {
@@ -149,7 +221,6 @@ public class MainPage {
FirstCaptorButton.setMaxWidth(Double.MAX_VALUE);
FirstCaptorButton.setAlignment(Pos.CENTER_LEFT);
-
Captor1.getChildren().add(FirstCaptorImage);
Captor1.getChildren().add(FirstCaptorButton);
@@ -245,6 +316,8 @@ public class MainPage {
VBox Captor = new VBox();
+ HBox submitCoef = new HBox();
+
Label ViewTempCaptor = new Label("Temperature du capteur " + cap.getName() + " : " + Math.round(cap.getTemperature()*10.0)/10.0 + "°C");
ViewTempCaptor.setFont(new Font("Arial",25));
@@ -258,9 +331,24 @@ public class MainPage {
CaptorImage.setFitHeight(300);
+
+ Label coefLabel = new Label("Changez le coef (de 1 à 10) : ");
+ coefLabel.setFont(new Font("Arial",20));
+
+ submitCoef.getChildren().add(coefLabel);
+
+ if (Objects.equals(cap.getName(), "c1")) {
+ submitCoef.getChildren().add(coefCaptor1);
+ submitCoef.getChildren().add(submitButton1);
+ } else if (Objects.equals(cap.getName(), "c2")) {
+ submitCoef.getChildren().add(coefCaptor2);
+ submitCoef.getChildren().add(submitButton2);
+ }
+
Captor.getChildren().add(CaptorImage);
Captor.getChildren().add(ViewTempCaptor);
-
+ Captor.getChildren().add(submitCoef);
+ Captor.getChildren().add(errorLabel);
ObservableList CaptorObs = FXCollections.observableArrayList(
TrueCaptor->new ObservableValue[]{
diff --git a/Source/src/view/Spinner.java b/Source/src/view/Spinner.java
index fbc7fd2..e669b55 100644
--- a/Source/src/view/Spinner.java
+++ b/Source/src/view/Spinner.java
@@ -1,22 +1,5 @@
package view;
-import model.CapteurVirtuel;
-import model.Observateur;
+public class Spinner {
-public class Spinner implements Observateur {
-
- public float temperature ;
-
- /*
- public void __construct(float temperature){
- this.temperature = new Capteur("Test").getTemperature();
- }
- */
- public void initialize(){
-
- }
-
- public void update() {
-
- }
}