jumeaux-numeriques/portail_coulissant/porcou_cmd.py

106 lines
3.0 KiB
Python

from porcou_lib import * # Bibliothèque portail coulissant
###############################################################################
# porcou_cmd.py
# @title: Commandes du portail coulissant
###############################################################################
###############################################################################
# Instructions élémentaires pour le portail coulissant
#
# 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)
#
# Capteurs (valeur retournée = True ou False) :
# - Capteur fin de course portail ouvert : fdc_o()
# - Capteur fin de course portail fermé : fdc_f()
# - Capteur barrage IR (absence d'obstacle) : ir_recep()
#
# Les consignes du pupitre (valeur retournée = True ou False) :
# - Bouton poussoir appel niveau 0 : ba_0()
# - Bouton poussoir appel niveau 1 : ba_1()
#
# Gestion du temps :
# - Temporisation en seconde : tempo(duree)
#
###############################################################################
# Brochage du jumeau réel
brochage={
'bp_ext' : [2,'d','i'],
'ebp_int' : [3,'d','i'],
'fdc_o' : [4,'d','i'],
'fdc_f' : [5,'d','i'],
'mot_o' : [6,'d','o'],
'mot_f' : [7,'d','o'],
'gyr' : [8,'d','o'],
'ir_emett' : [9,'d','o'],
'ir_recept' : [10,'d','i']}
###############################################################################
# Fonctions
###############################################################################
###############################################################################
# Commandes
###############################################################################
def commandes():
# jumeau(brochage)
# for i in range (5):
# gyr(True)
# tempo(1)
# gyr(False)
# tempo(1)
# Mise en place : Fermeture
print ("go go ")
while fdc_f() ==False :
gyr(True)
mot_f(True)
print ("a")
mot_f(False)
gyr(False)
# Fonctionnement normal
while True :
# Ouverture
if bp_int() or bp_ext() :
while fdc_o() ==False:
gyr(True)
mot_o(True)
gyr(False)
mot_o(False)
tempo(2) # Temporisation
# Fermeture
while fdc_f() ==False:
gyr(True)
mot_f(True)
gyr(False)
mot_f(False)
# # Ecrire votre code ici ...
# gyr(True) # Activer le gyrophare
# while True:
# pass
fin() # A garder
###############################################################################
# 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':
thread_cmd_stop()