• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FS2004 Not an elegant solution

Messages
1,468
Country
italy
Is there a better and easier way to do this? (L:upset_A,number) 1 == is the value returned from the switch and causes the hatched image to appear for 15 seconds (what I want). But after that it flickers from on image to another (not what I want).
How best can I get it to show the hatched image only once and only for fifteen seconds until the next time the switch returns a value of 1.
In effect what I'm after is the switch to return the value 1 (it does that ok) with this value the hatch image to appear once only for fifteen seconds and be replaced by the UPSET_UP.bmp until the next time.
your ideas appreciated.
vololiberista
Code:
<Gauge Name="Left Aileron Upset TI" Version="1.0">
   <Element>
<Image Name="UPSET_HATCH.bmp" Luminous="1"/>
 <Select>
<Value>(L:upset_A,number) 1 == if{ 2 (A:Fuel total quantity,gallons) 0 &gt; (A:Indicated Altitude,feet) and if{ (P:Local time,seconds) 15 % } } els{ (A:Fuel total quantity,gallons) 0 &gt; (A:Indicated Altitude,feet) and if{ (P:Local time,seconds) 0 % } } </Value>
<Failures>
            <SYSTEM_ELECTRICAL_PANELS Action="1"/>
         </Failures>
         <Case Value="0">
            <Image Name="UPSET_UP.bmp" Luminous="1"/>
         </Case>
         <Case Value="1">
            <Image Name="UPSET_HATCH.bmp" Luminous="1"/>
         </Case>
<Case Value="2">
            <Image Name="UPSET_UP.bmp" Luminous="1"/>
         </Case>
      </Select>
   </Element>
</Gauge>
 
One or two strange things here.
Code:
<Gauge Name="Left Aileron Upset TI" Version="1.0">
	<Element>
	<Image Name="UPSET_HATCH.bmp" Luminous="1"/> [COLOR="Red"] //this needs to go above <Element> //[/COLOR]
 		<Select>
			<Value>(L:upset_A,number) 1 == 
				if{ 2 (A:Fuel total quantity,gallons) 0 &gt; (A:Indicated Altitude,feet) and 
					if{ (P:Local time,seconds) 15 % } 
				} 
				els{ (A:Fuel total quantity,gallons) 0 &gt; (A:Indicated Altitude,feet) and 
					if{ (P:Local time,seconds) 0 % }  [COLOR="Red"]// this returns the time in seconds, not 0,1 or 2 //[/COLOR]	
				}	[COLOR="Red"]// should both the &gt; be &lt; //[/COLOR]
			</Value>
        			<Failures>		
				<SYSTEM_ELECTRICAL_PANELS Action="1"/>
         			</Failures>	
         				<Case Value="0">	
            					<Image Name="UPSET_UP.bmp" Luminous="1"/>		[COLOR="Red"]// Luminous ="True" not 1 //[/COLOR]
         				</Case>
         				<Case Value="1">
            					<Image Name="UPSET_HATCH.bmp" Luminous="1"/>
         				</Case>
				<Case Value="2">
            					<Image Name="UPSET_UP.bmp" Luminous="1"/>
         				</Case>	
		</Select>
   	</Element>
</Gauge>

