5 # copyright (c) 1999 Steve Franke K9AN
9 # 2001/12/16 added age of keps in the sh/sat output list.
10 # Note - there is the potential for problems when satellite name
11 # is longer than 20 characters. The list shows only the
12 # first 20 chars, so user won't know the full name.
13 # So far, it seems that only the GPS sats even come close...
15 my ($self, $line) = @_;
18 my @f = split /\s+/, $line;
19 my $satname = uc shift @f if @f;
20 my $numhours = shift @f if @f; # the number of hours ahead to print
21 my $step = shift @f if @f; # tracking table resolution in minutes
23 # default hours and step size
24 $numhours = 3 unless $numhours && $numhours =~ /^\d+$/;
25 $numhours = 3 if $numhours < 0;
26 $numhours = 24 if $numhours > 24;
27 $step = 5 unless $step && $step =~ /^\d+$/;
28 $step = 5 if $step < 0;
29 $step = 30 if $step > 30;
31 # get nearest lat and long (I can see we will need the altitude here soon as well :-)
32 my $lat = $self->user->lat;
33 my $lon = $self->user->long;
35 my $call = $self->call;
36 unless ($lon || $lat) {
37 $lat = $main::mylatitude;
38 $lon = $main::mylongitude;
39 $call = $main::mycall;
42 my $jtime; # lats and longs in radians
43 my ($sec, $min, $hr, $day, $mon, $yr) = (gmtime($main::systime))[0,1,2,3,4,5];
44 #printf("%2.2d %2.2d %2.2d %2.2d %2.2d\n",$min,$hr,$day,$mon,$yr);
49 $jtime=Sun::Julian_Day($yr,$mon,$day)+$hr/24+$min/60/24;
52 if ($satname && $Sun::keps{$satname}) {
54 ($yr,$mon,$day,$hr,$min)=Sun::Calendar_date_and_time_from_JD($jtime);
55 #printf("%2.2d %2.2d %2.2d %2.2d %2.2d\n",$min,$hr,$day,$mon,$yr);
56 push @out, $self->msg("pos", $call, slat($lat), slong($lon));
57 push @out, $self->msg("sat1", $satname, $numhours, $step);
58 push @out, $self->msg("sat2");
60 my ($slat,$slon,$salt,$az,$el,$distance)=Sun::get_satellite_pos($jtime,$lat*$d2r,$lon*$d2r,$alt,$satname);
61 # print the current satellite position
62 push @out,sprintf("Now %2.2d:%2.2d %7.1f %7.1f %7.1f %7.1f %7.1f %7.1f",
63 $hr,$min,$slat*$r2d,$slon*$r2d,$salt,
64 $az*$r2d,$el*$r2d,$distance);
67 $jtime=$jtime+$step/24/60;
68 my $disc = 0; # discontinuity flag
69 while ( $numsteps < $numhours*60/$step ) # look $numhours ahead for tracking table
71 my ($yr,$mon,$day,$hr,$min)=Sun::Calendar_date_and_time_from_JD($jtime);
72 my ($slat,$slon,$salt,$az,$el,$distance)=Sun::get_satellite_pos($jtime,$lat*$d2r,$lon*$d2r,$alt,$satname);
73 if ( $el*$r2d > -5 ) {
76 push @out, $self->msg("satdisc");
78 push @out,sprintf("%2.2d/%2.2d %2.2d:%2.2d %7.1f %7.1f %7.1f %7.1f %7.1f %7.1f",
79 $day,$mon,$hr,$min,$slat*$r2d,$slon*$r2d,$salt,
80 $az*$r2d,$el*$r2d,$distance);
85 $jtime=$jtime+$step/60/24;
88 push @out, $self->msg("satnf", $satname) if $satname;
89 push @out, $self->msg("sat3");
90 push @out, $self->msg("sat4");
94 foreach $sat (sort keys %Sun::keps) {
96 push @out,join ' ', @l;
100 my $epoch=$Sun::keps{$sat}->{epoch};
101 my $jt_epoch=Sun::Julian_Date_of_Epoch($epoch);
102 my $keps_age=int($jtime-$jt_epoch);
103 push @l, sprintf("%20s: %4s",$sat,$keps_age);
106 push @out, join ' ', @l;