Probleme avec une Jauge de ma creation

Programmation LUA, Macros FSUIPC, logiciel LINDA
et codage en LUA des gauges Air Manager

Probleme avec une Jauge de ma creation

Messagede arcc » Ven 18 Aoû 2017 16:44

Bonsoir à tous.

Si Jacques (ou d'autre bien sur) passe par la je vais essayé d'exposer mon probleme.

Je continue de créer mes jauges pour mon Twin.
J'ai un soucis avec la jauge Attitude. Pour l'instant le dessin n'est pas finalisé.
Image

Voici mon problème :

Pour la manœuvre du "Flag" Gyro. Au lancement le "Flag" descend lentement et s'efface quand le "ELECTRICAL MASTER BATTERY"est sur 1.
Si il y a un problème sur le Bus elect la variable "PARTIAL PANEL ELECTRICAL" la valeur est différente de 0 et le "Flag" redescend.

Tout ceci fonctionne. Lorsque je veux faire la même chose avec le "Flag" Steer , c'est la qu'il y a problème.
Au lancement ce Flag descend lentement comme celui du Gyro, mais si je veux rajouter une variable pour qu'il s'efface
genre "AUTOPILOT MASTER" les deux flags ne fonctionne pas.

Je soupconne un probleme avec "timer callback"

J'ai voulu separer les deux timer, un qui se nomme "tmr_gyroflag" et l'autre "tmr_steerflag" mais ... murrouge .


le code. J'ai mis deux -- sur une partie du code (à la fin) c'est cette partie qui ne fonctionne pas


Code: Tout sélectionner
---------------------------------------------
--        Load and display images          --
---------------------------------------------
img_add_fullscreen("background.png")
img_bg = img_add_fullscreen("attbackground.png")

img_horizon = img_add_fullscreen("atthorizon.png")
img_fd_horizontal = img_add_fullscreen("fd_horizontal.png")
img_fd_vertical = img_add_fullscreen("fd_vertical.png")
img_ring = img_add_fullscreen("attbankind.png")
img_gyroflag = img_add("gyroflag.png",330,-84,500,500)
img_steerflag = img_add("steerflag.png",-358,-78,500,500)
img_add_fullscreen("attfront.png")

---------------
-- Functions --
---------------
gyroflag_rotation = 0
gyroflag_state = 0
steerflag_rotation = 0
steerflag_state = 0
hoop_height = 0

function PT_atitude(roll, pitch, APmode, FDpitch, FDroll)   
-- roll outer ring
    img_rotate(img_ring, roll *-1)
       
-- roll horizon
    img_rotate(img_horizon  , roll * -1)
   img_rotate(img_bg, roll *-1)
   
-- move horizon pitch
    pitch = var_cap(pitch,-30,30)
    radial = math.rad(roll * -1)
    x = -(math.sin(radial) * pitch * 4.0)
    y = (math.cos(radial) * pitch * 4.0)
    img_move(img_horizon, x, y, nil, nil)
   
-- Flight director

-- Horizontal (pitch):
   if APmode < 1 then
      move(img_fd_horizontal, nil, 120, nil, nil)   
   else
      move(img_fd_horizontal, nil, (FDpitch - pitch) * -4, nil, nil)         
   end

-- Vertical (roll):
   if APmode < 1 then
      move(img_fd_vertical, -120, nil, nil, nil)
   else
      move(img_fd_vertical, (FDroll - roll) * 4, nil, nil, nil)
   end
end

function timer_callback()
   
   if gyroflag_state == 1 then
      -- extend
      gyroflag_rotation = gyroflag_rotation - 0.2
      if gyroflag_rotation <= -20 then
         gyroflag_rotation = -20
         timer_stop(tmr_gyroflag)
      end
   else
      -- retract
      gyroflag_rotation = gyroflag_rotation + 0.2
      if gyroflag_rotation >= 2 then
         gyroflag_rotation = 2
         timer_stop(tmr_gyroflag)
      end
      
   end   
      
      if steerflag_state == 1 then
      -- extend
      steerflag_rotation = steerflag_rotation - 0.4
      if steerflag_rotation <= -5then
         steerflag_rotation = -5
         timer_stop(tmr_steerflag)
      end
   else
      -- retract
      steerflag_rotation = steerflag_rotation + 0.4
      if steerflag_rotation >= 20 then
         steerflag_rotation = 20
         timer_stop(tmr_steerflag)
      end      

   img_rotate(img_gyroflag, gyroflag_rotation)      
   img_rotate(img_steerflag, steerflag_rotation)
   
   end      
   
end      

function new_gyroflag_fsx(gyrofail,gyro )
   if gyrofail > 0 or gyro == false then
      gyroflag_state = 1
   else
      gyroflag_state = 0
   end
    timer_stop(tmr_gyroflag)
   tmr_gyroflag = timer_start(0, 150, timer_callback)
end

-- function new_steerflag_fsx(steer )
--    if steer == false then
--       steerflag_state = 1
--    else
--       steerflag_state = 0
--    end
--     timer_stop(tmr_steerflag)
--    tmr_steerflag = timer_start(0, 150, timer_callback)
-- end


function new_attitude_fsx(roll, pitch, APmode, FDpitch, FDroll)
   
-- Convert boolean to INT
   APmode = fif(APmode, 1, 0)
   
   PT_atitude(roll * -1, pitch * -1,  APmode, FDpitch * -1, FDroll * -1)

end


fsx_variable_subscribe("ATTITUDE INDICATOR BANK DEGREES", "Degrees",
                  "ATTITUDE INDICATOR PITCH DEGREES", "Degrees",
                  "AUTOPILOT FLIGHT DIRECTOR ACTIVE", "Bool",
                  "AUTOPILOT FLIGHT DIRECTOR PITCH", "degrees",
                  "AUTOPILOT FLIGHT DIRECTOR BANK", "degrees", new_attitude_fsx)
fsx_variable_subscribe("PARTIAL PANEL ELECTRICAL", "Enum",
                  "ELECTRICAL MASTER BATTERY", "Bool", new_gyroflag_fsx)
-- fsx_variable_subscribe("AUTOPILOT HEADING LOCK", "Bool", new_steerflag_fsx)


Si vous voyez qq chose qui cloche.

A+
Christian
Un ancien sous-marinier qui a pris de la hauteur.
Avatar de l’utilisateur
arcc
 
Messages: 715
Inscription: 16/12/13
Localisation: La ou fini la terre (Finistere)

Re: Probleme avec une Jauge de ma creation

Messagede JacquesZ » Ven 18 Aoû 2017 22:51

Salut Christian
Le mieux serait que tu publies la jauge en entier, pour pouvoir la tester. Ça aiderait pour le debugging, sinon on est obligé d'imaginer le fonctionnement, c'est moins facile...

Jacques
(Une heure et demie de PA44 avec des pannes N-1 aujourd'hui)
Ma chaîne YouTube Tutos sur l’A320 par un Pilote de Ligne: https://youtube.com/channel/UCljftuoKBcgeR-WBgYJpuoA
Avatar de l’utilisateur
JacquesZ
 
Messages: 2848
Inscription: 24/11/10

Re: Probleme avec une Jauge de ma creation

Messagede arcc » Sam 19 Aoû 2017 12:24

Le mieux serait que tu publies la jauge en entier

Merci Jacques mais je ne sais pas comment faire.

Christian
Un ancien sous-marinier qui a pris de la hauteur.
Avatar de l’utilisateur
arcc
 
Messages: 715
Inscription: 16/12/13
Localisation: La ou fini la terre (Finistere)

Re: Probleme avec une Jauge de ma creation

Messagede JacquesZ » Sam 19 Aoû 2017 20:26

Alors dans Air Manager, dans l'onglet Create/Edit, un clic sur l'icône en forme de dossier t'ouvre la fenêtre du dossier de la jauge, avec un nom cabalistique, qui contient le Logic.lua et le sous dossier ressources.
Tu notes le début du nom du dossier (code) pour pouvoir le retrouver et tu remontes d'un niveau, puis tu zippes l'ensemble du dossier et tu publie le zip en fichier joint.

Jacques
Ma chaîne YouTube Tutos sur l’A320 par un Pilote de Ligne: https://youtube.com/channel/UCljftuoKBcgeR-WBgYJpuoA
Avatar de l’utilisateur
JacquesZ
 
Messages: 2848
Inscription: 24/11/10

Re: Probleme avec une Jauge de ma creation

Messagede arcc » Dim 20 Aoû 2017 11:00

Merci. En fait je ne savais pas ou héberger mon fichier Zip, je n'avais pas vu que l'on pouvait joindre un fichier.

Tu verras à la fin du code, c'est ce qui est en vert qui pose problème.
e9c4e6ec-4834-4ef2-9ce4-d325c309b1a1.zip
(323.14 Kio) Téléchargé 480 fois


A+
Christian
Un ancien sous-marinier qui a pris de la hauteur.
Avatar de l’utilisateur
arcc
 
Messages: 715
Inscription: 16/12/13
Localisation: La ou fini la terre (Finistere)

Re: Probleme avec une Jauge de ma creation

Messagede algue14 » Dim 20 Aoû 2017 14:32

Ce script semble fonctionner, du moins en mode test gratgrat
J'ai réorganisé le script et enlevé le premier stop timer de chaque élément.
peut-être que qu'enlever le 1er stop timer dans le script d'origine fonctionnerait mais bon....si tu as le courage d'essayer rirebleu


Code: Tout sélectionner
---------------------------------------------
--       images          --
---------------------------------------------
img_add_fullscreen("background.png")
img_bg = img_add_fullscreen("attbackground.png")

img_horizon = img_add_fullscreen("atthorizon.png")
img_fd_horizontal = img_add_fullscreen("fd_horizontal.png")
img_fd_vertical = img_add_fullscreen("fd_vertical.png")
img_ring = img_add_fullscreen("attbankind.png")
img_gyroflag = img_add("gyroflag.png",330,-84,500,500)
img_steerflag = img_add("steerflag.png",-358,-78,500,500)
img_add_fullscreen("attfront.png")

---------------
-- Functions --
---------------
gyroflag_rotation = 0
gyroflag_state = 0
steerflag_rotation = 0
steerflag_state = 0
hoop_height = 0

function PT_atitude(roll, pitch, APmode, FDpitch, FDroll)   
-- roll outer ring
    img_rotate(img_ring, roll *-1)
       
-- roll horizon
    img_rotate(img_horizon  , roll * -1)
   img_rotate(img_bg, roll *-1)
   
-- move horizon pitch
    pitch = var_cap(pitch,-30,30)
    radial = math.rad(roll * -1)
    x = -(math.sin(radial) * pitch * 4.0)
    y = (math.cos(radial) * pitch * 4.0)
    img_move(img_horizon, x, y, nil, nil)
   
-- Flight director

-- Horizontal (pitch):
   if APmode < 1 then
      move(img_fd_horizontal, nil, 0, nil, nil)   
   else
      move(img_fd_horizontal, nil, (FDpitch - pitch) * -4, nil, nil)         
   end

-- Vertical (roll):
   if APmode < 1 then
      move(img_fd_vertical, 0, nil, nil, nil)      
   else
      move(img_fd_vertical, (FDroll - roll) * 4, nil, nil, nil)
   end
end



function timer_callback()

if gyroflag_rotation <= -20 then
         gyroflag_rotation = -20
         
   else
   
      if gyroflag_rotation >= 2 then
      gyroflag_rotation = 2
      timer_stop(tmr_gyroflag)
   end
   end

   if gyroflag_state == 1 then
      gyroflag_rotation = gyroflag_rotation - 0.7  -- extend
      
      else
      
      gyroflag_rotation = gyroflag_rotation + 0.7  -- retract
      end
      
      
      img_rotate(img_gyroflag, gyroflag_rotation)   
      
      if steerflag_rotation <= -5 then
      steerflag_rotation = -5
      timer_stop(tmr_steerflag)
   else
   
if steerflag_rotation >= 20 then
   steerflag_rotation = 20
   
   end      
   end
      
      if steerflag_state == 1 then        
      steerflag_rotation = steerflag_rotation + 0.7  -- extend
      else
      -- retract
      steerflag_rotation = steerflag_rotation - 0.7
      end
      
      

   
   img_rotate(img_steerflag, steerflag_rotation)
   end      

   
   
   


   

      
   
   



   
   
function new_gyroflag_fsx(gyrofail,gyro)
   if gyrofail > 0 or gyro == false then
      gyroflag_state = 1   
   else
      gyroflag_state = 0   
   end
    timer_stop(tmr_gyroflag)
   tmr_gyroflag = timer_start(0, 50, timer_callback)

end

 function new_steerflag_fsx(steer)
   if steer == false then
      steerflag_state = 1
   else
      steerflag_state = 0
   end
   timer_stop(tmr_steerflag)
   tmr_steerflag = timer_start(0, 150, timer_callback)
 end


function new_attitude_fsx(roll, pitch, APmode, FDpitch, FDroll)
   
-- Convert boolean to INT
   APmode = fif(APmode, 1, 0)
   
   PT_atitude(roll * -1, pitch * -1,  APmode, FDpitch * -1, FDroll * -1)

end


fsx_variable_subscribe("ATTITUDE INDICATOR BANK DEGREES", "Degrees",
                  "ATTITUDE INDICATOR PITCH DEGREES", "Degrees",
                  "AUTOPILOT FLIGHT DIRECTOR ACTIVE", "Bool",
                  "AUTOPILOT FLIGHT DIRECTOR PITCH", "degrees",
                  "AUTOPILOT FLIGHT DIRECTOR BANK", "degrees", new_attitude_fsx)
fsx_variable_subscribe("PARTIAL PANEL ELECTRICAL", "Enum",
                  "ELECTRICAL MASTER BATTERY", "Bool", new_gyroflag_fsx)
 fsx_variable_subscribe("AUTOPILOT AVAILABLE", "Bool", new_steerflag_fsx)


EDIT:
J'ai remplacé "AUTOPILOT MASTER" par "AUTOPILOT AVAILABLE" dans l'appel des variables, mais après réflexion je ne pense pas que ça change grand chose.

EDIT2 :
la descente des flags (extend) est beaucoup plus lente que la remontée (retract) et ça lague, tu pourra surement corriger ça en jouant sur les valeurs.
A+

Alain
Avatar de l’utilisateur
algue14
 
Messages: 1626
Inscription: 20/04/09
Localisation: Caen ; Normandie

Re: Probleme avec une Jauge de ma creation

Messagede arcc » Dim 20 Aoû 2017 18:29

Merci bien Alain.

Même si je ne comprend pas tout ton cheminement ca semble fonctionner en test juste avec Air manager.
Par contre avec Fsx lancer il y a un petit bug.

Tout d'abord il ne faut pas utiliser la variable AUTOPILOT AVAILABLE car elle sert juste à dire que ton avion est équipé d'un Autopilot Oui/Non.
Le twin étant équipé la variable est toujours à 1.
J"ai mis la variable "Autopilot Master".

Le problème est : au lancement les Flags sont bien "Extend" Lorsque je met l'alimentation électrique le Flag Gyro se rétracte bien.
Je met le switch AP sur On, le Flag Steer se rétracte. Jusque maintenant tout est bon.

Je coupe l'auto pilot le Flag se déploie d'un millimètre et s'arrête. en manœuvrant le switch "Autopilot" le flag arrive à se déployer entièrement.
Pour le Flag Gyro, il semble de déployer normalement quand je coupe l'alim.

Effectivement pour les temps de descente et de remonté, j'ai fait ca à la va vite.

Je remet une nouvelle version de ma gauge si tu souhaites continuer à m'aider (J'ai virer le contour pour plus de faciliter à voir le mouvement des Flags).

e9c4e6ec-4834-4ef2-9ce4-d325c309b1a1.zip
(537.72 Kio) Téléchargé 461 fois


A+
Christian
Un ancien sous-marinier qui a pris de la hauteur.
Avatar de l’utilisateur
arcc
 
Messages: 715
Inscription: 16/12/13
Localisation: La ou fini la terre (Finistere)

Re: Probleme avec une Jauge de ma creation

Messagede JacquesZ » Dim 20 Aoû 2017 19:43

Désolé Christian
J'étais loin de mon PC ce week-end(*), mais je regarde ça ce soir et demain.

Au descriptif du fonctionnement un doute m'habite:
Tu dis: "le Flag gyro apparaît quand je coupe l'alimentation électrique".
Sur Twin Otter la pompe à vide pour les instruments est donc électrique, pas mécanique, tu es sûr?
D'habitude on met une pompe mécanique, et c'est couplé au moteur pour avoir une indépendance vis à vis de la géné electrique, histoire de garder quelques instruments actifs en cas de panne.
Mais il existe aussi des pompes à vide électrique, même si c'est plus rare.

Ou alors c'est un horizon électrique, plus rare, faut regarder la doc.
Dans ce cas un Flag Gyro me paraît inutile, car quand plus d'électricité, ça se voit(le moteur s'arrête et le gyro se fige au bout de 2/3 minutes), alors qu'une petite fuite sur un circuit pneumatique est plus difficile à détecter, le gyro va continuer à tourner, mais plus lentement et va commencer à précessionner, et commencer à indiquer une fausse assiette ou un mauvais cap pour le conservateur de Cap. Le Flag, qui va sortir en dessous d'une certaine vitesse du Gyro est alors utile.

Sur Twin Otter équipé turbines (PT6-A?), la dépression gyro est obtenue je pense comme sur les Beech, par prélèvement sur l'étage compresseur HP de chaque moteur (Bleed Air). Il doit y donc y avoir 2 inters Bleed Air quelque part.

Pour résumer:
Gyro électrique--> Couplé au Master battery, et même mieux, idéalement au MASTER BUS Voltage, car le flag gyro apparaît quand le gyro tourne trop faiblement
Gyro pneumatque--> indépendant de la génération électrique, dépend de la dépression gyro crée par pompe mécanique branchée sur le moteur(pistons) ou par prélèvement compresseur HP ou BP (Turbine), donc le Flag apparaît dès que les moteurs sont coupés

Jacques
(Test renouvellement MEP réussi hier, mal à la jambe gauche! ecroulerire)

(*) Paraît qu'il y a une vie en dehors d'Air Manager! lunettesnoires
Ma chaîne YouTube Tutos sur l’A320 par un Pilote de Ligne: https://youtube.com/channel/UCljftuoKBcgeR-WBgYJpuoA
Avatar de l’utilisateur
JacquesZ
 
Messages: 2848
Inscription: 24/11/10

Re: Probleme avec une Jauge de ma creation

Messagede algue14 » Dim 20 Aoû 2017 20:56

Bon là ça doit marcher,j'ai testé rapide sous P3D, ça a l'air de se comporter normalement.
J'ai gardé uniquement le deuxième stop timer, le premier devait bloquer l’exécution de la fonction extend


Code: Tout sélectionner
---------------------------------------------
--       images          --
---------------------------------------------
img_add_fullscreen("background.png")
img_bg = img_add_fullscreen("attbackground.png")

img_horizon = img_add_fullscreen("atthorizon.png")
img_fd_horizontal = img_add_fullscreen("fd_horizontal.png")
img_fd_vertical = img_add_fullscreen("fd_vertical.png")
img_ring = img_add_fullscreen("attbankind.png")
img_gyroflag = img_add("gyroflag.png",330,-84,500,500)
img_steerflag = img_add("steerflag.png",-358,-78,500,500)
img_add_fullscreen("attfront.png")

---------------
-- Functions --
---------------
gyroflag_rotation = 0
gyroflag_state = 0
steerflag_rotation = 0
steerflag_state = 0
hoop_height = 0

function PT_atitude(roll, pitch, APmode, FDpitch, FDroll)   
-- roll outer ring
    img_rotate(img_ring, roll *-1)
       
-- roll horizon
    img_rotate(img_horizon  , roll * -1)
   img_rotate(img_bg, roll *-1)
   
