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

FSX Gauge Test Function

TurboCompound

Resource contributor
Messages
190
I intend to code a Radar Altimeter gauge using the FS9 XML Syntax. I know enough to make the needle show the radar altitude and not function when their is no electrical power, but I would like to incorporate a "Test" function. The function is supposed to make the needle go through a set of very specific motions when the test button is clicked. Is their a way to make a needle do something "scripted" in this sense?

Thanks
 
Well, the VC10 Radio Altimeter also has a test function but I haven't as yet got around to doing it. However, the precision altimeter does have a test function. Pressing the test button sets the altimeter to 10,500ft and a constant warning light is displayed. A second button cancels the test. If the test is done once airborne it topples the altimeter which indicates a false reading of 12,500ft with a flashing warning light. This is unrecoverable until back on the ground.
In FS9 the only way to have a precision altimeter and a standby which work independently is to code them separately. (not necessary in FSX).
So I had to convert indicated altitude into different L:vars for both instruments. In the main body of the altimater code there is <Image Name="ALTIMETER_MBS_MASK_LIGHT.bmp" Bright="Yes"/> This is the mask for the warning light which is triggered by the test button. Another piece of code outside the altimeter controls the test indications. So you might from this be able to get an idea of how to set up the logic.
Code:
Gauge Name="Altimeter" Version="1.0">
  <Image Name="ALTIMETER.bmp" ImageSizes="120,125" Luminous="1"/>
//---------------------------------------------------
  <Element>
  <Position X="0" Y="0"/>
  <MaskImage Name="ALTIMETER_MBS_MASK.bmp" ImageSizes="120,125">
  <Axis X="88" Y="115"/>
  </MaskImage>
  <Image Name="NUMBER_ROLL_5.bmp" ImageSizes="8,119" Luminous="1">
   <Axis X="0" Y="108"/>
  </Image>
  <Shift>
  <Value>(L:precision_kohlsman, inHg) 100 * 1000 / flr</Value>
  <Nonlinearity>
  <Item Value="0" X="0" Y="0"/>
    <Item Value="10" X="0" Y="108"/>
  </Nonlinearity>
  </Shift>
  </Element>
  <Element>
  <Position X="0" Y="0"/>
  <MaskImage Name="ALTIMETER_MBS_MASK.bmp" ImageSizes="120,125">
  <Axis X="96" Y="115"/>
  </MaskImage>
  <Image Name="NUMBER_ROLL_5.bmp" ImageSizes="8,119" Luminous="1">
   <Axis X="0" Y="108"/>
  </Image>
  <Shift>
  <Value>(L:precision_kohlsman, inHg) 100 * 100 / 10 % flr</Value>
  <Nonlinearity>
  <Item Value="0" X="0" Y="0"/>
    <Item Value="10" X="0" Y="108"/>
  </Nonlinearity>
  </Shift>
  </Element>
  <Element>
  <Position X="0" Y="0"/>
  <MaskImage Name="ALTIMETER_MBS_MASK.bmp" ImageSizes="120,125">
  <Axis X="104" Y="115"/>
  </MaskImage>
  <Image Name="NUMBER_ROLL_5.bmp" ImageSizes="8,119" Luminous="1">
   <Axis X="0" Y="108"/>
  </Image>
  <Shift>
  <Value>(L:precision_kohlsman, inHg) 100 * 10 / 10 % flr</Value>
  <Nonlinearity>
  <Item Value="0" X="0" Y="0"/>
    <Item Value="10" X="0" Y="108"/>
  </Nonlinearity>
  </Shift>
  </Element>
  <Element>
  <Position X="0" Y="0"/>
  <MaskImage Name="ALTIMETER_MBS_MASK.bmp" ImageSizes="120,125">
  <Axis X="112" Y="115"/>
  </MaskImage>
  <Image Name="NUMBER_ROLL_5.bmp" ImageSizes="8,119" Luminous="1">
   <Axis X="0" Y="108"/>
  </Image>
  <Shift>
  <Value>(L:precision_kohlsman, inHg) 100 * 10 % near</Value>
  <Nonlinearity>
  <Item Value="0" X="0" Y="0"/>
    <Item Value="10" X="0" Y="108"/>
  </Nonlinearity>
  </Shift>
  </Element>
