• 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 Interesting problem, annunciator for landing gear lights

Messages
10,158
Country
us-arizona
Hey all,

Ive got a problem I cant seem to work out. I have some annunciator lights in the Learjet that turn on and off when working the landing gear system. Green on when gear is down and locked, green off when gear is up or on its way up (transition). Red lights on when in transition, red off when fully up or fully down.

So, I have 4 codes I ended up writing (new system). One for each light version; green on, off, red on, off. I have the green set functioning fine, but dang, I cannot seem to get the red versions to operate correctly. They either stay on or off.

NOTE: These are 'visibilities' of 3D objects. Diodes that are bright and dark, appear when a remote hidden gauge tells them to turn on and off. The landing light annunciator lights are thus controlled by this hidden gauge.

Does anyone know how to write a code for a landing gear annunciator light for 'in transition' and also one for when the gear is up or down fully? I cannot get anything to work. I have written controllers that turn them on and off. With percent, only 'near' seems to work. I cannot seem to get rng to work. I have tried quite a few variations.

I have tried perhaps 50 or 75 versions of writing this. Here is my latest one.


Code:
<!-- Landing Gear Warning Annunciator Lights -->

<!-- Green On Gear Down -->

<Element>
<Select>
<Value>
      (L:LJ24B BATT MASTER LEFT, bool) 1 ==
      (L:LJ24B BATT MASTER RIGHT, bool) 1 ==
      (A:Gear center position,percent) 100 near
       and and
          if{ 1 (&gt;L:LJ24B GearAnnunLites GreenOn, bool)
              0 (&gt;L:LJ24B GearAnnunLites GreenOff, bool) }
         els{ 0 }
  </Value>
</Select>
</Element>

<!-- Green Off Gear in Transition and Up -->

<Element>
<Select>
<Value>
      (L:LJ24B BATT MASTER LEFT, bool) 1 ==
      (L:LJ24B BATT MASTER RIGHT, bool) 1 ==
      (A:Gear center position,percent) 98 &lt;
       and and
          if{ 0 (&gt;L:LJ24B GearAnnunLites GreenOn, bool)
              1 (&gt;L:LJ24B GearAnnunLites GreenOff, bool) }
         els{ 0 }
  </Value>
</Select>
</Element>

<!-- Red On Gear In Transition -->

<Element>
<Select>
<Value>
      (L:LJ24B BATT MASTER LEFT, bool) 1 ==
      (L:LJ24B BATT MASTER RIGHT, bool) 1 ==
      (L:LJ24B GearAnnunLites RedOff, bool) 0 ==
       and and
          if{ 1 (&gt;L:LJ24B GearAnnunLites RedOn, bool) }
         els{ 0 }
  </Value>
</Select>
</Element>

<!-- Red Off * Gear Down -->

<Element>
<Select>
<Value>
      (L:LJ24B BATT MASTER LEFT, bool) 1 ==
      (L:LJ24B BATT MASTER RIGHT, bool) 1 ==
      (A:Gear center position,percent) 100 &gt;
      and and
        if{ 1 (&gt;L:LJ24B GearAnnunLites RedOff, bool) }
  </Value>
</Select>
</Element>

<!-- Red Off * Gear Up -->

<Element>
<Select>
<Value>
      (L:LJ24B BATT MASTER LEFT, bool) 1 ==
      (L:LJ24B BATT MASTER RIGHT, bool) 1 ==
      (A:Gear center position,percent) 0 &lt;
      and and
        if{ 1 (&gt;L:LJ24B GearAnnunLites RedOff, bool) }
  </Value>
</Select>
</Element>

Note, above, I ended up making '2' versions of red-off as I couldn't seem to get them to 'mix' in the logic. This also didn't work.


Mind you, I had originally wanted to add 'test' mode to this, as well as batteries off mode (all lights show off), but I cannot even get these to work (red versions) correctly, so holding short before I also mix in test mode and battery circuit off mode.
 
