XML Woes Again!
Moderators: Guru's, The Ministry
XML Woes Again!
Having twubble with my decision warning lights for Shack Mk2.
<Gauge Name="Decision Height Light" Version="1.0">
<Image Name="DecHtBgrd.bmp"/>
<Element>
<Position X="0" Y="0"/>
<Select>
<Value>(A:Radio height, feet) s0 900 > if{ 0 } els{ l0 (A:Decision height, feet) < if{ 1 } els{ l0 300 > 2 + } }</Value>
<Failures>
<SYSTEM_ELECTRICAL_PANELS Action="0"/>
</Failures>
<Case Value="1">
<Image Name="DecHtRed.bmp" />
</Case>
<Case Value="2">
<Image Name="DecHtOrng.bmp" />
</Case>
<Case Value="3">
<Image Name="DecHtGrn.bmp" />
</Case>
</Select>
</Element>
<Tooltip>Decision Height Warning Lights</Tooltip>
</Gauge>
Prob is this only gives me two lights (and if I am right only cos the condition test is incorrect)
Here's how I read it: Alt greater than 900 then the condition statement is not evaluated. Less than 900 generates a 1 and the if section is evaluated. Below Decis Height generates 'true' a one is stored in sierra0, the next bit I don't understand as it appears to checking that Decis Ht is greater than 300 (why). I started out with code from another Radio Alt gauge and modified to suit Shack. Can I get 3 lights using this method. And how, as this is my first attempt at a condition test with 'If'.
Hope someone can help. Else if && or || on error goto Shack in rubbish bin.
Paul
<Gauge Name="Decision Height Light" Version="1.0">
<Image Name="DecHtBgrd.bmp"/>
<Element>
<Position X="0" Y="0"/>
<Select>
<Value>(A:Radio height, feet) s0 900 > if{ 0 } els{ l0 (A:Decision height, feet) < if{ 1 } els{ l0 300 > 2 + } }</Value>
<Failures>
<SYSTEM_ELECTRICAL_PANELS Action="0"/>
</Failures>
<Case Value="1">
<Image Name="DecHtRed.bmp" />
</Case>
<Case Value="2">
<Image Name="DecHtOrng.bmp" />
</Case>
<Case Value="3">
<Image Name="DecHtGrn.bmp" />
</Case>
</Select>
</Element>
<Tooltip>Decision Height Warning Lights</Tooltip>
</Gauge>
Prob is this only gives me two lights (and if I am right only cos the condition test is incorrect)
Here's how I read it: Alt greater than 900 then the condition statement is not evaluated. Less than 900 generates a 1 and the if section is evaluated. Below Decis Height generates 'true' a one is stored in sierra0, the next bit I don't understand as it appears to checking that Decis Ht is greater than 300 (why). I started out with code from another Radio Alt gauge and modified to suit Shack. Can I get 3 lights using this method. And how, as this is my first attempt at a condition test with 'If'.
Hope someone can help. Else if && or || on error goto Shack in rubbish bin.
Paul
Re: XML Woes Again!
Shouldn't the Case values start at 0 ....1, 2, 3 etc. you are starting at 1..... 

