fix SSID ambiguity on spotter in DX
authorminima <minima>
Sat, 26 Feb 2005 21:34:47 +0000 (21:34 +0000)
committerminima <minima>
Sat, 26 Feb 2005 21:34:47 +0000 (21:34 +0000)
sort out auth in HELLO
add grayline stuff

cmd/Aliases
cmd/Commands_en.hlp
cmd/show/grayline.pl [new file with mode: 0644]
cmd/show/sun.pl
perl/Messages
perl/Spot.pm
perl/Sun.pm
perl/Thingy.pm
perl/Thingy/Dx.pm
perl/Thingy/Hello.pm

index 42a9aa2afcf1e2b14cc9c2cce0f3b472f554e515..971c5f1c2a2e085ece06bff2dc398c21e6ba5909 100644 (file)
@@ -127,6 +127,7 @@ package CmdAlias;
          '^sho?w?/fdx/(\d+)', 'show/dx real $1', 'show/fdx',
          '^sho?w?/fdx/d(\d+)', 'show/dx real from $1', 'show/fdx',
          '^sho?w?/fdx', 'show/dx real', 'show/fdx',
+         '^sho?w?/gre?y?l?i?n?e?', 'show/grayline', 'show/grayline',
          '^sho?w?/myd?x?/(\d+)-(\d+)', 'show/dx filter $1-$2', 'show/mydx',
          '^sho?w?/myd?x?/(\d+)', 'show/dx filter $1', 'show/mydx',
          '^sho?w?/myd?x?/d(\d+)', 'show/dx filter from $1', 'show/mydx',
index 592b71827a5751e60c0157999f87c07431ecc1e0..9e3982cba91851b2ceb1fd28c78e72d95d95a5f6 100644 (file)
@@ -2032,6 +2032,37 @@ See also TYPE - to see the contents of a file.
 Show the contents of all the filters that are set. This command displays
 all the filters set - for all the various categories.
 
+=== 0^SHOW/GRAYLINE [ndays] [<prefix>|<callsign>]^Show Civil dawn/dusk times
+This command is very similar to SHOW/SUN except that it shows the 
+start and end of "Official" or "Civil" Dawn and Dusk. This is defined 
+as when the Sun is 6 degrees below the horizon.
+
+If you don't specify any prefixes or callsigns, it will show the 
+times for your QTH (assuming you have set it with either SET/LOCATION 
+or SET/QRA), together with the current azimuth and elevation.
+
+If all else fails it will show the civil dawn and dusk times for 
+the node that you are connected to.
+
+For example:-
+
+  SH/GRAYLINE
+  SH/GRAYLINE G1TLH W5UN
+
+You can also use this command to see into the past or the future, so
+if you want to see yesterday's times then do:-
+
+  SH/GRAYLINE -1
+
+or in three days time:-
+
+  SH/GRAYLINE +3 W9
+
+Upto 366 days can be checked both in the past and in the future.
+
+Please note that the times are given as the UT times of the requested
+UT day.
+       
 === 0^SHOW/HFSTATS [days] [date]^Show the HF DX Statistics 
 Show the HF DX spots breakdown by band for the last <days> no of days 
 (default is 31), starting from a <date> (default: today).
