From 9cb17cdc59baad6fd8d175ec9a644575cdc8c5d5 Mon Sep 17 00:00:00 2001 From: minima Date: Sat, 26 Feb 2005 21:34:47 +0000 Subject: [PATCH] fix SSID ambiguity on spotter in DX sort out auth in HELLO add grayline stuff --- cmd/Aliases | 1 + cmd/Commands_en.hlp | 31 +++++++++++++++++ cmd/show/grayline.pl | 70 +++++++++++++++++++++++++++++++++++++ cmd/show/sun.pl | 3 +- perl/Messages | 2 ++ perl/Spot.pm | 2 ++ perl/Sun.pm | 83 +++++++++++++++++++++++++++++++++----------- perl/Thingy.pm | 2 +- perl/Thingy/Dx.pm | 4 ++- perl/Thingy/Hello.pm | 6 ++-- 10 files changed, 177 insertions(+), 27 deletions(-) create mode 100644 cmd/show/grayline.pl diff --git a/cmd/Aliases b/cmd/Aliases index 42a9aa2a..971c5f1c 100644 --- a/cmd/Aliases +++ b/cmd/Aliases @@ -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', diff --git a/cmd/Commands_en.hlp b/cmd/Commands_en.hlp index 592b7182..9e3982cb 100644 --- a/cmd/Commands_en.hlp +++ b/cmd/Commands_en.hlp @@ -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] [|]^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 no of days (default is 31), starting from a (default: today). diff --git a/cmd/show/grayline.pl b/cmd/show/grayline.pl new file mode 100644 index 00000000..c2c6fcff --- /dev/null +++ b/cmd/show/grayline.pl @@ -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); diff --git a/cmd/show/sun.pl b/cmd/show/sun.pl index d7c9766c..36aaa078 100644 --- a/cmd/show/sun.pl +++ b/cmd/show/sun.pl @@ -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); diff --git a/perl/Messages b/perl/Messages index 82ef55ef..a61c41df 100644 --- a/perl/Messages +++ b/perl/Messages @@ -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', diff --git a/perl/Spot.pm b/perl/Spot.pm index 85678a4d..53f98fa6 100644 --- a/perl/Spot.pm +++ b/perl/Spot.pm @@ -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; diff --git a/perl/Sun.pm b/perl/Sun.pm index 0616d473..182df931 100644 --- a/perl/Sun.pm +++ b/perl/Sun.pm @@ -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 { # diff --git a/perl/Thingy.pm b/perl/Thingy.pm index c1f010c1..2361561a 100644 --- a/perl/Thingy.pm +++ b/perl/Thingy.pm @@ -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); } diff --git a/perl/Thingy/Dx.pm b/perl/Thingy/Dx.pm index 3621d254..aa7322ed 100644 --- a/perl/Thingy/Dx.pm +++ b/perl/Thingy/Dx.pm @@ -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; } diff --git a/perl/Thingy/Hello.pm b/perl/Thingy/Hello.pm index aa51de1c..6c643026 100644 --- a/perl/Thingy/Hello.pm +++ b/perl/Thingy/Hello.pm @@ -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)]); -- 2.43.0