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

Timer?

Messages
74
Country
flag
Hi everyone
Just curious if I need to postpone execution of a function by 5 seconds, should I use a timer?
And if yes, could I place the timer on PANEL_SERVICE_PRE_UPDATE or somewhere else?

Thank you very much)
 
@ Naruto-kun thank you for a quick reply
how can i handle it?
something like:
Code:
void FSAPI test_f(...)
{
switch(...)
 case PANEL_SERVICE_PRE_UPDATE:
  double time1 = GetSimTime6();
  double time2 = GetSimTime6()+5;

 if(time1 ==  time2)
  {
   execute_calculation_code(" 1 (>L:vis_test, bool)", NULL, NULL, NULL)
  }
break;
}

sorry for that dumb question and example
before i never work with time at all

Thank you )
 
make a global double called old_time or something like that.

Code:
double time = GetSimTime6();

if(time-old_time >= 5)
{
   //do stuff
   old_time = time;
}
 
Hi,
another good way to deal with timer functions is using increment ticks, like this :

80 83 (A:Airspeed indicated,knots) rng (* Example trigger event*)

if{ (G:Var1) ++ (>G:Var1) } (*increment count.=One tick is 60 ms *)

(G:Var1) 45 > (* after 45 ticks= 3 sec the (G:Var2 will set to TRUE*)

if{ 0 (>G:Var1) 1 (>G:Var2) } (* trigger (G:Var2, is true after 3 sec*)

So, no timer variables are in use. To me an easy way to solve triggers with timer functions.

Dietmar
 
An aternative high-resolution C++ timer

Code:
//-----------------------------------------------------------------------------
//  Variables in .h file
LARGE_INTEGER Tick;
LARGE_INTEGER StartingTime;
LARGE_INTEGER EndingTime;
double StartingTicks;
double EndTicks;
double Ticks;
double Start;
double End;
double ElapsedTime;

//-----------------------------------------------------------------------------
// Get the system tick rate - needed only once on startup
QueryPerformanceFrequency(&Tick);
Ticks = Tick.QuadPart;

//-----------------------------------------------------------------------------
// Sample code to Get ElapsedTime between EndingTime and StartingTime events
//Get system Start time
QueryPerformanceCounter(&StartingTime);
Start =  StartingTime.QuadPart / Ticks;

// Code to be timed here ....

//Get system End time
QueryPerformanceCounter(&EndingTime);
End =  EndingTime.QuadPart / Ticks;

// Elapsed time
ElapsedTime = End - Start;
 
Back
Top