diff --git a/cmd/show/grayline.pl b/cmd/show/grayline.pl
new file mode 100644 (file)
index 0000000..c2c6fcf
--- /dev/null
@@ -0,0 +1,70 @@
+#!/usr/bin/perl
+#
+# show dawn, sunrise, sunset, and dusk times for each callsign or prefix entered
+#
+# 
+my ($self, $line) = @_;
+my @f = split /\s+/, $line;
+
+my @out;
+my $f;
+my $l;
+my $n_offset;
+my @list;
+
+while ($f = shift @f){
+        if(!$n_offset){
+                ($n_offset) = $f =~ /^([-+]?\d+)$/;
+                next if $n_offset;
+        }
+        push @list, $f;
+}
+$n_offset = 0 unless defined $n_offset;
+$n_offset = 0 if $n_offset > 365;  # can request moon rise/set up to 1 year ago or from now...
+$n_offset = 0 if $n_offset < -365;
+
+my ($lat, $lon);              # lats and longs in radians
+my ($sec, $min, $hr, $day, $month, $yr) = (gmtime($main::systime+$n_offset*24*60*60))[0,1,2,3,4,5];
+
+$month++;
+$yr += 1900;
+
+my @in;
+
+if (@list) {
+       foreach $l (@list) {
+               my $user = DXUser->get_current(uc $l);
+               if ($user && $user->lat && $user->long) {
+                       push @in, [$user->qth, $user->lat, -$user->long, uc $l ];
+               } else {
+                       # prefixes --->
+                       my @ans = Prefix::extract($l);
+                       next if !@ans;
+                       my $pre = shift @ans;
+                       my $a;
+                       foreach $a (@ans) {
+                               $lat = $a->{lat};
+                               $lon = -$a->{long};
+                               push @in, [ $a->name, $lat, $lon, $pre ];
+                       }
+               }
+       }
+} else {
+       if ($self->user->lat && $self->user->long) {
+               push @in, [$self->user->qth, $self->user->lat, -$self->user->long, $self->call ];
+       } else {
+               push @in, [$main::myqth, $main::mylatitude, -$main::mylongitude, $main::mycall ];
+       }
+}
+
+push @out, $self->msg('grayline1');
+push @out, $self->msg('grayline2');
+
+foreach $l (@in) {
+        my ($dawn, $rise, $set, $dusk, $az, $dec )=Sun::rise_set($yr,$month,$day,$hr,$min,$l->[1],$l->[2],0);
+        $l->[3] =~ s{(-\d+|/\w+)$}{};
+        push @out,sprintf("%-6.6s %-30.30s %02d/%02d/%4d %s %s %s %s", $l->[3], $l->[0], $day, $month, $yr, $dawn, $rise, $set, $dusk);
+}
+
+
+return (1, @out);
index d7c9766ccdcfea78a475007dbecc39b225c3bf6f..36aaa07897d2b3db4792f61dcb51db697733c9f4 100644 (file)
@@ -70,7 +70,8 @@ if( !$n_offset ) {
 }
 
 foreach $l (@in) {
-        my ($rise, $set, $az, $dec, $loss )=Sun::rise_set($yr,$month,$day,$hr,$min,$l->[1],$l->[2],0);
+       my ($dawn, $rise, $set, $dusk, $az, $dec )=Sun::rise_set($yr,$month,$day,$hr,$min,$l->[1],$l->[2],0);
+               
         $l->[3] =~ s{(-\d+|/\w+)$}{};
         if( !$n_offset ) {
         push @out,sprintf("%-6.6s %-30.30s %02d/%02d/%4d %s %s %6.1f %6.1f", $l->[3], $l->[0], $day, $month, $yr, $rise, $set, $az, $dec);
index 82ef55efaeb38a789ef8d728f4928b8ea7e94940..a61c41dfc018d71329a74f9a162b981a6a0752be 100644 (file)
@@ -115,6 +115,8 @@ package DXM;
                                filter4 => '$_[0]$_[1] Filter $_[2] deleted for $_[3]',
                                filter5 => 'need some filter commands...',
                                filter6 => '$_[0]$_[1] Filter for $[2] not found',
+                               grayline1 => '                                                 Beg of               End of',
+                               grayline2 => 'Location                              dd/mm/yyyy Dawn   Rise   Set    Dusk',
                                grids => 'DX Grid enabled for $_[0]',
                                gridu => 'DX Grid disabled for $_[0]',
                                illcall => 'Sorry, $_[0] is an invalid callsign',
index 85678a4dc2cf398ccb2a69fdac5ab4eac1b365f0..53f98fa66900808c7f9d77ee0b623c7a10b4555f 100644 (file)
@@ -361,6 +361,8 @@ sub dup
        $d = int ($d / 60);
        $d *= 60;
 
+       $by =~ s/-\d+$//g;
+       
        $freq = sprintf "%.1f", $freq;       # normalise frequency
        $call = substr($call, 0, $maxcalllth) if length $call > $maxcalllth;
 
index 0616d47321c5b57804b0e94c96745950e45b4ea1..182df931230abf3f1715b49b361c39cb9be252a3 100644 (file)
@@ -167,14 +167,12 @@ sub rise_set
        my $lat = shift;
        my $lon = shift;
        my $sun0_moon1=shift;           # 0 for sun, 1 for moon, 2 for venus...
+       my ($alpha1,$delta1,$alpha2,$delta2,$alpha3,$delta3);
+       my ($aznow,$hnow,$alphanow,$deltanow,$distance,$distancenow);
+       my ($h0,$H);
+       my ($risetime,$settime);
+       my ($dawntime,$dusktime);
 
-       my $norise = 0;
-       my $noset = 0;
-       my ($risehr,$risemin,$risetime,$sethr,$setmin,$settime);
-
-       my ($alpha1,$alpha2,$alpha3,$delta1,$delta2,$delta3);
-       my ($m0,$m1,$m2,$theta,$alpha,$delta,$H,$az,$h,$h0,$aznow,$hnow,$corr);
-       my ($i,$arg,$argtest,$H0,$alphanow,$deltanow,$distance,$distancenow);
        my ($ifrac,$ifracnow);
        
        my $julianday=Julian_Day($year,$month,$day);
@@ -196,12 +194,27 @@ sub rise_set
                ($alpha2, $delta2)=get_sun_alpha_delta($tt2);
                ($alpha3, $delta3)=get_sun_alpha_delta($tt3);
                ($alphanow, $deltanow)=get_sun_alpha_delta($ttnow);
-               $h0=-0.8333;
                $H=$thetanow-$lon-$alphanow;
                $H=reduce_angle_to_360($H);
                ($aznow,$hnow)=get_az_el($H,$deltanow,$lat);
                $hnow=$hnow +
                        1.02/(tandeg($hnow+10.3/($hnow+5.11)))/60;
+               $h0=-0.8333;      # this is for sun rise and sun set
+               ($risetime,$settime)=
+                       do_rise_set_calculations($h0,$theta0,$lat,$lon,$alpha1,$delta1,
+                               $alpha2,$delta2,$alpha3,$delta3);
+               $h0=-6.0;         # this is for civil dawn and dusk
+               ($dawntime,$dusktime)=
+                       do_rise_set_calculations($h0,$theta0,$lat,$lon,$alpha1,$delta1,
+                               $alpha2,$delta2,$alpha3,$delta3);
+               $dawntime = "------" if( $dawntime eq "NoRise" );
+               $dusktime = "------" if( $dusktime eq "NoSet " );
+
+               return (
+                       sprintf("%s", $dawntime), sprintf("%s",$risetime),
+                       sprintf("%s", $settime), sprintf("%s",$dusktime),
+                       $aznow+180,$hnow
+                       );
        }
 
        if ( $sun0_moon1 == 1 ) {
@@ -209,14 +222,41 @@ sub rise_set
                ($alpha2, $delta2, $distance, $ifrac)=get_moon_alpha_delta($tt2);
                ($alpha3, $delta3, $distance, $ifrac)=get_moon_alpha_delta($tt3);
                ($alphanow, $deltanow, $distancenow, $ifracnow)=get_moon_alpha_delta($ttnow);
-               $h0=0.7275*$r2d*asin(6378.14/$distancenow)-34./60.;
+               $h0=0.7275*$r2d*asin(6378.14/$distancenow)-34.0/60.;
                $H=$thetanow-$lon-$alphanow;
                $H=reduce_angle_to_360($H);
                ($aznow,$hnow)=get_az_el($H,$deltanow,$lat);
                $hnow=$hnow-$r2d*asin(sin(6378.14/$distancenow)*cosdeg($hnow))+
                        1.02/(tandeg($hnow+10.3/($hnow+5.11)))/60;
+               ($risetime,$settime)=
+                       do_rise_set_calculations($h0,$theta0,$lat,$lon,$alpha1,$delta1,
+                                       $alpha2,$delta2,$alpha3,$delta3);
+               return (sprintf("%s", $risetime), sprintf("%s",$settime), 
+                       $aznow+180,$hnow, -40*log10($distance/385000), $ifracnow );
+
        }
 
+}
+
+sub do_rise_set_calculations
+{
+       my $norise = 0;
+       my $noset = 0;
+       my ($risehr,$risemin,$risetime,$sethr,$setmin,$settime);
+       my ($m0,$m1,$m2,$theta,$alpha,$delta,$H,$az,$h,$corr);
+       my ($i,$arg,$argtest,$H0);
+
+    my $h0=shift;
+    my $theta0=shift;
+    my $lat=shift;
+    my $lon=shift;
+    my $alpha1=shift;
+    my $delta1=shift;
+    my $alpha2=shift;
+    my $delta2=shift;
+    my $alpha3=shift;
+    my $delta3=shift;
+    
        $arg = (sindeg($h0)-sindeg($lat)*sindeg($delta2))/(cosdeg($lat)*cosdeg($delta2));
        if ( abs($arg) > 1. ) {    # either up all day or down all day 
                $norise = 1;       # leave it to the user to examine 
@@ -254,7 +294,7 @@ sub rise_set
                $corr=-$H/360;
                $m0=$m0+$corr;
                $m0=$m0+1 if( $m0 < 0 );
-               $m0=$m0-1 if( $m0 > 1 );
+               $m0=$m0-1 if( $m0 >= 1 );
        }
 
 
@@ -271,7 +311,9 @@ sub rise_set
                        ($az,$h)=get_az_el($H,$delta,$lat);
                        $corr=($h-$h0)/(360*(cosdeg($delta)*cosdeg($lat)*sindeg($H)));
                        $m1=$m1+$corr;
-                       $norise=1 if( $m1 < 0 || $m1 > 1); 
+#                      $norise=1 if( $m1 < 0 || $m1 > 1);
+            $m1=$m1-1 if( $m1 >= 1);
+            $m1=$m1+1 if( $m1 < 0); 
                }
        }
 
