Adding a Delay to an XML Function

#1
I was wondering about how to add a delay to this function:

<!-- ENG2 ON AND GEN -->
(A:ENG2 N1 RPM, percent) 10 >
(L:O09_012_LT2, number) 0 == and
if{ 1 (>L:ENG2_POWER_ON,number) 1 (>L:AC_ON_ENG_PWR_STATE,number) } els{ 0 (>L:ENG2_POWER_ON,number) 0 (>L:AC_ON_ENG_PWR_STATE,number) }

Specifically, I want the else statement

{ 0 (>L:ENG2_POWER_ON,number) 0 (>L:AC_ON_ENG_PWR_STATE,number) }

to occur 2 seconds or so after the conditional statement returns false.
I've found lots of stuff about (P:Absolute time, seconds) but can't figure out how to get it to work.
 
Last edited:
#2
Code:
<!-- ENG2 ON AND GEN -->
(A:ENG2 N1 RPM, percent) 10 >
(L:O09_012_LT2, number) 0 ==
and
if{ 
  1 (>L:ENG2_POWER_ON,number) 
  1 (>L:AC_ON_ENG_PWR_STATE,number)
   }

(A:ENG2 N1 RPM, percent) 10 &lt;
(L:O09_012_LT2, number) 0 !=
or
if{
  (P:Absolute time, seconds)  2 + (>L:Timer_Delay,seconds)
  }

(L:ENG2_POWER_ON,number) 0 !=
(L:AC_ON_ENG_PWR_STATE,number) 0 !=
or
(P:Absolute time, seconds)  (>L:Timer_Delay,seconds) &gt;
and
if{
   0 (>L:ENG2_POWER_ON,number)
   0 (>L:AC_ON_ENG_PWR_STATE,number)
   }
I think this should work. Not tested!
 
#3
The above will not work..

Code:
<!-- ENG2 ON AND GEN -->
(A:ENG2 N1 RPM, percent) 10 >
(L:O09_012_LT2, number) 0 ==
and
if{
  1 (>L:ENG2_POWER_ON,number)
  1 (>L:AC_ON_ENG_PWR_STATE,number)
   }

(A:ENG2 N1 RPM, percent) 10 &lt;
(L:O09_012_LT2, number) 0 !=
or
(L:ENG2_POWER_ON,number) 1 ==
(L:AC_ON_ENG_PWR_STATE,number) 1 ==
or
and
(L:Timer_Delay,seconds) 0 ==
and
if{
  (P:Absolute time, seconds)  2 + (>L:Timer_Delay,seconds)
  }

(P:Absolute time, seconds)  (L:Timer_Delay,seconds) &gt;
(L:Timer_Delay,seconds) 0 !=
and
if{
   0 (>L:Timer_Delay,seconds)
   0 (>L:ENG2_POWER_ON,number)
   0 (>L:AC_ON_ENG_PWR_STATE,number)
   }
Not tested!
 
Last edited:
#4
If this is a gauge and not some model animation code then using the built in 18hz gauge read/refresh cycle will work.
2 seconds * 18 hz = 36
XML:
(A:ENG2 N1 RPM, percent) 10 > (L:O09_012_LT2, number) 0 == and
if{ 1 (>L:ENG2_POWER_ON,number) 1 (>L:AC_ON_ENG_PWR_STATE,number) 0 (>L:AC_ON_TIMER, number) }
els{ (L:AC_TIMER, number) ++ 36 min (>L:AC_TIMER, number) (L:AC_TIMER, number) 36 == if{ 0 (>L:ENG2_POWER_ON,number) 0 (>L:AC_ON_ENG_PWR_STATE,number) } }
 

rcbarend

Resource contributor
#5
As a sidenote (may not be important in this case, but good to realise):
There is a subtil difference between timers based on the AbsoluteTime Avar, and timers based on counting XML gauge schedules.
Namely in case you Pause the sim:

- Timers based on AbsoluteTime are stopped during Pause, because AbsoluteTime freezes.

- Timers based on counting gauge schedules keeps running, because gauges keep running when the sim is Paused.
Unless of course you add a Pause detection in the code, to explicitely stop the timer in Pause.

Rob
 
Top