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

Visibility tag and timer

rotorhub

Resource contributor
Messages
126
Country
norway
I am trying to get a light to work correctly, and it kind of works. Even if it is wrong.
The light is on, as long as the switch is hold, but i does not take in account if the fuel valve is shut or not.

Ideally this light should shut after 2 seconds, even if the switch is hold. The manual says "Light on for 2 seconds", valve ok. If light is hold more than 3 sec, something is wrong.
So in addition to fix the code, I need to incorporate (P:local time, seconds) to this syntax, somehow?

Anyone?

Rotorhub

Code:
<PartInfo>
<Name>T4_valve_L_light</Name>        <!-- show only during valve test -->
<Visibility>
<Parameter>
<Code>
  (A:CIRCUIT GENERAL PANEL ON, bool) 1 == (L:T4_valve_L, number) 1 ==  and if{(A:GENERAL ENG FUEL VALVE:1, bool) 1 == } els{ 0 }
</Code>
</Parameter>
</Visibility>
</PartInfo>

Code:
    <PartInfo>
    <Name>T4_valve_L</Name>
    <AnimLength>50</AnimLength>
    <Animation>
      <Parameter>
        <Code>(L:T4_valve_L, number) 50 *</Code>
        <Lag>400</Lag>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>hand</Cursor>
      <TooltipText>T4_valve_L</TooltipText>
      <MouseFlags>LeftSingle+LeftRelease+LeftDrag</MouseFlags>
   <CallbackCode>
        (M:Event) 'LeftRelease' scmp 0 == if{ 0 (>L:T4_valve_L, number) }
        (M:Event) 'LeftSingle' scmp 0 == if{ 1 (>L:T4_valve_L, number) }
    </CallbackCode>
    </MouseRect>
  </PartInfo>
 
This may do it, not tested.

XML:
<PartInfo>
    <Name>T4_valve_L_light</Name>        <!-- show only during valve test -->
    <Visibility>
        <Parameter>
            <Code>
                    <!-- reset the timer -->
                    (L:T4_valve_L_Tmr, number) (P:local time, seconds) &lt; (L:T4_valve_L_Tmr, number) 0 != (L:T4_valve_L, number) 0 == and and if{ 0 (>L:T4_valve_L_Tmr, number) }
                    <!-- actual vis code -->
                  (A:CIRCUIT GENERAL PANEL ON, bool)
                  (A:GENERAL ENG FUEL VALVE:1, bool)
                  (L:T4_valve_L_Tmr, number) (P:local time, seconds) &gt; and and
                  if{ 1 } els{ 0 }
            </Code>
        </Parameter>
    </Visibility>
</PartInfo>

<PartInfo>
<Name>T4_valve_L</Name>
<AnimLength>50</AnimLength>
    <Animation>
        <Parameter>
            <Code>(L:T4_valve_L, number) 50 *</Code>
        <Lag>400</Lag>
        </Parameter>
    </Animation>
<MouseRect>
    <Cursor>hand</Cursor>
    <TooltipText>T4_valve_L</TooltipText>
    <MouseFlags>LeftSingle+LeftRelease+LeftDrag</MouseFlags>
        <CallbackCode>
              (M:Event) 'LeftRelease' scmp 0 == if{ 0 (>L:T4_valve_L, number) }
              (M:Event) 'LeftSingle' scmp 0 == if{
                  1 (>L:T4_valve_L, number)
                  <!-- apply the timer only if not already running -->
                  (L:T4_valve_L_Tmr, number) 0 == if{ (P:local time, seconds) 2 + (>L:T4_valve_L_Tmr, number) }
              }
        </CallbackCode>
</MouseRect>
</PartInfo>

EDIT - Here's an alternate where the fuel valve is taken into account ( not sure what you really need )
If the valve is open, then a 2 second test light. If the valve is closed, a 5 second test light.
Whereas, the code above will only work if the fuel valve "is" open.

XML:
<PartInfo>
    <Name>T4_valve_L_light</Name>        <!-- show only during valve test -->
    <Visibility>
        <Parameter>
            <Code>
                    <!-- reset the timer -->
                    (L:T4_valve_L_Tmr, number) (P:local time, seconds) &lt; (L:T4_valve_L_Tmr, number) 0 != (L:T4_valve_L, number) 0 == and and if{ 0 (>L:T4_valve_L_Tmr, number) }
                    <!-- actual vis code -->
                  (A:CIRCUIT GENERAL PANEL ON, bool)               
                  (L:T4_valve_L_Tmr, number) (P:local time, seconds) &gt; and
                  if{ 1 } els{ 0 }
            </Code>
        </Parameter>
    </Visibility>
</PartInfo>

<PartInfo>
<Name>T4_valve_L</Name>
<AnimLength>50</AnimLength>
    <Animation>
        <Parameter>
            <Code>(L:T4_valve_L, number) 50 *</Code>
        <Lag>400</Lag>
        </Parameter>
    </Animation>
<MouseRect>
    <Cursor>hand</Cursor>
    <TooltipText>T4_valve_L</TooltipText>
    <MouseFlags>LeftSingle+LeftRelease+LeftDrag</MouseFlags>
        <CallbackCode>
              (M:Event) 'LeftRelease' scmp 0 == if{ 0 (>L:T4_valve_L, number) }
              (M:Event) 'LeftSingle' scmp 0 == if{
                  1 (>L:T4_valve_L, number)
                  <!-- apply the timer only if not already running -->
                  (L:T4_valve_L_Tmr, number) 0 == if{
                        <!-- valve is open, OK -->
                        (A:GENERAL ENG FUEL VALVE:1, bool) if{
                            (P:local time, seconds) 2 + (>L:T4_valve_L_Tmr, number)
                        } els{ <!-- valve not open, not ok -->
                            (P:local time, seconds) 5 + (>L:T4_valve_L_Tmr, number)
                        }
                  }            
              }
        </CallbackCode>
</MouseRect>
</PartInfo>
 
Last edited:
Thank you very much :-)
The code works perfectly. I will probably replace (A:GENERAL ENG FUEL VALVE:1, bool) with something that makes more sense, or an L:var. The gauge is monitoring equal flow from Port and Stbd tanks, so perhaps this is a better variable:

FUEL CROSS FEED Cross feed valve:
0 = Closed
1 = Open
Enum
 
Back
Top