Aggiunto supporto sperimentale per elettrovalcole mono-stabili

This commit is contained in:
lejubila
2017-05-13 12:14:02 +02:00
parent 2889758b28
commit 9743198315
3 changed files with 47 additions and 19 deletions

View File

@@ -1,3 +1,8 @@
## 0.3.1 - 13/05/2017
Add experimental support for monostable solenoid valve:
- define in your config file the variable EV_MONOSTABLE and assign value 1
- if the solenoid valves close instead of opening and vice versa, reverse the values of the RELE_GPIO_CLOSE and RELE_GPIO_OPEN variables in your configuration file
## 0.3.0 - 07/05/2017
Add command "open_in" for scheduling on the fly the opens/close a solenoid
Add command "del_cron_open_in" for delete scheduling the fly the opens/close a solenoid

View File

@@ -44,6 +44,10 @@ SED="/bin/sed"
# Percorso readlink
READLINK="/bin/readlink"
# Se impostato con il valore 1, indica che il sistema gestisce elettrovalvole monostabili,
# se impostato a 0 il sistema gestirà elettrovalvole bisstabili
EV_MONOSTABLE=0
# Id gpio usati per simulare il doppio deviatore con cui eseguire l'alimentazione alle elettrovalvole
SUPPLY_GPIO_1=2
SUPPLY_GPIO_2=3

View File

@@ -12,11 +12,13 @@ function initialize {
log_write "Run initialize"
# Imposta l'alimentazione con voltaggio negativo e setta i gpio in scrittura
$GPIO -g write $SUPPLY_GPIO_1 0
$GPIO -g write $SUPPLY_GPIO_2 0
$GPIO -g mode $SUPPLY_GPIO_1 out
$GPIO -g mode $SUPPLY_GPIO_2 out
# Imposta l'alimentazione con voltaggio negativo e setta i gpio in scrittura per le elettrovalvole bistabili
if [ "$EV_MONOSTABLE" != "1" ]; then
$GPIO -g write $SUPPLY_GPIO_1 0
$GPIO -g write $SUPPLY_GPIO_2 0
$GPIO -g mode $SUPPLY_GPIO_1 out
$GPIO -g mode $SUPPLY_GPIO_2 out
fi
# Elimina tutti gli stati delle elettrovalvole preesistenti
rm -f "$STATUS_DIR"/*
@@ -26,7 +28,7 @@ function initialize {
do
g=EV"$i"_GPIO
$GPIO -g write ${!g} RELE_GPIO_OPEN # chiude l'alimentazione all'elettrovalvole
$GPIO -g mode ${!g} out # setta il gpio nella modalita di scrittura
$GPIO -g mode ${!g} out # setta il gpio nella modalita di scrittura
ev_set_state $i 0
done
@@ -97,18 +99,26 @@ function ev_open {
state=2
fi
log_write "Solenoid '$1' open"
message_write "success" "Solenoid open"
supply_positive
# Dall'alias dell'elettrovalvola recupero il numero e dal numero recupero gpio da usare
ev_alias2number $1
EVNUM=$?
ev_number2gpio $EVNUM
g=$?
$GPIO -g write $g $RELE_GPIO_CLOSE
sleep 1
$GPIO -g write $g $RELE_GPIO_OPEN
# Gestisce l'apertura dell'elettrovalvola in base alla tipologia (monostabile / bistabile)
if [ "$EV_MONOSTABLE" == "1" ]; then
$GPIO -g write $g $RELE_GPIO_CLOSE
else
supply_positive
$GPIO -g write $g $RELE_GPIO_CLOSE
sleep 1
$GPIO -g write $g $RELE_GPIO_OPEN
fi
ev_set_state $EVNUM $state
log_write "Solenoid '$1' open"
message_write "success" "Solenoid open"
}
#
@@ -177,19 +187,28 @@ function ev_open_in {
# $1 alias elettrovalvola
#
function ev_close {
log_write "Solenoid '$1' close"
message_write "success" "Solenoid close"
supply_negative
#$GPIO_alias2number $1
# Dall'alias dell'elettrovalvola recupero il numero e dal numero recupero gpio da usare
ev_alias2number $1
EVNUM=$?
ev_number2gpio $EVNUM
g=$?
$GPIO -g write $g $RELE_GPIO_CLOSE
sleep 1
$GPIO -g write $g $RELE_GPIO_OPEN
# Gestisce l'apertura dell'elettrovalvola in base alla tipologia (monostabile / bistabile)
if [ "$EV_MONOSTABLE" == "1" ]; then
$GPIO -g write $g $RELE_GPIO_OPEN
else
supply_negative
$GPIO -g write $g $RELE_GPIO_CLOSE
sleep 1
$GPIO -g write $g $RELE_GPIO_OPEN
fi
ev_set_state $EVNUM 0
log_write "Solenoid '$1' close"
message_write "success" "Solenoid close"
cron_del open_in_stop $1 > /dev/null 2>&1
}