Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Is there a better way ?

Featured Replies

I am currently working on a cessna rpm gauge. The cessna gauge I want to replicate does not have the seconds strip like the FS9 cessna, so the first number that moves is the units, now after doing some testing using the fs9 cessna, one unit moves 1 number every 360 sec (6 mins) and completes one cycle in 3600 sec (60 mins). Pretty simple maths to work out how the others work.This code below works, but if I continue, this is going to become the longest code in history, I am sure there has got to be a better way, but at the moment one alludes me. Any ideas ?FLOAT64 FSAPI engine_units_y( PELEMENT_MOVING_IMAGE pelement ){ lookup_var(&working_time); engine_time = (working_time.var_value.n); engine_time_units = engine_time / 360; if (engine_time_units == 0) engine_time_units = 0; else if (engine_time_units == 1) engine_time_units = 1; else if (engine_time_units == 2) engine_time_units = 2; else if (engine_time_units == 3) engine_time_units = 3; else if (engine_time_units == 4) engine_time_units = 4; else if (engine_time_units == 5) engine_time_units = 5; else if (engine_time_units == 6) engine_time_units = 6; else if (engine_time_units == 7) engine_time_units = 7; else if (engine_time_units == 8) engine_time_units = 8; else if (engine_time_units == 9) engine_time_units = 9; else if (engine_time_units == 10) engine_time_units = 0; else if (engine_time_units == 11) engine_time_units = 1; else if (engine_time_units == 12) engine_time_units = 2; return engine_time_units;}

  • Moderator

Here is a routine I've used for years to record Hobbs Time:FLOAT64 total_time=0;FLOAT64 eng_time;int seconds = 0 ;int minutes = 0 ;int hobbs_start = 0 ;int initialize_time = 0 ;int latch = 0 ;case PANEL_SERVICE_PRE_UPDATE: if ( TURB_ENGINE_1_CORRECTED_N1var.var_value.n > 10 || TURB_ENGINE_2_CORRECTED_N1var.var_value.n > 10 ) { // if six minutes have accumulated, increment tenths digit and reset accumulator latches if ( minutes == 6 ) { latch = 1 ; hobbs_start = 1 ; } if ( seconds < 0 && hobbs_start == 2 ) { seconds = 0 ; hobbs_start = 1 ; } // capture a starting seconds count and set accumulator // latch to begin measuring elapsed seconds if ( hobbs_start == 1 ) { initialize_time=(int)CLOCK_TOTAL_SECONDSvar.var_value.n; hobbs_start = 2 ; } if ( hobbs_start == 2 ) { seconds=(int)CLOCK_TOTAL_SECONDSvar.var_value.n-initialize_time; } else { seconds = 0 ; } if ( hobbs_start == 2 ) { minutes = (int)( seconds - fmod(seconds,60.0) ) / 60 ; } else { minutes = 0 ; } // if 60 seconds have elapsed, increment total_time by 0.1 // tenth hour) and reset the accumulator latch if ( hobbs_start == 2 && minutes == 6 && latch == 1 ) { total_time = total_time + .1 ; latch = 0 ; } } // if both engines are off, display accumulated time else { total_time = total_time ; }break;

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator
  • Commercial Member

>I am currently working on a cessna rpm gauge. The cessna>gauge I want to replicate does not have the seconds strip like>the FS9 cessna, so the first number that moves is the units,>now after doing some testing using the fs9 cessna, one unit>moves 1 number every 360 sec (6 mins) and completes one cycle>in 3600 sec (60 mins). Pretty simple maths to work out how the>others work.>>This code below works, but if I continue, this is going to>become the longest code in history, I am sure there has got to>be a better way, but at the moment one alludes me. Any ideas>?>>FLOAT64 FSAPI engine_units_y( PELEMENT_MOVING_IMAGE pelement>)>{> lookup_var(&working_time);> engine_time = (working_time.var_value.n);>> engine_time_units = engine_time / 360;>> if (engine_time_units == 0) engine_time_units = 0;> else if (engine_time_units == 1) engine_time_units = 1;> else if (engine_time_units == 2) engine_time_units = 2;> else if (engine_time_units == 3) engine_time_units = 3;> else if (engine_time_units == 4) engine_time_units = 4;> else if (engine_time_units == 5) engine_time_units = 5;> else if (engine_time_units == 6) engine_time_units = 6;> else if (engine_time_units == 7) engine_time_units = 7;> else if (engine_time_units == 8) engine_time_units = 8;> else if (engine_time_units == 9) engine_time_units = 9;> else if (engine_time_units == 10) engine_time_units = 0;> else if (engine_time_units == 11) engine_time_units = 1;> else if (engine_time_units == 12) engine_time_units = 2;>> return engine_time_units;>}Uncertain if you're correct in the 6 minutes per digit value... but... ;)engine_time_units = fmod(engine_time_units,10);

Ed Wilson

Mindstar Aviation
My Playland - I69

BillWill take a look at your code, looks a bit complex so will print it out, sit down and see if I can work out how it works.Ed>Uncertain if you're correct in the 6 minutes per digit value... but... ;)I did test it twice. I have a string for ENGINE_WORKING_TIME in the rpm gauge I am doing, and the fs9 cessna gauge working along side it, when the string displayed 360 the 1 on the strip was just centering in the gauge, 720 the same thing happened with 2, 1080 - 3 etc. To be sure I will test it again, will let you know the results.> engine_time_units = fmod(engine_time_units,10);Thanks for that bit of code Ed, never seen fmod before, another thing to work out.This should keep me busy for a bit.ThanksEdit:Not a problem with this, but did not want to start a new topic on one question, but is it possible for a declaration of a variable to lose information ? The reason I asks is my altermeter loses, so by the time I get to 4000ft, it is 100 ft out, go higher and it continues to lose even more, did a search on the forum, and found one post with the same problem, but no answer.

  • Commercial Member

Ok... the reason I question the 360 value:A Hobbs-type meter usually indicates hours of use and the far right numbers indicate 10ths of an hour. You stated that your RPM gauge doesn't have the far right value, thus your first column of numbers should be indicating whole hours.Also, FYI... an actual RPM gauge usually indicates values based on level of RPMs.... thus the higher and longer RPMs are, the higher the value.

Ed Wilson

Mindstar Aviation
My Playland - I69

EdI see why you questioned the 360 value. From my understanding of this there are two types, hobbs meter and tach time. I have not done much research into the hobbs meter, but have done a fair bit on the tach time, which from my understanding works the same as the FS9 cessna, higher RPM's, time increases faster.I have done alot more testing using ENGINE_WORKING_TIME, and 1 unit (white number on the fs9 cessna) does take 360sec (6mins) one cycle takes 3600sec (60mins. I have also now worked out how the time is displayed in the aircraft state (hidden folder where fs9.cfg is) 1.000000 = 3600sec (6mins) 0.166666 = 60sec (1min) 1sec = 0.000277.Found out about fmod, via the cplusplus.com web site, gave it a try and of course it works :-) Will see if I can do a custom one over the weekend though and try and increase my knowledge of C++.Thanks for the help

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.