I'm not sure why you need on and off variables for green and red - a single boolean variable for each one should work fine. Why have two variables when you can use one?

For the red something like:


Code:
<!-- Red - Gear in Transition -->

<Element>
<Select>
<Value>
(L:LJ24B BATT MASTER LEFT, bool) 1 ==
(L:LJ24B BATT MASTER RIGHT, bool) 1 ==
(A:Gear center position,percent) 2 &gt;
(A:Gear center position,percent) 98 &lt;
and and and
if{ 1 (&gt;L:LJ24B GearAnnunLites RedOn, bool) }
els{ 0 (&gt;L:LJ24B GearAnnunLites RedOn, bool) }
</Value>
</Select>
</Element>

If L:LJ24B GearAnnunLites RedOn is 1 turn the light on, if 0 turn it off.
 
Try using GEAR ANIMATION POSITION and keyframes rather than GEAR CENTER POSITION and percent.

With GEAR ANIMATION POSITION I think 0 is supposed to be up, more than 0 and less than 100 is in transit (yellow) and 100 or more is down (green)

(A:GEAR ANIMATION POSITION:0,keyframe) is the center gear

(A:GEAR ANIMATION POSITION:1,keyframe) is usually the left and (A:GEAR ANIMATION POSITION:2,keyframe) is the right gear.
 
I doing it this way

Code:
<!-- Left Gear -->
  <Element>
    <Position X="7" Y="132"/>
    <Select>
      <Value>
      0.01 49.99 (A:GEAR ANIMATION POSITION:1,percent) rng     <!-- Left Gear -->
      (L:ElecM_DC28_BusEss_V,Volt) 22 &gt;
      &amp;&amp;
      </Value>
      <Case Value="1"><Image Name="Gear_LightsLeft_Red.bmp" Luminous="Yes"/></Case>
    </Select>
  </Element>

  <Element>
    <Position X="7" Y="194"/>
    <Select>
      <Value>
      (A:GEAR ANIMATION POSITION:1,percent) 49.99 &gt;         <!-- Left Gear -->
      (L:ElecM_DC28_BusEss_V,Volt) 22 &gt;
      &amp;&amp;
      </Value>
      <Case Value="1"><Image Name="Gear_LightsLeft_Green.bmp" Luminous="Yes"/></Case>
    </Select>
  </Element>

Put i have only red - transition - and green -full down.

Edi
 
Have a look at these. They may help.
The first is the nosewheel door light and can be repeated for main gear.
Code:
<Gauge Name="Landing Gear Centre Door" Version="1.0">
   <Element>
      <Select>
         <Value>(A:Gear center position,percent) 99 &lt; d (A:Gear center position,percent) 1 &gt; r &amp;&amp; </Value>
         <Failures>
            <SYSTEM_ELECTRICAL_PANELS Action="0"/>
         </Failures>
         <Case Value="0">
            <Image Name="RED_LIGHT_OFF.bmp"/>
         </Case>
         <Case Value="1">
            <Image Name="RED_LIGHT.bmp" Bright="Yes"/>
         </Case>
      </Select>
   </Element>
   <Mouse>
      <Help ID="HELPID_GAUGE_GEAR_LIGHT"/>
   </Mouse>
</Gauge>

The second is for the actual gear lights, The nosewheel has an offset fillament failure to simulate a no three greens situation. Plus if two engines are out the gear takes three minutes to drop.
(L:BUS_SWITCH,number) simulates the ground/flight switch.

Code:
<Gauge Name="Landing Gear Indicator" Version="1.0">
   <Image Name="LANDING_GEAR_INDICATOR.bmp" ImageSizes="80,80"/>
