• 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 Adding a timer.

Tom, once more again..
Thanks for the posting!!
It's always interesting to see other solutions!

Edi
 
I tried Tom's macros and they don't seem to work (my fault more likely) but, when I put
(P:Absolute Time,seconds) into an (L:var,number) I got tenths/hundredths of seconds instead of whole units.
Also the time interval of 15 seconds didn't work the engine shut down immediately.

Perhaps a simpler explanation for a mere mortal, please!
 
Let's start the other side: why don't you post your code so I can see where is the problem?

Tom
 
Let's start the other side: why don't you post your code so I can see where is the problem?

Tom
I tried to copy what you had posted here in the wiki. Obviously I'm missing something. Probably the variable names are wrong as well.

Code:
<Macro Name="GetElapsed">
  (P:Absolute time,seconds) (>L:time1,number) - abs 100 *
</Macro>
<Macro Name="SetElapsed">
  (P:Absolute time,seconds) (>L:time2,number) 100 *
</Macro>
When blackbox displays the L var values they are in tenths of a second i.e. 0.xx

This is what I'm trying to do in the next code to shut the engine down after 15 seconds
Code:
<!-- Engine Limitations Exceeded -->
 
<Element>
      <Select>
         <Value>(A:Turb eng1 N2, percent) 104.9 &gt; (L:eng1_stop,number) 0 == and
if{ @SetElapsed(L:time1,number) }</Value>
      </Select>
   </Element> 
 
<Element>
      <Select>
         <Value>@GetElapsed(L:time2,number) 15 >
if{ (>K:TOGGLE_ENGINE1_FAILURE) } }</Value>
      </Select>
   </Element>

I have to say the timers and me do not have the best of relationships.
Another curious thing I noticed was that (P:Absolute time,seconds) counts backwards!
 
Vololiberista: Another curious thing I noticed was that (P:Absolute time,seconds) counts backwards!

Thats because code (and maybe coders) are from an alternate universe... Totally backwards.. ;)
 
I don't think you need the L: in (L:time2,number) in @GetElapsed(L:time2,number).

Simply use @GetElapsed(time2,number)

Walter
 
I tried to copy what you had posted here in the wiki. Obviously I'm missing something. Probably the variable names are wrong as well.

Actually you didn't copy what is posted in the wiki:

Code:
<Macro Name="GetElapsed">
   (P:Absolute time,@2) (L:@1,@2) - abs
</Macro>
<Macro Name="SetElapsed">
  (P:Absolute time,@2) (>L:@1,@2)
</Macro>

@1 and @2 are macro parameters that you need to replace with your own data when invoking the macros:

Code:
<Element>
      <Select>
         <Value>
             (A:Turb eng1 N2, percent) 104.9 &gt; (L:eng1_stop,number) 0 == and
              if{ @SetElapsed(time1,seconds) 1 (>L:eng1_stop,number) }
          </Value>
      </Select>
</Element>

<Element>
      <Select>
         <Value>
            @GetElapsed(time1,seconds) 15 > (L:eng1_stop,number) 1 == and
            if{ (>K:TOGGLE_ENGINE1_FAILURE)  2 (>L:eng1_stop,number) }
         </Value>
      </Select>
</Element>

Notice that I use time1 as the name of the variable, without L: , and seconds as the unit for better readability.
Also added (L:eng1_stop,number) as a control var to avoid triggering @SetElapsed on every cycle.

When blackbox displays the L var values they are in tenths of a second i.e. 0.xx

You can't accurately display an absolute time in seconds or number units with !n.nf! because it is a number bigger than FLOAT64; you should use !s! instead, and it will show with exponentials, ie 1.34455e+10

Another curious thing I noticed was that (P:Absolute time,seconds) counts backwards!

In FSX it counts in a normal way and are seconds from january 1, 0000 at noon.
I believe in FS9 it might count backwards. I recall to use the abs operator, which you'll see written in the macro indeed, because it was necessary in FS9; not sure though.

For Absolute time, seconds, minutes and hours work properly; days and years don't.

Tom

EDIT: Macro "GetElapsed" with typo corrected.
 
Last edited:
Ok Tom,
Well, I don't know! Your code -
Code:
<Macro Name="GetElapsed">
   (P:Absolute time,@2) (>L:@1,@2) - abs
</Macro>
<Macro Name="SetElapsed">
  (P:Absolute time,@2) (>L:@1,@2)
