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

P3D v2 XML Timer Question...

Messages
95
Country
ireland
I've pasted below some xml code that I'm using for an antiskid system light. The light is set to 'appear' or 'turn on' a half of a second after I click the switch and in that regard it works fine. Having read about timers on here and remain somewhat confused about how they work, I'm wondering if someone can shed a little light on this code. What I need to know is..... is the code below all I need ? I read somewhere that a timer has to be reset once it's job is done, otherwise FS will continue to run the counter as a recurring loop. Do I need to do that in this case ? If so, how would that be done ?

I'd like to use several more timers like this on some other cockpit lights and I need to make sure they wont drag the sim to it's knees :)

Thanks for any help or tips.

Skip.

Code:
<PartInfo>
    <Name>L200_ASKID_LITE</Name>
    <Visibility>
    <Parameter>
    <Code>
        (A:GENERAL ENG GENERATOR ACTIVE:1, bool) 1 ==
        (A:ELECTRICAL BATTERY VOLTAGE, volts) 26.5 &gt;
        (A:ANTISKID BRAKES ACTIVE, bool) 0 ==
        and
        and
        (L:L200_SWITCH_BATT_MASTER, bool) 100 *
        (A:ELECTRICAL BATTERY VOLTAGE, volts) 26.5 &gt;
        (L:L200_ROUNIT_test_button, bool) 1 ==
        and
        and
        or
        if{ (E:ABSOLUTE TIME, seconds) 0.5 + (>L:L200Timer1,enum) }
       (L:L200Timer1,enum) (E:ABSOLUTE TIME, seconds) >
    </Code>
    </Parameter>
    </Visibility>
</PartInfo>
 
Last edited:
I don't see anything in the code that will cause such a problem.
 
... The light is set to 'appear' or 'turn on' a half of a second after I click the switch and in that regard it works fine.

Actually your code is doing the opposite; the light is turning ON as soon as test button is pressed or Antiskid is off, and is turning OFF 0.5 secs after test button is released/switched off or Antiskid is on.

To obtain what you seem to need, you could code something like (verbosed and not tested):

Code:
<PartInfo>
    <Name>L200_ASKID_LITE</Name>
    <Visibility>
    <Parameter>
    <Code>
        (A:GENERAL ENG GENERATOR ACTIVE:1, bool)
        (A:ANTISKID BRAKES ACTIVE, bool)
        and
        (L:L200_SWITCH_BATT_MASTER, bool)
        (L:L200_ROUNIT_test_button, bool)
        and
        or
       (A:ELECTRICAL BATTERY VOLTAGE, volts) 26.5 &gt;
       and
       if{ (L:L200Timer1,enum) 0 ==
            if{ (E:ABSOLUTE TIME, seconds) 0.5 + (>L:L200Timer1,enum) }
          }
       els{ 0 (>L:200Timer1,enum) }
       (E:ABSOLUTE TIME, seconds) (L:L200Timer1,enum) >
       (L:200Timer1,enum) 0 !=
       and
    </Code>
    </Parameter>
    </Visibility>
</PartInfo>


I'd like to use several more timers like this on some other cockpit lights and I need to make sure they wont drag the sim to it's knees

Don't worry, your timers won't drag the sim to it's knees forr sure ;)

Tom
 
Hi Tom,
My apologies..... I explained it incorrectly above but you are sharp as a tack to spot that in the code.
The lights are set to go OFF when the switch is turned ON, (the (red) lights are on as a warning that the system is turned OFF).
Thanks for the updated timer code and optimised logic.
Regarding yours and Tom's comments that the timer in my code is good to go.. that's great :).
But one quick further query if you wouldn't ...... Will I have to create a new L:var timer for every item I want to effect a delay ? even if it's also for 0.5 sec ?

Many thanks.

Skip
 
I'm still confused about your light's logic. I thought (L:L200_ROUNIT_test_button, bool) was a test button which, when pressed, turns light ON to confirm the system is working ok, so my code handled that situation.

