Skip to content
Snippets Groups Projects
Commit e9295ba5 authored by Elisa Giglio's avatar Elisa Giglio
Browse files

lkjhgf

parent 9db51f3b
No related branches found
No related tags found
No related merge requests found
package code;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
......@@ -15,9 +16,9 @@ public class Automa {
private int statoAttuale;
private String statoInterruttore;
private String statoSuono;
private static final String FILE_AUTOMA = "../automa.json";
public static final String FILE_STATO = "../stato.json";
private static final String FILE_DELTA_SENSORI = "../CONF/deltaSensoriMovimento.json";
private static final String FILE_AUTOMA = "../res/automa.json";
public static final String FILE_STATO = "../res/stato.json";
private static final String FILE_DELTA_SENSORI = "../res/CONF/deltaSensoriMovimento.json";
public Automa() throws JSONException, IOException {
......
package code;
import java.io.IOException;
import java.time.Duration;
import java.time.LocalDateTime;
......@@ -11,7 +12,7 @@ public class Esecutore extends Thread {
private MyQueue<Integer> codaVal; // coda in cui vengono mantenuti i valori da sommare alla variabile valore
private int valore; // variabile numerica cumulativa inizialmente impostata a 0
public final int SOGLIA = 100;
private static int soglia = 100;
private Publisher publisher;
private Automa automa;
private String outputSuono; // nome logico dell'interruttore che fa scattare il suono dell'allarme
......@@ -40,7 +41,7 @@ public class Esecutore extends Thread {
try {
Helper.modificaFileStato(codaVal, false, delta, valore, Automa.FILE_STATO);
if(valore >= SOGLIA && (!automa.allarme()) ) {
if(valore >= soglia && (!automa.allarme()) ) {
publisher.aggiungiComando("to/"+Antifurto.getMqttTree()+"/gpio/"+outputSuono, "{cmd:1}");
tempoAllarme = LocalDateTime.now();
JSONObject statoJson = new JSONObject(Helper.leggiFile(Automa.FILE_STATO));
......@@ -50,7 +51,7 @@ public class Esecutore extends Thread {
if(automa.allarme()) {
LocalDateTime tempoAttuale = LocalDateTime.now();
long durata = Math.abs(Duration.between(tempoAllarme, tempoAttuale).toMinutes());
if(valore < SOGLIA || durata >= DURATA_SUONO || !automa.antifurtoAttivo() ) {
if(valore < soglia || durata >= DURATA_SUONO || !automa.antifurtoAttivo() ) {
publisher.aggiungiComando("to/"+Antifurto.getMqttTree()+"/gpio/"+outputSuono, "{cmd:0}"); // l'allarme viene disattivato
}
}
......
package code;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
......
package code;
import java.util.ArrayList;
public class MyQueue<T> {
......
package code;
import org.json.JSONException;
import org.json.JSONObject;
......
package code;
import org.eclipse.paho.client.mqttv3.MqttException;
......
package code;
import java.io.IOException;
import java.util.Date;
......
package code;
public class Timer extends Thread {
private int delay;
......
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