</Macro>

Which I changed to -
Code:
<Macro Name="GetElapsed">
  (P:Absolute time,seconds) (>L:time1,number) - abs
</Macro>
<Macro Name="SetElapsed">
  (P:Absolute time,seconds) (>L:time2,number)
</Macro>

does something strange.
(P:Absolute time,seconds) (>L:time2,number) stays at zero until the counter reaches 15
@GetElapsed(time1,seconds) 15 > (L:eng1_stop,number) 1 == and
at which point P:Absolute time,seconds) (>L:time2,number) puts a value into L:time2
So nothing happens to the engine because the second var L:time2 is never ahead of L:time1
 
I made a typo here, sorry:

WRONG-
Code:
<Macro Name="GetElapsed">
  ( P:Absolute time,@2) (>L:@1,@2) - abs
</Macro>

Instead it must be:

RIGHT-
Code:
<Macro Name="GetElapsed">
   (P:Absolute time,@2) (L:@1,@2) - abs
</Macro>

Do not replace @1 and @2 with your own data in the macro itself, do it in the invoke name:

@SetElapsed(time1,seconds)
@GetElapsed(time1,seconds) 15 >

Also use the same var name in both macros (time1)

Tom
 
Glad you finally made it work :coffee:

Now I leave you another issue to take into account:

For the engine to fail, a reaching overtemp condition is necessary alone to trigger the failure after 15 seconds, or the overtemp condition must remain for 15 seconds to make it fail?

Current code depicts the first situation.

Tom

PS: maybe would be better to open a new thread if this has to continue; I think we would be a little off topic here.
 
Timers can be Blinker or Elapsed Time (cumulative time) variety. There's a good wiki entry that discusses the blink-type timers a little more thoroughly. The Elapsed Time types can be based on cycle counting or P:Absolute Time.

Here's a simple elapsed time example based on gauge update cycle counting. It assumes an update rate of 18 cycles per second and is analogous to the cycle counting approach used in Bill Leaming's script above -- and note this is the logic structure suggested by Bill in his reply#2:
Code:
<Update Frequency="18">
  (A:TURB ENG ITT:1, celsius) 906 &gt;
      if{ (L:Eng1Exceed906CNumCycles, enum) ++ (>L:Eng1Exceed906CNumCycles, enum) }
     els{ (L:Eng1Exceed906CNumCycles, enum) 0.5 - 0 max (>L:Eng1Exceed906CNumCycles, enum) }
  (L:Eng1Exceed906CNumCycles, enum) 18 60 * 5 * &gt;= if{ (>K:TOGGLE_ENGINE1_FAILURE) 0 (>L:Eng1Exceed906CNumCycles, enum) }
</Update>
In this example, the els{ ... 0.5 - 0 max ... } line is inserted to accomodate engine cooling that could occur before the 5 minute failure point is reached. Maybe not quite realistic, but you get the idea.

Hope this adds to both Bill's responses.

Bob


Im really intriqued with this code, but I would like it to 'clear' the timer (reset it) if you dip back under the temp range (for cooling down moments). SO far, this isnt working. So, what I did was setup an Initializer. But... How would you reset the timer to zero (or max if its counting backwards).

I have created an experimental reset to see if my idea will work, below.


Code:
<Gauge Name="Turbine Overheat Manager" Version="1.0">
  <Size X="5" Y="5" />

<Update Frequency="18">

<!-- Make Active -->
  (L:Turbine Overheat Manager Initializer,bool) 0 ==
  (A:TURB ENG ITT:1, celsius) 410 &gt; and
  (A:TURB ENG ITT:2, celsius) 410 &gt; and
       if{ 1 (&gt;L:Turbine Overheat Manager Initializer,bool) }

