Jump to content

Sign in to follow this  
Guest Karl R Pettersen

Magnetos

Recommended Posts

Guest bones

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

(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
Guest bones

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
Guest bones

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
Guest bones

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
Guest bones

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
Guest bones

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
Guest Karl R Pettersen

HiI'd just like to add a few comments to this thread.--SNIP-->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.--SNAP--Not necessarily: There could be an extreme situation where somehow the current manage to pass through a switch in the off position, making the light actually shine though just very briefly. Real comparison; a lightning strike. FS comparison; when you're trying to code some radio logic that just doesn't seem to make sense - there is actually something else going on that you have completely overlooked (localizer states if I recall correctly). Sometimes when coding xml the logic doesn't seem to add up at all.--SNIP-->Does it go out if you engage Nav Hold or turn the AP Master to off?--SNAP--Oh my, the autopilot :) I still haven't figured out the complete logics behind this little gizmo yet, and I have the manual! :) Yes, so much for the switch on or off, but how about the light? HDG or NAV? Or could it actully be BOTH? What is a capture zone? Ugh - the memories... :)Bills sequence of 1. load a/c, 2. DO_ONCE etc, is a key sequence that should be learned as quickly as possible, because you'll need it so many times ahead. However, for this particular application of the sequence I would like to state the importance of a missed step, the WAIT step. I *strongly* adwise to use a WAIT step in there, but only when dealing with the LOAD A/C step. The particular problem occurs when the loading is complete, your gauges are properly initialized, and here is the clue: FS9 isn't even finished initializing on it's own! What do you think happens when you set the fuel switch in an initialization gauge, then FS9 does something else because it's still processing the .FLT file?--SNIP-->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.--SNAP--As for coding logic, I have found that almost anything is possible once you've figured out the logic yourself. I.e. I did a four-switch bar-guarded version of a magneto switch for a Cessna C421B, which at the time appeared to be impossible because FS9 didn't have it "built in". Through the use of own L:Var's and bitwise checking of the A:Var's, I managed to bring it home (thangs to the guys in this forum I might add, putting me in the right direction). Just don't give up, cool down with a few beers and you'll think more clearly.--SNIP-->"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?"--SNAP--The problem with us FS-coders, is that we refuse to recognize the problem in the first place ;) We always blame it on Bill (no, the Gates version :D)--SNIP-->For any really complex project, I always begin by flowcharting the logic, then testing every possible branch for validity--SNAP--Sorry, but I disagree:1. Begin simple project.2. Works fine, but needs a little more.3. Yes, that's it! But... huh? Why did?4. Need to recode something else.5. Project growing, just realized.6. In order to fix no.3, I need to add a pressurization system.7. ...which needs other engine parameters...8. ...NOW we start the flowcharting!9. Realize that some of the flowchart branches are invisible.10. Realize flowchart bubbles that shouldn't be connected, are.11. Recheck your initial time/cost/planning chart.12. Release the project with options as it was at no. 1.The story for many game developers maybe? :D

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...