In case anyone is interested I just added a varient of the high res C172 rpm
gauge that implements a digital hobbs meter instead of the original
"static/non-changing" hobbs meter that was cooked into the background
texture.
The hobbs meter runs when the engine runs and is saved periodically to your
~/.fgfs/<aircraft-name>.xml file. This gauge uses the very nice Nasal based
aircraft timer and thus requires a bit of per-aircraft Nasal to be added
before the hobbs meter will work. I don't think it makes sense to do this
universally because different aircraft don't handle this always in the same
way. Note: I configured the code to save all the aircraft specific state
every 5 minutes. This avoids too much lost time if your computer crashes or
if FlightGear is externally terminated without using a graceful exit.
(Normally aircraft state is only saved during a graceful application exit.)
If you drop in the following code to your aircraft specific nasal file (or
one of them) the hobbs meter should come to life.
# initialize the hobbs meter and configure to save every 5 minutes
var hobbs = aircraft.timer.new("/instrumentation/clock/hobbs-meter-sec");
aircraft.data.save(5);
hobbs.stop();
setlistener( "/engines/engine[0]/running",
func {
var running = getprop("/engines/engine[0]/running");
if ( running ) {
hobbs.start();
} else {
hobbs.stop();
}
}
);
setlistener( "/instrumentation/clock/hobbs-meter-sec",
func {
var secs = getprop("/instrumentation/clock/hobbs-meter-sec");
setprop("/instrumentation/clock/hobbs-meter-hours", secs / 3600);
},
1
);
I just noticed one thing ... if you reset FlightGear (from the built in
menu) it resets the hobbs meter to whatever it was when you started the
program. I can't see why that is since the actual save file has been
updated. On startup is the save file copied into some separate property
tree and then on (re)init, these values copied over to the main property
tree? It doesn't seem like that's what the code does ... hmmm ....
Thanks,
Curt.
--
Curtis Olson: http://baron.flightgear.org/~curt/
------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel