mirror of
https://forge.apps.education.fr/blender-edutech/jumeaux-numeriques.git
synced 2024-01-27 06:56:18 +01:00
Jumelage numérique du monte-charge et amélioration du jumelage du portail
This commit is contained in:
parent
a43fd2d547
commit
656813b7f3
@ -79,59 +79,12 @@ def init(cont):
|
||||
|
||||
system_init() # Initialisation du système
|
||||
|
||||
###############################################################################
|
||||
# Voyants
|
||||
###############################################################################
|
||||
|
||||
##
|
||||
# Etat voyant 0
|
||||
# Modele 3d -> Arduino : FIXME
|
||||
# Arduino -> Modele 3d : FIXME
|
||||
##
|
||||
|
||||
# def voy_0 (cont):
|
||||
# if scene.objects['System']['run']:
|
||||
# obj = cont.owner
|
||||
|
||||
# # Activation
|
||||
# if obj['activated'] and scene.objects['Led niveau 0-on'].visible == False:
|
||||
# scene.objects['Led niveau 0-on'].setVisible(True,False)
|
||||
# scene.objects['Led niveau 0'].setVisible(False,False)
|
||||
|
||||
# # Modele 3D -> Arduino
|
||||
# if scene.objects['System']['twins']:
|
||||
# if scene.objects['Led']['pin'] is not None:
|
||||
# scene.objects['Led']['pin'].write(1)
|
||||
|
||||
# # Désactivation
|
||||
# if obj['activated']==False and scene.objects['Led niveau 0-on'].visible == True:
|
||||
# scene.objects['Led niveau 0'].setVisible(True,False)
|
||||
# scene.objects['Led niveau 0-on'].setVisible(False,False)
|
||||
|
||||
##
|
||||
# Etat voyant 1
|
||||
# Modele 3d -> Arduino : FIXME
|
||||
# Arduino -> Modele 3d : FIXME
|
||||
##
|
||||
|
||||
# def voy_1 (cont):
|
||||
# if scene.objects['System']['run']:
|
||||
# obj = cont.owner
|
||||
# if obj['activated'] and scene.objects['Led niveau 1-on'].visible == False:
|
||||
# scene.objects['Led niveau 1-on'].setVisible(True,False)
|
||||
# scene.objects['Led niveau 1'].setVisible(False,False)
|
||||
# if obj['activated']==False and scene.objects['Led niveau 1-on'].visible == True:
|
||||
# scene.objects['Led niveau 1'].setVisible(True,False)
|
||||
# scene.objects['Led niveau 1-on'].setVisible(False,False)
|
||||
|
||||
###############################################################################
|
||||
# Actionneurs
|
||||
###############################################################################
|
||||
|
||||
##
|
||||
# Moteur et cabine
|
||||
# Modele 3d -> Arduino : FIXME
|
||||
# Arduino -> Modele 3d : FIXME
|
||||
##
|
||||
|
||||
def mot (cont):
|
||||
@ -213,13 +166,6 @@ def pc_0 (cont):
|
||||
|
||||
# Couleurs
|
||||
twin.cycle_sensitive_color(obj)
|
||||
# if obj['activated'] == True and obj.color !=color_activated:
|
||||
# obj.color =color_activated
|
||||
# if obj['activated'] == False :
|
||||
# if obj['mo'] == True and obj.color !=color_hl:
|
||||
# obj.color =color_hl
|
||||
# if obj['mo'] == False and obj.color !=color_active:
|
||||
# obj.color =color_active
|
||||
|
||||
##
|
||||
# Etat capteur présence cabine niveau 1
|
||||
@ -249,13 +195,6 @@ def pc_1 (cont):
|
||||
|
||||
# Couleurs
|
||||
twin.cycle_sensitive_color(obj)
|
||||
# if obj['activated'] == True and obj.color !=color_activated:
|
||||
# obj.color =color_activated
|
||||
# if obj['activated'] == False :
|
||||
# if obj['mo'] == True and obj.color !=color_hl:
|
||||
# obj.color =color_hl
|
||||
# if obj['mo'] == False and obj.color !=color_active:
|
||||
# obj.color =color_active
|
||||
|
||||
###############################################################################
|
||||
# Système
|
||||
|
@ -18,18 +18,6 @@ scene = bge.logic.getCurrentScene()
|
||||
|
||||
# Récupérer le brochage du jumeau réel
|
||||
from montchg import pin_config
|
||||
# system=importlib.import_module('montchg') # Système
|
||||
# pin_config = system.get_pin_config()
|
||||
|
||||
# pin_config = {
|
||||
# 'voy_0' : [['d','o'],['Led niveau 0','pin']],
|
||||
# 'voy_1' : [['d','o'],['Led niveau 1','pin']],
|
||||
# 'pc_0' : [['d','i'],['Microrupteur niveau 0','pin']],
|
||||
# 'pc_1' : [['d','i'],['Microrupteur niveau 0','pin']],
|
||||
# 'ba_0' : [['d','i'],['Bp niveau 0','pin']],
|
||||
# 'ba_1' : [['d','i'],['Bp niveau 1','pin']],
|
||||
# 'mot_m' : [['d','o'],['Moteur','pin_m']],
|
||||
# 'mot_d' : [['d','o'],['Moteur','pin_d']]}
|
||||
|
||||
# UPBGE constants
|
||||
JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
|
||||
@ -67,11 +55,17 @@ def mot_d (order):
|
||||
|
||||
# Compte-rendu du capteur de présence cabine niveau 0
|
||||
def pc_0 ():
|
||||
return scene.objects['Microrupteur niveau 0']['activated']
|
||||
if scene.objects['Microrupteur niveau 0']['activated'] or scene.objects['Microrupteur niveau 0']['activated_real']:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
# Compte-rendu du capteur de présence cabine niveau 0
|
||||
def pc_1 ():
|
||||
return scene.objects['Microrupteur niveau 1']['activated']
|
||||
if scene.objects['Microrupteur niveau 1']['activated'] or scene.objects['Microrupteur niveau 1']['activated_real']:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
###############################################################################
|
||||
# Boutons poussoirs
|
||||
@ -79,11 +73,17 @@ def pc_1 ():
|
||||
|
||||
# Compte-rendu du bouton pousssoir appel niveau 0
|
||||
def ba_0 ():
|
||||
return scene.objects['Bp niveau 0']['activated']
|
||||
if scene.objects['Bp niveau 0']['activated'] or scene.objects['Bp niveau 0']['activated_real']:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
# Compte-rendu du bouton pousssoir appel niveau 1
|
||||
def ba_1 ():
|
||||
return scene.objects['Bp niveau 1']['activated']
|
||||
if scene.objects['Bp niveau 1']['activated'] or scene.objects['Bp niveau 1']['activated_real']:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
###############################################################################
|
||||
# Jumeau
|
||||
|
Binary file not shown.
@ -16,6 +16,18 @@ import time
|
||||
# Récupérer la scène UPBGE
|
||||
scene = bge.logic.getCurrentScene()
|
||||
|
||||
# Configuration du brochage du jumeau réel
|
||||
pin_config = {
|
||||
'bp_ext' : [['d','i'],['Bp cote cour','pin']],
|
||||
'bp_int' : [['d','i'],['Bp cote rue','pin']],
|
||||
'fdc_o' : [['d','i'],['Microrupteur fdc ouvert','pin']],
|
||||
'fdc_f' : [['d','i'],['Microrupteur fdc ferme','pin']],
|
||||
'mot_o' : [['d','o'],['Moteur','pin_o']],
|
||||
'mot_f' : [['d','o'],['Moteur','pin_f']],
|
||||
'gyr' : [['d','o'],['Led','pin']],
|
||||
'ir_emet' : [['d','o'],['Emetteur IR','pin']],
|
||||
'ir_recep' : [['d','i'],['Recepteur IR','pin']]}
|
||||
|
||||
# Couleurs
|
||||
color_passive = (0.800, 0.005, 0.315,1) # bouton non activable : magenta
|
||||
color_active = (0.799, 0.130, 0.063,1) # bouton activable : orange
|
||||
@ -40,18 +52,12 @@ def init(cont):
|
||||
|
||||
twin.manip_init() # Manipulation du modèle 3D
|
||||
twin.cmd_init() # Commandes
|
||||
twin.manip_init() # Cacher les objets de l'aide
|
||||
# twin.manip_init() # Cacher les objets de l'aide
|
||||
|
||||
# Brochage
|
||||
scene.objects['Bp cote cour']['pin'] = None
|
||||
scene.objects['Bp cote rue']['pin'] = None
|
||||
scene.objects['Microrupteur fdc ouvert']['pin'] = None
|
||||
scene.objects['Microrupteur fdc ferme']['pin'] = None
|
||||
scene.objects['Moteur']['pin_o'] = None
|
||||
scene.objects['Moteur']['pin_f'] = None
|
||||
scene.objects['Led']['pin'] = None
|
||||
scene.objects['Emetteur IR']['pin'] = None
|
||||
scene.objects['Recepteur IR']['pin'] = None
|
||||
for pin in pin_config:
|
||||
# print (pin_config[pin][1][0], pin_config[pin][1][1])
|
||||
scene.objects[pin_config[pin][1][0]][pin_config[pin][1][1]] = None
|
||||
|
||||
# Mémorisation de la position et orientation des composants du système
|
||||
scene.objects['Portail']['init_lx']=scene.objects['Portail'].worldPosition.x
|
||||
@ -75,34 +81,6 @@ def init(cont):
|
||||
# Actionneurs
|
||||
###############################################################################
|
||||
|
||||
##
|
||||
# Gyrophare
|
||||
##
|
||||
|
||||
def gyr (cont):
|
||||
if scene.objects['System']['run']:
|
||||
obj = cont.owner
|
||||
|
||||
# Activation
|
||||
if obj['activated'] and scene.objects['Led-on'].visible == False:
|
||||
scene.objects['Led-on'].setVisible(True,False)
|
||||
scene.objects['Led'].setVisible(False,False)
|
||||
|
||||
# Modele 3D -> Arduino
|
||||
if scene.objects['System']['twins']:
|
||||
if scene.objects['Led']['pin'] is not None:
|
||||
scene.objects['Led']['pin'].write(1)
|
||||
|
||||
# Désactivation
|
||||
if obj['activated']==False and scene.objects['Led-on'].visible == True:
|
||||
scene.objects['Led'].setVisible(True,False)
|
||||
scene.objects['Led-on'].setVisible(False,False)
|
||||
|
||||
# Modele 3D -> Arduino
|
||||
if scene.objects['System']['twins']:
|
||||
if scene.objects['Led']['pin'] is not None:
|
||||
scene.objects['Led']['pin'].write(0)
|
||||
|
||||
##
|
||||
# Moteur et portail
|
||||
##
|
||||
|
@ -13,19 +13,11 @@ import time
|
||||
# @license: GNU GPL
|
||||
###############################################################################
|
||||
|
||||
# Récupérer la scène UPBGE
|
||||
scene = bge.logic.getCurrentScene()
|
||||
|
||||
# Brochage du jumeau réel
|
||||
pin_config = {
|
||||
'bp_ext' : ['d','i'],
|
||||
'bp_int' : ['d','i'],
|
||||
'fdc_o' : ['d','i'],
|
||||
'fdc_f' : ['d','i'],
|
||||
'mot_o' : ['d','o'],
|
||||
'mot_f' : ['d','o'],
|
||||
'gyr' : ['d','o'],
|
||||
'ir_emet' : ['d','o'],
|
||||
'ir_recep' : ['d','i']}
|
||||
# Récupérer le brochage du jumeau réel
|
||||
from porcou import pin_config
|
||||
|
||||
# UPBGE constants
|
||||
JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
|
||||
@ -75,7 +67,6 @@ def fdc_f ():
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
# Compte-rendu du capteur barrage IR
|
||||
def ir_recep ():
|
||||
if scene.objects['Recepteur IR']['activated'] or scene.objects['Recepteur IR']['activated_real']==False:
|
||||
@ -109,8 +100,8 @@ def bp_int ():
|
||||
def jumeau_get_pin(board, name, brochage):
|
||||
for pin in brochage :
|
||||
if pin ==name:
|
||||
# print (pin_config[pin][0]+':'+str(brochage[pin])+':'+pin_config[pin][1])
|
||||
return board.get_pin(pin_config[pin][0]+':'+str(brochage[pin])+':'+pin_config[pin][1])
|
||||
# print (pin_config[pin][0][0]+':'+str(brochage[pin])+':'+pin_config[pin][0][1])
|
||||
return board.get_pin(pin_config[pin][0][0]+':'+str(brochage[pin])+':'+pin_config[pin][0][1])
|
||||
return None
|
||||
|
||||
# Activer le jumelage
|
||||
@ -123,15 +114,8 @@ def jumeau (brochage=None):
|
||||
|
||||
# Brochage
|
||||
if brochage is not None:
|
||||
scene.objects['Bp cote cour']['pin'] = jumeau_get_pin(board, 'bp_int', brochage)
|
||||
scene.objects['Bp cote rue']['pin'] = jumeau_get_pin(board, 'bp_ext', brochage)
|
||||
scene.objects['Microrupteur fdc ouvert']['pin'] =jumeau_get_pin(board, 'fdc_o', brochage)
|
||||
scene.objects['Microrupteur fdc ferme']['pin'] =jumeau_get_pin(board, 'fdc_f', brochage)
|
||||
scene.objects['Moteur']['pin_o'] = jumeau_get_pin(board, 'mot_o', brochage)
|
||||
scene.objects['Moteur']['pin_f'] = jumeau_get_pin(board, 'mot_f', brochage)
|
||||
scene.objects['Led']['pin'] = jumeau_get_pin(board, 'gyr', brochage)
|
||||
scene.objects['Emetteur IR']['pin'] = jumeau_get_pin(board, 'ir_emet', brochage)
|
||||
scene.objects['Recepteur IR']['pin'] = jumeau_get_pin(board, 'ir_recep', brochage)
|
||||
for pin in pin_config :
|
||||
scene.objects[pin_config[pin][1][0]][pin_config[pin][1][1]] = jumeau_get_pin(board, pin, brochage)
|
||||
|
||||
# Désactiver le jumelage
|
||||
def jumeau_stop ():
|
||||
|
Binary file not shown.
@ -1,7 +1,7 @@
|
||||
<data>
|
||||
<screen>
|
||||
<width>1368</width>
|
||||
<height>769</height>
|
||||
<width>1573</width>
|
||||
<height>884</height>
|
||||
<quality>1</quality>
|
||||
</screen>
|
||||
</data>
|
Loading…
Reference in New Issue
Block a user