2023-01-18 18:21:12 +01:00
|
|
|
from porcou_lib import * # Bibliothèque utilisateur du portail coulissant
|
2022-12-11 08:40:31 +01:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# porcou_cmd.py
|
|
|
|
# @title: Commandes du portail coulissant
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
###############################################################################
|
2022-12-18 00:55:45 +01:00
|
|
|
# Instructions élémentaires pour le portail coulissant
|
2022-12-11 08:40:31 +01:00
|
|
|
#
|
|
|
|
# Actions (ordre = True ou False) :
|
2022-12-22 08:11:43 +01:00
|
|
|
# - Gyrophare : gyr(True | False)
|
|
|
|
# - Ouvrir le portail (moteur sens trigo) : mot_o(True | False)
|
|
|
|
# - Fermer le portail (moteur sens horaire) : mot_f(True | False)
|
|
|
|
# - Emetteur pour le capteur barrage IR : ir_emet(True | False)
|
2022-12-11 08:40:31 +01:00
|
|
|
#
|
2022-12-18 00:55:45 +01:00
|
|
|
# Capteurs (valeur retournée = True ou False) :
|
2022-12-13 02:42:31 +01:00
|
|
|
# - Capteur fin de course portail ouvert : fdc_o()
|
|
|
|
# - Capteur fin de course portail fermé : fdc_f()
|
2022-12-11 08:40:31 +01:00
|
|
|
# - Capteur barrage IR (absence d'obstacle) : ir_recep()
|
|
|
|
#
|
2022-12-23 14:30:13 +01:00
|
|
|
# Consignes du pupitre (valeur retournée = True ou False) :
|
|
|
|
# - Bouton poussoir coté rue : bp_ext()
|
|
|
|
# - Bouton poussoir coté cour : bp_int()
|
2022-12-11 08:40:31 +01:00
|
|
|
#
|
2022-12-18 00:55:45 +01:00
|
|
|
# Gestion du temps :
|
|
|
|
# - Temporisation en seconde : tempo(duree)
|
2022-12-11 08:40:31 +01:00
|
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
|
2023-01-11 23:56:03 +01:00
|
|
|
# Brochage du portail coulissant
|
|
|
|
brochage={}
|
|
|
|
|
2022-12-11 08:40:31 +01:00
|
|
|
###############################################################################
|
|
|
|
# Fonctions
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# Commandes
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
def commandes():
|
2022-12-18 00:55:45 +01:00
|
|
|
|
2023-01-19 02:27:47 +01:00
|
|
|
# Init -> Ouverture
|
2023-01-18 18:21:12 +01:00
|
|
|
while fdc_o() ==False :
|
|
|
|
gyr(True)
|
|
|
|
mot_f(False)
|
|
|
|
mot_o(True)
|
|
|
|
mot_o(False)
|
|
|
|
gyr(False)
|
|
|
|
|
|
|
|
# Fermeture
|
2023-01-19 02:27:47 +01:00
|
|
|
mot_digitset (10) # 1,3 rad/s par défaut
|
|
|
|
|
|
|
|
tf_d,xf_d, af_d= get('t'), get('portail_x'), get('mot_angle')
|
|
|
|
print ("Début fermeture : portail_x : "+str(round(get('portail_x'),3)) + " - mot_angle : " + str(round(get('mot_angle'),3)))
|
2023-01-18 06:06:15 +01:00
|
|
|
while fdc_f() ==False :
|
|
|
|
gyr(True)
|
|
|
|
mot_o(False)
|
|
|
|
mot_f(True)
|
2023-01-19 02:27:47 +01:00
|
|
|
mot_pas, mot_vitesse, portail_pas, portail_vitesse= get('mot_pas'), get('mot_vitesse'), get('portail_pas'), get('portail_vitesse')
|
2023-01-18 06:06:15 +01:00
|
|
|
mot_f(False)
|
|
|
|
gyr(False)
|
2023-01-19 02:27:47 +01:00
|
|
|
|
|
|
|
mot_digitset () # 1,3 rad/s par défaut
|
|
|
|
print ("Fin fermeture : portail_x : "+str(round(get('portail_x'),3)) + " - mot_angle : " + str(round(get('mot_angle'),3)))
|
|
|
|
tf_f,xf_f, af_f= get('t'), get('portail_x'), get('mot_angle')
|
|
|
|
print ("")
|
|
|
|
print ("Fermeture : "+str(round(tf_f-tf_d,3)) +" s - distance : " +str(round(xf_f-xf_d,3))+" mm - angle : " +str(round(af_f-af_d,3))+
|
|
|
|
" rad - portail_vitesse : " +str(round(portail_vitesse,3))+" mm/s - moteur_vitesse : " +str(round(mot_vitesse,3))+
|
|
|
|
" rad/s - portail_pas : " +str(round(portail_pas,3))+" mm/impulsion - moteur_pas : " +str(round(mot_pas,3))+" rad/impulsion")
|
2023-01-18 18:21:12 +01:00
|
|
|
|
|
|
|
# Ouverture
|
2023-01-19 02:27:47 +01:00
|
|
|
print ("")
|
|
|
|
to_d,xo_d, ao_d= get('t'), get('portail_x'), get('mot_angle')
|
|
|
|
print ("Début ouverture : portail_x : "+str(round(get('portail_x'),3)) + " - mot_angle : " + str(round(get('mot_angle'),3)))
|
2023-01-18 06:06:15 +01:00
|
|
|
while fdc_o() ==False :
|
|
|
|
gyr(True)
|
|
|
|
mot_f(False)
|
|
|
|
mot_o(True)
|
2023-01-19 02:27:47 +01:00
|
|
|
mot_pas, mot_vitesse, portail_pas, portail_vitesse= get('mot_pas'), get('mot_vitesse'), get('portail_pas'), get('portail_vitesse')
|
2023-01-18 06:06:15 +01:00
|
|
|
mot_o(False)
|
|
|
|
gyr(False)
|
2023-01-19 02:27:47 +01:00
|
|
|
print ("Fin ouverture : portail_x : "+str(round(get('portail_x'),3)) + " - mot_angle : " + str(round(get('mot_angle'),3)))
|
|
|
|
to_f,xo_f, ao_f= get('t'), get('portail_x'), get('mot_angle')
|
|
|
|
print ("")
|
|
|
|
print ("Ouverture : "+str(round(to_f-to_d,3)) +" s - distance : " +str(round(xo_f-xo_d,3))+" mm - angle : " +str(round(ao_f-ao_d,3))+
|
|
|
|
" rad - portail_vitesse : " +str(round(portail_vitesse,3))+" mm/s - moteur_vitesse : " +str(round(mot_vitesse,3))+
|
|
|
|
" rad/s - portail_pas : " +str(round(portail_pas,3))+" mm/impulsion - moteur_pas : " +str(round(mot_pas,3))+" rad/impulsion")
|
2023-01-09 05:54:31 +01:00
|
|
|
|
2023-01-07 10:42:19 +01:00
|
|
|
fin() # A garder
|
2022-12-11 08:40:31 +01:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# En: External call << DONT CHANGE THIS SECTION >>
|
|
|
|
# Fr: Appel externe << NE PAS MODIFIER CETTE SECTION >>
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
if __name__=='start':
|
|
|
|
thread_cmd_start(commandes)
|
|
|
|
if __name__=='stop':
|
2023-01-07 00:01:01 +01:00
|
|
|
stop()
|