Affichage de la descrption des composants lors d'un highlight

This commit is contained in:
Philippe Roy 2023-01-06 21:23:44 +01:00
parent d228f79b96
commit ea3a95dc36
16 changed files with 135 additions and 46 deletions

View File

@ -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_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_ry']=scene.objects['Moteur pignon'].worldOrientation.to_euler().y
scene.objects['Moteur pignon']['init_rz']=scene.objects['Moteur pignon'].worldOrientation.to_euler().z 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 system_init() # Initialisation du système

View File

@ -42,6 +42,8 @@ brochage={}
def commandes(): def commandes():
jumeau()
# Ecrire votre code ici ... # Ecrire votre code ici ...
while True: while True:
voy_0(True) voy_0(True)

View File

@ -1,6 +1,6 @@
import bge # Bibliothèque Blender Game Engine (UPBGE) import bge # Bibliothèque Blender Game Engine (UPBGE)
from twin_threading import thread_cmd_start, thread_cmd_stop, fin # Multithreading from twin_threading import thread_cmd_start, thread_cmd_stop, thread_cmd_end # Multithreading
from twin_serial import jumeau # Liaison série import twin_serial # Liaison série
import time import time
############################################################################### ###############################################################################
@ -9,7 +9,7 @@ import time
# @project: Blender-EduTech # @project: Blender-EduTech
# @lang: fr # @lang: fr
# @authors: Philippe Roy <philippe.roy@ac-grenoble.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 # @license: GNU GPL
############################################################################### ###############################################################################
@ -77,8 +77,28 @@ def ba_1 ():
return scene.objects['Bp niveau 1']['activated'] return scene.objects['Bp niveau 1']['activated']
############################################################################### ###############################################################################
# Temporisation # Jumeau
############################################################################### ###############################################################################
def jumeau ():
twin_serial.open()
###############################################################################
# Cycle
###############################################################################
# Temporisation
def tempo (duree): def tempo (duree):
time.sleep(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.

View File

@ -47,6 +47,14 @@ def init(cont):
scene.objects['Engrenage']['init_rx']=scene.objects['Engrenage'].worldOrientation.to_euler().x 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_ry']=scene.objects['Engrenage'].worldOrientation.to_euler().y
scene.objects['Engrenage']['init_rz']=scene.objects['Engrenage'].worldOrientation.to_euler().z 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 system_init() # Initialisation du système

View File

@ -42,7 +42,9 @@ brochage={}
def commandes(): def commandes():
# Ecrire votre code ici ... # Ecrire votre code ici ...
# jumeau()
gyr(True) # Activer le gyrophare gyr(True) # Activer le gyrophare
# ir_emet(True)
while True: while True:
pass pass

View File

@ -1,6 +1,6 @@
import bge # Bibliothèque Blender Game Engine (UPBGE) import bge # Bibliothèque Blender Game Engine (UPBGE)
from twin_threading import thread_cmd_start, thread_cmd_stop, fin # Multithreading from twin_threading import thread_cmd_start, thread_cmd_stop, thread_cmd_end # Multithreading
from twin_serial import jumeau # Liaison série import twin_serial # Liaison série
import time import time
############################################################################### ###############################################################################
@ -9,7 +9,7 @@ import time
# @project: Blender-EduTech # @project: Blender-EduTech
# @lang: fr # @lang: fr
# @authors: Philippe Roy <philippe.roy@ac-grenoble.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 # @license: GNU GPL
############################################################################### ###############################################################################
@ -98,8 +98,28 @@ def bp_int ():
return scene.objects['Bp cote cour']['activated'] return scene.objects['Bp cote cour']['activated']
############################################################################### ###############################################################################
# Temporisation # Jumeau
############################################################################### ###############################################################################
def jumeau ():
twin_serial.open()
###############################################################################
# Cycle
###############################################################################
# Temporisation
def tempo (duree): def tempo (duree):
time.sleep(duree) time.sleep(duree)
# Fin
def end():
if scene.objects['System']['twins']:
twin_serial.close()
thread_cmd_end()
def fin():
end()
def quit():
end()

15
twin.py
View File

@ -197,7 +197,6 @@ def cmd_hl(cont):
"About-cmd": "A propos"} "About-cmd": "A propos"}
scene.objects['Cmd-text']['modal']= False scene.objects['Cmd-text']['modal']= False
scene.objects['Cmd-text']['Text']= text_hl[obj.name] scene.objects['Cmd-text']['Text']= text_hl[obj.name]
print (obj.name)
if scene.objects['Doc']['page_chap']== "" and obj.name =="Doc-cmd-colbox" : if scene.objects['Doc']['page_chap']== "" and obj.name =="Doc-cmd-colbox" :
scene.objects['Cmd-text']['Text']= "Chargement de la documentation ..." scene.objects['Cmd-text']['Text']= "Chargement de la documentation ..."
if scene.objects['Doc']['page_chap']!= "" and obj.name =="Doc-cmd-colbox" : if scene.objects['Doc']['page_chap']!= "" and obj.name =="Doc-cmd-colbox" :
@ -547,7 +546,6 @@ def cycle_end (cont):
def cycle_hl(cont): def cycle_hl(cont):
obj = cont.owner obj = cont.owner
# name=obj.name
# Passif # Passif
if "active" in obj.getPropertyNames(): 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']: if cont.sensors['MO'].status == JUST_ACTIVATED and scene.objects['System']['run']:
obj.color = color_hl obj.color = color_hl
obj['mo'] = True obj['mo'] = True
# scene.objects[name].color = color_hl if obj['description'] is not None:
# scene.objects[name]['mo'] = True scene.objects['Cmd-text']['Text']=obj['description']
scene.objects['Cmd-text'].setVisible(True,True)
# Désactivation # 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.color = color_active
obj['mo'] = False obj['mo'] = False
# scene.objects[name].color = color_active scene.objects['Cmd-text']['Text']=""
# scene.objects[name]['mo'] = False
## ##
# Click sur les éléments cliquables du systèmes (activation numérique) # Click sur les éléments cliquables du systèmes (activation numérique)
@ -587,7 +585,6 @@ def cycle_click(cont):
# Activation # Activation
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive and scene.objects['System']['manip_mode']==0: if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive and scene.objects['System']['manip_mode']==0:
obj.color = color_activated obj.color = color_activated
# scene.objects[name].color = color_activated
obj['activated'] = True obj['activated'] = True
obj['click'] = True obj['click'] = True
# Modele 3d -> Arduino : FIXME # Modele 3d -> Arduino : FIXME
@ -599,7 +596,5 @@ def cycle_click(cont):
# Modele 3d -> Arduino : FIXME # Modele 3d -> Arduino : FIXME
if cont.sensors['MO'].positive: if cont.sensors['MO'].positive:
obj.color = color_hl obj.color = color_hl
# scene.objects[name].color = color_hl
else: else:
obj.color = color_active obj.color = color_active
# scene.objects[name].color = color_active

