Comportement des capteurs de fin de course du volet

This commit is contained in:
Philippe Roy 2022-12-28 14:16:14 +01:00
parent 3add0238cd
commit fae3d690b9
4 changed files with 181 additions and 65 deletions

View File

@ -565,7 +565,8 @@ def cycle_hl(cont):
def cycle_click(cont):
obj = cont.owner
# name=obj.name
if scene.objects['System']['run'] ==False:
return
# Passif
if "active" in obj.getPropertyNames():

Binary file not shown.

Binary file not shown.

View File

@ -85,65 +85,131 @@ def mot (cont):
obj = cont.owner
print (obj['frame_up'], obj['frame_down'])
layer = 0
# bge.render.drawLine([0,0,0],[1,1,1], (0.8, 0.8, 0.8, 1)) # Redraw pour l'éclairage de la scène
# Monter
if obj['up']:
start = obj['frame_up']
end = 100
priority = 1
blendin = 1.0
mode = bge.logic.KX_ACTION_MODE_PLAY
layerWeight = 0.0
ipoFlags = 0
speed = 0.2
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)
obj['frame_down']= 100-obj['frame_up']
# FIXME : Touner sans fin
if obj['frame_down']<105: # Volet pas cassé
if obj['frame_up'] <0: # Réinit entre 0 et -4
obj['frame_up']=0
if obj['frame_up']<104 : # Cycle normal de 0 à 100 (buté en 105)
start = obj['frame_up']
end = 105
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
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)
vitesse = 0.015
pas_axe_enrouleur = 0.5
pas_axe_fdc = 0.5/3
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['Volet'].applyRotation((pas_axe_enrouleur*vitesse, 0, 0), True)
obj['frame_up'] +=1
obj['frame_down']= 100-obj['frame_up']
# Descendre
if obj['down']:
start = obj['frame_down']
end = 100
layer = 0
priority = 1
blendin = 1.0
mode = bge.logic.KX_ACTION_MODE_PLAY
layerWeight = 0.0
ipoFlags = 0
speed = 0.2
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)
obj['frame_up']= 100-obj['frame_down']
# FIXME : Touner sans fin
if obj['frame_up']<105: # Volet pas cassé
if obj['frame_down'] <0: # Réinit entre 0 et -4
obj['frame_down']=0
if obj['frame_down']<134 : # Cycle normal de 0 à 100 (buté en 135)
start = obj['frame_down']
end = 135
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)
vitesse = 0.015
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']
# Arrêt
if obj['up'] == False and obj['down'] == False:
@ -178,13 +244,29 @@ def fdc_h (cont):
if scene.objects['System']['run'] :
obj = cont.owner
# Etat capteur en fonction de la grille : worldPosition.x : 0 -> 65.5 et localPosition.x : 0 -> 218
# FIXME : animation par keyframe
# if scene.objects['Portail'].localPosition.x <= 0 and obj['activated'] == False :
# Etat capteur en fonction du volet
if scene.objects['Moteur']['frame_up'] >= 95 and scene.objects['Moteur']['frame_up'] <= 105 and obj['activated'] == False :
obj['activated'] = True
if (scene.objects['Moteur']['frame_up'] < 95 or scene.objects['Moteur']['frame_up'] > 105) and obj['activated'] == True :
obj['activated'] = False
# if scene.objects['Moteur']['frame_up'] >= 95 and obj['activated'] == False :
# obj['activated'] = True
# if scene.objects['Portail'].localPosition.x > 0 and obj['activated'] == True :
# if scene.objects['Moteur']['frame_up'] < 95 and obj['activated'] == True :
# obj['activated'] = False
if scene.objects['Moteur']['frame_up']>105:
frame = scene.objects['Moteur']['frame_up'] % 2500
# print ("Frame modulo :", frame)
if frame >= 0 and frame <= 100 and obj['activated'] == False :
obj['activated'] = True
if frame > 100 and obj['activated'] == True :
obj['activated'] = False
# if frame >= 2295 and frame <= 2425 and obj['activated'] == False :
# obj['activated'] = True
# if frame < 2295 and frame > 2425 and obj['activated'] == True :
# obj['activated'] = False
# Forçage (click)
if obj['click'] == True:
obj['activated'] = True
@ -208,12 +290,18 @@ def fdc_b (cont):
if scene.objects['System']['run'] :
obj = cont.owner
# Etat capteur en fonction de la grille : worldPosition.x : 0 -> 65.5 et localPosition.x : 0 -> 218
# FIXME : animation par keyframe
# if scene.objects['Portail'].localPosition.x >= 218 and obj['activated'] == False :
# obj['activated'] = True
# if scene.objects['Portail'].localPosition.x < 218 and obj['activated'] == True :
# obj['activated'] = False
# Etat capteur en fonction du volet
if scene.objects['Moteur']['frame_down'] >= 95 and scene.objects['Moteur']['frame_down'] <= 105 and obj['activated'] == False :
obj['activated'] = True
if (scene.objects['Moteur']['frame_down'] < 95 or scene.objects['Moteur']['frame_down'] > 105) and obj['activated'] == True :
obj['activated'] = False
if scene.objects['Moteur']['frame_down']>105:
frame = scene.objects['Moteur']['frame_down'] % 2500
# print ("Frame modulo :", frame)
if frame >= 2295 and frame <= 2425 and obj['activated'] == False :
obj['activated'] = True
if frame < 2295 and frame > 2425 and obj['activated'] == True :
obj['activated'] = False
# Forçage (click)
if obj['click'] == True:
@ -292,7 +380,34 @@ def system_reset ():
scene.objects['Led auto-on'].setVisible(False,False)
# Volet
# FIXME : animation par keyframe
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)
print ("reset")
obj['frame_up'] = scene.objects['Axe enrouleur'].getActionFrame(layer)
obj['frame_down']= 100-obj['frame_up']
# I/O à l'état initial
scene.objects['Led auto']['activated']=False