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

Help Understanding Timers

Messages
10,088
Country
us-arizona
Hey all,

I use timers for boot screens on screen type gauges all the time. My Stingrey recently done, had 3 screens and had several stage screen pop-ups for the bootup sequence for all three screens. WITH... dings and sounds...

But... I still do not fully understand them on the basic level. How do they work on the most basic basic level of explanation?


This is one of Dwight's boot screens from one of his exotic gauges. I had to redo some of it as it was half Macro scripted.
Code:
<!-- BOOT UP SEQUENCE -->
 <Element>
     <Visible>(L:GTX327_POWER,bool) 0 == (L:GTX327_BOOT,bool) 0 == and if{ 1 (&gt;L:GTX327_BOOT,bool) 
                   1 (&gt;L:GTX327_POWER,bool) (P:ABSOLUTE TIME,seconds) 5 + (&gt;L:BOOTCOMPLETE,seconds) } </Visible>
 </Element>
The above code by Dwight had several Elements within this one so that when this element was active, they showed up.

This is one of my boot screens from the Stingrey;
Code:
<!-- BOOT SCREEN -->
     <!-- Initialize all variables when power is OFF -->
    <Element>
       <Select>
        <Value>
        (A:Avionics Master Switch,bool) 0 == (A:Electrical Master Battery,bool) 0 == || if{
        0 (>L:3306BootScreen,enum)
        0 (>L:3306BootTime,enum) }
        </Value>
       </Select>
    </Element>

     <!-- Start timer and increment when both battery and avionics are ON -->
    <Element>
       <Select>
        <Value>
        (A:Avionics Master Switch,bool) (A:Electrical Master Battery,bool) and (L:3306BootTime,enum) 320 &lt;= and
        if{ (L:3306BootTime,enum) ++ (>L:3306BootTime,enum) 1 (>L:3306BootScreen,enum) }
        </Value>
       </Select>
    </Element>

     <!-- Stop timer after 20 seconds -->
    <Element>
       <Select>
        <Value>
        (L:3306BootTime,enum) 320 > if{ 0 (>L:3306BootScreen,enum) }
        </Value>
       </Select>
    </Element>

     <!-- AAA While the "bootscreen" variable is ON and battery is ON, display the bootscreen bitmap -->
    <Element>
        <Visible>(L:3306BootScreen,enum) 1 == </Visible>
         <Position X="0" Y="0"/>
        <Image Name="Hello.bmp" ImageSizes="1500,681" Bright="Yes">
        </Image>
    </Element>

     <!-- CCC While the "bootscreen" variable is ON and battery is ON, display the bootscreen bitmap -->
    <Element>
        <Visible>(L:3306BootTime,enum) 230 &lt;</Visible>
         <Position X="0" Y="0"/>
        <Image Name="BootModelNumber.bmp" ImageSizes="1500,681" Bright="Yes">
        </Image>
    </Element>

     <!-- CCC While the "bootscreen" variable is ON and battery is ON, display the bootscreen bitmap -->
    <Element>
       <Select>
        <Value>
                    (A:Avionics Master Switch,bool) (A:Electrical Master Battery,bool) and (L:3306BootTime,enum) 179 == and
                                  if{ 1 (>L:XMLSND192,bool) }
        </Value>
       </Select>
    </Element>


     <!-- CCC While the "bootscreen" variable is ON and battery is ON, display the bootscreen bitmap -->
    <Element>
        <Visible>(L:3306BootTime,enum) 165 &lt;</Visible>
         <Position X="0" Y="0"/>
        <Image Name="BootCodeIntro.bmp" ImageSizes="1500,681" Bright="Yes">
        </Image>
    </Element>

     <!-- BBB While the "bootscreen" variable is ON and battery is ON, display the bootscreen bitmap -->
    <Element>
        <Visible>(L:3306BootTime,enum) 70 &lt;</Visible>
         <Position X="0" Y="0"/>
        <Image Name="SyrosScreenOff.bmp" ImageSizes="1500,681" Bright="Yes">
        </Image>
    </Element>
 

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
Bill, unless otherwise limited, XML "timers" run at 18 cycles per second. For a 20 second timer your target needs to be 320 (18 x 20).