Re: XML Woes Again!
Dan
Don't think so; There is only 1 light position on the Shack Mk2, so the 0 gives me my default no lights display. What annoys me is that I could do this as a text only display in Pascal, COBOL and 'C' not that monstrosity C++. If only I could find some detailed syntax and decision structure rules for XML with FS9 I would be OK. (I think).
Thanks
Paul
Don't think so; There is only 1 light position on the Shack Mk2, so the 0 gives me my default no lights display. What annoys me is that I could do this as a text only display in Pascal, COBOL and 'C' not that monstrosity C++. If only I could find some detailed syntax and decision structure rules for XML with FS9 I would be OK. (I think).
Thanks
Paul
Re: XML Woes Again!
<Value>(A:Radio height, feet) 900 > if{ 1 } els{ (A:Radio height, feet) 100 < if{ 3 } els{ 2 } }</Value>
You have to use 1, 2 and 3 because those are your CASE values.
This will give you CASE 1 if you are above 900ft, CASE3 if you are below 100ft and CASE 2 if you are between the two.
Regards
Jim
PS
It's so much simpler in C
FLOAT64 val = pelement->var_value.n;
if(val>900) return 1;
else if(val<100) return 3;
else return 2;
You have to use 1, 2 and 3 because those are your CASE values.
This will give you CASE 1 if you are above 900ft, CASE3 if you are below 100ft and CASE 2 if you are between the two.
Regards
Jim
PS
It's so much simpler in C
FLOAT64 val = pelement->var_value.n;
if(val>900) return 1;
else if(val<100) return 3;
else return 2;
- DaveB
- The Ministry
- Posts: 30457
- Joined: 17 Jun 2004, 20:46
- Location: Pelsall, West Mids, UK
- Contact:
Re: XML Woes Again!
Tks Jim.. I wondered if you'd pop in
I like your definition of 'simple' in 'C'.
(not simple enough for me I'm afraid)
ATB
DaveB :tab:

I like your definition of 'simple' in 'C'.


ATB
DaveB :tab:


Old sailors never die.. they just smell that way!
- Garry Russell
- The Ministry
- Posts: 27180
- Joined: 29 Jan 2005, 00:53
- Location: On the other side of the wall
Re: XML Woes Again!
Didn't you used to be a 'C'man Dave? :roll:
Perhaps I misheard
Garry
Perhaps I misheard


Garry
Garry

"In the world of virtual reality things are not always what they seem."

"In the world of virtual reality things are not always what they seem."
Re: XML Woes Again!
If you want a Light On/Light Off display then you only need a Case 1/Case 2 scenario (or Case 0 / Case 1)Paule wrote:Dan
Don't think so; There is only 1 light position on the Shack Mk2, so the 0 gives me my default no lights display. What annoys me is that I could do this as a text only display in Pascal, COBOL and 'C' not that monstrosity C++. If only I could find some detailed syntax and decision structure rules for XML with FS9 I would be OK. (I think).
Thanks
Paul
<Value>(A:Radio height, feet) 900 > if{ 1 } els{ 2 } </Value>
or
<Value>(A:Radio height, feet) 900 > if{ 0 } els{ 1 } </Value>
However rather than a fixed 900 you need to put in a variable (Decision Height)
<Value>(A:Radio height, feet) (A:Decision height, feet) > if{ 0 } els{ 1 } </Value>
Regards
Jim
Last edited by JimCooper on 19 Oct 2007, 22:11, edited 1 time in total.
- DaveB
- The Ministry
- Posts: 30457
- Joined: 17 Jun 2004, 20:46
- Location: Pelsall, West Mids, UK
- Contact:
Re: XML Woes Again!
:o :o :o
Err.. no Garry. Seamen are sailors who pull ropes around and paint things.. deckies for want of a better word. I was never one of those.. oh dear me no
ATB
DaveB :tab:
Err.. no Garry. Seamen are sailors who pull ropes around and paint things.. deckies for want of a better word. I was never one of those.. oh dear me no

ATB
DaveB :tab:


Old sailors never die.. they just smell that way!
Re: XML Woes Again!
<value> Variable1 Variable2 Compare if{TRUE value} els{False value} </value>Paule wrote: If only I could find some detailed syntax and decision structure rules for XML with FS9 I would be OK. (I think).
Thanks
Paul
You want to make a decision about how Variable1 compares with Variable2 (eg equals, >, <, not equal etc)
If the comparison is TRUE then do whatever is in the IF brackets if its FALSE do whatever is in the ELS brackets
The ELS brackets can contain more Comparisons (and if you need to store and use results then use s0,l0,s1,l1 etc)
There are some tutorials at http://www.fs2x.com
Regards
Jim
Re: XML Woes Again!
Jim
Confused myself and everyone else; perhaps my 'user' name should be "easilyconfuseddotcom". Shack 2 has 3 lights, Green for safely above, orange for Near or At and red for below Dec Height.
Just off to try out something so, in a deep voice "I'll be back".
Paul
Confused myself and everyone else; perhaps my 'user' name should be "easilyconfuseddotcom". Shack 2 has 3 lights, Green for safely above, orange for Near or At and red for below Dec Height.
Just off to try out something so, in a deep voice "I'll be back".
Paul