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) = @_;
31 if ($via && $via ne $to) {
39 $text = ' ' unless $text && length $text > 0;
40 return "PC10^$from^$user1^$text^*^$user2^$main::mycall^~";
43 # create a dx message (call, freq, dxcall, text)
46 my ($mycall, $freq, $dxcall, $text) = @_;
47 my $hops = get_hops(11);
49 $text = ' ' if !$text;
50 return sprintf "PC11^%.1f^$dxcall^%s^%s^$text^$mycall^$main::mycall^$hops^~", $freq, cldate($t), ztime($t);
53 # create an announce message
56 my ($call, $text, $tonode, $sysop, $wx) = @_;
57 my $hops = get_hops(12);
58 $sysop = ' ' if !$sysop;
59 $text = ' ' if !$text;
61 $tonode = '*' if !$tonode;
62 return "PC12^$call^$tonode^$text^$sysop^$main::mycall^$wx^$hops^~";
66 # add one or more users (I am expecting references that have 'call',
67 # 'confmode' & 'here' method)
69 # this will create a list of PC16 with up pc16_max_users in each
70 # called $self->pc16(..)
78 my $str = "PC16^$self->{call}";
81 for ($i = 0; @_ > 0 && $i < $DXProt::pc16_max_users; $i++) {
83 $str .= sprintf "^%s %s %d", $ref->call, $ref->confmode ? '*' : '-', $ref->here;
85 $str .= sprintf "^%s^", get_hops(16);
94 my ($self, $ref) = @_;
95 my $hops = get_hops(17);
96 return "PC17^$ref->{call}^$self->{call}^$hops^";
102 my $info = DXCluster::cluster;
103 return "PC18^$info^$DXProt::myprot_version^";
107 # add one or more nodes
118 for ($i = 0; @_ && $i < $DXProt::pc19_max_nodes; $i++) {
120 my $here = $ref->{here} ? '1' : '0';
121 my $confmode = $ref->{confmode} ? '1' : '0';
122 $str .= "^$here^$ref->{call}^$confmode^$ref->{pcversion}";
124 $str .= sprintf "^%s^", get_hops(19);
139 my ($call, $reason) = @_;
140 my $hops = get_hops(21);
141 $reason = "Gone." if !$reason;
142 return "PC21^$call^$reason^$hops^";
155 my $call = $self->call;
156 my $flag = $self->here ? '1' : '0';
157 my $hops = get_hops(24);
159 return "PC24^$call^$flag^$hops^";
163 # create a merged dx message (freq, dxcall, t, text, spotter, orig-node)
166 my ($freq, $dxcall, $t, $text, $spotter, $orignode) = @_;
167 $text = ' ' unless $text;
168 $orignode = $main::mycall unless $orignode;
169 return sprintf "PC26^%.1f^$dxcall^%s^%s^$text^$spotter^$orignode^ ^~", $freq, cldate($t), ztime($t);
172 # create a merged WWV spot (logger, t, sfi, a, k, forecast, orig-node)
175 my ($logger, $t, $sfi, $a, $k, $forecast, $orignode) = @_;
176 return sprintf "PC27^%s^%-2.2s^$sfi^$a^$k^$forecast^$logger^$orignode^ ^~", cldate($t), ztime($t);
179 # message start (fromnode, tonode, to, from, t, private, subject, origin)
182 my ($tonode, $fromnode, $to, $from, $t, $private, $subject, $origin, $rr) = @_;
183 my $date = cldate($t);
184 my $time = ztime($t);
185 $private = $private ? '1' : '0';
186 $rr = $rr ? '1' : '0';
187 return "PC28^$tonode^$fromnode^$to^$from^$date^$time^$private^$subject^ ^5^$rr^ ^$origin^~";
190 # message text (from and to node same way round as pc29)
193 my ($fromnode, $tonode, $stream, $text) = @_;
194 $text = ' ' unless $text && length $text > 0;
195 $text =~ s/\^/%5E/og; # remove ^
196 return "PC29^$fromnode^$tonode^$stream^$text^~";
199 # subject acknowledge (will have to and from node reversed to pc28)
202 my ($fromnode, $tonode, $stream) = @_;
203 return "PC30^$fromnode^$tonode^$stream^";
206 # acknowledge this tranche of lines (to and from nodes reversed to pc29 and pc28
209 my ($fromnode, $tonode, $stream) = @_;
210 return "PC31^$fromnode^$tonode^$stream^";
213 # end of message from the sending end (pc28 node order)
216 my ($fromnode, $tonode, $stream) = @_;
217 return "PC32^$fromnode^$tonode^$stream^";
220 # acknowledge end of message from receiving end (opposite pc28 node order)
223 my ($fromnode, $tonode, $stream) = @_;
224 return "PC33^$fromnode^$tonode^$stream^";
230 my($fromnode, $tonode, $msg) = @_;
231 return "PC34^$tonode^$fromnode^$msg^~";
237 my($fromnode, $tonode, $msg) = @_;
238 return "PC35^$tonode^$fromnode^$msg^~";
241 # send all the DX clusters I reckon are connected
244 my @nodes = map { ($_->dxchan && $_->dxchan->isolate) ? () : $_->call } DXNode->get_all();
245 return "PC38^" . join(',', @nodes) . "^~";
248 # tell the local node to discconnect
251 my ($call, $reason) = @_;
252 my $hops = get_hops(39);
253 $reason = "Gone." if !$reason;
254 return "PC39^$call^$reason^$hops^";
257 # cue up bulletin or file for transfer
260 my ($to, $from, $fn, $bull) = @_;
261 $bull = $bull ? '1' : '0';
262 return "PC40^$to^$from^$fn^$bull^5^";
268 my ($call, $sort, $info) = @_;
269 my $hops = get_hops(41);
270 $sort = $sort ? "$sort" : '0';
271 return "PC41^$call^$sort^$info^$hops^~";
277 my ($fromnode, $tonode, $stream) = @_;
278 return "PC42^$fromnode^$tonode^$stream^";
284 my ($fromnode, $tonode, $stream, $db, $req, $call) = @_;
286 return "PC44^$tonode^$fromnode^$stream^$db^$req^$call^";
292 my ($fromnode, $tonode, $stream, $data) = @_;
293 return "PC45^$tonode^$fromnode^$stream^$data^";
296 # remote db data complete
299 my ($fromnode, $tonode, $stream) = @_;
300 return "PC46^$tonode^$fromnode^$stream^";
306 my ($from, $subject) = @_;
307 my $hops = get_hops(49);
308 return "PC49^$from^$subject^$hops^~";
311 # periodic update of users, plus keep link alive device (always H99)
315 $n = 0 unless $n >= 0;
316 return "PC50^$main::mycall^$n^H99^";
322 my ($to, $from, $val) = @_;
323 return "PC51^$to^$from^$val^";
326 # clx remote cmd send
329 my($fromnode, $tonode, $call, $msg) = @_;
330 return "PC84^$tonode^$fromnode^$call^$msg^~";
333 # clx remote cmd reply
336 my($fromnode, $tonode, $call, $msg) = @_;
337 return "PC85^$tonode^$fromnode^$call^$msg^~";