In your example script, you are incrementing the (L:3306BootTime,enum) variable by 1 at every cycle.
(L:3306BootTime,enum) 320 &lt;= conditional says increment each cycle until the count reaches 320. At that point the timer counter has "expired" and whatever you intend to do at that point becomes active.

It truly is that simple. Keep in mind though that like many tasks the concept may be simple, but execution may be a major pain! :rotfl:
 
Messages
10,088
Country
us-arizona
Many thanks Bill. Roger that on 18 cycles per second. That helps.

For some reason, I have a gauge that is parts of 2 different gauges mixed together. Something is causing the gauge to malfunction in the timer so I thought maybe I need a refresher. I was dwelling on timers and realized I never fully understood how the code worked, so I thought I would ask.

During the weekend, I studied a few timer scripts. I found that they ramp up or down via the ++ or -- command. Normally we have this, not as a timer, but an on/off;
(L:Misc Counter,bool) ! (>L:Misc Counter,bool)
This would work a normal animation.

With a timer, the ! is switched out for ++ or -- to cause a running timer. The bool is switched out for either enum or number and in some cases, seconds. Example;
(L:Misc Counter, enum) ++ (>L:Misc Counter, enum)
....which starts the counter going upwards in count

Then one needs to make sure the counter is preset, so one makes a condition that causes the counter to 'set' at a certain time or number count, such as zero or 300, etc.

Next, you have the activation time that the 'feature' you wish to use the timer for turns on or off. For a part to run while the timer is on, you simply have the part turn on 'with' the timer. Then a secondary script block would say 'at counter point XX (for instance, 300), your L:var terminates (goes invisible again). Or... turns on... etc..

Example;
(L:This Event Happens,bool) 1 ==
if{ (L:Misc Counter, enum) ++ (>L:Misc Counter, enum)
(L:Show this thing,bool) ! (>L:Show this thing,bool) }

And the kill switch;
(L:Misc Countery, enum) 300 ==
if{ 0 (>L:Misc Counter, enum)
0 (>L:Show this thing,bool) }

Setting a countdown, you pre-set your timer to 300, then when it does run, it counts down to zero. I am assuming it stops at zero instead of going through negatives. :S Then you reset it with a condition back to 300 (for a countdown timer for 300).

Now this one has me confused. This is a code by Dwight in his GTX327 gauge. I am assuming this code causes the command string to work via being next to the P:time code script?

Code:
 <Element Name="BOOT TIMER">
     <Select>
      <Value>(L:GTX327_BOOT,bool)  if{ (P:ABSOLUTE TIME,seconds) (L:BOOTCOMPLETE,seconds) &gt;= if{ 0 (&gt;L:GTX327_BOOT,bool) 0 (&gt;L:BOOTCOMPLETE,seconds) } }</Value>
     </Select>
 </Element>

This too has me puzzled.. One single + symbol in this script equasion;

Code:
<Macro Name="PowerUp">(L:GTX327_POWER,bool) 0 == (L:GTX327_BOOT,bool) 0 == and if{ 1 (&gt;L:GTX327_BOOT,bool)
            1 (&gt;L:GTX327_POWER,bool) (P:ABSOLUTE TIME,seconds) @BOOTTIME + (&gt;L:BOOTCOMPLETE,seconds) }

So a 'bool' script next to a P:Absolute Time' script will run? That begins running when its next to a P: time script? And a single + can be used? I havent seen a single + symbol used before. I thought it was ++ always.

This is the Macro for BootTime; <Macro Name="BOOTTIME">5</Macro> So the equasion would then be;
1 (&gt;L:GTX327_POWER,bool) (P:ABSOLUTE TIME,seconds) 5 + (&gt;L:BOOTCOMPLETE,seconds) }

