mirror of
https://forge.apps.education.fr/blender-edutech/jumeaux-numeriques.git
synced 2024-01-27 06:56:18 +01:00
Affichage de la descrption des composants lors d'un highlight
This commit is contained in:
parent
d228f79b96
commit
ea3a95dc36
@ -52,6 +52,12 @@ def init(cont):
|
||||
scene.objects['Moteur pignon']['init_rx']=scene.objects['Moteur pignon'].worldOrientation.to_euler().x
|
||||
scene.objects['Moteur pignon']['init_ry']=scene.objects['Moteur pignon'].worldOrientation.to_euler().y
|
||||
scene.objects['Moteur pignon']['init_rz']=scene.objects['Moteur pignon'].worldOrientation.to_euler().z
|
||||
|
||||
# Description des composants sensibles
|
||||
scene.objects['Bp niveau 0']['description']="Bouton poussoir appel niveau 0 : ba_0()"
|
||||
scene.objects['Bp niveau 1']['description']="Bouton poussoir appel niveau 1 : ba_1()"
|
||||
scene.objects['Microrupteur niveau 0']['description']="Capteur présence cabine niveau 0 : pc_0()"
|
||||
scene.objects['Microrupteur niveau 1']['description']="Capteur présence cabine niveau 1 : pc_1()"
|
||||
|
||||
system_init() # Initialisation du système
|
||||
|
||||
|
@ -42,6 +42,8 @@ brochage={}
|
||||
|
||||
def commandes():
|
||||
|
||||
jumeau()
|
||||
|
||||
# Ecrire votre code ici ...
|
||||
while True:
|
||||
voy_0(True)
|
||||
|
@ -1,6 +1,6 @@
|
||||
import bge # Bibliothèque Blender Game Engine (UPBGE)
|
||||
from twin_threading import thread_cmd_start, thread_cmd_stop, fin # Multithreading
|
||||
from twin_serial import jumeau # Liaison série
|
||||
from twin_threading import thread_cmd_start, thread_cmd_stop, thread_cmd_end # Multithreading
|
||||
import twin_serial # Liaison série
|
||||
import time
|
||||
|
||||
###############################################################################
|
||||
@ -9,7 +9,7 @@ import time
|
||||
# @project: Blender-EduTech
|
||||
# @lang: fr
|
||||
# @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
|
||||
# @copyright: Copyright (C) 2022 Philippe Roy
|
||||
# @copyright: Copyright (C) 2022-2023 Philippe Roy
|
||||
# @license: GNU GPL
|
||||
###############################################################################
|
||||
|
||||
@ -77,8 +77,28 @@ def ba_1 ():
|
||||
return scene.objects['Bp niveau 1']['activated']
|
||||
|
||||
###############################################################################
|
||||
# Temporisation
|
||||
# Jumeau
|
||||
###############################################################################
|
||||
|
||||
def jumeau ():
|
||||
twin_serial.open()
|
||||
|
||||
###############################################################################
|
||||
# Cycle
|
||||
###############################################################################
|
||||
|
||||
# Temporisation
|
||||
def tempo (duree):
|
||||
time.sleep(duree)
|
||||
|
||||
# Fin
|
||||
def end():
|
||||
if scene.objects['System']['twins']:
|
||||
twin_serial.close()
|
||||
thread_cmd_end()
|
||||
|
||||
def fin():
|
||||
end()
|
||||
|
||||
def quit():
|
||||
end()
|
||||
|
Binary file not shown.
@ -47,6 +47,14 @@ def init(cont):
|
||||
scene.objects['Engrenage']['init_rx']=scene.objects['Engrenage'].worldOrientation.to_euler().x
|
||||
scene.objects['Engrenage']['init_ry']=scene.objects['Engrenage'].worldOrientation.to_euler().y
|
||||
scene.objects['Engrenage']['init_rz']=scene.objects['Engrenage'].worldOrientation.to_euler().z
|
||||
|
||||
# Description des composants sensibles
|
||||
scene.objects['Bp cote cour']['description']="Bouton poussoir coté cour : bp_int()"
|
||||
scene.objects['Bp cote rue']['description']="Bouton poussoir coté rue : bp_ext()"
|
||||
scene.objects['Microrupteur fdc ouvert']['description']="Capteur fin de course portail ouvert : fdc_o()"
|
||||
scene.objects['Microrupteur fdc ferme']['description']="Capteur fin de course portail fermé : fdc_f()"
|
||||
scene.objects['Emetteur IR']['description']="Capteur barrage IR (absence d\"obstacle) : ir_recep()"
|
||||
scene.objects['Recepteur IR']['description']="Capteur barrage IR (absence d\"obstacle) : ir_recep()"
|
||||
|
||||
system_init() # Initialisation du système
|
||||
|
||||
|
@ -42,7 +42,9 @@ brochage={}
|
||||
def commandes():
|
||||
|
||||
# Ecrire votre code ici ...
|
||||
# jumeau()
|
||||
gyr(True) # Activer le gyrophare
|
||||
# ir_emet(True)
|
||||
while True:
|
||||
pass
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import bge # Bibliothèque Blender Game Engine (UPBGE)
|
||||
from twin_threading import thread_cmd_start, thread_cmd_stop, fin # Multithreading
|
||||
from twin_serial import jumeau # Liaison série
|
||||
from twin_threading import thread_cmd_start, thread_cmd_stop, thread_cmd_end # Multithreading
|
||||
import twin_serial # Liaison série
|
||||
import time
|
||||
|
||||
###############################################################################
|
||||
@ -9,7 +9,7 @@ import time
|
||||
# @project: Blender-EduTech
|
||||
# @lang: fr
|
||||
# @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
|
||||
# @copyright: Copyright (C) 2020-2022 Philippe Roy
|
||||
# @copyright: Copyright (C) 2020-2023 Philippe Roy
|
||||
# @license: GNU GPL
|
||||
###############################################################################
|
||||
|
||||
@ -98,8 +98,28 @@ def bp_int ():
|
||||
return scene.objects['Bp cote cour']['activated']
|
||||
|
||||
###############################################################################
|
||||
# Temporisation
|
||||
# Jumeau
|
||||
###############################################################################
|
||||
|
||||
def jumeau ():
|
||||
twin_serial.open()
|
||||
|
||||
###############################################################################
|
||||
# Cycle
|
||||
###############################################################################
|
||||
|
||||
# Temporisation
|
||||
def tempo (duree):
|
||||
time.sleep(duree)
|
||||
|
||||
# Fin
|
||||
def end():
|
||||
if scene.objects['System']['twins']:
|
||||
twin_serial.close()
|
||||
thread_cmd_end()
|
||||
|
||||
def fin():
|
||||
end()
|
||||
|
||||
def quit():
|
||||
end()
|
||||
|
Binary file not shown.
15
twin.py
15
twin.py
@ -197,7 +197,6 @@ def cmd_hl(cont):
|
||||
"About-cmd": "A propos"}
|
||||
scene.objects['Cmd-text']['modal']= False
|
||||
scene.objects['Cmd-text']['Text']= text_hl[obj.name]
|
||||
print (obj.name)
|
||||
if scene.objects['Doc']['page_chap']== "" and obj.name =="Doc-cmd-colbox" :
|
||||
scene.objects['Cmd-text']['Text']= "Chargement de la documentation ..."
|
||||
if scene.objects['Doc']['page_chap']!= "" and obj.name =="Doc-cmd-colbox" :
|
||||
@ -547,7 +546,6 @@ def cycle_end (cont):
|
||||
|
||||
def cycle_hl(cont):
|
||||
obj = cont.owner
|
||||
# name=obj.name
|
||||
|
||||
# Passif
|
||||
if "active" in obj.getPropertyNames():
|
||||
@ -559,15 +557,15 @@ def cycle_hl(cont):
|
||||
if cont.sensors['MO'].status == JUST_ACTIVATED and scene.objects['System']['run']:
|
||||
obj.color = color_hl
|
||||
obj['mo'] = True
|
||||
# scene.objects[name].color = color_hl
|
||||
# scene.objects[name]['mo'] = True
|
||||
if obj['description'] is not None:
|
||||
scene.objects['Cmd-text']['Text']=obj['description']
|
||||
scene.objects['Cmd-text'].setVisible(True,True)
|
||||
|
||||
# Désactivation
|
||||
if cont.sensors['MO'].status == JUST_RELEASED:
|
||||
if cont.sensors['MO'].status == JUST_RELEASED and scene.objects['System']['run']:
|
||||
obj.color = color_active
|
||||
obj['mo'] = False
|
||||
# scene.objects[name].color = color_active
|
||||
# scene.objects[name]['mo'] = False
|
||||
scene.objects['Cmd-text']['Text']=""
|
||||
|
||||
##
|
||||
# Click sur les éléments cliquables du systèmes (activation numérique)
|
||||
@ -587,7 +585,6 @@ def cycle_click(cont):
|
||||
# Activation
|
||||
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive and scene.objects['System']['manip_mode']==0:
|
||||
obj.color = color_activated
|
||||
# scene.objects[name].color = color_activated
|
||||
obj['activated'] = True
|
||||
obj['click'] = True
|
||||
# Modele 3d -> Arduino : FIXME
|
||||
@ -599,7 +596,5 @@ def cycle_click(cont):
|
||||
# Modele 3d -> Arduino : FIXME
|
||||
if cont.sensors['MO'].positive:
|
||||
obj.color = color_hl
|
||||
# scene.objects[name].color = color_hl
|
||||
else:
|
||||
obj.color = color_active
|
||||
# scene.objects[name].color = color_active
|
||||
|
@ -1,7 +1,7 @@
|
||||
<data>
|
||||
<screen>
|
||||
<width>1280</width>
|
||||
<height>720</height>
|
||||
<width>1411</width>
|
||||
<height>794</height>
|
||||
<quality>1</quality>
|
||||
</screen>
|
||||
</data>
|
@ -1,5 +1,6 @@
|
||||
import bge # Bibliothèque Blender Game Engine (UPBGE)
|
||||
import numpy as np
|
||||
import time
|
||||
|
||||
import serial # Liaison série
|
||||
import pyfirmata # Protocole Firmata
|
||||
@ -18,11 +19,13 @@ from serial.tools.list_ports import comports # Détection du port automatique
|
||||
# UPBGE scene
|
||||
scene = bge.logic.getCurrentScene()
|
||||
|
||||
board = None
|
||||
|
||||
##
|
||||
# Recherche automatique du port
|
||||
##
|
||||
|
||||
def serial_autoget_port():
|
||||
def autoget_port():
|
||||
# USB Vendor ID, USB Product ID
|
||||
board_dict={'microbit' :[3368, 516],
|
||||
'uno' :[9025, 67],
|
||||
@ -59,7 +62,7 @@ def serial_init(port,speed):
|
||||
# Affiche la liste des cartes (communication série)
|
||||
##
|
||||
|
||||
def serial_devices():
|
||||
def devices():
|
||||
for com in comports():
|
||||
print ("Name : "+str(com.name)+"\n"
|
||||
+" Device : "+str(com.device)+"\n"
|
||||
@ -78,16 +81,16 @@ def serial_devices():
|
||||
# pyfirmata : baudrate=57600
|
||||
##
|
||||
|
||||
def jumeau(pins):
|
||||
# def jumeau(pins):
|
||||
def open():
|
||||
global board
|
||||
# global gyr_pin
|
||||
|
||||
# UI : étape 1
|
||||
scene.objects['Twins-text']['Text'] = "Connection en cours ..."
|
||||
|
||||
# Mise en place de la carte
|
||||
speed = 57600
|
||||
[device,board_name] =serial_autoget_port() # Recherche automatique du port
|
||||
[device,board_name] =autoget_port() # Recherche automatique du port
|
||||
if device is None:
|
||||
scene.objects['System']['twins'] = False
|
||||
scene.objects['Twins-text']['Text'] = "Aucune connection disponible : jumeau réel débranché."
|
||||
@ -110,7 +113,7 @@ def jumeau(pins):
|
||||
scene.objects['Twins-text']['Text'] = "Connection ouverte : "+device+" - "+str(speed)+" baud."
|
||||
else:
|
||||
scene.objects['Twins-text']['Text'] = "Connection ouverte : "+board_name+" sur "+device+" à "+str(speed)+" baud."
|
||||
tempo (0.1)
|
||||
time.sleep(0.1)
|
||||
|
||||
# Déclaration des entrées - sorties
|
||||
# for pin in pins:
|
||||
@ -138,16 +141,23 @@ def jumeau(pins):
|
||||
# Fermeture de la communication série
|
||||
##
|
||||
|
||||
def jumeau_close():
|
||||
def close():
|
||||
global board
|
||||
# twins_serial.close() # Fermer proprement le port série
|
||||
scene.objects['Twins-text']['Text'] = "Connection fermée."
|
||||
board.exit() # Fermer proprement la communication avec la carte
|
||||
scene.objects['System']['twins'] = False
|
||||
scene.objects['Twins-text']['Text'] = "Connection fermée."
|
||||
|
||||
# def jumeau_close():
|
||||
# global board
|
||||
# scene.objects['Twins-text']['Text'] = "Connection fermée."
|
||||
# print ("Connection fermée.")
|
||||
# # twins_serial.close() # Fermer proprement le port série
|
||||
# board.exit() # Fermer proprement la communication avec la carte
|
||||
# scene.objects['System']['twins'] = False
|
||||
|
||||
# Configuration manuelle du port
|
||||
# FIXME
|
||||
def jumeau_config(port, speed):
|
||||
def config(port, speed):
|
||||
pass
|
||||
# global board
|
||||
# global twins_serial
|
||||
|
@ -3,6 +3,7 @@ import threading # Multithreading
|
||||
import trace
|
||||
import sys
|
||||
import time
|
||||
import twin_serial # Liaison série
|
||||
|
||||
###############################################################################
|
||||
# twin_threading.py
|
||||
@ -64,6 +65,7 @@ def thread_start(threads, type_txt, fct):
|
||||
if (debug_thread):
|
||||
print ("Thread",type_txt, "#", len(threads)-1, "open.")
|
||||
|
||||
# Stop des threads
|
||||
def thread_stop(threads, type_txt):
|
||||
i=0
|
||||
zombie_flag=False
|
||||
@ -94,27 +96,21 @@ def thread_stop(threads, type_txt):
|
||||
print ("There are zombies threads",type_txt, ".")
|
||||
return False
|
||||
|
||||
###############################################################################
|
||||
# Fonctions utilisateur
|
||||
###############################################################################
|
||||
|
||||
def thread_cmd_start(fct):
|
||||
thread_start(threads_cmd, "commands", fct)
|
||||
|
||||
def thread_cmd_stop():
|
||||
if scene.objects['System']['twins']:
|
||||
twin_serial.close()
|
||||
thread_stop(threads_cmd, "commands")
|
||||
|
||||
def end():
|
||||
|
||||
# Jumeau numérique
|
||||
# if scene.objects['System']['twins']:
|
||||
# jumeau_close()
|
||||
|
||||
# Thread
|
||||
def thread_cmd_end():
|
||||
if (debug_thread):
|
||||
print ("Thread commands is arrived.")
|
||||
time.sleep(0.125)
|
||||
scene.objects['System']['thread_cmd']=False
|
||||
time.sleep(0.125)
|
||||
|
||||
def fin():
|
||||
end()
|
||||
|
||||
def quit():
|
||||
end()
|
||||
|
Binary file not shown.
@ -38,6 +38,15 @@ def init(cont):
|
||||
|
||||
twin.manip_init() # Manipulation du modèle 3D
|
||||
twin.cmd_init() # Commandes
|
||||
|
||||
# Description des composants sensibles
|
||||
scene.objects['Bp monter']['description']="Bouton poussoir monter volet : bp_m()"
|
||||
scene.objects['Bp descendre']['description']="Bouton poussoir descendre volet : bp_d()"
|
||||
scene.objects['Bp arret']['description']="Bouton poussoir arrêt volet : bp_a()"
|
||||
scene.objects['Bp auto']['description']="Bouton poussoir mode automatique : bp_auto()"
|
||||
scene.objects['Microrupteur haut']['description']="Capteur fin de course volet en haut : fdc_h()"
|
||||
scene.objects['Microrupteur bas']['description']="Capteur fin de course volet en bas : fdc_b()"
|
||||
scene.objects['Recepteur LDR']['description']="Capteur de luminosité (LDR) : lum()"
|
||||
|
||||
system_init() # Initialisation du système
|
||||
|
||||
|
@ -45,6 +45,7 @@ brochage={}
|
||||
def commandes():
|
||||
|
||||
# Ecrire votre code ici ...
|
||||
jumeau()
|
||||
voy_auto(True) # Activer le gyrophare
|
||||
while True:
|
||||
pass
|
||||
|
@ -1,6 +1,6 @@
|
||||
import bge # Bibliothèque Blender Game Engine (UPBGE)
|
||||
from twin_threading import thread_cmd_start, thread_cmd_stop, fin # Multithreading
|
||||
from twin_serial import jumeau # Liaison série
|
||||
from twin_threading import thread_cmd_start, thread_cmd_stop, thread_cmd_end # Multithreading
|
||||
import twin_serial # Liaison série
|
||||
import time
|
||||
|
||||
###############################################################################
|
||||
@ -93,8 +93,28 @@ def bp_auto ():
|
||||
return scene.objects['Bp auto']['activated']
|
||||
|
||||
###############################################################################
|
||||
# Temporisation
|
||||
# Jumeau
|
||||
###############################################################################
|
||||
|
||||
def jumeau ():
|
||||
twin_serial.open()
|
||||
|
||||
###############################################################################
|
||||
# Cycle
|
||||
###############################################################################
|
||||
|
||||
# Temporisation
|
||||
def tempo (duree):
|
||||
time.sleep(duree)
|
||||
|
||||
# Fin
|
||||
def end():
|
||||
if scene.objects['System']['twins']:
|
||||
twin_serial.close()
|
||||
thread_cmd_end()
|
||||
|
||||
def fin():
|
||||
end()
|
||||
|
||||
def quit():
|
||||
end()
|
||||
|
Loading…
Reference in New Issue
Block a user