Skip to content
Snippets Groups Projects
Commit 512d3cf2 authored by Puissegur Alexis's avatar Puissegur Alexis
Browse files

stop

parent a206a954
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ import Bluetooth.BluetoothThread;
import Interfaces.Observable;
import Interfaces.Observer;
import Util.CalendarUtil;
import java.io.IOException;
import java.net.URL;
import java.text.NumberFormat;
import java.util.Calendar;
......@@ -107,7 +108,7 @@ public class FXMLVueController implements Initializable, Observer {
private boolean alert;
private boolean isConnected = false;
private BluetoothManager bluetoothManager;
private BluetoothThread workingThread;
/**
......@@ -134,6 +135,19 @@ public class FXMLVueController implements Initializable, Observer {
if (!(seuil.getText().isEmpty()) && !(Integer.parseInt(seuil.getText())<100)){
seuilError.setText("La valeur du seuil doit être inférieure à 100%");
}
if(newValue != null && Integer.parseInt(newValue) > Integer.parseInt(humidityPlante.getText())){ // STOP
boolean tmp = true;
while(tmp){
try{
System.out.println("STOP");
workingThread.sendInstruction("STOP");
tmp = false;
} catch(IOException e){
e.printStackTrace();
}
}
}
}
});
//Bind the label for the senewValueuil in Accueil and the value in configurations
......@@ -147,8 +161,20 @@ public class FXMLVueController implements Initializable, Observer {
alert = true;
work();
}
else if(alert){
changeImagePlante(false);
else {
if(alert){
changeImagePlante(false);
}
boolean tmp = true;
while(tmp){
try{
System.out.println("STOP");
workingThread.sendInstruction("STOP");
tmp = false;
} catch(IOException e){
e.printStackTrace();
}
}
}
}
});
......@@ -189,6 +215,7 @@ public class FXMLVueController implements Initializable, Observer {
if(isConnected){
try {
bluetoothManager.startThread();
this.workingThread = bluetoothManager.getWorkingThread();
this.activationMessage.setText("Connection bluetooth activée");
this.activationMessage.setStyle("-fx-background-color: #7fca5eff");
this.buttonBluetooth.setDisable(true);
......@@ -204,7 +231,7 @@ public class FXMLVueController implements Initializable, Observer {
*/
@Override
public void update(Observable obs) {
if(obs instanceof BluetoothThread){
if(obs instanceof BluetoothThread && ((BluetoothThread) obs).equals(this.workingThread)){
BluetoothThread t = (BluetoothThread) obs;
String[] values = t.getBuffer().split(";");
......@@ -284,6 +311,28 @@ public class FXMLVueController implements Initializable, Observer {
public void computeGravity(){
int humidity = Integer.parseInt(humidityPlante.getText().replaceFirst("^0+(?!$)", ""));
int seuil = Integer.parseInt(seuil.getText().replaceFirst("^0+(?!$)", ""));
if(humidity < seuil / 2) { // la moitié du seuil = critique, sound
boolean tmp = true;
while(tmp){
try{
this.workingThread.sendInstruction("SOUND");
tmp = false;
} catch(IOException e){
e.printStackTrace();
}
}
} else { // light
boolean tmp = true;
while(tmp){
try{
this.workingThread.sendInstruction("LIGHT");
tmp = false;
} catch(IOException e){
e.printStackTrace();
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment