Sign in to follow this  
Guest Karl R Pettersen

Magnetos

Recommended Posts

Jorge Salas made life a lot easier for us gauge newbies by releasing his cockpit switch files - for which I am indebted to him.Most switches are two state - either on or off - and so a couple of bitmaps placed as Case 0 and 1 combined with a mouse click to toggle the event work absolutely fine. In the case of magnetos though there is a flaw.Jorge's code works fine for my aircraft as the magneto switch is a simple on/off switch rather than the usual off,left,right,on,start type. He has:(G:Var1,bool)(G:Var1) ! (>G:Var1) (G:Var1) if{ 0 (>K:MAGNETO1_BOTH) } els{ 0 (>K:MAGNETO1_OFF) }The problem with the above code is that on starting FS the magento switches (bitmaps) are always off - whether the aircraft has engines running or not. I presume the code should include a check on present engine status and should set the appropriate magneto bitmap but may I ask how this should be done?

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

(RECIP ENG LEFT MAGNETO:1,bool)(RECIP ENG LEFT MAGNETO:1) 0 == if{ (>K:MAGNETO1_OFF) }els { >K:MAGNETO1_BOTH }(RECIP ENG LEFT MAGNETO:1) 0 == if{ (>K:MAGNETO1_BOTH) } els{ (>K:MAGNETO1_OFF) }

Share this post


Link to post
Share on other sites

A man of few words Bill - but every one a gem..I suspect I was locked into thinking events would do the trick and ignoring variables..Many thanks indeed.

Share this post


Link to post
Share on other sites

>A man of few words Bill - but every one a gem..>>I suspect I was locked into thinking events would do the trick>and ignoring variables..>>Many thanks indeed. Well, I offer no warranty that it will work in that precise syntax, but it is likely close... ;)It occured to me that since you are only interested in the cases of OFF or BOTH, that either one of the magneto variables could serve as a flag, hence I simply chose the LEFT one for the conditional check. You could just as easily substitute RIGHT magnetor for the same result.Also, I am usually averse to using G:VarX forms simply because (a) they are not strictly necessary and (:( they are most certainly not very descriptive! ;)I tend to put "initialization" checks into all my gauges to keep thing in synch.

Share this post


Link to post
Share on other sites

It is slowly sinking into my dim brain that gauges need more thought than one may realise. A two state switch is a doddle but then you have to think about further effects or conditions that the switch operation may trigger - and this is what caught me out.A light switch only turns a light on or off. A magneto is more complex because the gauge needs to check if the engine is running first and set the switch position accordingly. An autopilot HDG Hold button can be created very simply too - but then I see further conditions creeping in. Does it go out if you engage Nav Hold or turn the AP Master to off? For a newcomer this is all very new stuff but it's certainly addictive. I readily admit that I have a long way to go..P.S. Your code was good in that the mag switch state is now reflecting engine on/off condition but the switch itself is immobile. Leave that one with me - it will be a good learning process trying to work out the cure..Many thanks, as always.

Share this post


Link to post
Share on other sites

>P.S. Your code was good in that the mag switch state is now>reflecting engine on/off condition but the switch itself is>immobile. Leave that one with me - it will be a good learning>process trying to work out the cure..Fair enough! I'll give you a hint though... How can you tell if you've already done something? IOW, how would you flowchart the logic to preform an action only once? :)

Share this post


Link to post
Share on other sites

I'm getting to the age were I find it hard to remember if I have already done something or not. :( Having never been a programmer (so don't laugh) logic tells me that the solution is to check the state first. If a light is on then the lightswitch should also show in the on position and the next (and only) action must be to turn it off.For the magnetos they are indeed on because the engine is running and the clever tooltip says they are on. In this case the gauge must be coded to show the on bitmap and that the next click action is to turn the mags off (and change the bitmap). The reverse must also be true.That is how I see the logic but is it logic for a programmer? :)

Share this post


Link to post
Share on other sites

>That is how I see the logic but is it logic for a programmer?That's what you have so far... Now you need to take the next step:1. load a/c2. if DO_ONCE = 1 skip to step 43. if engine running set magnetos to BOTH & set DO_ONCE = 1, else set DO_ONCE = 14. Rest of code...Notice that regardless of whether the engine is running or not, the DO_ONCE flag is set, meaning that step #3 will only be checked the first time the panel is loaded.Now, "translate" the pseudo-code above to XML... ;)

Share this post


Link to post
Share on other sites

Hi There is no need for a DO_ONCE here :-)It's enough with an element that reads the FS magneto vars' state and show the proper bitmap: (A:RECIP ENG1 LEFT MAGNETO,bool) (A:RECIP ENG1 RIGHT MAGNETO,bool) || If the engine is running when you start the flight, both AVars should be 1 (ON) then value=1, and vice versa.In fact, this element's value will always return the combined state of both magnetos, so no extra code is needed.And to switch magnetos: (A:RECIP ENG1 LEFT MAGNETO, bool) (A:RECIP ENG1 RIGHT MAGNETO, bool) || if{ (>K:MAGNETO_OFF) } (* for a single eng a/c *) els{ (>K:MAGNETO_BOTH) } (* for a single eng a/c *) Now, the code by Jorge Salas used a (G:Var) to handle the bitmaps, so in that case at startup will ALWAYS show the Bitmap0 (off) unless a DO_ONCE element is formely coded to give that GVar the proper value.In this case it is not necessary because an FS own's AVar is directly used.Hope this helpsTom

Share this post


Link to post
Share on other sites

".S. Your code was good in that the mag switch state is nowreflecting engine on/off condition but the switch itself isimmobile. Leave that one with me - it will be a good learningprocess trying to work out the cure.."This was a "teaching moment." There's always more than one way to solve a problem...In fact, my initial post contained a similar solution to the one you've offered, albeit one that has the above mentioned "flaw." The assignment was to find a solution. ;)

Share this post


Link to post
Share on other sites

Bill,Hey, mine was a "teaching moment" also!:-)You were driving him towards HOW to use a DO_ONCE logic.I simply showed a manner to understand WHEN to use it :-)Regards,Tom

Share this post


Link to post
Share on other sites

Interesting reply Tom because I can now see a potential redesign.The Aztec has two rocker switches for left and right magnetos for each engine - two switches either side of the starter. I had assumed that separate mag switches were not possible so I had only created one for each engine, switching from OFF to BOTH.From your post I am now wondering if the dual mag switches are actually a possibility. It depends if FS recognises that if Eng1 Left Mag is on and Eng1 right mag is on it automatically works out that the Eng1 Mag Both condition is true.Off to play..

Share this post


Link to post
Share on other sites

Bones,Just a HINT...FS does not have an internal variable like "Eng1 Mag Both"...Go figure the logic :-)Tom

Share this post


Link to post
Share on other sites

>Bill,>>Hey, mine was a "teaching moment" also!:-)>>You were driving him towards HOW to use a DO_ONCE logic.>I simply showed a manner to understand WHEN to use it :-)I see you're point. The best advice I can give anyone who is serious about learning programming is what I used to tell my CS101 students back when I was teaching at U of F, Gainesville:"If you can't solve the problem with pencil and paper, how on earth do you expect to be able to tell a computer how to solve it?" ;)For any really complex project, I always begin by flowcharting the logic, then testing every possible branch for validity... ;)

Share this post


Link to post
Share on other sites

Nicely said Bill. The key is always in getting the thinking logic kick started into action - not easy when a total newbie like myself tries to jump in at the deep end.. :)I'm getting there slowly.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this