-- move horizon pitch
    pitch = var_cap(pitch,-30,30)
    radial = math.rad(roll * -1)
    x = -(math.sin(radial) * pitch * 4.0)
    y = (math.cos(radial) * pitch * 4.0)
    img_move(img_horizon, x, y, nil, nil)
   
-- Flight director

-- Horizontal (pitch):
   if APmode < 1 then
      move(img_fd_horizontal, nil, 0, nil, nil)   
   else
      move(img_fd_horizontal, nil, (FDpitch - pitch) * -4, nil, nil)         
   end

-- Vertical (roll):
   if APmode < 1 then
      move(img_fd_vertical, 0, nil, nil, nil)      
   else
      move(img_fd_vertical, (FDroll - roll) * 4, nil, nil, nil)
   end
end


function timer_callback()

if gyroflag_rotation <= -20 then
   gyroflag_rotation = -20
      
else
if gyroflag_rotation >= 2 then
   gyroflag_rotation = 2
end
end
-------------------------------------------------------
if gyroflag_state == 1 then
   gyroflag_rotation = gyroflag_rotation - 0.7  -- extend
else
   gyroflag_rotation = gyroflag_rotation + 0.7  -- retract
end
   img_rotate(img_gyroflag, gyroflag_rotation)   
   
if steerflag_rotation <= -5 then
   steerflag_rotation = -5