@@ -282,6 +324,7 @@ sub rise_set
                        $risemin=$risemin-60;
                        $risehr=$risehr+1;
                }
+               $risehr=0 if($risehr==24);
                $risetime=sprintf("%02d:%02dZ",$risehr,$risemin);
        } else {
                $risetime="NoRise";
@@ -290,7 +333,7 @@ sub rise_set
        if( !$noset ){
                $m2 = $m0 + $H0/360.;
                $m2=$m2+1 if( $m2 < 0 );
-               $m2=$m2-1 if( $m2 > 1 );
+               $m2=$m2-1 if( $m2 >= 1 );
                for ($i=1; $i<=2; $i++) {
                        $theta = $theta0+360.985647*$m2;
                        $alpha=$alpha2+$m2*($aa+$ba+$m2*$ca)/2;
@@ -300,7 +343,9 @@ sub rise_set
                        ($az,$h)=get_az_el($H,$delta,$lat);
                        $corr=($h-$h0)/(360*(cosdeg($delta)*cosdeg($lat)*sindeg($H)));
                        $m2 = $m2 + $corr;
-                       $noset=1 if( $m2 < 0 || $m2 > 1); 
+#                      $noset=1 if( $m2 < 0 || $m2 > 1); 
+            $m2=$m2-1 if( $m2 >= 1);
+            $m2=$m2+1 if( $m2 < 0);
                }
        }
 
@@ -311,20 +356,16 @@ sub rise_set
                        $setmin=$setmin-60;
                        $sethr=$sethr+1;
                }