//-------------------- Centre Gear -----------------------
   <Element>
      <Select>
         <Value>(A:Gear center position,percent) 90 &gt; (L:filament_burnt_out,number) 0 == and (L:BUS_SWITCH,number) (P:local time, seconds) &lt; and (L:nose_gear_delay,number) (P:local time, seconds) &lt; and </Value>
         <Failures>
            <SYSTEM_ELECTRICAL_PANELS Action="0"/>
         </Failures>
         <Case Value="1">
            <Image Name="LANDING_GEAR_C_LOCKED.bmp" Bright="Yes" ImageSizes="80,80"/>
         </Case>
      </Select>
   </Element>
   <Element>
      <Select>
         <Value>(A:Gear center position,percent) 90 &lt; d (A:Gear center position,percent) 20 &gt; r &amp;&amp;</Value>
         <Failures>
            <SYSTEM_ELECTRICAL_PANELS Action="0"/>
         </Failures>
         <Case Value="1">
            <Image Name="LANDING_GEAR_C_TRANSIT.bmp" Bright="Yes" ImageSizes="80,80"/>
         </Case>
      </Select>
   </Element>
//-------------------- Left Gear -----------------------
   <Element>
      <Select>
         <Value>(A:Gear left position,percent) 90 &gt; (L:BUS_SWITCH,number) (P:local time, seconds) &lt; and (L:left_gear_delay,number) (P:local time, seconds) &lt; and </Value>
         <Failures>
            <SYSTEM_ELECTRICAL_PANELS Action="0"/>
         </Failures>
         <Case Value="1">
            <Image Name="LANDING_GEAR_L_LOCKED.bmp" Bright="Yes" ImageSizes="80,80"/>
         </Case>
      </Select>
   </Element>
   <Element>
      <Select>
         <Value>(A:Gear left position,percent) 90 &lt; d (A:Gear left position,percent) 20 &gt; r &amp;&amp;</Value>
         <Failures>
            <SYSTEM_ELECTRICAL_PANELS Action="0"/>
         </Failures>
         <Case Value="1">
            <Image Name="LANDING_GEAR_L_TRANSIT.bmp" Bright="Yes" ImageSizes="80,80"/>
         </Case>
      </Select>
   </Element>
//-------------------- Right Gear -----------------------
   <Element>
      <Select>
         <Value>(A:Gear right position,percent) 90 &gt; (L:BUS_SWITCH,number) (P:local time, seconds) &lt; and (L:right_gear_delay,number) (P:local time, seconds) &lt; and </Value>
         <Failures>
            <SYSTEM_ELECTRICAL_PANELS Action="0"/>
         </Failures>
         <Case Value="1">
            <Image Name="LANDING_GEAR_R_LOCKED.bmp" Bright="Yes" ImageSizes="80,80"/>
         </Case>
      </Select>
   </Element>
   <Element>
      <Select>
         <Value>(A:Gear right position,percent) 90 &lt; d (A:Gear right position,percent) 20 &gt; r &amp;&amp;</Value>
         <Failures>
            <SYSTEM_ELECTRICAL_PANELS Action="0"/>
         </Failures>
         <Case Value="1">
            <Image Name="LANDING_GEAR_R_TRANSIT.bmp" Bright="Yes" ImageSizes="80,80"/>
         </Case>
      </Select>
   </Element>
   <Mouse>
      <Help ID="HELPID_GAUGE_GEAR_LIGHT"/>
   </Mouse>
</Gauge>
vololiberista
 
Maybe you can post some photos, it will be easier to understand the movement of it all if you do. It can be that you may need a black mask or shadow behind the lights as well so that they switch color at the appropriate time. It may not be the programming. Just a thought, I am far from an expert. I had simillar problems when creating the gear annun panel for my Falcon 50 but after I created a black mask in the background the lights did not light up at inappropriate times.
 
I use this for my nosegear. Similar scripts are used for the left and right main gear. This is for the "gear in transit" (red) light:
Code:
  <PartInfo>
    <Name>KA350i_light_nosegear_intransit_ON</Name>
    <Visibility>
      <Parameter>
        <Code>
          (A:GEAR CENTER POSITION, percent) d 0 &gt; r 100 &lt; and 50 *
          (A:ELECTRICAL MASTER BATTERY,bool) and
          if{ 1 (>L:KA350i_NoseGearInTransit,bool) } els{ 0 (>L:KA350i_NoseGearInTransit,bool) }
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>
 