Before you go any further have a look at Arne Bartels tutorial xmlgau01.zip from flightSim.com library 'FS2002-All files' section.
I find it very useful and have made myself a card with the salient points on as an aid.[ I've foud how to attch *.zip files = RTFM ]
Ted
 

Attachments

Hi,
not sure about the timer section of the code you have, maybe someone else can comment on that. If it works than that's ok, i just don't really understand the modulo in that code.

But i see something strange right away in other parts of your code:

Code:
2 (A:Fuel total quantity,gallons) 0 &gt; (A:Indicated Altitude,feet) and

and also

Code:
(A:Fuel total quantity,gallons) 0 &gt; (A:Indicated Altitude,feet) and if

You are saying:
if (A:Fuel total quantity,gallons) greater than 0 and (A:Indicated Altitude,feet) then blabla.

You want something to compare (A:Indicated Altitude,feet) to.
Like :
(A:Indicated Altitude,feet) 100 &gt;
meaning (A:Indicated Altitude,feet) greater than 100 feet.

As i said before, write down in pseudo code what you want and then convert that to xml.

A different approach (untested) and leaving the altitude and fuel out of the equation for now- you can add that if you need it of course.
Also i took out case value 2 since it is the same bitmap as case value 0.
Assuming L:Upset_A, number gets set and reset in a different gauge :

Code:
<Gauge Name="Left Aileron Upset TI" Version="1.0">
<Image Name="UPSET_HATCH.bmp" Luminous="True"/>
   <Element>
    <Select>
   <Value>(L:upset_A,number) 1 == if{ (P:Local time,seconds) 15 + (&gt;L:Timer,enum) 1 (&gt;L:Upset_Image, enum) } </Value>
      </Select>
   </Element>
   <Element>
    <Select>
   <Value>(P:Local time,seconds) (L:Timer,enum) == if{ 0 (&gt;L:Upset_Image, enum) } </Value>
      </Select>
   </Element>
    <Element>
 <Select>
<Value>(L:Upset_image, enum) </Value>
<Failures>
            <SYSTEM_ELECTRICAL_PANELS Action="1"/>
         </Failures>
         <Case Value="0">
            <Image Name="UPSET_UP.bmp" Luminous="True"/>
         </Case>
         <Case Value="1">
            <Image Name="UPSET_HATCH.bmp" Luminous="True"/>
         </Case>
     </select>
   </Element>
</gauge>

Hope this helps.
Grt
Willem

edit:
Post ammended to reflect Ted's comments. :)
 
Last edited:
Thanks Both,
The origin was from one or two other gauges where I have a self cancelling switch with an accompanying light(another gauge) which lights up during the test period. They work well , but obviously for this gauge another approach is needed. I'll look carefull at your suggestions.
Many Thanks,
vololiberista
 
Willem,
It took most of the afternoon to get your code to appear in FS2004!! There were some "little syntax errors" But who am I to criticise!!
However, your 15 + (&gt;L:Timer,enum) is continuously being incremented by (P:Local time,seconds) so in effect it always stays 15 seconds ahead! I'm trying at the moment to find a way to break the loop.

Ted,
Thanks for your test gauge. But, it too won't appear in the sim. Once it does I'll report back.
vololiberista
 
Willem,
However, your 15 + (&gt;L:Timer,enum) is continuously being incremented by (P:Local time,seconds) so in effect it always stays 15 seconds ahead! I'm trying at the moment to find a way to break the loop.

Haha, that's why i said this in my answer...

Assuming L:Upset_A, number gets set and reset in a different gauge
By this i meant that (L:upset_A,number) needs to be reset to another value (for instance zero) by the other gauge as soon as the switch is released otherwise indeed 15 keeps getting added...
I assumed that it was a test switch that was operated and released again, momentarily setting L:Upset_A, number to 1 and back to 0 again. (if L:Upset_A, number keeps its value for 15 seconds already as programmed by the other gauge, then you don't need the timer code in this gauge)

You could an additional condition to prevent this:
Code:
 <Value>(L:upset_A,number) 1 == (L:Upset_Set,enum) 0 == and if{ (P:Local time,seconds) 15 + (&gt;L:Timer,enum) 1 (&gt;L:Upset_Image, enum) 1 (&gt;L:Upset_Set,enum) } </Value>
      </Select>

And then in the other section of the code:
Code:
 <Value>(P:Local time,seconds) (L:Timer,enum) == if{ 0 (&gt;L:Upset_Image, enum) 0 (&gt;L:Upset_Set,enum) } </Value>

Once the timer +15 has been set into (L:Timer,enum), (L:Upset_Set,enum) prevents continuous setting until absolute time has caught up with (L:Timer,enum). Then (L:Upset_Set,enum) gets reset to zero, thus again enabling (L:Timer,enum) to be filled with a new time when (L:upset_A,number) equals 1 again.

Hope this helps.
grt
Willem

ps sorry for the syntax errors :o
i don't have a working simulator setup right now, therefore i cannot test what i write. But i do hope it helps pointing you in the right direction.
 
Last edited:
Latest report!:-
I have a solution that works with a two way switch, but it is necessary in this case to have a three way switch. I've tried half a dozen options but the sim never sees the switch.
May I ask you to have a look at the codes below and tell me the best way to incorporate the working code from the two way switch into the three way switch.
Many Thanks vololiberista
Code:
 [COLOR="Red"]Working code in a two way switch[/COLOR]
<Gauge Name="Aileron Upset Switch" Version="1.0">
<Element>
      <Select>
         <Value>(L:upset_A,number)</Value>
         <Case Value="0">
            <Image Name="UPSET_SWITCH_NORM.bmp"/>
         </Case>
         <Case Value="1">
            <Image Name="UPSET_SWITCH_ARM.bmp"/>
         </Case>
      </Select>
   </Element>
   <Mouse>
         <Tooltip>Aileron Upset</Tooltip>
         <Cursor Type="Hand"/>
	<Click>
     (L:upset_A,number) ! (&gt;L:upset_A,number)
     (L:upset_A,number) 1 ==
     if{ (P:local time, seconds) 15 + (>L:UPSET LIGHT,number) }</Click>
   </Mouse>
</Gauge>

Code:
[COLOR="Red"]Original code for the three way switch[/COLOR]
<Gauge Name="Aileron Upset Switch" Version="1.0">
   <Element>
      <Select>
         <Value>(G:Var1)</Value>
<Failures>
            <SYSTEM_ELECTRICAL_PANELS Action="2"/>
         </Failures>
         <Case Value="1">
            <Image Name="UPSET_SWITCH_ARM.bmp" ImageSizes="24,36"/>
         </Case>
         <Case Value="0">
            <Image Name="UPSET_SWITCH_NORM.bmp" ImageSizes="24,36"/>
         </Case>
         <Case Value="2">
            <Image Name="UPSET_SWITCH_TEST.bmp" ImageSizes="24,36"/>
         </Case>
      </Select>
   </Element>
   <Mouse>
<Tooltip>Aileron Upset B</Tooltip>
      <Area Top="0" Bottom="10">
         <Cursor Type="Hand"/>
         <Click>1 (&gt;G:Var1) 2 (&gt;L:upset_B,number) 1 (>L:Sound_click,enum)</Click>
      </Area>
      <Area Top="11" Bottom="20">
         <Cursor Type="Hand"/>
         <Click>0 (&gt;G:Var1) 0 (&gt;L:upset_B,number) 1 (>L:Sound_click,enum)</Click>
      </Area>
      <Area Top="21" Bottom="31">
         <Cursor Type="Hand"/>
         <Click>2 (&gt;G:Var1) 1 (&gt;L:upset_B,number) 1 (>L:Sound_click,enum)</Click>
      </Area>
   </Mouse>
</Gauge>

Code:
 [COLOR="Red"]New code for the indicators which works with the two way switch[/COLOR]
<Gauge Name="Left Aileron Upset TI" Version="1.0">
   <Element>
<Image Name="UPSET_HATCH.bmp" Luminous="1"/>
 <Select>
<Value>
     (L:UPSET LIGHT,number) (P:local time, seconds) &gt;
     (L:upset_A,number)
     and
</Value>
<Failures>
            <SYSTEM_ELECTRICAL_PANELS Action="1"/>
         </Failures>
         <Case Value="0">
            <Image Name="UPSET_UP.bmp" Luminous="1"/>
         </Case>
         <Case Value="1">
            <Image Name="UPSET_HATCH.bmp" Luminous="1"/>
         </Case>
<Case Value="2">
            <Image Name="UPSET_UP.bmp" Luminous="1"/>
         </Case>
      </Select>
   </Element>
</Gauge>
 
You seem to be confusing 'normal' numbers with Binary numbers.

The binary operators ! .. and .. &and;&and; or & only give outputs of TRUE or FALSE indicated by 1 or 0. So you will never get (L:upset_A,number) to contain the value of 2.
 
Hi Ted,
are you referring to:-
Code:
<Value>
     (L:UPSET LIGHT,number) (P:local time, seconds) &gt;
     (L:upset_A,number)
    [COLOR="Red"] and[/COLOR]
</Value>

If I take that out it doesn't work at all!!! Left in it works perfectly but only in two way switch format i.e. 0 or 1.
The three way switch in itself is no problem it's just trying to get it to do the above function in the test postion. The switch is manually controlled. When the visual test i.e. "the hatches" is complete after 15 seconds the switch is manually returned to the centre position. It's very similar to my horizon comparator test switch. But that is a two way switch.
vololiberista
 
Could you explain why this feeds (P:local time, seconds) plus 15 seconds into (L:UPSET LIGHT,number)
Code:
<Click>
     (L:upset_A,number) ! (&gt;L:upset_A,number)
     (L:upset_A,number) 1 ==
     if{ (P:local time, seconds) 15 + (>L:UPSET LIGHT,number) }</Click>
and this doesn't
vololiberista
Code:
<Click>2 (&gt;G:Var1) 1 (>L:upset_A,number) if{ (P:local time, seconds) 15 + (>L:UPSET LIGHT,number) }</Click>
 
and this doesn't
Code:
<Click>2 (&gt;G:Var1) 1 (>L:upset_A,number) if{ (P:local time, seconds) 15 + (>L:UPSET LIGHT,number) }</Click>

the if function has nothing to look at:
- 2 (&gt;G:Var1) stuffs a value of 2 into G:Var1.
- 1 (>L:upset_A,number) stuffs a value of 1 into 1 L:upset_A,number...

So what is it you want the if to refer to?

btw 1 (>L:upset_A,number) can also be written like this: 1 (&gt;L:upset_A,number) ;)

Take a closer look this code again and you'll surely see what's wrong with the above code:
Code:
<Click>
     (L:upset_A,number) ! (&gt;L:upset_A,number)
     [COLOR="Red"](L:upset_A,number) 1 ==
     if[/COLOR]{ (P:local time, seconds) 15 + (>L:UPSET LIGHT,number) }</Click>

Also be aware that (L:upset_A,number) ! (&gt;L:upset_A,number) flips the value of (L:upset_A,number) before the if function is entered in the above code.

grt
Willem
 
Last edited:
This is what I meant.

Code:
[COLOR="Red"]New code for the indicators which works with the two way switch[/COLOR]
<Gauge Name="Left Aileron Upset TI" Version="1.0">
   <Element>
<Image Name="UPSET_HATCH.bmp" Luminous="1"/>
 <Select>
<Value>
     (L:UPSET LIGHT,number) (P:local time, seconds) &gt;
     (L:upset_A,number)
     and            [COLOR="DarkOliveGreen"] <-- [/COLOR](* this can only give a boolean 0 or 1 *)
</Value>
<Failures>
            <SYSTEM_ELECTRICAL_PANELS Action="1"/>
         </Failures>
         <Case Value="0">
            <Image Name="UPSET_UP.bmp" Luminous="1"/>
         </Case>
         <Case Value="1">
            <Image Name="UPSET_HATCH.bmp" Luminous="1"/>
         </Case>
        <Case Value="2">           [COLOR="DarkOliveGreen"]<--[/COLOR](* so this is redundant *)
            <Image Name="UPSET_UP.bmp" Luminous="1"/>
         </Case>
      </Select>
   </Element>
</Gauge>
 
Hi Ted,
Again thanks for your advice. I did think later on that the if{} might indeed be superfluous. So now I've ditched it and everything works properly!
Thanks again,
vololiberista
 
Back
Top