<?xml version="1.0"?>
<!--

This file implements (on the instrument panel)
  an  interval timer
  aka approach timer
  aka stopwatch (*).

This is applicable to a wide range of simulated aircraft in connection
with the FlightGear flight simulator, fgfs.

Having an interval timer is more-or-less indispensible for performing
certain types of instrument approaches.

We assume the aircraft already has an ordinary clock that uses the
"clock.cxx" backend.  (Some fancy aircraft models have other clocks,
which we do not handle.)

USAGE: 
  ++ To start interval timer, press "q". 
     Each time you press "q", the timer restarts from zero.
  ++ To convert the timer back to being an ordinary time-of-day clock,
     press Q.  

Using the interval timer does not disturb the accuracy of the
time-of-day clock; you just can't see the time-of-day indication while
you're using the interval timer.  Alas the converse does not hold; if
you decide to peek at the time-of-day clock, when you return to the
interval timer it will restart from zero.  (If you feel strongly about
this, you can put /two/ clocks in the panel of your aircraft, one to
display time-of-day and one for use as an interval timer.)

Enable these features by placing the option
   [-]-config=.../stopwatch.xml 
on the fgfs command line or in your .fgfsrc file.

(*) Note that there is not (yet) any provision for stopping the timer
nor for taking split-times.  These would be nice, but for now are
classified as creeping features.  They would require recompiling
clock.cxx, and I can't get the fgfs package to compile on my machine
(Debian etch).

Note that since about August of 2006 the bleeding-edge CVS versions of
FlightGear have had a stopwatch "dialog" that can be found via the
"debug" menu.  It is a popup dialog, not an instrument on the panel.

  http://cvs.flightgear.org/cgi-bin/viewvc/viewvc.cgi/data/gui/dialogs/stopwatch.xml?view=log&pathrev=HEAD

By marrying the backend of the popup with a suitable frontend, it
should be possible to make a very nice panel-mounted stopwatch.

  
-->

<PropertyList>

<input><keyboard>
 <key n="113">
  <name>q</name>
  <desc>Stopwatch timer reset</desc>
  <binding>
   <command>nasal</command>
   <script>
   <!-- Note that the "indicated-sec" variable is a large number,
     probably seconds since midnight ... *not* modulo 60. -->
      ttt = props.globals.getNode("/instrumentation/clock/indicated-sec", 1).getValue();
      node = props.globals.getNode("/instrumentation/clock/offset-sec", 1);
      off = node.getValue();
      node.setValue(off-ttt);
   </script>
  </binding>
 </key>

 <key n="81">
  <name>Q</name>
  <desc>Stopwatch timer becomes clock again</desc>
  <binding>
   <command>nasal</command>
   <script>
      props.globals.getNode("/instrumentation/clock/offset-sec", 1).setValue(0);
   </script>
  </binding>
 </key>
</keyboard></input>

</PropertyList>
