I've now added a mechanism that saves aircraft specific data.
For example, for the bo105 into ~/.fgfs/aircraft-data/bo105.xml
(Unix) or %APPDATA%\flightgear.org\aircraft-data\bo105.xml (MS).

The file is loaded at the beginning [settimer(.., 0)] and
saved at exit and fgfs reset. It can additionally be saved
in intervals (see below). If the file doesn't exist then
you'll currently get an error message that can be ignored.
This needs to be fixed, and is the reason why currently the
file is always written, even if there's nothing in it,
so that one gets the message at least only once per aircraft.

All one has to do is to define which properties should be saved.
This is done via add() function. It takes one or more property
paths or props.Node hashes, or a mixture thereof:

  var foo = props.globals.getNode("/sim/foo", 1);

  aircraft.data.add("/sim/model/bo105/state");
  aircraft.data.add(foo);
  aircraft.data.add(props.globals);    # save whole tree  :-)

You can list several properties, or lists thereof, or hashes,
or lists of lists, or ...  A property with children saves the
whole subtree. You can list all properties in one add() or each
in its own.

If you don't want the data only saved on exit and reset, you
can use the save() command:

  aircraft.data.save();

This saves immediately, but only once. If you call the function
with one argument (interval in minutes), then the data is saved
in that interval, and additionally on exit/reset:

  aircraft.data.save(0.5);  # save every 30 seconds

If such an automatic loop runs, then you can stop it with an
interval of 0 or no argument (like above):

  aircraft.data.save();


TODOs:
- check a property node for path entries that are automatically
  added. That way one doesn't need nasal for saving properties. 
- implement a Hobbs class that makes use of the data class and
  does the time incrementing etc.

m.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to