fix console.pl max scroll depth
[spider.git] / cmd / wcy.pl
1 #
2 # WCY command
3 #
4 # This can only be used if the appropriate flag is enabled.
5 #
6 # I would STRONGLY recommend that, unless your callsign is DK8LV, you
7 # DO NOT ENABLE THIS COMMAND - YES THAT MEANS YOU!!!
8 #
9 # The command line sent from DK0WCY (the only known valid source of data
10 # for this command [and its only legitimate user BTW]):-
11 #
12 #    WCY k=6,expk=5,a=25,r=220,sf=202,sa=act,gmf=act,au=strong
13 #
14 #       k: Kiel k-Index  (0..9)
15 #    expK: expected Kiel k-index for the current 3-h-measuring period
16 #       A: Kiel A-Index (0..400)
17 #       R: Sunspot Number, SSN (0..300)
18 #      SF: Solar Flux Index (65..300)
19 #      SA: Sun Activity (qui,eru,act,maj,pro,war,nil)
20 #     GMF: Geomagnetic Field (qui,act,min,maj,sev,mag,war,nil)
21 #      AU: Aurora Status (no,aurora,strong)
22 #
23 # Copyright (c) 2001 Dirk Koopman G1TLH
24 #
25 #
26 #
27 my ($self, $line) = @_;
28 my $call = $self->call;
29 $call =~ s/-\d+$//;
30 return (1, $self->msg('e5')) unless grep $call eq $_, @WCY::allowed;
31 my @out;
32
33 # calc 18 minutes past the hour in time_t seconds
34 my $hour = (gmtime $main::systime)[2];
35 my $d = int ($main::systime / 3600) * 3600 + 18 * 60; 
36
37 # make a hash out of the args
38 $line = unpad($line);
39 my %args = map {split /\s*=\s*/} split /\s*,\s*/, lc $line;
40
41 # check the ranges of each one
42 push @out, $self->msg('wcy1', 'k') unless defined $args{k} && $args{k} >= 0 && $args{k} <= 9;
43 push @out, $self->msg('wcy1', 'espk') unless defined $args{expk} && $args{expk} >= 0 && $args{expk} <= 9;
44 push @out, $self->msg('wcy1', 'a') unless defined $args{a} && $args{a} >= 0 && $args{a} <= 400;
45 push @out, $self->msg('wcy1', 'r') unless defined $args{r} && $args{r} >= 0 && $args{r} <= 500;
46 push @out, $self->msg('wcy1', 'sf') unless defined $args{sf} && $args{sf} >= 65 && $args{sf} <= 300;
47 push @out, $self->msg('wcy1', 'sa') unless defined $args{sa} && grep $args{sa} eq $_, qw(qui eru act maj pro war nil);
48 push @out, $self->msg('wcy1', 'gmf') unless defined $args{gmf} && grep $args{gmf} eq $_, qw(qui act min maj sev mag war nil);
49 push @out, $self->msg('wcy1', 'au') unless defined $args{au} && grep $args{au} eq $_, qw(no aurora strong);
50
51 push @out, $self->msg('wcy2') if WCY::dup($d);
52 #$DB::single=1;
53
54 return (1, @out) if @out;
55
56 # now this is all subject to change, but it will do for now, I think. 
57 my $today = cldate($main::systime);
58
59 # PC73^14-Dec-2001^15^220^  3^1^0^212^act^qui^no^DK0WCY-3^DB0SUE-7^H96^
60 # Date        Hour   SFI   A   K Exp.K   R SA    GMF   Aurora   Logger
61 # 14-Dec-2001   15   220   3   1     0 212 act   qui       no <DK0WCY-3>
62 my @field = ('PC73',$today,$hour,$args{sf},$args{a},$args{k},$args{expk},$args{r},$args{sa},$args{gmf},$args{au}, $self->call ,$main::mycall, 'H99');
63
64 my $s = sprintf "%s^%s^%02d^%3d^%3d^%2d^%2d^%3d^%s^%s^%s^%s^%s^%s^", @field;
65 WCY::update($d, @field[2..12]);
66 DXProt::send_wcy_spot($self, $s, $d, @field[2..12]);
67 $self->wcy($s, 0, @field[1..12]);
68 return (1, @out);
69
70