Jump to content
Sign in to follow this  
n4gix

XML - How do you do it?

Recommended Posts

Guest Captain Geoff

I've now been playing with my hoist gauge and I am getting very frustrated. I want to add a timer to the gauge. Simple code - even found some on here.I'm using the FS Panel Studio's gauge editor, editing the XML myself.I add a line of code the gauge disappears. remove the line - gauge is still gone. Fiddle with the **** XML for 30 minutes and suddenly the gauge reappears. Put a different but similar line back in and the gauge disappears repeat above steps ad nauseum.Is there a syntax checker or some tool or some means available to find out why my switch disappears (and by disappear - I mean it literally does not appear on a loaded aircraft panel in FS9).I swear I'm back to what was working code and now it's not.TOTALLY frustrated!Senior Captain, Pier Glass Aviation

Share this post


Link to post
Share on other sites

Hi,It helps when you show the code.Jan"Beatus ille qui procul negotiis..."

Share this post


Link to post
Share on other sites
Guest Captain Geoff

I'm not sure it's a code issue. I just tried an experiment in which I created a copy of the xml file of my working switch. Saved the copy safely away.I then used FSPS to make my 1 line change in which I added a one second timer. Naturally, the switch disappeared.So, I then opened up the saved good xml file copied the contents, closed the file. The I opened up the XML editor via FSPS, selected it's contents, deleted them and pasted the good xml file's contents into it. Saved the xml which now contains the original good file's contents. Switch doesn't show up. ARRGGHH!Is FS Panel Studio screwing with me?here's the code that is the from the "good" xml file:(L:gmm_winch_switch, enum) 0 == (L:gmm_winch_switch, enum) 1 == (L:gmm_winch_switch, enum) 2 == 2 (>L:gmm_winch_sound, enum) 1 (>L:gmm_winch_switch, enum) 0 (>L:gmm_winch_sound, enum) 0 (>L:gmm_winch_switch, enum) 2 (>L:gmm_winch_sound, enum) 2 (>L:gmm_winch_switch, enum) Senior Captain, Pier Glass Aviation

Share this post


Link to post
Share on other sites

Hi,This seems to be ok, but show the code which has given troubles, with the timer(?)Btw.This is more efficient instead of all the visibles:(L:gmm_winch_switch,enum)Jan"Beatus ille qui procul negotiis..."

Share this post


Link to post
Share on other sites
Guest Captain Geoff

Apparently, if I add a statement to the third (or any element) - even if it is a null one such as below - the switch disappears on the panel. Any thoughts on why this is happening? (L:gmm_winch_switch, enum) 2 == What I would really like to add is(L:gmm_winch_timer, seconds) 1 + (>L:gmm_winch_timer, seconds)and some more code would go here as well.....Senior Captain, Pier Glass Aviation

Share this post


Link to post
Share on other sites

Hi,This is very wrong:This is always possible:(L:gmm_winch_timer, seconds) 1 +(>L:gmm_winch_timer, seconds)and some more code would go here as well.....It is better to put the timer in the click like:(P:absolute time,seconds) 1 + (>L:gmm_winch_timer,seconds)and in the value:(L:gmm_winch_timer,seconds) (L:gmm_winch_timer,seconds) > if{ 1 (>L:------) } els{ 0 (>L:------) } etc.Jan"Beatus ille qui procul negotiis..."

Share this post


Link to post
Share on other sites
Guest Captain Geoff

OK, This is weird!I was putting the Select on one line and the Value on another. Just for giggles I put the code all together like this:(L:gmm_winch_timer, seconds) 1 + (>L:gmm_winch_timer, seconds)AND THIS WORKS!?! What's the difference other than a newline character between the two Statements? I think there is something wrong with FSPS. ANyone else experience this sort of strange behavior?Senior Captain, Pier Glass Aviation

Share this post


Link to post
Share on other sites
Guest Captain Geoff

Thanks Jan - excellent idea. I was using another example from code here in the forum as a starting point.Senior Captain, Pier Glass Aviation

Share this post


Link to post
Share on other sites
Guest Captain Geoff

Allright - I go back to add the next line of code, and FSPS has moved the select and the values on separate lines. Still, the switch shows up on the panel.Add 2 lines of code - one at a time and test after each is added. works fine. Think I'm finally going forward. Add another line of code - no switch. remove last entered code. no switch. I'm about to dump FSPS on the floor and stomp on it. This is INSANE. It's like it's taunting me - "Go ahead add a line, and I'll remove the gauge. nyeah, nyeah, nyeah, nyeah, nyeah!" I've got over 20 years of coding experience and I've never run into something so flakey. Maybe it's time to drop back to real basics and forget FSPS at least for gauges.Senior Captain, Pier Glass Aviation

Share this post


Link to post
Share on other sites

This is not an FSPS issue. It's an XML issue. If you get the syntax wrong, the gauge will not draw. Just think, if you were coding in C, every time you made a mistake like this, the sim would crash to desktop...Keep at it, you will get it eventually.Doug

Share this post


Link to post
Share on other sites

Hi,I only use Notepad.Jan"Beatus ille qui procul negotiis..."

Share this post


Link to post
Share on other sites
Guest Captain Geoff

Well, I don't know what program is at fault but get this -Working code - I change the time check from 5 secs to 50 secs - a simple change of adding a single zero to the XML file.reload the aircraft in FS - switch disappears.In desperation I shutdown FS completely, and restarted it. switch reappears.So - is it XML? I don't think so since the code itself was not changed. Is it FSPS? Probably not since once again the code for the gauge didn't change. FS9 - it has to be. If I have to shutdown FS9 everytime I make a gauge change where the switch disappears my rate of progress will be so slow that a snail will out code me.I've been beating my head against the wall and all I have to say is I really admire gauge developers. I'm going to toss in the towel if this behavior persists. Well, I'll keep on restarting FS if I have to 'cause I'm so close to having this done, but it is totally aggravating. Senior Captain, Pier Glass Aviation

Share this post


Link to post
Share on other sites
Guest Captain Geoff

Well, now FSPS has lost the bitmap to the switch. The bitmap is sitting in the CAB file just as it should... The Final straw! It is nice to use FSPS to place gauges on a panel - but forget about using it to design a gauge.Senior Captain, Pier Glass Aviation

Share this post


Link to post
Share on other sites
Guest Captain Geoff

I now see what FSPS is doing. If there is an error in the XML it summarily throws out existing XML code near or after the error and apparently tries to close all the reamining open tags. So now I keep a copy of the XML in a separate file so I can cut and paste it back when FSPS destroys it's copy of the XML. FS9 is still having some problems reading the gauge/having it show up, but now I've learned to just shut it down and re-run FS9.So, I'm making progress, but my switch isn't quite correct yet. Below is the code and I've added my comments to explain what I think it is doing/supposed to do.Off the top though - the switch moves visually the way it is supposed to. Since the hoist starts out raised - clicking on the up causes the switch to flicker momentarily to up, a brief sound, and back to off - which is correct behavior.Clicking on the down side of the switch, causes a 5 second timer to run causing the down switch to be displayed and the hoist noise to sound for five seconds, and then the sound cuts off and switch returns to off.So far so good. But now the up portion of the switch when clicked on, never stops the noise or returns to off... which it should... so here's the code and my description.... ### are my comments for this posting (not in the actual code)(L:gmm_winch_switch, number) (P:absolute time, seconds) (L:gmm_winch_timer, seconds) >= if{ 0 (>L:gmm_winch_switch, number) 0 (>L:gmm_winch_sound, enum) } els{ (L:gmm_winch_switch, number) 1 == if{ (L:gmm_winch_payout_time, number) 1 - (>L:gmm_winch_payout_time, number) } els{ (L:gmm_winch_payout_time, number) 1 + (>L:gmm_winch_payout_time, number) } } ###############################here's what I think I've said in pseudo codeif (the current time >= winch shutdown time) { set the switch position to 0 turn the sound off} else { if (the switch is in the up position){ subtract one from the payout time } else { add one to the payout time }}################################ 2 (>L:gmm_winch_sound, enum) 1 (>L:gmm_winch_switch, number) (P:absolute time, seconds) (L:gmm_winch_payout_time, number) + (>L:gmm_winch_timer, seconds) ################################if (click on the up position) { turn the sound on turn the up switch on (graphic) set the shutoff timer = current time + payout time}################################ 0 (>L:gmm_winch_sound, enum) 0 (>L:gmm_winch_switch, number) (P:absolute time, seconds) (>L:gmm_winch_timer)################################if (click in the off position) { turn off the sound turn the switch graphic to off set the winch timer to current time}################################ 2 (>L:gmm_winch_sound, enum) 2 (>L:gmm_winch_switch, number) (P:absolute time, seconds) 5 + (>L:gmm_winch_timer, seconds) (L:gmm_winch_timer, seconds) (L:gmm_winch_payout_time, number) - (>L:gmm_winch_timer, seconds)###############################if (click in the lower/down position){ turn the sound on turn the switch graphic to down Set the winch timer to current time + 5 seconds set the winch timer = winch timer - payout time############################### The payout time allows the winch to payout for say 20 seconds and be manually stopped - and then the retraction should only take 20 seconds - at least that's my intent. Note that I tried doing this:(P:absolute time, seconds) 5 (L:gmm_winch_payout_time, number) + - (>L:gmm_winch_timer, seconds)but apparently it's not correct and I don't know why. the formula should be: timer = current time + 5 seconds - payout timeNote that I'm using 5 seconds as the max payout time just to literally speed things up - eventually it will be 60 seconds.Any help to discover a coding or logic error will be most appreciated.Senior Captain, Pier Glass Aviation

Share this post


Link to post
Share on other sites

>Well, I don't know what program is at fault but get this ->>Working code - I change the time check from 5 secs to 50 secs>- a simple change of adding a single zero to the XML file.>I've been beating my head against the wall and all I have to>say is I really admire gauge developers. I'm going to toss in>the towel if this behavior persists. Well, I'll keep on>restarting FS if I have to 'cause I'm so close to having this>done, but it is totally aggravating. You don't have to keep starting/stopping/starting FS at all. You can either install a tiny XML gauge on your 2d panel to "Reload" the panel, or configure a keyboard entry for "Reload Panels" in FS.After first loading the a/c, use "Reload Panels" to unlock the XML gauges so that you can save your revisions to disk.After making/saving any changes to your XML code, use "Reload Panels" to reinitialize the gauge system and see your changes instantly.Attached here is a zipped version of the Reload gauge I use that will work in both FS9 and FSX...


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

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  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...