XML Woes Again!

A quiet place for budding model makers to share thoughts, get answers to questions and request and share references.

Moderators: Guru's, The Ministry

Paule
Comet
Comet
Posts: 165
Joined: 17 Oct 2005, 15:28
Location: NE Lincs

XML Woes Again!

Post 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

User avatar
DanKH
Battle of Britain
Battle of Britain
Posts: 3526
Joined: 02 Dec 2004, 10:53
Location: EKCH, Denmark
Contact:

Re: XML Woes Again!

Post by DanKH »

Shouldn't the Case values start at 0 ....1, 2, 3 etc. you are starting at 1..... :dunno:
Best Rgds
Dan
Image
Image Image
Who's General Failure, and why is he reading my harddisk?

Paule
Comet
Comet
Posts: 165
Joined: 17 Oct 2005, 15:28
Location: NE Lincs

Re: XML Woes Again!

Post 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

User avatar
JimCooper
Lightning
Lightning
Posts: 296
Joined: 30 Mar 2006, 18:42
Contact:

Re: XML Woes Again!

Post 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;

User avatar
DaveB
The Ministry
Posts: 30457
Joined: 17 Jun 2004, 20:46
Location: Pelsall, West Mids, UK
Contact:

Re: XML Woes Again!

Post 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:
ImageImage
Old sailors never die.. they just smell that way!

User avatar
Garry Russell
The Ministry
Posts: 27180
Joined: 29 Jan 2005, 00:53
Location: On the other side of the wall

Re: XML Woes Again!

Post by Garry Russell »

Didn't you used to be a 'C'man Dave? :roll:

Perhaps I misheard :lol: :lol:

Garry
Garry

Image

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

User avatar
JimCooper
Lightning
Lightning
Posts: 296
Joined: 30 Mar 2006, 18:42
Contact:

Re: XML Woes Again!

Post 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
Last edited by JimCooper on 19 Oct 2007, 22:11, edited 1 time in total.

User avatar
DaveB
The Ministry
Posts: 30457
Joined: 17 Jun 2004, 20:46
Location: Pelsall, West Mids, UK
Contact:

Re: XML Woes Again!

Post 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:
ImageImage
Old sailors never die.. they just smell that way!

User avatar
JimCooper
Lightning
Lightning
Posts: 296
Joined: 30 Mar 2006, 18:42
Contact:

Re: XML Woes Again!

Post 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

Paule
Comet
Comet
Posts: 165
Joined: 17 Oct 2005, 15:28
Location: NE Lincs

Re: XML Woes Again!

Post 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

Post Reply