else
   
if steerflag_rotation >= 20 then
   steerflag_rotation = 20
   timer_stop(tmr_steerflag)
end
end
      
if steerflag_state == 1 then        
steerflag_rotation = steerflag_rotation + 0.7  -- extend
else
   steerflag_rotation = steerflag_rotation - 0.7-- retract
end
img_rotate(img_steerflag, steerflag_rotation)
end      

   
function new_gyroflag_fsx(gyrofail,gyro)
   if gyrofail > 0 or gyro == false then
      gyroflag_state = 1   
   else
      gyroflag_state = 0   
   end
    timer_stop(tmr_gyroflag)
   tmr_gyroflag = timer_start(0, 50, timer_callback)

end

 function new_steerflag_fsx(steer)
   if steer == false then
      steerflag_state = 1
   else
      steerflag_state = 0
   end
   timer_stop(tmr_steerflag)
   tmr_steerflag = timer_start(0, 150, timer_callback)
 end


function new_attitude_fsx(roll, pitch, APmode, FDpitch, FDroll)
   
-- Convert boolean to INT
   APmode = fif(APmode, 1, 0)
   
   PT_atitude(roll * -1, pitch * -1,  APmode, FDpitch * -1, FDroll * -1)

end


fsx_variable_subscribe("ATTITUDE INDICATOR BANK DEGREES", "Degrees",
                  "ATTITUDE INDICATOR PITCH DEGREES", "Degrees",
                  "AUTOPILOT FLIGHT DIRECTOR ACTIVE", "Bool",
                  "AUTOPILOT FLIGHT DIRECTOR PITCH", "degrees",
                  "AUTOPILOT FLIGHT DIRECTOR BANK", "degrees", new_attitude_fsx)
