|
|
|
@ -18,6 +18,10 @@ public class MainPage {
|
|
|
|
|
@FXML private VBox vb1;
|
|
|
|
|
@FXML private VBox vb2;
|
|
|
|
|
@FXML private ImageView open;
|
|
|
|
|
@FXML private final Button FirstCaptorButton = new Button();
|
|
|
|
|
@FXML private final Button SecondCaptorButton = new Button();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CPUTemp cpuTemp = new CPUTemp("CPU Captor");
|
|
|
|
|
CapteurVirtuel cV1 = new CapteurVirtuel("CaptVirt1");
|
|
|
|
@ -37,7 +41,7 @@ public class MainPage {
|
|
|
|
|
FirstButton.setOnAction(e -> {
|
|
|
|
|
|
|
|
|
|
vb1.getChildren().clear();
|
|
|
|
|
vb1.getChildren().add(setVboxCPUCaptor());
|
|
|
|
|
vb1.getChildren().add(setDisplayCPUCaptor());
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -47,20 +51,35 @@ public class MainPage {
|
|
|
|
|
|
|
|
|
|
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(setHBoxFirstCaptor());
|
|
|
|
|
vb2.getChildren().add(setHBoxSecondCaptor());
|
|
|
|
|
vb2.getChildren().add(setDisplayFirstCaptor());
|
|
|
|
|
vb2.getChildren().add(setDisplaySecondCaptor());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
FirstCaptorButton.setOnAction(e -> {
|
|
|
|
|
|
|
|
|
|
vb1.getChildren().clear();
|
|
|
|
|
vb1.getChildren().add(setDisplayCaptor(c1));
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
SecondCaptorButton.setOnAction(e -> {
|
|
|
|
|
|
|
|
|
|
vb1.getChildren().clear();
|
|
|
|
|
vb1.getChildren().add(setDisplayCaptor(c2));
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private VBox setVboxCPUCaptor() {
|
|
|
|
|
private VBox setDisplayCPUCaptor() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VBox FirstCaptorCPU = new VBox();
|
|
|
|
@ -117,7 +136,7 @@ public class MainPage {
|
|
|
|
|
return FirstCaptorCPU;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private HBox setHBoxFirstCaptor(){
|
|
|
|
|
private HBox setDisplayFirstCaptor(){
|
|
|
|
|
|
|
|
|
|
HBox Captor1 = new HBox();
|
|
|
|
|
|
|
|
|
@ -125,19 +144,19 @@ public class MainPage {
|
|
|
|
|
FirstCaptorImage.setFitHeight(73);
|
|
|
|
|
FirstCaptorImage.setFitWidth(73);
|
|
|
|
|
|
|
|
|
|
Button FirstCaptorButton = new Button();
|
|
|
|
|
FirstCaptorButton.setText(c1.getName());
|
|
|
|
|
FirstCaptorButton.setFont(new Font("System", 13));
|
|
|
|
|
FirstCaptorButton.setMaxWidth(Double.MAX_VALUE);
|
|
|
|
|
FirstCaptorButton.setAlignment(Pos.CENTER_LEFT);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Captor1.getChildren().add(FirstCaptorImage);
|
|
|
|
|
Captor1.getChildren().add(FirstCaptorButton);
|
|
|
|
|
|
|
|
|
|
return Captor1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private HBox setHBoxSecondCaptor(){
|
|
|
|
|
private HBox setDisplaySecondCaptor(){
|
|
|
|
|
|
|
|
|
|
HBox Captor2 = new HBox();
|
|
|
|
|
|
|
|
|
@ -145,7 +164,6 @@ public class MainPage {
|
|
|
|
|
SecondCaptorImage.setFitHeight(73);
|
|
|
|
|
SecondCaptorImage.setFitWidth(73);
|
|
|
|
|
|
|
|
|
|
Button SecondCaptorButton = new Button();
|
|
|
|
|
SecondCaptorButton.setText(c2.getName());
|
|
|
|
|
SecondCaptorButton.setFont(new Font("System", 13));
|
|
|
|
|
SecondCaptorButton.setMaxWidth(Double.MAX_VALUE);
|
|
|
|
@ -162,7 +180,7 @@ public class MainPage {
|
|
|
|
|
|
|
|
|
|
VBox CaptorVirtual = new VBox();
|
|
|
|
|
|
|
|
|
|
Label ViewTempVirtualCaptor = new Label("Temperature moyenne des sous-capteurs du capteur virtuel : " + cV1.getTempMoyenne() + "°C");
|
|
|
|
|
Label ViewTempVirtualCaptor = new Label("Temperature moyenne des sous-capteurs du capteur virtuel : " + Math.round(cV1.getTempMoyenne()*10.0)/10.0 + "°C");
|
|
|
|
|
|
|
|
|
|
ViewTempVirtualCaptor.setFont(new Font("Arial",20));
|
|
|
|
|
ViewTempVirtualCaptor.setMaxWidth(Double.MAX_VALUE);
|
|
|
|
@ -223,4 +241,61 @@ public class MainPage {
|
|
|
|
|
return CaptorVirtual;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private VBox setDisplayCaptor(Captor cap){
|
|
|
|
|
|
|
|
|
|
VBox Captor = new VBox();
|
|
|
|
|
|
|
|
|
|
Label ViewTempCaptor = new Label("Temperature du capteur " + cap.getName() + " : " + Math.round(cap.getTemperature()*10.0)/10.0 + "°C");
|
|
|
|
|
|
|
|
|
|
ViewTempCaptor.setFont(new Font("Arial",25));
|
|
|
|
|
ViewTempCaptor.setMaxWidth(Double.MAX_VALUE);
|
|
|
|
|
ViewTempCaptor.setAlignment(Pos.CENTER);
|
|
|
|
|
ViewTempCaptor.setWrapText(true);
|
|
|
|
|
|
|
|
|
|
ImageView CaptorImage = new ImageView(new Image("https://static.thenounproject.com/png/7561-200.png"));
|
|
|
|
|
|
|
|
|
|
CaptorImage.setFitWidth(500);
|
|
|
|
|
CaptorImage.setFitHeight(300);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Captor.getChildren().add(CaptorImage);
|
|
|
|
|
Captor.getChildren().add(ViewTempCaptor);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ObservableList<Captor> CaptorObs = FXCollections.observableArrayList(
|
|
|
|
|
TrueCaptor->new ObservableValue[]{
|
|
|
|
|
TrueCaptor.getTemperatureProperty()
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
CaptorObs.addListener((ListChangeListener.Change<? extends Captor> c) ->{
|
|
|
|
|
while (c.next()){
|
|
|
|
|
|
|
|
|
|
if (c.wasUpdated()){
|
|
|
|
|
|
|
|
|
|
Double temp = cap.getTemperature();
|
|
|
|
|
|
|
|
|
|
if (temp < 0){
|
|
|
|
|
|
|
|
|
|
ViewTempCaptor.setStyle("-fx-text-fill : blue");
|
|
|
|
|
|
|
|
|
|
} else if (temp > 30) {
|
|
|
|
|
|
|
|
|
|
ViewTempCaptor.setStyle("-fx-text-fill : red");
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
|
|
ViewTempCaptor.setStyle("-fx-text-fill : black");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
ViewTempCaptor.textProperty().set("Temperature du capteur " + cap.getName() + " : " + Math.round(cap.getTemperature()*10.0)/10.0 + "°C");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
CaptorObs.add(cap);
|
|
|
|
|
|
|
|
|
|
return Captor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|