Page 1 of 2

XML Woes Again!

Posted: 18 Oct 2007, 15:19
by Paule
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

Re: XML Woes Again!

Posted: 19 Oct 2007, 15:30
by DanKH
Shouldn't the Case values start at 0 ....1, 2, 3 etc. you are starting at 1..... :dunno:

Re: XML Woes Again!

Posted: 19 Oct 2007, 16:51
by Paule
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

Re: XML Woes Again!

Posted: 19 Oct 2007, 21:47
by JimCooper
<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;

Re: XML Woes Again!

Posted: 19 Oct 2007, 22:02
by DaveB
Tks Jim.. I wondered if you'd pop in :thumbsup:

I like your definition of 'simple' in 'C'. :lol: (not simple enough for me I'm afraid) :$

ATB

DaveB :tab:

Re: XML Woes Again!

Posted: 19 Oct 2007, 22:05
by Garry Russell
Didn't you used to be a 'C'man Dave? :roll:

Perhaps I misheard :lol: :lol:

Garry

Re: XML Woes Again!

Posted: 19 Oct 2007, 22:07
by JimCooper
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
If you want a Light On/Light Off display then you only need a Case 1/Case 2 scenario (or Case 0 / Case 1)

<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

Re: XML Woes Again!

Posted: 19 Oct 2007, 22:07
by DaveB
: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 :lol:

ATB

DaveB :tab:

Re: XML Woes Again!

Posted: 19 Oct 2007, 22:45
by JimCooper
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
<value> Variable1 Variable2 Compare if{TRUE value} els{False value} </value>

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!

Posted: 20 Oct 2007, 14:51
by Paule
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