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

codice antifurto

parent e11386f8
No related branches found
No related tags found
No related merge requests found
Showing
with 129 additions and 0 deletions
public class Timer extends Thread {
private int delay;
private int deltaK; // e' un valore negativo
private Esecutore esec;
private Automa automa;
public Timer(int delay, int deltaK, Esecutore esec, Automa automa) {
this.delay = delay;
this.deltaK = deltaK;
this.esec = esec;
this.automa = automa;
}
public void run() {
while(true) {
while(automa.antifurtoAttivo()) { // finché l'antifurto è acceso
esec.aggiungiVal(deltaK);
try {
Thread.sleep(delay);
} catch(InterruptedException e) {
System.out.println(e);
}
}
}
}
}
File added
{
"riga0": {"stato": 0,
"cmdoff": 0,
"cmdon": 1,
"eventValMaggioreSoglia": 0,
"eventValMinoreSoglia": 0,
"out0":"off",
"out1":"off"
},
"riga1": {"stato": 1,
"cmdoff": 0,
"cmdon": 1,
"eventValMaggioreSoglia": 2,
"eventValMinoreSoglia": 1,
"out0":"on",
"out1":"off"
},
"riga2": {"stato": 2,
"cmdoff": 0,
"cmdon": 2,
"eventValMaggioreSoglia": 2,
"eventValMinoreSoglia": 1,
"out0":"on",
"out1":"on"
}
}
#!/bin/bash
if [ ! -d "/home/debian/hat_home" ]; then mkdir /home/debian/hat_home; fi
#!/bin/bash
status="OFF"
running=$(/usr/bin/pgrep antifurto)
if [ -f "/home/debian/CONFIG/antifurto/STATUS" ]; then status=$(cat /home/debian/CONFIG/antifurto/STATUS); fi
if [ ! -z "$running" ]; then status="OFF"; fi
if [ $status == "ON" ]; then (/home/debian/CONFIG/antifurto/bin/antifurto /home/debian/CONFIG/antifurto &>/dev/null&); fi
#!/bin/bash
status="NONE"
if [ -f "/home/debian/CONFIG/antifurto/STATUS" ]; then status=$(cat /home/debian/CONFIG/antifurto/STATUS); fi
if [ $status == "OFF" ]; then /home/debian/bin/stopag antifurto; fi
connection bridge-pissir-20030784
address luci.local:1883
bridge_cafile /etc/mosquitto/ca_certificates/ca_certificate.pem
tls_version tlsv1.2
try_private false
remote_username gruppo2
remote_password funziona
topic to/all in 2
topic rpc/gruppo2/luci/antifurto in 2
topic from/gruppo2/luci/gpio/+ both 2
topic from/gruppo2/luci/antifurto/description out 1
topic from/gruppo2/luci/antifurto out 1
<?xml version="1.0" ?><set type="pathnames">
<attribute category="generic" name="agenttype" value="antifurto"/>
<attribute category="generic" name="agentname" value="antifurto_$HOST"/>
<attribute category="generic" name="homedir" value="/home/debian/hat_home/antifurto"/>
<attribute category="generic" name="emergency_homedir" value="/home/debian/hat_home/antifurto"/>
<attribute category="generic" name="description" value="Local Antifurto"/>
<attribute category="generic" name="port" value="8090"/>
<attribute category="generic" name="threads" value="threads"/>
<attribute category="generic" name="mqtt_domain" value=""/>
<attribute category="generic" name="mqtt_subdomain" value=""/>
<attribute category="generic" name="mqtt_service" value="antifurto"/>
</set>
<?xml version="1.0" ?><set type="pathnames">
<attribute category="generic" name="log_theme" value="from/$MQTT_DOMAIN/$MQTT_SUBDOMAIN/$MQTT_SERVICE/logger"/>
<attribute category="generic" name="status_theme" value="from/$MQTT_DOMAIN/$MQTT_SUBDOMAIN/$MQTT_SERVICE/$LOCALNAME"/>
<attribute category="generic" name="notify_theme" value="from/any"/>
<attribute category="generic" name="describe_theme" value="from/$MQTT_DOMAIN/$MQTT_SUBDOMAIN/$MQTT_SERVICE/description"/>
<attribute category="generic" name="log_msg" value="{$LOCALNAME:$MESSAGE}"/>
<attribute category="generic" name="status_msg" value="{status:$MESSAGE}"/>
<attribute category="generic" name="notify_msg" value="{$INFOTYPE:$MESSAGE}"/>
<attribute category="generic" name="describe_msg" value=" $MESSAGE "/>
</set>
File added
File added
File added
<?xml version="1.0"?>
<set type="interruttore">
<attribute name="type" value="booleanin"/>
<attribute name="name" value=""/> <!-- DA RIEMPIRE CON IL NOME SPECIFICATO DALL'UTENTE PER QUELL'INTERRUTTORE. SE NON SPECIFICATO, IL NOME SARA' LO STESSO DEL NOME LOGICO DI QUELL'INPUT -->
<attribute name="capename" value=""/> <!-- DA RIEMPIRE CON IL NOME LOGICO DELL'INPUT -->
</set>
<?xml version="1.0"?>
<set type="sensoremovimento">
<attribute name="type" value="booleanin"/>
<attribute name="name" value=""/> <!-- DA RIEMPIRE CON IL NOME SPECIFICATO DALL'UTENTE PER QUEL SENSORE. SE NON SPECIFICATO, IL NOME SARA' LO STESSO DEL NOME LOGICO DI QUELL'INPUT -->
<attribute name="capename" value=""/> <!-- DA RIEMPIRE CON IL NOME LOGICO DELL'INPUT -->
</set>
<?xml version="1.0"?>
<set type="thread">
<attribute category="generic" name="status" value="ON"/>
<attribute category="generic" name="host" value="localhost"/>
<attribute category="generic" name="port" value="1883"/>
<attribute category="topic" name="to/$MQTT_DOMAIN/$MQTT_SUBDOMAIN/$MQTT_SERVICE/#" value="mqtt_sub"/> <!-- Sottoscrivo i messaggi che provengono da qualsiasi mia componente, ovvero dall'interruttore on/off e dai sensori di movimento -->
<attribute category="topic" name="from/$MQTT_DOMAIN/+/gpio/#" value="mqtt_sub"/> <!-- Sottoscrivo i messaggi che notificano il cambiamento di stato dei sensori -->
<attribute category="topic" name="rpc/$MQTT_DOMAIN/$MQTT_SUBDOMAIN/$MQTT_SERVICE" value="mqtt_sub"/> <!-- Su questo topic ricevero' le richieste di inviare il mio stato attuale -->
<attribute category="topic" name="rpc/$MQTT_DOMAIN/$MQTT_SUBDOMAIN/$MQTT_SERVICE/#" value="mqtt_sub"/> <!-- Su questo topic ricevero' le richieste di inviare lo stato delle mie componenti, che prendero' dallo stato corrispondente del gpio -->
<attribute category="topic" name="to/all" value="mqtt_sub"/> <!-- Su questo topic ricevero' un messaggio del tipo {request:descripion.json} Dovro' quindi mandare la mia descrizione json -->
</set>
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