Sign in to follow this  
n4gix

XML - How do you do it?

Recommended Posts

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
Help AVSIM continue to serve you!
Please donate today!

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

Share this post


Link to post
Share on other sites

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

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

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

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

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

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

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

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...

Share this post


Link to post
Share on other sites

Thanks for the gauge - I tried it, but I get the same behavior if I use it or the reload keyboard command. It just seems that FS loses it's mind and refuses to reload the panel (correctly). I'd say about 90% of the time the reload works. For the rest I have to re-start FS9. I can live with it. Now if I could only find out what is wrong with the hoist's up code....Senior Captain, Pier Glass Aviation

Share this post


Link to post
Share on other sites

Well - here's a straightforward question -in the section where I do the test for the current time being greater than the winch_timer time - how often is this actually entered? I was thinking it was once per second but maybe it is not so?Edit: And the answer is no it is not. I had to set up another 1 second timer so that the code would only execute once per second.I now have a properly functioning three position hoist activation switch that produces an audio output and retains it's cable payout so that if you extend the hook for 20 seconds, it only takes 20 seconds to retract it.Woo Hoo! Wow! talk about a learning curve. I advise anyone using FSPS to be wary of it's XML parsing and changing of files. That was only about one hour per line of code!Thanks for all your help folks! Much Appreciated.Senior Captain, Pier Glass Aviation

Share this post


Link to post
Share on other sites

Which might explain why Jan (and me too !) still develop XML the oldfashioned way, with Notepad :-)And use InternetExplorer as syntax checker.In general, it wouldn't be the first time that a "tool" introduces more problems than it solves :-)Although I can't tell if this is the case with FSPS.Cheers, Rob

Share this post


Link to post
Share on other sites

In FSPS, Edit the gauge, and then edit the XML - I set it to bring up Notepad with the xml file in it.No matter how you format in Notepad (I like to use tabs rather than spaces for indentation), it (FSPS) reformats the xml itself replacing the tabs with spaces which makes it hard to tell which <> goes with which > type of tag.As I said above, if there is an error in the xml it doesn't like, it tends to remove any code near or after it, and substitutes its own > type tags. So, for instance, I had a syntax error in the area, and *all* of the area of text disappeared because it was after the error. I can think of many different ways to point out an error without eliminating code that had nothing to do with it. Strikes me as lazy programming. Meanwhile I was going nuts because the switch's visuals and/or behavior was wrong. It wasn't until this morning (after a good night's sleep) I realized what FSPS was doing.But now I, and anyone who reads these posts, knows of this bizarre behavior and hopefully this will help those folks avoid the same traps and frustration I was feeling for the past several days.Senior Captain, Pier Glass Aviation

Share this post


Link to post
Share on other sites

Hi, Geoff...It's very difficult to tell from a distance, but I think you may be introducing the problem by editing .xml files with FSPS while FS9 is active.FWIW, I use FSPS, too, but I prefer to do my initial gauge creation and testing a slightly different way.I use NotePad to create an .xml file and name it something like "TEST 1 hyd sys.xml". Then I install it in FSPS. If it won't show up in FSPS, there are missing graphics or a .bmp labeling problem, so that has to be fixed first.Next, with the "TEST 1 hyd sys" gauge properly placed in FSPS, I start FS9 or reload the panel if FS9 is already running. The gauge may show up in the FS9 panel or it may not. It might be there but not work correctly. Either way, I go back to NotePad and modify the .xml file, then save it as "TEST 2 hyd sys.xml". Then I use the swap feature in FSPS to replace the TEST 1 gauge with the modified TEST 2 gauge. Save FSPS. Reload the FS9 aircraft & panel. Repeat as necessary, changing the number and swapping the gauge each time.That process continues until the coding is completely finished. At that point, the last TEST ?? file is renamed, for example, "hyd sys.xml". A copy of the finalized gauge files is saved separately from FS9 and all the intermediate files are deleted. Use FSPS to swap the last TEST file with the final version and the job's done. (Btw, do NOT try to rename the last TEST file or both FSPS and FS9 will prevent the name change.) With modifications of a .bmp file, you can ignore FSPS entirely. Just modify the bitmap and reload the aircraft. Since the file hasn't changed names, FSPS doesn't come into play. Just remember to refresh FSPS later, after the final modification. There are probably many ways to create and test gauges using FSPS and FS9. I'm not saying this is the best way, but it works well for me.Good luck,Glenn

Share this post


Link to post
Share on other sites

Personally, I'd forget about the so-called XML Editor in FSPS entirely.Use FSPS for what it was originally intended: design and edit panels... ;)If you are just looking for a decent XML Editor for checking syntax and formatting, use XMLnotepade.exe 2007:http://www.microsoft.com/downloads/details...&displaylang=enUse the DTD supplied with the FS9 SDK: gauges.dtd and you will have a nicely behaved XML editing setup... ;)

Share this post


Link to post
Share on other sites

Hi Bill,Just intalled and tried XMLnotepad. Seems very similar to ACE editor, a tree-style format, not suitable for me (too slow to work with :-( ) ; I prefer to use UltraEdit32, a powerful text editor that accepts XML schemas; and test the file with Internet Explorer.Thank you anyway for the link :-)Tom

Share this post


Link to post
Share on other sites

>Hi Bill,>>Just intalled and tried XMLnotepad. Seems very similar to ACE>editor, a tree-style format, not suitable for me (too slow to>work with :-( ) ; I prefer to use UltraEdit32, a powerful text>editor that accepts XML schemas; and test the file with>Internet Explorer.>>Thank you anyway for the link :-)No problem. I know that everyone will have different priorities and preferences, but it's always nice to have choices... :-beerchug

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