jumeaux-numeriques/portail_coulissant/porcou_cmd.py

98 lines
2.9 KiB
Python
Raw Normal View History

2022-12-11 08:40:31 +01:00
from porcou_lib import * # Bibliothèque portail coulissant
###############################################################################
# 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) :
# - 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()
#
# 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
#
###############################################################################
# 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-14 07:49:53 +01:00
# # Mise en place : Fermeture
# print ("Version sans sécurité : sans réouverture")
# print ("Mise en place : Fermeture")
# while fdc_f() ==False :
# gyr(True)
# mot_o(False)
# mot_f(True)
# mot_f(False)
# gyr(False)
tdf= get_t()
print ("Début fermeture : ", tdf)
while fdc_f() ==False :
gyr(True)
mot_o(False)
mot_f(True)
mot_f(False)
gyr(False)
tff = get_t()
print ("Fin fermeture : ", tff)
print ("Temp fermeture : ", str(tff-tdf))
tdo= get_t()
print ("Début ouverture : ", tdo)
while fdc_o() ==False :
gyr(True)
mot_f(False)
mot_o(True)
mot_o(False)
gyr(False)
tfo = get_t()
print ("Fin ouverture : ", tfo)
print ("Temp ouverture : ", str(tfo-tdo))
2023-01-14 07:49:53 +01:00
# plot(['gyr'])
# plot(['bp_ext'])
# plot(['gyr', 'bp_ext', 'bp_int'])
# while True:
# print (get_t())
# gyr(True)
# tempo(0.25)
# gyr(False)
# tempo(0.25)
fin() # A garder
2022-12-11 08:40:31 +01:00
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()