View File

@ -1,7 +1,7 @@
<data> <data>
<screen> <screen>
<width>1280</width> <width>1411</width>
<height>720</height> <height>794</height>
<quality>1</quality> <quality>1</quality>
</screen> </screen>
</data> </data>

View File

@ -1,5 +1,6 @@
import bge # Bibliothèque Blender Game Engine (UPBGE) import bge # Bibliothèque Blender Game Engine (UPBGE)
import numpy as np import numpy as np
import time
import serial # Liaison série import serial # Liaison série
import pyfirmata # Protocole Firmata import pyfirmata # Protocole Firmata
@ -18,11 +19,13 @@ from serial.tools.list_ports import comports # Détection du port automatique
# UPBGE scene # UPBGE scene
scene = bge.logic.getCurrentScene() scene = bge.logic.getCurrentScene()
board = None
## ##
# Recherche automatique du port # Recherche automatique du port
## ##
def serial_autoget_port(): def autoget_port():
# USB Vendor ID, USB Product ID # USB Vendor ID, USB Product ID
board_dict={'microbit' :[3368, 516], board_dict={'microbit' :[3368, 516],
'uno' :[9025, 67], 'uno' :[9025, 67],
@ -59,7 +62,7 @@ def serial_init(port,speed):
# Affiche la liste des cartes (communication série) # Affiche la liste des cartes (communication série)
## ##
def serial_devices(): def devices():
for com in comports(): for com in comports():
print ("Name : "+str(com.name)+"\n" print ("Name : "+str(com.name)+"\n"
+" Device : "+str(com.device)+"\n" +" Device : "+str(com.device)+"\n"
@ -78,16 +81,16 @@ def serial_devices():
# pyfirmata : baudrate=57600 # pyfirmata : baudrate=57600
## ##
def jumeau(pins): # def jumeau(pins):
def open():
global board global board
# global gyr_pin
# UI : étape 1 # UI : étape 1
scene.objects['Twins-text']['Text'] = "Connection en cours ..." scene.objects['Twins-text']['Text'] = "Connection en cours ..."
# Mise en place de la carte # Mise en place de la carte
speed = 57600 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: if device is None:
scene.objects['System']['twins'] = False scene.objects['System']['twins'] = False
scene.objects['Twins-text']['Text'] = "Aucune connection disponible : jumeau réel débranché." 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." scene.objects['Twins-text']['Text'] = "Connection ouverte : "+device+" - "+str(speed)+" baud."
else: else:
scene.objects['Twins-text']['Text'] = "Connection ouverte : "+board_name+" sur "+device+" à "+str(speed)+" baud." 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 # Déclaration des entrées - sorties
# for pin in pins: # for pin in pins:
@ -138,16 +141,23 @@ def jumeau(pins):
# Fermeture de la communication série # Fermeture de la communication série
## ##
def jumeau_close(): def close():
global board 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 board.exit() # Fermer proprement la communication avec la carte
scene.objects['System']['twins'] = False 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 # Configuration manuelle du port
# FIXME # FIXME
def jumeau_config(port, speed): def config(port, speed):
pass pass
# global board # global board
# global twins_serial # global twins_serial

View File

@ -3,6 +3,7 @@ import threading # Multithreading
import trace import trace
import sys import sys
import time import time
import twin_serial # Liaison série
############################################################################### ###############################################################################
# twin_threading.py # twin_threading.py
@ -64,6 +65,7 @@ def thread_start(threads, type_txt, fct):
if (debug_thread): if (debug_thread):
print ("Thread",type_txt, "#", len(threads)-1, "open.") print ("Thread",type_txt, "#", len(threads)-1, "open.")
# Stop des threads
def thread_stop(threads, type_txt): def thread_stop(threads, type_txt):
i=0 i=0
zombie_flag=False zombie_flag=False
@ -94,27 +96,21 @@ def thread_stop(threads, type_txt):
print ("There are zombies threads",type_txt, ".") print ("There are zombies threads",type_txt, ".")
return False return False
###############################################################################
# Fonctions utilisateur
###############################################################################
def thread_cmd_start(fct): def thread_cmd_start(fct):
thread_start(threads_cmd, "commands", fct) thread_start(threads_cmd, "commands", fct)
def thread_cmd_stop(): def thread_cmd_stop():
if scene.objects['System']['twins']:
twin_serial.close()
thread_stop(threads_cmd, "commands") thread_stop(threads_cmd, "commands")
def end(): def thread_cmd_end():
# Jumeau numérique
# if scene.objects['System']['twins']:
# jumeau_close()
# Thread
if (debug_thread): if (debug_thread):
print ("Thread commands is arrived.") print ("Thread commands is arrived.")
time.sleep(0.125) time.sleep(0.125)
scene.objects['System']['thread_cmd']=False scene.objects['System']['thread_cmd']=False
time.sleep(0.125) time.sleep(0.125)
def fin():
end()
def quit():
end()

Binary file not shown.

View File

@ -38,6 +38,15 @@ def init(cont):
twin.manip_init() # Manipulation du modèle 3D twin.manip_init() # Manipulation du modèle 3D
twin.cmd_init() # Commandes 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 system_init() # Initialisation du système

View File

@ -45,6 +45,7 @@ brochage={}
def commandes(): def commandes():
# Ecrire votre code ici ... # Ecrire votre code ici ...
jumeau()
voy_auto(True) # Activer le gyrophare voy_auto(True) # Activer le gyrophare
while True: while True:
pass pass

View File

@ -1,6 +1,6 @@
import bge # Bibliothèque Blender Game Engine (UPBGE) import bge # Bibliothèque Blender Game Engine (UPBGE)
from twin_threading import thread_cmd_start, thread_cmd_stop, fin # Multithreading from twin_threading import thread_cmd_start, thread_cmd_stop, thread_cmd_end # Multithreading
from twin_serial import jumeau # Liaison série import twin_serial # Liaison série
import time import time
############################################################################### ###############################################################################
@ -93,8 +93,28 @@ def bp_auto ():
return scene.objects['Bp auto']['activated'] return scene.objects['Bp auto']['activated']
############################################################################### ###############################################################################
# Temporisation # Jumeau
############################################################################### ###############################################################################
def jumeau ():
twin_serial.open()
###############################################################################
# Cycle
###############################################################################
# Temporisation
def tempo (duree): def tempo (duree):
time.sleep(duree) time.sleep(duree)
# Fin
def end():
if scene.objects['System']['twins']:
twin_serial.close()
thread_cmd_end()
def fin():
end()
def quit():
end()