+               $sethr=0 if($sethr==24);
                $settime=sprintf("%02d:%02dZ",$sethr,$setmin);
        } else {
                $settime="NoSet ";
        }                       
+       return $risetime,$settime;
+}
+
 
 
-       if ( $sun0_moon1 == 0 ) {
-               return (sprintf("%s", $risetime), sprintf("%s",$settime),$aznow+180,$hnow);
-       }
-       if ( $sun0_moon1 == 1 ) {
-               return (sprintf("%s", $risetime), sprintf("%s",$settime), 
-                       $aznow+180,$hnow, -40*log10($distance/385000), $ifracnow );
-       }
-}
 sub get_moon_alpha_delta 
 {
        #
index c1f010c11e3a7c2790759a87acac08187e83fc6e..2361561af527edc43c0f474adfc1bc29236ec1a9 100644 (file)
@@ -201,7 +201,7 @@ sub add_auth
 {
        my $thing = shift;
        my $s = $thing->{'s'} = sprintf "%X", int(rand() * 100000000);
-       my $auth = Verify->new("DXSp,$main::mycall,$s,$main::version,$main::build");
+       my $auth = Verify->new("DXSp,$main::mycall,$s,$thing->{v},$thing->{b}");
        $thing->{auth} = $auth->challenge($main::me->user->passphrase);
 }
 
index 3621d2545c926d1aa53679ecbf104243d472cb35..aa7322ed12c1a6a4e9e2bc03b6bd2176372f833b 100644 (file)
@@ -46,14 +46,16 @@ sub from_Aranea
        return unless $thing;
        my $t = hex($thing->{t}) if exists $thing->{t};
        $t ||= int($thing->{time} / 60);        # if it is an aranea generated
+       my $by = $thing->{b} || $thing->{fromuser} || $thing->{user} || $thing->{origin};
        my @spot = Spot::prepare(
                                                         $thing->{f},
                                                         $thing->{c},
                                                         $t*60,
                                                         ($thing->{i} || ''),
-                                                        ($thing->{b} || $thing->{fromuser} || $thing->{user} || $thing->{origin}),
+                                                        $by,
                                                         ($thing->{o} || $thing->{origin}),
                                                        );
+       $spot[4] = $by;                         # don't modify the spotter SSID
        $thing->{spotdata} = \@spot;
        return $thing;
 }
index aa51de1c539ba7fce04fbf08b2d70e0605e1e047..6c64302662e8bb505cd22bf5215c525a9c1c7c47 100644 (file)
@@ -39,11 +39,11 @@ sub gen_Aranea
                if ($thing->{user}) {
                        $thing->{h} ||= $dxchan->here;
                } else {
-                       $thing->add_auth;
                        $thing->{sw} ||= 'DXSp';
-                       $thing->{v} ||= $main::version;
-                       $thing->{b} ||= $main::build;
+                       $thing->{v} ||= $main::me->version;
+                       $thing->{b} ||= $main::me->build;
                        $thing->{h} ||= $main::me->here;
+                       $thing->add_auth;
                }
                
                $thing->{Aranea} = Aranea::genmsg($thing, [qw(sw h v b s auth)]);