fsx_variable_subscribe("PARTIAL PANEL ELECTRICAL", "Enum",
                  "ELECTRICAL MASTER BATTERY", "Bool", new_gyroflag_fsx)
 fsx_variable_subscribe("AUTOPILOT MASTER", "Bool", new_steerflag_fsx)
A+

Alain
Avatar de l’utilisateur
algue14
 
Messages: 1626
Inscription: 20/04/09
Localisation: Caen ; Normandie

Re: Probleme avec une Jauge de ma creation

Messagede algue14 » Lun 21 Aoû 2017 14:04

JacquesZ a écrit:Pour résumer:
Gyro électrique--> Couplé au Master battery, et même mieux, idéalement au MASTER BUS Voltage, car le flag gyro apparaît quand le gyro tourne trop faiblement
Gyro pneumatque--> indépendant de la génération électrique, dépend de la dépression gyro crée par pompe mécanique branchée sur le moteur(pistons) ou par prélèvement compresseur HP ou BP (Turbine), donc le Flag apparaît dès que les moteurs sont coupés

Jacques
(Test renouvellement MEP réussi hier, mal à la jambe gauche! ecroulerire)

(*) Paraît qu'il y a une vie en dehors d'Air Manager! lunettesnoires


@ Jacques félicitation pour ton renouvellement MEP applaublanc

Christian, pourquoi tu n'utilise pas la gauge "seneca V" de AM, elle semble fonctionner comme l'indique Jacques, de plus après un rapide coup d’œil sur airliner.net, elle ressemble beaucoup plus a celle d'un DHC-6-200 que celle que tu a faite
(désolé, le but n'est pas d’être désagréable mais.... blemeblanc ), et puis tu peux toujours retravailler les couleurs avec un éditeur d'image(toshop, gimp ...)si tu veux du noir a la place du marron.
A+

Alain
Avatar de l’utilisateur
algue14
 
Messages: 1626
Inscription: 20/04/09
Localisation: Caen ; Normandie

Suivante

Retourner vers LUA, Linda, Macros & gauges Air Manager





Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 7 invités

cron