2022-12-18 22:46:19 +01:00
|
|
|
import bge # Bibliothèque Blender Game Engine (UPBGE)
|
|
|
|
import twin # Bibliothèque de l'environnement 3D des jumeaux numériques
|
|
|
|
import math
|
|
|
|
import time
|
|
|
|
|
|
|
|
###############################################################################
|
2022-12-19 17:28:29 +01:00
|
|
|
# volrou.py
|
2022-12-18 22:46:19 +01:00
|
|
|
# @title: Commandes pour le volet roulant
|
|
|
|
# @project: Blender-EduTech
|
|
|
|
# @lang: fr
|
|
|
|
# @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
|
2023-01-01 17:34:01 +01:00
|
|
|
# @copyright: Copyright (C) 2022-2023 Philippe Roy
|
2022-12-18 22:46:19 +01:00
|
|
|
# @license: GNU GPL
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
# Récupérer la scène UPBGE
|
|
|
|
scene = bge.logic.getCurrentScene()
|
|
|
|
|
|
|
|
# Couleurs
|
2022-12-22 05:02:33 +01:00
|
|
|
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
|
|
|
|
color_hl = (0.8, 0.8, 0.8, 1) # bouton focus : blanc
|
|
|
|
color_activated = (0.8, 0.619, 0.021, 1) # bouton activé : jaune
|
2022-12-18 22:46:19 +01:00
|
|
|
|
|
|
|
# Constantes UPBGE
|
|
|
|
JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
|
|
|
|
JUST_RELEASED = bge.logic.KX_INPUT_JUST_RELEASED
|
|
|
|
ACTIVATE = bge.logic.KX_INPUT_ACTIVE
|
|
|
|
# JUST_DEACTIVATED = bge.logic.KX_SENSOR_JUST_DEACTIVATED
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# Initialisation de la scène
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
def init(cont):
|
|
|
|
if cont.sensors['Init'].positive == False: # 1 seule fois
|
|
|
|
return False
|
|
|
|
|
|
|
|
twin.manip_init() # Manipulation du modèle 3D
|
|
|
|
twin.cmd_init() # Commandes
|
|
|
|
|
|
|
|
system_init() # Initialisation du système
|
|
|
|
|
|
|
|
###############################################################################
|
2022-12-23 14:30:13 +01:00
|
|
|
# Voyants
|
2022-12-18 22:46:19 +01:00
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
##
|
2022-12-23 14:30:13 +01:00
|
|
|
# Etat voyant mode automatique
|
|
|
|
# Modele 3d -> Arduino : FIXME
|
|
|
|
# Arduino -> Modele 3d : FIXME
|
2022-12-18 22:46:19 +01:00
|
|
|
##
|
|
|
|
|
2022-12-23 14:30:13 +01:00
|
|
|
def voy_auto (cont):
|
2022-12-18 22:46:19 +01:00
|
|
|
if scene.objects['System']['run']:
|
|
|
|
obj = cont.owner
|
2022-12-23 14:30:13 +01:00
|
|
|
if obj['activated'] and scene.objects['Led auto-on'].visible == False:
|
|
|
|
scene.objects['Led auto-on'].setVisible(True,False)
|
|
|
|
scene.objects['Led auto'].setVisible(False,False)
|
|
|
|
if obj['activated']==False and scene.objects['Led auto-on'].visible == True:
|
|
|
|
scene.objects['Led auto'].setVisible(True,False)
|
|
|
|
scene.objects['Led auto-on'].setVisible(False,False)
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# Actionneurs
|
|
|
|
###############################################################################
|
2022-12-18 22:46:19 +01:00
|
|
|
|
|
|
|
##
|
2022-12-23 14:30:13 +01:00
|
|
|
# Moteur et volet
|
|
|
|
# Modele 3d -> Arduino : FIXME
|
|
|
|
# Arduino -> Modele 3d : FIXME
|
2022-12-18 22:46:19 +01:00
|
|
|
##
|
|
|
|
|
2022-12-23 14:30:13 +01:00
|
|
|
def mot (cont):
|
2022-12-18 22:46:19 +01:00
|
|
|
if scene.objects['System']['run']:
|
2022-12-29 10:08:55 +01:00
|
|
|
# scene.objects['System'].applyMovement((0, 0, 0), False)
|
|
|
|
# scene.objects['System'].applyRotation((0, 0, 0), True)
|
2022-12-18 22:46:19 +01:00
|
|
|
obj = cont.owner
|
2022-12-26 19:16:30 +01:00
|
|
|
layer = 0
|
2022-12-26 18:10:17 +01:00
|
|
|
# Monter
|
|
|
|
if obj['up']:
|
2022-12-28 14:16:14 +01:00
|
|
|
if obj['frame_down']<105: # Volet pas cassé
|
|
|
|
if obj['frame_up'] <0: # Réinit entre 0 et -4
|
|
|
|
obj['frame_up']=0
|
2022-12-28 18:15:42 +01:00
|
|
|
if obj['frame_up']<110 : # Cycle normal de 0 à 100 (butée en 110)
|
2022-12-28 14:16:14 +01:00
|
|
|
start = obj['frame_up']
|
2022-12-28 18:15:42 +01:00
|
|
|
end = 111
|
2022-12-28 14:16:14 +01:00
|
|
|
priority = 1
|
|
|
|
blendin = 1.0
|
|
|
|
mode = bge.logic.KX_ACTION_MODE_PLAY
|
|
|
|
layerWeight = 0.0
|
|
|
|
ipoFlags = 0
|
|
|
|
speed = 0.4
|
|
|
|
scene.objects['Axe enrouleur'].playAction('Axe enrouleur-Up', start, 135, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Axe fdc'].playAction('Axe fdc-Up', start, 135, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 1'].playAction('Lame volet 1-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 2'].playAction('Lame volet 2-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 3'].playAction('Lame volet 3-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 4'].playAction('Lame volet 4-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 5'].playAction('Lame volet 5-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 6'].playAction('Lame volet 6-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 7'].playAction('Lame volet 7-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 8'].playAction('Lame volet 8-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 9'].playAction('Lame volet 9-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 10'].playAction('Lame volet 10-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 11'].playAction('Lame volet 11-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 12'].playAction('Lame volet 12-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 13'].playAction('Lame volet 13-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
obj['frame_up'] = scene.objects['Axe enrouleur'].getActionFrame(layer)
|
|
|
|
else: # Tourner sans fin
|
2022-12-28 18:15:42 +01:00
|
|
|
# vitesse = 0.015
|
|
|
|
vitesse = 0.03
|
2022-12-28 14:16:14 +01:00
|
|
|
pas_axe_enrouleur = 0.5
|
|
|
|
pas_axe_fdc = 0.5/3
|
2022-12-28 18:15:42 +01:00
|
|
|
# scene.objects['Axe enrouleur'].applyRotation((pas_axe_enrouleur*vitesse, 0, 0), True)
|
|
|
|
scene.objects['Axe fdc'].stopAction(layer)
|
2022-12-28 14:16:14 +01:00
|
|
|
scene.objects['Axe fdc'].applyRotation((-pas_axe_fdc*vitesse, 0, 0), True)
|
2022-12-28 18:15:42 +01:00
|
|
|
if obj['frame_up'] ==170: # Réinit
|
|
|
|
obj['frame_up']=110
|
|
|
|
start = obj['frame_up']
|
|
|
|
end = 171
|
|
|
|
priority = 1
|
|
|
|
blendin = 1.0
|
|
|
|
mode = bge.logic.KX_ACTION_MODE_PLAY
|
|
|
|
layerWeight = 0.0
|
|
|
|
ipoFlags = 0
|
|
|
|
speed = 0.4
|
|
|
|
scene.objects['Axe enrouleur'].playAction('Axe enrouleur-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
# scene.objects['Axe fdc'].playAction('Axe fdc-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 1'].playAction('Lame volet 1-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 2'].playAction('Lame volet 2-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 3'].playAction('Lame volet 3-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 4'].playAction('Lame volet 4-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 5'].playAction('Lame volet 5-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 6'].playAction('Lame volet 6-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 7'].playAction('Lame volet 7-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 8'].playAction('Lame volet 8-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 9'].playAction('Lame volet 9-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 10'].playAction('Lame volet 10-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 11'].playAction('Lame volet 11-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 12'].playAction('Lame volet 12-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 13'].playAction('Lame volet 13-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
obj['frame_up'] = scene.objects['Axe enrouleur'].getActionFrame(layer)
|
2022-12-28 14:16:14 +01:00
|
|
|
obj['frame_down']= 100-obj['frame_up']
|
2022-12-26 18:10:17 +01:00
|
|
|
|
|
|
|
# Descendre
|
|
|
|
if obj['down']:
|
2022-12-28 14:16:14 +01:00
|
|
|
if obj['frame_up']<105: # Volet pas cassé
|
|
|
|
if obj['frame_down'] <0: # Réinit entre 0 et -4
|
|
|
|
obj['frame_down']=0
|
2022-12-28 18:15:42 +01:00
|
|
|
if obj['frame_down']<135 : # Cycle normal de 0 à 100 (butée en 135)
|
2022-12-28 14:16:14 +01:00
|
|
|
start = obj['frame_down']
|
2022-12-28 18:15:42 +01:00
|
|
|
end = 136
|
2022-12-28 14:16:14 +01:00
|
|
|
layer = 0
|
|
|
|
priority = 1
|
|
|
|
blendin = 1.0
|
|
|
|
mode = bge.logic.KX_ACTION_MODE_PLAY
|
|
|
|
layerWeight = 0.0
|
|
|
|
ipoFlags = 0
|
|
|
|
speed = 0.4
|
|
|
|
scene.objects['Axe enrouleur'].playAction('Axe enrouleur-Down', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Axe fdc'].playAction('Axe fdc-Down', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 1'].playAction('Lame volet 1-Down', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 2'].playAction('Lame volet 2-Down', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 3'].playAction('Lame volet 3-Down', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 4'].playAction('Lame volet 4-Down', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 5'].playAction('Lame volet 5-Down', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 6'].playAction('Lame volet 6-Down', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 7'].playAction('Lame volet 7-Down', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 8'].playAction('Lame volet 8-Down', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 9'].playAction('Lame volet 9-Down', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 10'].playAction('Lame volet 10-Down', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 11'].playAction('Lame volet 11-Down', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 12'].playAction('Lame volet 12-Down', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 13'].playAction('Lame volet 13-Down', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
obj['frame_down'] = scene.objects['Axe enrouleur'].getActionFrame(layer)
|
|
|
|
else: # Tourner sans fin et volet cassé
|
|
|
|
scene.objects['Axe enrouleur'].stopAction(layer)
|
|
|
|
scene.objects['Axe fdc'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 1'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 2'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 3'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 4'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 5'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 6'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 7'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 8'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 9'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 10'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 11'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 12'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 13'].stopAction(layer)
|
2022-12-28 18:15:42 +01:00
|
|
|
vitesse = 0.03
|
|
|
|
# vitesse = 0.015
|
2022-12-28 14:16:14 +01:00
|
|
|
pas_axe_enrouleur = 0.5
|
|
|
|
pas_axe_fdc = 0.5/3
|
|
|
|
pas_volet = 10
|
|
|
|
scene.objects['Axe enrouleur'].applyRotation((-pas_axe_enrouleur*vitesse, 0, 0), True)
|
|
|
|
scene.objects['Axe fdc'].applyRotation((pas_axe_fdc*vitesse, 0, 0), True)
|
|
|
|
scene.objects['Lame volet 1'].applyMovement((0, 0, -pas_volet*vitesse), False)
|
|
|
|
scene.objects['Lame volet 2'].applyMovement((0, 0, -pas_volet*vitesse), False)
|
|
|
|
scene.objects['Lame volet 3'].applyMovement((0, 0, -pas_volet*vitesse), False)
|
|
|
|
scene.objects['Lame volet 4'].applyMovement((0, 0, -pas_volet*vitesse), False)
|
|
|
|
scene.objects['Lame volet 5'].applyMovement((0, 0, -pas_volet*vitesse), False)
|
|
|
|
scene.objects['Lame volet 6'].applyMovement((0, 0, -pas_volet*vitesse), False)
|
|
|
|
scene.objects['Lame volet 7'].applyMovement((0, 0, -pas_volet*vitesse), False)
|
|
|
|
scene.objects['Lame volet 8'].applyMovement((0, 0, -pas_volet*vitesse), False)
|
|
|
|
scene.objects['Lame volet 9'].applyMovement((0, 0, -pas_volet*vitesse), False)
|
|
|
|
scene.objects['Lame volet 10'].applyMovement((0, 0, -pas_volet*vitesse), False)
|
|
|
|
scene.objects['Lame volet 11'].applyMovement((0, 0, -pas_volet*vitesse), False)
|
|
|
|
scene.objects['Lame volet 12'].applyMovement((0, 0, -pas_volet*vitesse), False)
|
|
|
|
scene.objects['Lame volet 13'].applyMovement((0, 0, -pas_volet*vitesse), False)
|
|
|
|
obj['frame_down'] +=1
|
|
|
|
obj['frame_up']= 100-obj['frame_down']
|
2022-12-18 22:46:19 +01:00
|
|
|
|
2022-12-26 19:16:30 +01:00
|
|
|
# Arrêt
|
|
|
|
if obj['up'] == False and obj['down'] == False:
|
|
|
|
if scene.objects['Axe enrouleur'].isPlayingAction(layer):
|
|
|
|
scene.objects['Axe enrouleur'].stopAction(layer)
|
|
|
|
scene.objects['Axe fdc'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 1'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 2'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 3'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 4'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 5'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 6'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 7'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 8'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 9'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 10'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 11'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 12'].stopAction(layer)
|
|
|
|
scene.objects['Lame volet 13'].stopAction(layer)
|
|
|
|
|
2022-12-18 22:46:19 +01:00
|
|
|
###############################################################################
|
|
|
|
# Capteurs fin de course
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
##
|
2022-12-23 14:30:13 +01:00
|
|
|
# Etat capteur fin de course volet en haut
|
|
|
|
# Modele 3d -> Arduino : FIXME
|
|
|
|
# Arduino -> Modele 3d : FIXME
|
2022-12-18 22:46:19 +01:00
|
|
|
##
|
|
|
|
|
2022-12-23 14:30:13 +01:00
|
|
|
def fdc_h (cont):
|
2022-12-18 22:46:19 +01:00
|
|
|
if scene.objects['System']['run'] :
|
|
|
|
obj = cont.owner
|
|
|
|
|
2022-12-28 14:16:14 +01:00
|
|
|
# Etat capteur en fonction du volet
|
2022-12-28 18:15:42 +01:00
|
|
|
scene.objects['Axe fdc']['rx']= scene.objects['Axe fdc'].localOrientation.to_euler().x *(180/math.pi)
|
|
|
|
if scene.objects['Axe fdc']['rx'] >= -175 and scene.objects['Axe fdc']['rx'] <= -155 and obj['activated'] == False :
|
2022-12-28 14:16:14 +01:00
|
|
|
obj['activated'] = True
|
2022-12-28 18:15:42 +01:00
|
|
|
if scene.objects['Axe fdc']['rx'] < -175 or scene.objects['Axe fdc']['rx'] > -155 and obj['activated'] == True :
|
2022-12-28 14:16:14 +01:00
|
|
|
obj['activated'] = False
|
2022-12-28 18:15:42 +01:00
|
|
|
|
2022-12-23 14:30:13 +01:00
|
|
|
# Forçage (click)
|
|
|
|
if obj['click'] == True:
|
|
|
|
obj['activated'] = True
|
2022-12-18 22:46:19 +01:00
|
|
|
|
2022-12-23 14:30:13 +01:00
|
|
|
# Couleurs
|
|
|
|
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
|
2022-12-18 22:46:19 +01:00
|
|
|
|
|
|
|
##
|
2022-12-23 14:30:13 +01:00
|
|
|
# Etat capteur fin de course volet en bas
|
|
|
|
# Modele 3d -> Arduino : FIXME
|
|
|
|
# Arduino -> Modele 3d : FIXME
|
2022-12-18 22:46:19 +01:00
|
|
|
##
|
|
|
|
|
2022-12-23 14:30:13 +01:00
|
|
|
def fdc_b (cont):
|
2022-12-18 22:46:19 +01:00
|
|
|
if scene.objects['System']['run'] :
|
|
|
|
obj = cont.owner
|
|
|
|
|
2022-12-28 14:16:14 +01:00
|
|
|
# Etat capteur en fonction du volet
|
2022-12-28 18:15:42 +01:00
|
|
|
if scene.objects['Axe fdc']['rx'] >= -10 and scene.objects['Axe fdc']['rx'] <= 10 and obj['activated'] == False :
|
2022-12-28 14:16:14 +01:00
|
|
|
obj['activated'] = True
|
2022-12-28 18:15:42 +01:00
|
|
|
if scene.objects['Axe fdc']['rx'] < -10 or scene.objects['Axe fdc']['rx'] > 10 and obj['activated'] == True :
|
2022-12-28 14:16:14 +01:00
|
|
|
obj['activated'] = False
|
2022-12-23 14:30:13 +01:00
|
|
|
|
|
|
|
# Forçage (click)
|
|
|
|
if obj['click'] == True:
|
|
|
|
obj['activated'] = True
|
|
|
|
|
|
|
|
# Couleurs
|
|
|
|
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
|
2022-12-18 22:46:19 +01:00
|
|
|
|
|
|
|
###############################################################################
|
2022-12-23 14:30:13 +01:00
|
|
|
# Boutons
|
2022-12-18 22:46:19 +01:00
|
|
|
###############################################################################
|
|
|
|
|
2022-12-23 14:30:13 +01:00
|
|
|
# Modele 3d -> Arduino : FIXME
|
|
|
|
# Arduino -> Modele 3d : FIXME
|
|
|
|
|
|
|
|
# Arduino -> numérique
|
|
|
|
# bt_a_m_txt = txt_extrac_bool(serial_msg,"bt_a_m: ")
|
|
|
|
# bt_a_d_txt = txt_extrac_bool(serial_msg,"bt_a_d: ")
|
|
|
|
# bt_b_m_txt = txt_extrac_bool(serial_msg,"bt_b_m: ")
|
|
|
|
# bt_b_d_txt = txt_extrac_bool(serial_msg,"bt_b_d: ")
|
|
|
|
# bt_c_m_txt = txt_extrac_bool(serial_msg,"bt_c_m: ")
|
|
|
|
# bt_c_d_txt = txt_extrac_bool(serial_msg,"bt_c_d: ")
|
|
|
|
# bp_phy('Bp Am', bt_a_m_txt)
|
|
|
|
# bp_phy('Bp Ad', bt_a_d_txt)
|
|
|
|
# bp_phy('Bp Bm', bt_b_m_txt)
|
|
|
|
# bp_phy('Bp Bd', bt_b_d_txt)
|
|
|
|
# bp_phy('Bp Cm', bt_c_m_txt)
|
|
|
|
# bp_phy('Bp Cd', bt_c_d_txt)
|
|
|
|
|
|
|
|
# # Affichage de l'activation physique des boutons
|
|
|
|
# def bp_phy(obj_name, bp_phy_sig):
|
|
|
|
# obj=scene.objects[obj_name]
|
|
|
|
# if bp_phy_sig =="0":
|
|
|
|
# obj['actif_phy'] = True
|
|
|
|
# obj.color = couleur_jaune
|
|
|
|
# else:
|
|
|
|
# if obj['actif_phy']:
|
|
|
|
# obj['actif_phy'] = False
|
|
|
|
# obj.color = couleur_orange
|
2022-12-18 22:46:19 +01:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# Système
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
##
|
|
|
|
# Initialisation du système
|
|
|
|
# Le moteur est géré en continue.
|
|
|
|
##
|
|
|
|
|
|
|
|
def system_init ():
|
|
|
|
|
2022-12-23 14:30:13 +01:00
|
|
|
# Voyants statiques
|
|
|
|
scene.objects['Led capteur courant'].setVisible(True,False)
|
|
|
|
scene.objects['Led capteur courant-on'].setVisible(False,False)
|
|
|
|
scene.objects['Led moteur'].setVisible(True,False)
|
|
|
|
scene.objects['Led moteur-on'].setVisible(False,False)
|
|
|
|
scene.objects['Led alimentation'].setVisible(True,False)
|
|
|
|
scene.objects['Led alimentation-on'].setVisible(False,False)
|
2022-12-18 22:46:19 +01:00
|
|
|
|
2022-12-23 14:30:13 +01:00
|
|
|
system_reset()
|
2022-12-18 22:46:19 +01:00
|
|
|
|
|
|
|
##
|
|
|
|
# Réinitialisation du système
|
|
|
|
##
|
|
|
|
|
|
|
|
def system_reset ():
|
|
|
|
|
2022-12-23 14:30:13 +01:00
|
|
|
# Voyants aux états initiaux
|
|
|
|
scene.objects['Led auto'].setVisible(True,False)
|
|
|
|
scene.objects['Led auto-on'].setVisible(False,False)
|
2022-12-18 22:46:19 +01:00
|
|
|
|
2022-12-23 14:30:13 +01:00
|
|
|
# Volet
|
2022-12-28 14:16:14 +01:00
|
|
|
obj = scene.objects['Moteur']
|
|
|
|
start = 49
|
|
|
|
end = 50
|
|
|
|
priority = 1
|
|
|
|
layer = 0
|
|
|
|
blendin = 1.0
|
|
|
|
mode = bge.logic.KX_ACTION_MODE_PLAY
|
|
|
|
layerWeight = 0.0
|
|
|
|
ipoFlags = 0
|
|
|
|
speed = 0.4
|
|
|
|
scene.objects['Axe enrouleur'].playAction('Axe enrouleur-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Axe fdc'].playAction('Axe fdc-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 1'].playAction('Lame volet 1-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 2'].playAction('Lame volet 2-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 3'].playAction('Lame volet 3-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 4'].playAction('Lame volet 4-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 5'].playAction('Lame volet 5-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 6'].playAction('Lame volet 6-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 7'].playAction('Lame volet 7-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 8'].playAction('Lame volet 8-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 9'].playAction('Lame volet 9-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 10'].playAction('Lame volet 10-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 11'].playAction('Lame volet 11-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 12'].playAction('Lame volet 12-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
|
|
scene.objects['Lame volet 13'].playAction('Lame volet 13-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
2022-12-28 18:15:42 +01:00
|
|
|
# print ("reset")
|
2022-12-28 14:16:14 +01:00
|
|
|
obj['frame_up'] = scene.objects['Axe enrouleur'].getActionFrame(layer)
|
|
|
|
obj['frame_down']= 100-obj['frame_up']
|
2022-12-18 22:46:19 +01:00
|
|
|
|
2022-12-23 14:30:13 +01:00
|
|
|
# I/O à l'état initial
|
|
|
|
scene.objects['Led auto']['activated']=False
|
|
|
|
scene.objects['Bp monter']['activated']=False
|
|
|
|
scene.objects['Bp arret']['activated']=False
|
|
|
|
scene.objects['Bp descendre']['activated']=False
|
|
|
|
scene.objects['Bp auto']['activated']=False
|
|
|
|
scene.objects['Microrupteur haut']['activated']=False
|
|
|
|
scene.objects['Microrupteur bas']['activated']=False
|
|
|
|
scene.objects['Moteur']['up']=False
|
|
|
|
scene.objects['Moteur']['down']=False
|
|
|
|
scene.objects['Recepteur LDR']['activated']=False
|