//---------------------------------------------------
  <Element>
  <Position X="0" Y="0"/>
  <MaskImage Name="ALTIMETER_MBS_MASK.bmp" ImageSizes="120,125">
  <Axis X="0" Y="115"/>
  </MaskImage>
  <Image Name="NUMBER_ROLL_5.bmp" ImageSizes="8,119" Luminous="1">
   <Axis X="0" Y="108"/>
  </Image>
  <Shift>
  <Value>(L:precision_kohlsman, millibars) 1000 / flr</Value>
  <Nonlinearity>
  <Item Value="0" X="0" Y="0"/>
    <Item Value="10" X="0" Y="108"/>
  </Nonlinearity>
  </Shift>
  </Element>
  <Element>
  <Position X="0" Y="0"/>
  <MaskImage Name="ALTIMETER_MBS_MASK.bmp" ImageSizes="120,125">
  <Axis X="8" Y="115"/>
  </MaskImage>
  <Image Name="NUMBER_ROLL_5.bmp" ImageSizes="8,119" Luminous="1">
   <Axis X="0" Y="108"/>
  </Image>
  <Shift>
  <Value>(L:precision_kohlsman, millibars) 100 / 10 % flr</Value>
  <Nonlinearity>
  <Item Value="0" X="0" Y="0"/>
    <Item Value="10" X="0" Y="108"/>
  </Nonlinearity>
  </Shift>
  </Element>
  <Element>
  <Position X="0" Y="0"/>
  <MaskImage Name="ALTIMETER_MBS_MASK.bmp" ImageSizes="120,125">
  <Axis X="16" Y="115"/>
  </MaskImage>
  <Image Name="NUMBER_ROLL_5.bmp" ImageSizes="8,119" Luminous="1">
   <Axis X="0" Y="108"/>
  </Image>
  <Shift>
  <Value>(L:precision_kohlsman, millibars) 10 / 10 % flr</Value>
  <Nonlinearity>
  <Item Value="0" X="0" Y="0"/>
    <Item Value="10" X="0" Y="108"/>
  </Nonlinearity>
  </Shift>
  </Element>
  <Element>
  <Position X="0" Y="0"/>
  <MaskImage Name="ALTIMETER_MBS_MASK.bmp" ImageSizes="120,125">
  <Axis X="24" Y="115"/>
  </MaskImage>
  <Image Name="NUMBER_ROLL_5.bmp" ImageSizes="8,119,8,119" Luminous="1">
   <Axis X="0" Y="108"/>
  </Image>
  <Shift>
  <Value>(L:precision_kohlsman, millibars) 10 % flr</Value>
  <Nonlinearity>
  <Item Value="0" X="0" Y="0"/>
    <Item Value="10" X="0" Y="108"/>
  </Nonlinearity>
  </Shift>
  </Element>
//---------------------------------------------------
  <Element>
  <Position X="0" Y="0"/>
  <MaskImage Name="ALTIMETER_ALT_MASK.bmp" ImageSizes="120,125">
  <Axis X="25" Y="41"/>
  </MaskImage>
  <Image Name="NUMBER_ROLL_1.bmp" ImageSizes="11,187" Luminous="1">
   <Axis X="0" Y="170"/>
  </Image>
  <Shift>
  <Value>(L:precision_indicated_altitude, feet) 100000 + 100000 % d 100 % 100 / 0.61 - 0.38 / r 10 / flr d 1000 / 10 % flr  r 1000 %  996 &gt; if{ + } </Value>
  <Nonlinearity>
  <Item Value="0" X="0" Y="0"/>
    <Item Value="10" X="0" Y="170"/>
  </Nonlinearity>
  <Failures>
  <SYSTEM_PITOT_STATIC Action="Freeze"/>
  <GAUGE_ALTIMETER Action="Freeze"/>
  </Failures>
  </Shift>
  </Element>

  <Element>
  <Position X="0" Y="0"/>
  <MaskImage Name="ALTIMETER_ALT_MASK.bmp" ImageSizes="120,125">
  <Axis X="42" Y="41"/>
  </MaskImage>
  <Image Name="NUMBER_ROLL_2.bmp" ImageSizes="11,187" Luminous="1">
  <Axis X="0" Y="170"/>
  </Image>
  <Shift>
  <Value>(L:precision_indicated_altitude, feet) 100000 + 100000 % d 100 % 100 / 0.61 - 0.38 / r 10 / flr d 100 / 10 % flr  r 100 %  96 &gt; if{ + } </Value>
  <Nonlinearity>
  <Item Value="0" X="0" Y="0"/>
    <Item Value="10" X="0" Y="170"/>
  </Nonlinearity>
  <Failures>
  <SYSTEM_PITOT_STATIC Action="Freeze"/>
  <GAUGE_ALTIMETER Action="Freeze"/>
  </Failures>
  </Shift>
  </Element>

  <Element>
  <Position X="0" Y="0"/>
  <MaskImage Name="ALTIMETER_ALT_MASK.bmp" ImageSizes="120,125">
  <Axis X="65" Y="41"/>
  </MaskImage>
  <Image Name="NUMBER_ROLL_2.bmp" ImageSizes="11,187" Luminous="1">
   <Axis X="0" Y="170"/>
  </Image>
  <Shift>
  <Value>(L:precision_indicated_altitude, feet) 100000 + 100000 % d 100 % 100 / 0.61 - 0.38 / r 10 / flr d 10 / 10 % flr  r 10 %  6 &gt; if{ + } </Value>
  <Nonlinearity>
  <Item Value="0" X="0" Y="0"/>
    <Item Value="10" X="0" Y="170"/>
  </Nonlinearity>
  <Failures>
  <SYSTEM_PITOT_STATIC Action="Freeze"/>
  <GAUGE_ALTIMETER Action="Freeze"/>
  </Failures>
  </Shift>
  </Element>

  <Element>
  <Position X="0" Y="0"/>
  <MaskImage Name="ALTIMETER_ALT_MASK.bmp" ImageSizes="120,125">
  <Axis X="77" Y="41"/>
  </MaskImage>
  <Image Name="NUMBER_ROLL_05.bmp" ImageSizes="11,51" Luminous="1">
  <Axis X="0" Y="34"/>
  </Image>
  <Shift>
  <Value>(L:precision_indicated_altitude, feet) 10 / 10 %</Value>
  <Nonlinearity>
  <Item Value="0" X="0" Y="0"/>
  <Item Value="10" X="0" Y="34"/>
  </Nonlinearity>
  <Failures>
  <SYSTEM_PITOT_STATIC Action="Freeze"/>
  <GAUGE_ALTIMETER Action="Freeze"/>
  </Failures>
  </Shift>
  </Element>
//---------------------------------------------------


<Element>
  <Select>
<Position X="0" Y="0"/>
  <Value>(L:ALT_TEST,bool) 1 == (L:alt_warn,bool) 1 == and</Value>   
  <Case Value="1">
  <Image Name="ALTIMETER_MBS_MASK_LIGHT.bmp" Bright="Yes"/>
  </Case>
  </Select>
  </Element>

<Element>
  <Visible>(L:ALT_TEST,bool) 1 == (L:alt_warn,bool) 0 == and
(P:Absolute time,seconds) 1 % 0.5 1 * > ! and </Visible>
<Image Name="ALTIMETER_MBS_MASK_LIGHT.bmp" Bright="Yes"/>   
  </Element>



  <Element>
  <Position X="59.5" Y="59.5"/>
  <Image Name="NEEDLE_ALT.bmp" PointsTo="North"  ImageSizes="9,52" Luminous="1">
  <Axis X="4" Y="47"/>
  </Image>
  <Rotate>
  <Value>(L:precision_indicated_altitude, feet)</Value>
  <Failures>
  <SYSTEM_PITOT_STATIC Action="Freeze"/>
  <GAUGE_ALTIMETER Action="Freeze"/>
  </Failures>
  <Nonlinearity>
  <Item Value="0" X="59.5" Y="9"/>
  <Item Value="500" X="59.5" Y="109"/>
  </Nonlinearity>
  </Rotate>
  </Element>
//---------------------------------------------------
   
</Gauge>

Code:
<!-- Precision Altimeter Test Values -->
   <Element>
      <Select>
         <Value>(L:precision_kohlsman, millibars) 1012.9 &gt; (L:precision_kohlsman, millibars) 1013.6 &lt; and (L:ALT_TEST,bool) 1 == and
if{ (L:precision_indicated_altitude, feet) (>L:pr_in_altitude, number) 10500 (>L:precision_indicated_altitude, feet) 1 (>L:alt_warn,bool) } els{ (L:pr_in_altitude, number) (>L:precision_indicated_altitude, feet) 0 (>L:alt_warn,bool) 0 (>L:pr_in_altitude, number) }</Value>
      </Select>
   </Element>

   <Element>
      <Select>
         <Value>(L:precision_kohlsman, millibars) 1012.9 &gt; (L:precision_kohlsman, millibars) 1013.6 &lt; and (L:ALT_TEST,bool) 1 == and (A:SIM ON GROUND, bool) 0 == and
if{ 12500 (>L:precision_indicated_altitude, feet) 0 (>L:alt_warn,bool) 1 (>L:alt_fault,bool) }</Value>
      </Select>
   </Element>
 
Unfortunately, that doesn't seem to be quite what I'm looking for. What I'm trying to get it to do is move slowly to 1000 ft agl, then quickly to 2500, then slowly back to 0. I'm thinking of maybe using a set of timers to achieve this.
 
Pseudo code:

If test button is pushed, set "pushed" variable to 1. Test for this in all later lines (not shown).
If altitude is greater than gauge max and flag variable = 0 then set display variable to gauge max. Set flag variable to 1.
If altitude is below gauge max and flag variable = 0 then set display variable to current altitude. Set flag variable to 1.
Change gauge display from current altitude to the display variable using flag variable > 0 as a trigger.
If altitude is below gauge max and flag variable = 1, reduce display variable from the current altitude value (subtract a value from the display variable each cycle). This value will depend on how fast you want the needle to move. The gauges usually cycle 18 times per second.
If altitude is less than or equal to 0 and flag variable = 1, set display variable to 0 and set flag variable to 2.
If altitude is less than or equal to 1000 ft and flag variable = 2, increase slowly (add a small value to the display variable each cycle).
If altitude is less than 2500 ft and greater than 1000 ft and flag variable = 2, increase quickly (add a larger value to the display variable each cycle).
If altitude is greater or equal to 2500 ft and flag variable = 2, set flag variable to 3.
If altitude is greater than 0 and flag variable = 3, decrease slowly (subtract a small value from the display variable each cycle).
If altitude is less than or equal to 0 and flag variable = 3 , reset flag, display, and pushed variables to 0 (which changes display from display variable back to current altitude).

Hope this helps,
 
Posted at the same time as Tom - Very, very similar... With "off the top of head" code, not tested.

Have a few variables -

L:RA_Test, bool - Test sequence on/off
L:RA_Test_Val, number - the values outputted for the test.
G:Var9 - 0 = counting up, 1 = counting down

The RA needle val -

Code:
<Value>(L:RA_Test, bool) ! if{ (A:RADIO HEIGHT, feet) } els{ (L:RA_Test_Val, number) }</Value>

Easily adjustable rates -

Code:
<Macro Name="Test_Up_Low"> some number </Macro>
<Macro Name="Test_Up_Hi"> some number </Macro>
<Macro Name="Test_Down"> some number </Macro>

The test sequence -

Code:
<Update>
(L:RA_Test, bool) ! if{ 0 (>L:RA_Test_Val, number) 0 (>G:Var9) } els{
(G:Var9) 0 == (L:RA_Test_Val, number) 1000 &lt;= and  if{ (L:RA_Test_Val, number) @Test_Up_Low + (>L:RA_Test_Val, number) }
(G:Var9) 0 == (L:RA_Test_Val, number) 1000 &gt; and  if{ (L:RA_Test_Val, number) @Test_Up_Hi + 2500 min (>L:RA_Test_Val, number) }
(G:Var9) 0 == (L:RA_Test_Val, number) 2500 == and if{ 1 (>G:Var9) }
(G:Var9) 1 == if{ (L:RA_Test_Val, number) @Test_Down - 0 max (>L:RA_Test_Val, number) }
<!-- Auto off after sequence -->
(G:Var9) 1 == (L:RA_Test_Val, number) 0 == and if{ 0 (>L:RA_Test, bool) }
}
</Update>

The button -

Code:
<Click>(L:RA_Test, bool) ! (>L:RA_Test, bool)</Click>
 
Back
Top