Regarding whether you need to create a new L:Var timer or not for every item, I would say yes you need to do so providing each one is triggered by its own logical condition.

Tom
 
Hi Tom,

When I thanked you for the optimised logic, I was referring to the...
Code:
or
(A:ELECTRICAL BATTERY VOLTAGE, volts) 26.5 &gt;
and

.... that you adjusted, I had that A:var in both of my sets of conditions.

Yes, L:L200_ROUNIT_test_button is as you say, a test button which makes the light come on when pressed.
Thanks for the clarification re timers for other objects, I suspected that myself but wanted it confirmed by an expert :).

Skip.
 
When it comes to timers this is the place to be! The gurus have all sorts of tricks and have been extremely helpful to me too.
I use the elapsed timer macro to shut down an engine if limitations are exceeded.
and Absolute time for various other functions. For example momentarily turning off lights when switching from ground to flight, test warning lights on for a few seconds, doors/hatches closing after a period slightly longer than the the pre-flights, cabin announcements the list goes on!
 
Hi Vololiberista,

Very interesting.. that's what I wanna do with my lights.

As we know, the code above...

Code:
if{ (E:ABSOLUTE TIME, seconds) 0.5 + (>L:L200Timer1,enum) }
       (L:L200Timer1,enum) (E:ABSOLUTE TIME, seconds) >

causes the light to remain on for 0.5 of a sec after it would other wise go out / turn off.
How can I adjust that code to make a light delay for say, 0.5 of a sec, before it comes on ?

I tried some things but nothing worked.

Thanks.

Skip
 
This code briefly extinguishes the lights when the ground/flight switch is thrown. So you might want to set the light (second example) to &gt; to briefly turn it on instead of off as in this example. You only need to play with the (P:local time, seconds) and (L:BUS_SWITCH,number) variables

Code:
<Click>(G:Var1) 0 != if{ 0 (&gt;G:Var1) 1 (>L:Sound_button,enum) 1 (>L:ground2,enum) 0 (>L:flight,enum) (P:local time, seconds) 0.21 + (>L:BUS_SWITCH,number) } els{ 1 (&gt;G:Var1) 1 (>L:Sound_button,enum) 1 (>L:flight,enum) 0 (>L:ground2,enum) (P:local time, seconds) 0.21 + (>L:BUS_SWITCH,number) }</Click>




<Gauge Name="Bus Fail warning" Version="1.0">
   <Element>
      <Select>
         <Value>(A:GENERAL ENG1 GENERATOR ACTIVE,bool) 0 == (L:BUS_SWITCH,number) (P:local time, seconds) &lt; and</Value>
         <Failures>
            <SYSTEM_ELECTRICAL_PANELS Action="0"/>
         </Failures>
         <Case Value="0">
            <Image Name="RED_OFF.bmp"/>
         </Case>
         <Case Value="1">
            <Image Name="RED_ON.bmp" Bright="Yes"/>
         </Case>
      </Select>
   </Element>
   <Mouse>
      <Tooltip>Gen Bus 1 Fail</Tooltip>
   </Mouse>
</Gauge>
 
....
How can I adjust that code to make a light delay for say, 0.5 of a sec, before it comes on ?

I gave you an example on post #3. You didn't check it, did you? :confused:

Besides, if you want a light delay 0.5 sec before and 0.5 sec after, here you have another example, simple and easy to understand:

Code:
    <Code>
     ...
     ...
     if{ (L:L200Timer1,enum) 0 ==
          if{ (E:ABSOLUTE TIME, seconds) 0.5 + (>L:L200Timer1,enum) }
          1 (>L:L200Timer2,enum)
          (E:ABSOLUTE TIME, seconds) (L:L200Timer1,enum) >
         }
    els{  (L:L200Timer2,enum) 1 ==
            if{ (E:ABSOLUTE TIME, seconds) 0.5 + (>L:L200Timer2,enum) }
           0 (>L:L200Timer1,enum)
          (L:L200Timer2,enum) (E:ABSOLUTE TIME, seconds) >       
         }
  <Code>

Tom
 
Back
Top