I assume then that when POWER and BOOT are at zero, Boot is made ACTIVE, and something called BOOTCOMPLETE runs for 5 seconds?

This looks like it loops, but in his code, in his gauge, it doesnt. It works lovely. But if I use something similar, I get a looping, the boot never shuts down.

I installed my own boot screen by Bill Leaming (thanks Bill, I use this as a template on TONS of my own timers) and for some reason, my boot windows do not work. I have written perhaps 10 different versions of boot windows (something that should show up for say 5 seconds) and nothing seems to work. It blips over and over, or it stays on, or it doesnt show up. Its like 'time' is effected in the gauge and timers arent working right.

So it seems I am using something that is causing a loop.

But it was good to learn about the ++ and -- (instead of using the ! ) which simplified things for my non-coder brain. (I think in polygons and graphics mainly.. Equasions try to take advantage of my polygon mentality).

I will try using a condition that uses the L:GTX327_POWER as its own condition, then use the new condition to run the timer. That might be what I am needing, instead of using the Power script as a condition in the stack.

I use the Battery and Panel (Avionics) switches alongside the L:GTX327_POWER in a stack of 3 conditions to use as the trigger. I have mixed them so that the A: Battery and Avionics are one cluster, then a secondary if{ as the GTX327_POWER as the second inline condition, but none seem to work...

This is 'one' of the many...

Code:
<!-- BOOT SCREEN -->
     <!-- Initialize all variables when power is OFF -->
    <Element>
       <Select>
        <Value>
                       (L:GTX327_Power,bool) 0 ==
                              if{
        0 (>L:GTX BootScreen,enum)
        0 (>L:GTX BootTime,enum) }
        </Value>
       </Select>
    </Element>

     <!-- Start timer and increment when both battery and avionics are ON -->
    <Element>
       <Select>
        <Value>
        (A:Avionics Master Switch,bool) (A:Electrical Master Battery,bool) and (L:GTX BootTime,enum) 80 &lt;= and
        if{ (L:GTX BootTime,enum) ++ (>L:GTX BootTime,enum) 1 (>L:GTX BootScreen,enum) }
        </Value>
       </Select>
    </Element>

     <!-- Stop timer after 20 seconds -->
    <Element>
       <Select>
        <Value>
        (L:GTX BootTime,enum) 80 > if{
                                    0 (>L:GTX BootTime,enum)
                                    0 (>L:GTX BootScreen,enum) }
        </Value>
       </Select>
    </Element>


 <Element>
    <Visible>(L:GTX BootScreen,enum) 1 == </Visible>
     <Element>
       <Position X="155" Y="25"/>
          <Text X="320" Y="23" Bright="Yes" Length="29" Font="Arial" Color="#CADB35" Adjust="center" VerticalAdjust="Top" Multiline="No" Fixed="No">
            <String>GARMIN Corporation GTX 327</String>
          </Text>
     </Element>

     <Element>
        <Position X="165" Y="50"/>
            <Text X="300" Y="16" Bright="Yes" Length="33" Font="Arial"  Color="#CADB35" Adjust="center" VerticalAdjust="Top" Multiline="No" Fixed="No">
              <String>Software Version 2.10  &#169;1999-2008</String>
             </Text>
     </Element>

     <Element>
           <Position X="165" Y="72"/>
                 <Text X="300" Y="16" Bright="Yes" Length="22" Font="Arial" Color="#CADB35" Adjust="center" VerticalAdjust="Top" Multiline="No" Fixed="No">
                    <String>Self Test In Progress</String>
                 </Text>
     </Element>
 </Element>

This one was done late at night, I havent gone through it this morning yet. Last night, it didnt work and I flew my hands up in the air and did a 3 second 'flip out,bool' and then shut things down.

Trying to be patient. Trying to figure this out....
 
Messages
10,088
Country
us-arizona
I posted the TONS OF DETAILS in there for others in the future (like I was) that might be wanting to learn about how timers work.
 
Messages
10,088
Country
us-arizona
Ok, I have one working. I thought I could be all hot and create a neat 'newer' version (higher, advanced, more exotic, cleaner) form of timer code... I guess I was a little too optimistic.

I got an old one working, one from my Stingrey flying flapjack saucer plane to work... One made from the famed template of Bill Leaming, world reknown gauge maker and also components from Dwight Ferleighs GTX327 unit. A masterpiece in exotic code and a fine example of how to Macro every single thing in the known universe in a single gauge.


Code:
     <!-- Initialize all variables when power is OFF -->
    <Element>
       <Select>
        <Value>
        (L:GTX327_Power,bool) 0 == if{
        0 (>L:3307REGISTRY Screen,enum)
        0 (>L:3307REGISTRY Time,enum) }
        </Value>
       </Select>
    </Element>

     <!-- Start timer and increment when both battery and avionics are ON -->
    <Element>
       <Select>
        <Value>
        (L:GTX327_Power,bool) 1 == (L:3307REGISTRY Time,enum) 90 &lt;= and
        if{ (L:3307REGISTRY Time,enum) ++ (>L:3307REGISTRY Time,enum) 1 (>L:3307REGISTRY Screen,enum)
                            3 (>L:TIER2 CLICK LAYER,enum) }
        </Value>
       </Select>
    </Element>

     <!-- Stop timer after 20 seconds -->
    <Element>
       <Select>
        <Value>
                            (L:3307REGISTRY Time,enum) 90 > if{ 0 (>L:3307REGISTRY Screen,enum) }
        </Value>
       </Select>
    </Element>

     <!-- Reset Wakeup when timer is turned off -->
    <Element>
       <Select>
        <Value>
                            (L:GTX327_Power,bool) 1 ==
        (L:3307REGISTRY Time,enum) 90 > and
                                  if{ 0 (>L:REGISTRY PAGE WAKEUP Switch,bool) }
        </Value>
       </Select>
    </Element>

     <!-- While the "bootscreen" variable is ON and battery is ON, display the bootscreen bitmap -->

       <Element>
          <Visible>(L:3307REGISTRY Screen,enum) (A:Electrical master battery,bool) (A:Avionics master switch,bool) and and </Visible>
    <Element>
     <Position X="150" Y="16" />
     <Image Name="GTX327_OFF_Screen.bmp" Bright="Yes" ImageSizes="324,79"/>
    </Element>

    <Element>
       <Position X="155" Y="25"/>
          <Text X="320" Y="21" Bright="Yes" Length="29" Font="Arial" Color="#CADB35" Adjust="center" VerticalAdjust="Top" Multiline="No" Fixed="No">
            <String>GARMIN Corporation GTX 327</String>
          </Text>
    </Element>

     <!-- While the "bootscreen" variable is ON and battery is ON, display the bootscreen bitmap -->
    <Element>
        <Position X="165" Y="50"/>
            <Text X="300" Y="14" Bright="Yes" Length="33" Font="Arial"  Color="#CADB35" Adjust="center" VerticalAdjust="Top" Multiline="No" Fixed="No">
              <String>Software Version 2.10  &#169;1999-2008</String>
             </Text>
    </Element>

     <!-- While the "bootscreen" variable is ON and battery is ON, display the bootscreen bitmap -->
    <Element>
           <Position X="165" Y="67"/>
                 <Text X="300" Y="14" Bright="Yes" Length="22" Font="Arial" Color="#CADB35" Adjust="center" VerticalAdjust="Top" Multiline="No"

Fixed="No">
                    <String>Self Test In Progress</String>
                 </Text>
    </Element>
       </Element>
 
Messages
10,088
Country
us-arizona
I really need to learn to start doing Marco's. Everyone's having fun but me in that field...

Be thankful, you coders, that you can do this with such ease. Its such a struggle for me....
 

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
Bill, "Macros" are nothing more complicated than a literal replacement of a whole string of script that can be assigned to a "Macro" name.

The ONLY time it is the least bit useful is if you have to use the same "string of script" many times in any XML "gauge" and it is a long "string of script."
 
Top