<!-- Cooling Reset -->
  (L:Turbine Overheat Manager Initializer,bool) 1 ==
  (A:TURB ENG ITT:1, celsius) 398 &lt: and
  (A:TURB ENG ITT:2, celsius) 398 &lt: and
       if{ 0 (&gt;L:Turbine Overheat Manager Initializer,bool) 
           0.5 (&gt;L:Eng1Exceed906CNumCycles, enum)
           0.5 (&gt;L:Eng2Exceed906CNumCycles, enum) }

  (L:Turbine Overheat Manager Initializer,bool) 0 ==
  (A:TURB ENG ITT:1, celsius) 415 &gt; and
      if{ (L:Eng1Exceed906CNumCycles, enum) ++ (>L:Eng1Exceed906CNumCycles, enum) }
     els{ (L:Eng1Exceed906CNumCycles, enum) 0.5 - 0 max (>L:Eng1Exceed906CNumCycles, enum) }
  (L:Eng1Exceed906CNumCycles, enum) 18 60 * 5 * &gt;= if{ (>K:TOGGLE_ENGINE1_FAILURE) 0 (>L:Eng1Exceed906CNumCycles, enum) }

  (L:Turbine Overheat Manager Initializer,bool) 0 ==
  (A:TURB ENG ITT:2, celsius) 412 &gt; and
      if{ (L:Eng2Exceed906CNumCycles, enum) ++ (>L:Eng2Exceed906CNumCycles, enum) }
     els{ (L:Eng2Exceed906CNumCycles, enum) 0.5 - 0 max (>L:Eng2Exceed906CNumCycles, enum) }
  (L:Eng2Exceed906CNumCycles, enum) 18 60 * 5 * &gt;= if{ (>K:TOGGLE_ENGINE2_FAILURE) 0 (>L:Eng2Exceed906CNumCycles, enum) }

</Update>

</Gauge>

EDITED
 
Last edited:
Hello Bill,

Some points:

1. I believe the cycle count timer is a good choice for the engine overheat scenario postulated in this thread for exactly the situation you mention - cooling. If you model cooling as reduction of the accumulated time in an overheat condition, it's straight-forward to handle in a cycle counter, although it can be handled using absolute time too.

2. Sorry for being redundant, but I think I should repeat what Tom said earlier in response to my posting because it's the basis for your script, above. A cycle count-based timer fails under any of the following conditions: a) Update frequency and number of cycles to count aren't based on the same frequency assumption, b) simulation is Paused, or, c) Simulation rate is changed. Further, he showed how to mitigate conditions b) and c) in Reply#20. Condition a) is easy to avoid of course. Tom also opined that my original response #6 could be considered as ok for personal or freeware, but would be "buggy" for a commercial product because it did not provide for b) and c). It's a good point. Timers based on absolute time don't fail when Paused or Sim Rate is changed. Cycle count timers will fail, so mitigations (#20) are needed.

3. For your example, I don't see the need of an Initializer. Why doesn't this work for you?

Code:
  (A:TURB ENG ITT:1, celsius) 906 &gt;
      if{ (L:Eng1Exceed906CNumCycles, enum) ++ (>L:Eng1Exceed906CNumCycles, enum) }
     els{ (L:Eng1Exceed906CNumCycles, enum) 0.5 - 0 max (>L:Eng1Exceed906CNumCycles, enum) }
  (L:Eng1Exceed906CNumCycles, enum) 18 60 * 5 * &gt;= if{ (>K:TOGGLE_ENGINE1_FAILURE) 0 (>L:Eng1Exceed906CNumCycles, enum) }

In the example, whenever temp is greater than the critical 906C, the over-heat time accumulates (L:Eng1Exceed906CNumCycles, enum). And, whenever temp is equal to or below the critical 906C, the accumulated over-heat time is reduced, but at half the rate that it can increase (the 0.5 is arbitrary. Is it realistic? That's another topic). If the accumulated time ever reaches 5 minutes (18 60 * 5 *), the engine fails. What this lacks are the mitigators in response #20.

For a commercial project or a robust personal or freeware one, you either need to use something like Tom did in #20, or re-wire the script to work off of absolute time in which case you can utilize the macros in #9.

Bob
 
Last edited:
Hey Bob,

Well, I took it up for testing (sim plane) and when I reached critical temps, I would back the throttle off and still the engines would fail. I installed 'blinkie lights' in the engines temp gauges to let me know when it was over limit, so I watched it pretty good. Something seemed to set them off. After a few flights and adjusting things, I decided to comment it out. I had hoped my initializer would have helped it to reset, but I probably didnt write it correctly.

I'll read back on this thread and check details. I must have skimmed over them by mistake.

This brings me to another question. Someone mentioned 'reset'. Do you have the ability to 'reset' a engine in flight? Another words, is the engine cooked, or is it mimicking a computer over-ride shut down? Can people reset an engine to restart somehow? or are we talking resetting the flight?


Bill
 
Back
Top