mirror of
https://forge.apps.education.fr/blender-edutech/jumeaux-numeriques.git
synced 2024-01-27 06:56:18 +01:00
Bugfix : Erreur suite aux changement de format du dictionnaire des variables publiques
This commit is contained in:
parent
89f6a5b473
commit
c02813a251
@ -34,7 +34,7 @@ card_pin_title="Brochage"
|
||||
card_pin_text=""" Le brochage est un dictionnaire qui permet \n d'associer les objets 3D du jumeau \n numérique aux broches du jumeau réel,
|
||||
brochage = { nom:[type, broche, mode] } :
|
||||
- nom : nom de l'objet 3D,
|
||||
- type : a (analogique) ou d (numérique),
|
||||
- type : a (analogique) ou d (binaire),
|
||||
- broche : numéro de la broche de carte,
|
||||
- mode : i (entrée), o (sortie) ou p (pwm).
|
||||
Par exemple : brochage = { 'ba_0':['d',2,'i'] }.\n
|
||||
|
@ -154,10 +154,10 @@ def mot (cont):
|
||||
|
||||
# Modele 3D -> Arduino
|
||||
if scene.objects['System']['twins'] and obj['prior_real']:
|
||||
if scene.objects['Moteur']['pin_o'] is not None :
|
||||
if scene.objects['Moteur']['pin_f'] is not None:
|
||||
scene.objects['Moteur']['pin_f'].write(0)
|
||||
scene.objects['Moteur']['pin_o'].write(1)
|
||||
if scene.objects['Moteur']['pin_open'] is not None :
|
||||
if scene.objects['Moteur']['pin_close'] is not None:
|
||||
scene.objects['Moteur']['pin_close'].write(0)
|
||||
scene.objects['Moteur']['pin_open'].write(1)
|
||||
|
||||
# Fermer
|
||||
# else: # Pas de priorité
|
||||
@ -177,10 +177,10 @@ def mot (cont):
|
||||
|
||||
# Modele 3D -> Arduino
|
||||
if scene.objects['System']['twins'] and obj['prior_real']:
|
||||
if scene.objects['Moteur']['pin_f'] is not None:
|
||||
if scene.objects['Moteur']['pin_o'] is not None:
|
||||
scene.objects['Moteur']['pin_o'].write(0)
|
||||
scene.objects['Moteur']['pin_f'].write(1)
|
||||
if scene.objects['Moteur']['pin_close'] is not None:
|
||||
if scene.objects['Moteur']['pin_open'] is not None:
|
||||
scene.objects['Moteur']['pin_open'].write(0)
|
||||
scene.objects['Moteur']['pin_close'].write(1)
|
||||
|
||||
# Arrêrer
|
||||
if obj['open']== False and obj['close'] == False and obj['prior']:
|
||||
@ -193,10 +193,10 @@ def mot (cont):
|
||||
|
||||
# Modele 3D -> Arduino
|
||||
if scene.objects['System']['twins'] and obj['prior_real']:
|
||||
if scene.objects['Moteur']['pin_f'] is not None:
|
||||
if scene.objects['Moteur']['pin_o'] is not None:
|
||||
scene.objects['Moteur']['pin_o'].write(0)
|
||||
scene.objects['Moteur']['pin_f'].write(0)
|
||||
if scene.objects['Moteur']['pin_close'] is not None:
|
||||
if scene.objects['Moteur']['pin_open'] is not None:
|
||||
scene.objects['Moteur']['pin_open'].write(0)
|
||||
scene.objects['Moteur']['pin_close'].write(0)
|
||||
|
||||
###############################################################################
|
||||
# Capteurs fin de course
|
||||
|
@ -39,13 +39,29 @@ from porcou_lib import * # Bibliothèque utilisateur du portail coulissant
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
# Brochage du portail coulissant
|
||||
# Brochage du portail coulissant (Grove)
|
||||
brochage={
|
||||
'bp_ext' : [],'bp_int' : [],
|
||||
'fdc_o' : [],'fdc_f' : [],
|
||||
'mot_o' : [],'mot_f' : [],
|
||||
'gyr' : [],
|
||||
'ir_emet' : [],'ir_recep' : []}
|
||||
'bp_ext' : ['a',0,'i'],'bp_int' : ['a',1,'i'],
|
||||
'fdc_o' : ['d',7,'i'],'fdc_f' : ['d',8,'i'],
|
||||
'mot_o' : ['d',5,'o'],'mot_f' : ['d',6,'o'],
|
||||
'gyr' : ['d',4,'o'],
|
||||
'ir_emet' : ['d',2,'o'],'ir_recep' : ['a',3,'i']}
|
||||
|
||||
# Brochage du portail coulissant (AutoProgUno)
|
||||
# brochage={
|
||||
# 'bp_ext' : ['d',2,'i'],'bp_int' : ['d',3,'i'],
|
||||
# 'fdc_o' : ['d',7,'i'],'fdc_f' : ['d',8,'i'],
|
||||
# 'mot_o' : ['d',5,'o'],'mot_f' : ['d',6,'o'],
|
||||
# 'gyr' : ['d',4,'o'],
|
||||
# 'ir_emet' : ['d',9,'o'],'ir_recep' : ['d',10,'i']}
|
||||
|
||||
# Brochage vierge
|
||||
# brochage={
|
||||
# 'bp_ext' : [],'bp_int' : [],
|
||||
# 'fdc_o' : [],'fdc_f' : [],
|
||||
# 'mot_o' : [],'mot_f' : [],
|
||||
# 'gyr' : [],
|
||||
# 'ir_emet' : [],'ir_recep' : []}
|
||||
|
||||
###############################################################################
|
||||
# Fonctions
|
||||
@ -69,14 +85,42 @@ def commandes():
|
||||
# Données
|
||||
# daq(['mot_angle', 'mot_vitesse', 'portail_x', 'portail_vitesse'])
|
||||
reset_t()
|
||||
daq(['bp_ext', 'bp_ext_r', 'bp_int', 'bp_int_r', 'fdc_o', 'fdc_o_r', 'fdc_f', 'fdc_f_r', 'mot_o', 'mot_f', 'gyr', 'mot_angle', 'mot_vitesse', 'portail_x', 'portail_vitesse', 'ir_emet', 'ir_recep', 'ir_recep_r'])
|
||||
|
||||
# daq(['bp_ext', 'bp_ext_r', 'bp_int', 'bp_int_r', 'fdc_o', 'fdc_o_r', 'fdc_f', 'fdc_f_r', 'mot_o', 'mot_f', 'gyr', 'mot_angle', 'mot_vitesse', 'portail_x', 'portail_vitesse', 'ir_emet', 'ir_recep', 'ir_recep_r'])
|
||||
# daq(['bp_ext', 'bp_ext_r', 'bp_int', 'bp_int_r', 'fdc_o', 'fdc_o_r', 'fdc_f', 'fdc_f_r', 'mot_o', 'mot_f', 'gyr'])
|
||||
plot(['mot_angle', 'mot_vitesse', 'portail_x', 'portail_vitesse'])
|
||||
|
||||
# plot(['mot_angle', 'mot_vitesse', 'portail_x', 'portail_vitesse'])
|
||||
|
||||
# plot([['bp_ext', 'bp_ext_r'], ['bp_int', 'bp_int_r'], ['fdc_o', 'fdc_o_r'], ['fdc_f', 'fdc_f_r'], 'mot_o', 'mot_f', 'gyr', ['mot_angle', 'mot_vitesse', 'portail_x', 'portail_vitesse']])
|
||||
|
||||
# Jumelage
|
||||
# jumeau_mode(True,True, False, False)
|
||||
jumeau(brochage)
|
||||
# jumeau_mode()
|
||||
# jumeau_mode(True,True, False, False)
|
||||
# jumeau_mode(True,True, True, True)
|
||||
|
||||
# jumeau_mode_object ('gyr', False, True)
|
||||
gyr(False)
|
||||
while True :
|
||||
|
||||
jumeau_mode_object ('gyr', False, True)
|
||||
gyr(True)
|
||||
print ('gyr Numérique')
|
||||
tempo(0.5)
|
||||
jumeau_mode_object ('gyr', True, True)
|
||||
gyr(False)
|
||||
tempo(0.1)
|
||||
|
||||
jumeau_mode_object ('gyr', True, False)
|
||||
gyr(True)
|
||||
print (('gyr Physique'))
|
||||
tempo(0.5)
|
||||
jumeau_mode_object ('gyr', True, True)
|
||||
gyr(False)
|
||||
tempo(0.1)
|
||||
|
||||
if bp_ext():
|
||||
break
|
||||
|
||||
# Fermeture
|
||||
mot_vitesse (1256) # Vitesse par défaut 125,6 rad /s ( 20 tr / s )
|
||||
@ -102,6 +146,7 @@ def commandes():
|
||||
mot_o(True)
|
||||
mot_o(False)
|
||||
gyr(False)
|
||||
tempo(1)
|
||||
|
||||
fin() # A garder
|
||||
|
||||
|
Binary file not shown.
12
twin.py
12
twin.py
@ -732,10 +732,10 @@ def cycle_voy(cont):
|
||||
elif scene.objects['System']['run']:
|
||||
|
||||
# Activation
|
||||
if obj['activated'] and obj_on.visible == False:
|
||||
if obj['activated']:
|
||||
|
||||
# Modele 3D
|
||||
if obj['prior']:
|
||||
# Physique du modèle 3D
|
||||
if obj_on.visible == False and obj['prior']:
|
||||
obj_on.setVisible(True,False)
|
||||
obj.setVisible(False,False)
|
||||
|
||||
@ -745,10 +745,10 @@ def cycle_voy(cont):
|
||||
obj['pin'].write(1)
|
||||
|
||||
# Désactivation
|
||||
if obj['activated']==False and obj_on.visible == True:
|
||||
if obj['activated']==False:
|
||||
|
||||
# Modele 3D
|
||||
if obj['prior']:
|
||||
# Physique du modèle 3D
|
||||
if obj_on.visible == True and obj['prior']:
|
||||
obj.setVisible(True,False)
|
||||
obj_on.setVisible(False,False)
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<data>
|
||||
<screen>
|
||||
<width>1590</width>
|
||||
<height>894</height>
|
||||
<width>999</width>
|
||||
<height>562</height>
|
||||
<quality>1</quality>
|
||||
</screen>
|
||||
<plot>
|
||||
|
@ -176,7 +176,8 @@ def jumeau (brochage=None):
|
||||
# Brochage
|
||||
if brochage is not None:
|
||||
for pin in pin_config :
|
||||
scene.objects[pin_config[pin][0][0]][pin_config[pin][1][0]] = jumeau_get_pin(board, pin, brochage)
|
||||
if len (pin_config[pin][1])>0:
|
||||
scene.objects[pin_config[pin][0][0]][pin_config[pin][1][0]] = jumeau_get_pin(board, pin, brochage)
|
||||
return board
|
||||
else:
|
||||
return None
|
||||
|
Binary file not shown.
@ -34,7 +34,7 @@ card_pin_title="Brochage"
|
||||
card_pin_text=""" Le brochage est un dictionnaire qui permet \n d'associer les objets 3D du jumeau \n numérique aux broches du jumeau réel,
|
||||
brochage = { nom:[type, broche, mode] } :
|
||||
- nom : nom de l'objet 3D,
|
||||
- type : a (analogique) ou d (numérique),
|
||||
- type : a (analogique) ou d (binaire),
|
||||
- broche : numéro de la broche de carte,
|
||||
- mode : i (entrée), o (sortie) ou p (pwm).
|
||||
Par exemple : brochage = { 'bp_m':['d',2,'i'] }.\n
|
||||
|
Loading…
Reference in New Issue
Block a user