Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/webif-page
- <?
- . /usr/lib/webif/webif.sh
- ############################################################################
- # Pagina comandi - centrala i2c
- #
- #############################################################################
- header "Info" "System" "<img src=\"/images/telecomando.jpg\" alt=\"@TR<<>>\"/>@TR<< Comandi >>"
- bus=1
- indirizzo=0x3b
- grade="$(echo $(ds1621 -d /dev/i2c-0 -a 0x48))"
- # Già provato con: gradi="$(ds1621 -d /dev/i2c-0 -a 0x48)"
- # gradi="$(/usr/bin/ds1621 -d /dev/i2c-0 -a 0x48)"
- # gradi=`ds1621 -d /dev/i2c-0 -a 0x48`
- #
- #
- # ma non funziona
- for n in $(seq 1 8);do
- eval pin$n="$(cat /etc/centralina/device | sed -n '/Device'$n'/p'| awk '{ print $3 }')"
- done
- gradi="$(echo $(ds1621 -d /dev/i2c-1 -a 0x48))"
- for n in $pin1 $pin2 $pin3 $pin4 $pin5 $pin6 $pin7 $pin8;do
- eval stato$n="$(echo "$(pcf8574 -d /dev/i2c-$bus -a $indirizzo -r -v)" | sed -n '3p' | awk '{ print $('$n') }')"
- done
- for n in $pin1 $pin2 $pin3 $pin4 $pin5 $pin6 $pin7 $pin8;do
- pin=FORM_npin$n
- eval pin=\$$pin
- statozero="0000"
- if equal $pin "ACCENDI" ; then
- eval stato$n="0"
- fi
- if equal $pin "SPEGNI" ; then
- eval stato$n="1"
- fi
- stato="$stato8$stato7$stato6$stato5$stato4$stato3$stato2$stato1"
- statopin2="$stato4$stato3$stato2$stato1"
- statopin1="$stato8$stato7$Stato6$stato5"
- if ! equal $pin " " ;then
- if equal $statopin1 "0000" ;then
- stato="$statopin2"
- fi
- if equal $statopin2 "0000" ;then
- stato="$statopin1$statozero"
- fi
- codice="$(echo "ibase=2; $stato" | bc)"
- codiceesa="$(echo "obase=16; $codice" | bc)"
- echo "$(pcf8574 -d /dev/i2c-$bus -a $indirizzo -w 0x$codiceesa)"
- fi
- done
- done
- if equal $FORM_pin1 "APRI" ; then
- echo "<img src=\"../../../images/clessidra.gif\">"
- echo "Attendi... sto aprendo la porta..."
- stato1="0"
- statochiudi="1"
- statoa="$stato8$stato7$stato6$stato5$stato4$stato3$stato2$stato1"
- statob="$stato8$stato7$stato6$stato5$stato4$stato3$stato2$statochiudi"
- statopin2="$stato1$stato2$stato3$stato4"
- statopin1="$stato5$stato6$Stato7$stato8"
- if equal $statopin1 "0000" ;then
- statoa="$stato4$stato3$stato2$stato1"
- statob="$stato4$stato3$stato2$statochiudi"
- fi
- if equal $statopin2 "0000" ;then
- statoa="$statopin8$stato7$stato6$stato$statozero"
- statob="$statopin8$stato7$stato6$stato$Stato1$stato1$stato1$statochiudi"
- fi
- codicea="$(echo "ibase=2; $statoa" | bc)"
- codiceesaa="$(echo "obase=16; $codicea" | bc)"
- codiceb="$(echo "ibase=2; $statob" | bc)"
- codiceesab="$(echo "obase=16; $codiceb" | bc)"
- echo "$(pcf8574 -d /dev/i2c-$bus -a $indirizzo -w 0x$codiceesaa)"
- sleep 2
- echo "$(pcf8574 -d /dev/i2c-$bus -a $indirizzo -w 0x$codiceesab)"
- cat <<EOF
- <script language="JavaScript" type="text/javascript">
- setTimeout('top.location.href=\"/cgi-bin/webif/centralina/comandi.sh\"',"100")
- </script>
- EOF
- exit
- fi
- if equal $FORM_internet "ABILITA";then
- echo "<img src=\"../../../images/clessidra.gif\">"
- echo "Attendi... sto abilitando l'accesso a Internet"
- uci set network.eth0.vlan0="0 1 2 3 5*"
- /etc/init.d/network restart > /dev/null
- cat <<EOF
- <script language="JavaScript" type="text/javascript">
- setTimeout('top.location.href=\"/cgi-bin/webif/centralina/comandi.sh\"',"3")
- </script>
- EOF
- exit
- fi
- if equal $FORM_internet "DISABILITA";then
- echo "<img src=\"../../../images/clessidra.gif\">"
- echo "Attendi... sto disabilitando l'accesso a Internet"
- uci set network.eth0.vlan0="2 3 5*"
- /etc/init.d/network restart > /dev/null
- cat <<EOF
- <script language="JavaScript" type="text/javascript">
- setTimeout('top.location.href=\"/cgi-bin/webif/centralina/comandi.sh\"',"3")
- </script>
- EOF
- exit
- fi
- if equal $FORM_generale "SPEGNI_TUTTO" ; then
- echo "Attendi... sto chiudendo tutto..."
- echo "<img src=\"../../../images/clessidra.gif\">"
- echo "$(pcf8574 -d /dev/i2c-$bus -a $indirizzo -w 0xff)"
- ocat <<EOF
- <script language="JavaScript" type="text/javascript">
- setTimeout('top.location.href=\"/cgi-bin/webif/centralina/comandi.sh\"',"300")
- </script>
- EOF
- exit
- fi
- cat <<EOF
- <form method="get" action="comandi.sh">
- <p><p><center>
- Temperatura interna: $gradi Gradi
- <table width="40%">
- <tr><td><strong></td><td><strong><center>STATO</td>
- <td><strong><center>COMANDO</strong></td></tr>
- EOF
- cat <<EOF
- <tr><td>Apriporta :</td><td><center><center><img src="/images/chiave.jpg"></td>
- <td><center><input type="submit" name="pin1" value=APRI
- onClick="javascript:return confirm('Vuoi veramente aprire la porta?');"></td></tr>
- EOF
- for n in $pin2 $pin3 $pin4 $pin5 $pin6 $pin7 $pin8;do
- stato="$(echo "$(pcf8574 -d /dev/i2c-$bus -a $indirizzo -r -v)" | sed -n '3p' | awk '{ print $('$n') }')"
- per="$(cat /etc/centralina/device | sed -n '/ '$n'/p'| awk '{ print $2 }')"
- per="$(echo "$per" | sed '/_/s// /g')"
- if equal $stato "0" ; then
- cat <<EOF
- <tr><td>$per:</td><td><center><img src="/images/lamp.jpg"></td>
- <td><center><input type="submit" name="npin$n" value=SPEGNI ></td></tr>
- EOF
- else
- cat <<EOF
- <tr><td>$per :</td><td><center><img src="/images/lamp1.jpg"></td>
- <td><center><input type="submit" name="npin$n" value=ACCENDI ></td></tr>
- EOF
- fi
- done
- accesso="$(echo "$(uci get network.eth0.vlan0)" | awk '{ print $1 }' )"
- if equal $accesso "2";then
- cat <<EOF
- <tr><td>Internet :</td><td><center><img src="/images/internet1.jpg"></td>
- <td><center><input type="submit" name="internet" value="ABILITA"
- onClick="javascript:return confirm('Vuoi veramente abilitare Internet?');"><td></tr>
- EOF
- else
- cat <<EOF
- <tr><td>Internet :</td><td><center><img src="/images/internet.jpg"></td>
- <td><center><input type="submit" name="internet" value="DISABILITA"
- onClick="javascript:return confirm('Vuoi veramente dasabilitare Internet?');"></td></tr>
- EOF
- fi
- cat <<EOF
- <tr><td>Generale :</td><td></td><td><center><input type="submit" name="generale" value="SPEGNI_TUTTO" ></td></tr>
- </table></form>
- <p> <p>
- EOF
- display_form <<EOF
- start_form|@TR<< >>
- end_form
- EOF
- presenza="$(cat /etc/centralina/presenza)"
- if ! equal $presenza "" ; then
- echo "Il centro è attualmente utilizzato da:<strong> $presenza </strong>"
- fi
- cat <<EOF
- <script language="JavaScript" type="text/javascript">
- setTimeout('top.location.href=\"/cgi-bin/webif/centralina/comandi.sh\"',"30000")
- </script>
- EOF
- footer
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement