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

FSXA Automatic Timer

Messages
61
Country
france
I want to make a timer controlled by a variable, not by the mouse
example:
if "FLAPS HANDLE INDEX" = 1
then the object appears for 2 seconds and then disappears.

I wrote this code (thank n4gix !), but it doesn't work because,naturally, the value is always equal to 1


Code:
<PartInfo>
<Name>00-Essai</Name>
<Visibility>
      <Parameter>
        <Code>
	(A:FLAPS HANDLE INDEX, number) 1 ==
	if{  (E:LOCAL TIME, seconds) 2 + (&gt;L:MyTimer,enum) }
         (L:MyTimer,enum) (E:LOCAL TIME, seconds) &gt; 
        </Code>
      </Parameter>
    </Visibility>
</PartInfo>

Can anyone help me ?

Thank you in advance
 
You have to set one variable as 0 change it to 1 in the if{} statement and then reset it to 0 otherwise the P:local time variable will run and run. This has caused me mountains of headaches in the past. These guys here have the patience of Saints!
This code is for gear down lights. It simulates the gear dropping under gravity in a two engine out scenario.
vololiberista
Code:
<!-- Gear Delay for two engines out-->
<Element>
      <Select>
         <Value>(L:gear_raised,bool) 0 == (A:Turb eng1 N2, percent) 5 &lt; (A:Turb eng2 N2, percent) 5 &lt; and
(A:SIM ON GROUND, bool) 0 == and (L:sound_played2,bool) 1 == and
(A:Gear center position,percent) 0 == and
if{ 1 (>L:gear_raised,bool) }</Value>
      </Select>
   </Element>
<Element>
      <Select>
         <Value>(L:gear_raised,bool) 1 == [COLOR="Red"](L:gear_reselected,bool) 0 == [/COLOR]and (A:Gear handle position,percent) 50 &gt; and if{ [COLOR="Red"]1 (>L:gear_reselected,bool)[/COLOR] (P:local time, seconds) 180 + (>L:nose_gear_delay,number) (P:local time, seconds) 140 + (>L:left_gear_delay,number) (P:local time, seconds) 160 + (>L:right_gear_delay,number) }</Value>
      </Select>
   </Element>
<Element>
      <Select>
         <Value>(A:SIM ON GROUND, bool) 1 == (L:sound_played2,bool) 0 == and (A:Gear center position,percent) 0 &gt; and
if{ 0 (>L:gear_raised,bool) [COLOR="Red"]0 (>L:gear_reselected,bool)[/COLOR] }</Value>
      </Select>
   </Element>
 
Hi,
have a good look at your if-statement...
It says:
if flaps handle index,number = 1 then set mytimer,enum to local time +2 seconds.

So as long as your handle has index 1, the variable keeps being reset to time + 2 seconds every gauge update cycle (18 times per second)...

You can prevent this by adding another condition to your if statement by using a new L:variable that changes value once the timer has been set.

Code:
(A:FLAPS HANDLE INDEX, number) 1 == (L:timerset,enum) 0 == and
	if{  (E:LOCAL TIME, seconds) 2 + (&gt;L:MyTimer,enum) 1 (&gt;L:timerset,enum) }
         (L:MyTimer,enum) (E:LOCAL TIME, seconds) &gt;

This will only work once, though.
So if your flaps handle index is set to 2 and then to 1 again, L:timerset,enum (having a value of 1) prevents your timer to be set again.
You can think about how to fix that (reset L:timerset,enum to 0 once the flaps handle index is not 1, and L:timerset is not 0)

Aahh the joys of xml coding!!

grt
Willem
 
How about this:

Code:
<update>
  (A:FLAPS HANDLE INDEX) 1 == ! if{ (A:CURRENT TIME) 2 + (>L:TIMER) }
</update>

<element>
<visible> (A:FLAPS HANDLE INDEX) 1 == (A:CURRENT TIME) (L:TIMER) &lt; &amp;&amp; </visible>
</element>
 
Most examples are from gauge code, though it seems the original post makes reference to a model snippet. A simple solution could be something like:

Code:
<Code>
	(L:FlapsControl,number) (A:FLAPS HANDLE INDEX, number) != (>L:FlapsControl,number)
	(A:FLAPS HANDLE INDEX, number) 1 ==
	(L:FlapsControl,number) and
	if{ (E:ABSOLUTE TIME, seconds) 2 + (>L:MyTimer,enum) }
       (L:MyTimer,enum) (E:ABSOLUTE TIME, seconds) >
</Code>
I always suggest to use ABSOLUTE instead of LOCAL time as to avoid the midnight shift.

Tom
 
Last edited:
Tom,

i'm also using (P:Absolute time,second).