I'm always confused as to why this kind of code is built into the 3D model to begin with. It's not the appropriate location for systems coding, in my opinion.
 
Thank you Bill for your 'gear in transit' code. That worked perfect.

They now all appear to be working fine. Thanks everyone.
 
I'm always confused as to why this kind of code is built into the 3D model to begin with. It's not the appropriate location for systems coding, in my opinion.

Mine wasn't, its in a hidden gauge. The gauge triggers Visibilities of parts, in this case, diode lights. I also like to keep as much programming and logic in gauges rather then parts themselves so that its more easily reprogrammed without having to do model changes as my models tend to sometimes have variants.
 
Sure Bill, yours was simple gauge code... now look at Fr. Bill's... part code for a VC. Like I said, I dunno why system logic is in a 3D model... bad location because correcting code flaws is much, much harder after you ship.
 
Sure Bill, yours was simple gauge code... now look at Fr. Bill's... part code for a VC. Like I said, I dunno why system logic is in a 3D model... bad location because correcting code flaws is much, much harder after you ship.
I won't disagree with you at all, Ed. Different philosophy I suspect. Part of my reason is convenience for me while I'm modeling. It's not at all difficult to strip out the "logic" before wrapping up the project though.
 
Hi

I installed the 'in transit' code into a hidden gauge in my 2D cockpit.

It caused the gear-in-transit light to stay on the whole time.

When I changed it to

(A:GEAR CENTER POSITION, percent) d 1 &gt; r 99 &lt; and 50 *

things worked fine (Or have I fouled things up?).

Is this because my code was in a gauge in the 2D cockpit and not in the model?

I still have very little idea what the code means, especially the and 50 *.

The code certainly simplified what had been in the gauge already (again copied from some other gauge from the internet!).

Thanks

Walter
 
Walter,

The 50 * is only necessary when the script is used in the modeldef.xml file. It converts the output value to be either 0 or 50, which is necessary for keyframe animation.

It is not necessary for a 2d version of the script, although frankly it does no harm either.

The "and" is a conjunction which is required to test two conditions. First, we need to parse the XML script to understand all of the parts...
(A:GEAR CENTER POSITION, percent) d 1 &gt; r 99 &lt; and 50 *

The 'd' duplicates the preceding (A:variable) for later use.
The 'r' retrieves the previously duplicated (A:variable)

These are simply shortcuts to eliminate the need to repeatedly type out the full (A:variable). :wizard:

The first condition is "is the (A:variable) greater than 1?
The second condition is "is the (A:variable) less than 99?
The conjuction "and" ties the two conditions such that when evaluated, the combination results in either "0" (false) or "1" (true) being returned by the expression.
 
Bill, thank you.

Despite looking at the FS2004 SDK on Panel and Gauges, I could not get the significance of the 'd' and 'r'.

All is clear now, and I shall look out for other situations where I can use that construction to save typing.

Walter
 
It's buried around the middle of the SDK's "Creating XML Gauges" section, in the brief description of the Stack Operators. It's really quite obfuscated... o_O

Actually the "r" is described as "Pops and discards the top value on the stack" which is frankly not very helpful. In effect though, it does essentially retrieve the previously duplicated top of stack value... :scratchch
 
Actually what "r" does is reverse the last two operands of the stack.

For example:

15 20 2 * + results 55
15 20 r 2 * + results 50

Tom
 
So, Tom... what actually does happen is absolutely nothing like the SDK itself describes. How curious! :stirthepo

What actually is of interest to me is that it does what I want it to do, irrespective of precisely how it does it... :rotfl:
 
Bill, there have been discussions elsewhere about the pros and cons of XML versus C++.

One up for XML here then - it can read minds....

Walter
 
Back
Top