| 1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
require "telnet.pl"; |
| 4 |
|
| 5 |
use strict; |
| 6 |
|
| 7 |
my( $airport_id ) = "KSNA"; |
| 8 |
my( $rwy_no ) = "19R"; |
| 9 |
my( $reset_sec ) = 300; |
| 10 |
|
| 11 |
my( $server ) = "localhost"; |
| 12 |
my( $port ) = 5401; |
| 13 |
my( $timeout ) = 5; |
| 14 |
|
| 15 |
while ( 1 ) { |
| 16 |
print "Reseting to $airport_id $rwy_no\n"; |
| 17 |
reset_position( $airport_id, $rwy_no ); |
| 18 |
sleep( $reset_sec ); |
| 19 |
} |
| 20 |
|
| 21 |
|
| 22 |
sub reset_position { |
| 23 |
my( $aptid ) = shift; |
| 24 |
my( $rwy ) = shift; |
| 25 |
|
| 26 |
my( $prop, $value ); |
| 27 |
my( %HASH ) = (); |
| 28 |
|
| 29 |
$HASH{ "/sim/presets/airport-id" } = $aptid; |
| 30 |
$HASH{ "/sim/presets/runway" } = $rwy; |
| 31 |
$HASH{ "/sim/presets/vor-id" } = ""; |
| 32 |
$HASH{ "/sim/presets/vor-freq" } = ""; |
| 33 |
$HASH{ "/sim/presets/ndb-id" } = ""; |
| 34 |
$HASH{ "/sim/presets/ndb-freq" } = ""; |
| 35 |
$HASH{ "/sim/presets/fix" } = ""; |
| 36 |
$HASH{ "/sim/presets/longitude-deg" } = "-9999.0"; |
| 37 |
$HASH{ "/sim/presets/latitude-deg" } = "-9999.0"; |
| 38 |
$HASH{ "/sim/presets/offset-distance" } = ""; |
| 39 |
$HASH{ "/sim/presets/offset-azimuth" } = ""; |
| 40 |
$HASH{ "/sim/presets/heading-deg" } = "-9999.0"; |
| 41 |
$HASH{ "/sim/presets/altitude-ft" } = ""; |
| 42 |
$HASH{ "/sim/presets/glideslope-deg" } = ""; |
| 43 |
$HASH{ "/sim/presets/airspeed-kt" } = ""; |
| 44 |
|
| 45 |
my( $fgfs ); |
| 46 |
|
| 47 |
if ( !( $fgfs = &connect($server, $port, $timeout) ) ) { |
| 48 |
print "Error: can't open socket\n"; |
| 49 |
return; |
| 50 |
} |
| 51 |
|
| 52 |
&send( $fgfs, "data" ); # switch to raw data mode |
| 53 |
|
| 54 |
foreach $prop ( keys(%HASH) ) { |
| 55 |
$value = $HASH{$prop}; |
| 56 |
# if ( $value eq "" ) { |
| 57 |
# $value = 0; |
| 58 |
# } |
| 59 |
print "setting $prop = $value\n"; |
| 60 |
&set_prop( $fgfs, $prop, $value ); |
| 61 |
} |
| 62 |
|
| 63 |
&send( $fgfs, "run presets-commit" ); |
| 64 |
|
| 65 |
# set time of day to noon |
| 66 |
&send( $fgfs, "run timeofday noon" ); |
| 67 |
|
| 68 |
# start the engine |
| 69 |
&set_prop( $fgfs, "/controls/engines/engine[0]/magnetos", "3" ); |
| 70 |
&set_prop( $fgfs, "/controls/engines/engine[0]/starter", "true" ); |
| 71 |
sleep(2); |
| 72 |
&set_prop( $fgfs, "/controls/engines/engine[0]/starter", "false" ); |
| 73 |
|
| 74 |
&send( $fgfs, "quit" ); |
| 75 |
close $fgfs; |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
|