Code:
      %P:Absolute time,min\t%((P:Absolute time,minutes))%!6.5f!\n
      %\n

      %P:Absolute time,sec\t%((P:Absolute time,second))%!08.5f!\n
      %Differ,sec\t%((P:Absolute time,second) (L:Test_Sec,second) -)%!08.5f!\n
      %((P:Absolute time,second) (&gt;L:Test_Sec,enum))
      %L:Test_Sec,sec\t%((L:Test_Sec,enum))%!08.5f!\n
      %\n

But the output is only from 00.00000.. to 00.99999..
I get no fully seconds.

I hope i'm understandable.

Edi
 
Thanks to you all.
If this can be of any help, here is the code I wrote and wich works correctly.
  1. The timer is set for two seconds,
  2. The corresponding sound is played,
  3. The timer is reset,
  4. The timer can be relaunched as many times as needed.


HTML:
<PartInfo>
<Name>00-Essai</Name>
	<Visibility>
      		<Parameter>
       	 		<Code>
		<!-- Start the timer for two seconds -->
			(A:FLAPS HANDLE INDEX, number) 1 ==
			(L:Volets_Son_10,bool) 0 == and 
			if{ 1 (&gt;L:Volets_Son_10,bool) 
			(E:ABSOLUTE TIME, seconds) 2.0 + (&gt;L:Timer_Sons_Volets_10,enum) }
			(L:Timer_Sons_Volets_10,enum) (E:ABSOLUTE TIME, seconds) &gt; 
		<!-- Play the sound " Nord_Son_Volets_10" -->
			(E:ABSOLUTE TIME, seconds) (L:Timer_Sons_Volets_10,enum) &lt; 
			if{ 1 (&gt;L:Nord_Son_Volets_10, enum) }
			els{ 0 (&gt;L:Nord_Son_Volets_10, enum) }
		<!-- Reset the Timer --> 
			(A:FLAPS HANDLE INDEX, number) 1 !=
			if{ 0 (&gt;L:Volets_Son_10,bool) }
      			 </Code> 
     		 </Parameter>
    	</Visibility>   
</PartInfo>
 
Try (P:Absolute time,seconds), NOT (P:Absolute time,second)

Hope this helps,
 
Code:
Try (P:Absolute time,seconds), NOT (P:Absolute time,second)

Already done.

I think seconds are enums and XML is not able to show them.
I know only s, d, f.

But nevertheless my timers are working properly.:)
As Tom A. explained.

Edi
 
Hi,
glad you got it working!

One thing i would personally add is in the reset code:

Code:
<!-- Reset the Timer --> 
			(A:FLAPS HANDLE INDEX, number) 1 != [COLOR="Red"] L:Volets_Son_10,bool) 0 != and[/COLOR]
			if{ 0 (&gt;L:Volets_Son_10,bool) }
      			 </Code>

Only set L:Volets_Son_10,bool to 0 if the Flaps Handle Index is not equal to 1 AND L:Volets_Son_10,bool is not already 0.
This prevents continuous "firing" of the code (while the flaps are not at index posn 1) which might influence your framerate.

grt
Willem
 
Last edited:
Try (P:Absolute time,seconds), NOT (P:Absolute time,second)

Hope this helps,

The SDK says that either second or seconds are valid.

All the _TIME variables are Environment type: E:
 
Hi FBVLV

in the segment of your code shown below, what is the purpose of the statement

(L:Timer_Sons_Volets_10,enum) (E:ABSOLUTE TIME, seconds) &gt;

(just before "<!-- Play the sound")

I am not an experienced XML user and I cannot understand what it does.

I would like to be able to use this nifty timer in some gauges but need to know what is happening in them.

Thanks

Walter
 
Last edited:
The SDK says that either second or seconds are valid.

All the _TIME variables are Environment type: E:

Bill,
What then is the difference between P:absolute time and E:absolute time

Why have two when one will suffice.
vololiberista
 
Bill,
What then is the difference between P:absolute time and E:absolute time

Why have two when one will suffice.
vololiberista
The SDK states that E: is for Environmental variables (all time related), and that P: is for Program Date variables (SIMULATION RATE and UNITS OF MEASURE).

As you've noted though, in practice it seems to make no difference whatever! :eek:
 
Hi FBVLV

in the segment of your code shown below, what is the purpose of the statement

(L:Timer_Sons_Volets_10,enum) (E:ABSOLUTE TIME, seconds) &gt;

(just before "<!-- Play the sound")

I am not an experienced XML user and I cannot understand what it does.

I would like to be able to use this nifty timer in some gauges but need to know what is happening in them.

Thanks

Walter


(L:Timer_Sons_Volets_10,enum) (E:ABSOLUTE TIME, seconds) &gt;

makes the object (part) appear for two seconds, while (L:Timer_Sons_Volets_10,enum) is greater than (E:ABSOLUTE TIME, seconds), and then disappear until the proper condition is met again.

Tom
 
Thanks Tom.

I may not quite understand how it actually works yet but I have made use of the timer already in a number of gauges. It certainly does the job efficiently and cleanly!

Walter
 
Back
Top