3 # This module impliments the outgoing PCxx generation routines
5 # These are all the namespace of DXProt and are separated for "clarity"
7 # Copyright (c) 1998 Dirk Koopman G1TLH
14 @ISA = qw(DXProt DXChannel);
23 # All the PCxx generation routines
26 # create a talk string ($from, $to, $via, $text)
29 my ($from, $to, $via, $text) = @_;
30 my $user2 = $via ? $to : ' ';
31 my $user1 = $via ? $via : $to;
33 $text = ' ' if !$text;
34 return "PC10^$from^$user1^$text^*^$user2^$main::mycall^~";
37 # create a dx message (call, freq, dxcall, text)
40 my ($mycall, $freq, $dxcall, $text) = @_;
41 my $hops = get_hops(11);
43 $text = ' ' if !$text;
44 return sprintf "PC11^%.1f^$dxcall^%s^%s^$text^$mycall^$main::mycall^$hops^~", $freq, cldate($t), ztime($t);
47 # create an announce message
50 my ($call, $text, $tonode, $sysop, $wx) = @_;
51 my $hops = get_hops(12);
52 $sysop = ' ' if !$sysop;
53 $text = ' ' if !$text;
55 $tonode = '*' if !$tonode;
56 return "PC12^$call^$tonode^$text^$sysop^$main::mycall^$wx^$hops^~";
60 # add one or more users (I am expecting references that have 'call',
61 # 'confmode' & 'here' method)
63 # this will create a list of PC16 with up pc16_max_users in each
64 # called $self->pc16(..)
72 my $str = "PC16^$self->{call}";
75 for ($i = 0; @_ > 0 && $i < $DXProt::pc16_max_users; $i++) {
77 $str .= sprintf "^%s %s %d", $ref->call, $ref->confmode ? '*' : '-', $ref->here;
79 $str .= sprintf "^%s^", get_hops(16);
88 my ($self, $ref) = @_;
89 my $hops = get_hops(17);
90 return "PC17^$ref->{call}^$self->{call}^$hops^";
96 my $info = DXCluster::cluster;
97 return "PC18^$info^$DXProt::myprot_version^";
101 # add one or more nodes
112 for ($i = 0; @_ && $i < $DXProt::pc19_max_nodes; $i++) {
114 my $here = $ref->{here} ? '1' : '0';
115 my $confmode = $ref->{confmode} ? '1' : '0';
116 $str .= "^$here^$ref->{call}^$confmode^$ref->{pcversion}";
118 $str .= sprintf "^%s^", get_hops(19);
133 my ($call, $reason) = @_;
134 my $hops = get_hops(21);
135 $reason = "Gone." if !$reason;
136 return "PC21^$call^$reason^$hops^";
149 my $call = $self->call;
150 my $flag = $self->here ? '1' : '0';
151 my $hops = get_hops(24);
153 return "PC24^$call^$flag^$hops^";
157 # create a merged dx message (freq, dxcall, t, text, spotter, orig-node)
160 my ($freq, $dxcall, $t, $text, $spotter, $orignode) = @_;
161 $text = ' ' unless $text;
162 $orignode = $main::mycall unless $orignode;
163 return sprintf "PC26^%.1f^$dxcall^%s^%s^$text^$spotter^$orignode^ ^~", $freq, cldate($t), ztime($t);
166 # create a merged WWV spot (logger, t, sfi, a, k, forecast, orig-node)
169 my ($logger, $t, $sfi, $a, $k, $forecast, $orignode) = @_;
170 return sprintf "PC27^%s^%-2.2s^$sfi^$a^$k^$forecast^$logger^$orignode^ ^~", cldate($t), ztime($t);
173 # message start (fromnode, tonode, to, from, t, private, subject, origin)
176 my ($tonode, $fromnode, $to, $from, $t, $private, $subject, $origin, $rr) = @_;
177 my $date = cldate($t);
178 my $time = ztime($t);
179 $private = $private ? '1' : '0';
180 $rr = $rr ? '1' : '0';
181 return "PC28^$tonode^$fromnode^$to^$from^$date^$time^$private^$subject^ ^5^$rr^ ^$origin^~";
184 # message text (from and to node same way round as pc29)
187 my ($fromnode, $tonode, $stream, $text) = @_;
188 $text =~ s/\^/:/og; # remove ^
189 # $text =~ s/\~/S/og;
190 return "PC29^$fromnode^$tonode^$stream^$text^~";
193 # subject acknowledge (will have to and from node reversed to pc28)
196 my ($fromnode, $tonode, $stream) = @_;
197 return "PC30^$fromnode^$tonode^$stream^";
200 # acknowledge this tranche of lines (to and from nodes reversed to pc29 and pc28
203 my ($fromnode, $tonode, $stream) = @_;
204 return "PC31^$fromnode^$tonode^$stream^";
207 # end of message from the sending end (pc28 node order)
210 my ($fromnode, $tonode, $stream) = @_;
211 return "PC32^$fromnode^$tonode^$stream^";
214 # acknowledge end of message from receiving end (opposite pc28 node order)
217 my ($fromnode, $tonode, $stream) = @_;
218 return "PC33^$fromnode^$tonode^$stream^";
224 my($fromnode, $tonode, $msg) = @_;
225 return "PC34^$tonode^$fromnode^$msg^~";
231 my($fromnode, $tonode, $msg) = @_;
232 return "PC35^$tonode^$fromnode^$msg^~";
235 # send all the DX clusters I reckon are connected
238 my @nodes = map { ($_->dxchan && $_->dxchan->isolate) ? () : $_->call } DXNode->get_all();
239 return "PC38^" . join(',', @nodes) . "^~";
242 # tell the local node to discconnect
245 my ($call, $reason) = @_;
246 my $hops = get_hops(39);
247 $reason = "Gone." if !$reason;
248 return "PC39^$call^$reason^$hops^";
251 # cue up bulletin or file for transfer
254 my ($to, $from, $fn, $bull) = @_;
255 $bull = $bull ? '1' : '0';
256 return "PC40^$to^$from^$fn^$bull^5^";
262 my ($call, $sort, $info) = @_;
263 my $hops = get_hops(41);
264 $sort = $sort ? "$sort" : '0';
265 return "PC41^$call^$sort^$info^$hops^~";
271 my ($fromnode, $tonode, $stream) = @_;
272 return "PC42^$fromnode^$tonode^$stream^";
278 my ($fromnode, $tonode, $stream, $db, $req, $call) = @_;
280 return "PC44^$tonode^$fromnode^$stream^$db^$req^$call^";
286 my ($fromnode, $tonode, $stream, $data) = @_;
287 return "PC45^$tonode^$fromnode^$stream^$data^";
290 # remote db data complete
293 my ($fromnode, $tonode, $stream) = @_;
294 return "PC46^$tonode^$fromnode^$stream^";
300 my ($from, $subject) = @_;
301 my $hops = get_hops(49);
302 return "PC49^$from^$subject^$hops^~";
305 # periodic update of users, plus keep link alive device (always H99)
308 my $me = DXCluster->get_exact($main::mycall);
309 my $n = $me->users ? $me->users : '0';
310 return "PC50^$main::mycall^$n^H99^";
316 my ($to, $from, $val) = @_;
317 return "PC51^$to^$from^$val^";