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;
41 return "PC10^$from^$user1^$text^*^$user2^$main::mycall^~";
44 # create a dx message (call, freq, dxcall, text)
47 my ($mycall, $freq, $dxcall, $text) = @_;
48 my $hops = get_hops(11);
50 $text = ' ' if !$text;
52 return sprintf "PC11^%.1f^$dxcall^%s^%s^$text^$mycall^$main::mycall^$hops^~", $freq, cldate($t), ztime($t);
55 # create an announce message
58 my ($call, $text, $tonode, $sysop, $wx) = @_;
59 my $hops = get_hops(12);
60 $sysop = ' ' if !$sysop;
61 $text = ' ' if !$text;
63 $tonode = '*' if !$tonode;
65 return "PC12^$call^$tonode^$text^$sysop^$main::mycall^$wx^$hops^~";
69 # add one or more users (I am expecting references that have 'call',
70 # 'confmode' & 'here' method)
72 # this will create a list of PC16 with up pc16_max_users in each
73 # called $self->pc16(..)
81 my $str = "PC16^$self->{call}";
84 for ($i = 0; @_ > 0 && $i < $DXProt::pc16_max_users; $i++) {
86 $str .= sprintf "^%s %s %d", $ref->call, $ref->confmode ? '*' : '-', $ref->here;
88 $str .= sprintf "^%s^", get_hops(16);
97 my ($self, $ref) = @_;
98 my $hops = get_hops(17);
99 return "PC17^$ref->{call}^$self->{call}^$hops^";
102 # Request init string
105 my $info = DXCluster::cluster;
106 return "PC18^$info^$DXProt::myprot_version^";
110 # add one or more nodes
121 for ($i = 0; @_ && $i < $DXProt::pc19_max_nodes; $i++) {
123 my $here = $ref->{here} ? '1' : '0';
124 my $confmode = $ref->{confmode} ? '1' : '0';
125 $str .= "^$here^$ref->{call}^$confmode^$ref->{pcversion}";
127 $str .= sprintf "^%s^", get_hops(19);
142 my ($call, $reason) = @_;
143 my $hops = get_hops(21);
144 $reason = "Gone." if !$reason;
145 return "PC21^$call^$reason^$hops^";
158 my $call = $self->call;
159 my $flag = $self->here ? '1' : '0';
160 my $hops = get_hops(24);
162 return "PC24^$call^$flag^$hops^";
166 # create a merged dx message (freq, dxcall, t, text, spotter, orig-node)
169 my ($freq, $dxcall, $t, $text, $spotter, $orignode) = @_;
170 $text = ' ' unless $text;
171 $orignode = $main::mycall unless $orignode;
172 return sprintf "PC26^%.1f^$dxcall^%s^%s^$text^$spotter^$orignode^ ^~", $freq, cldate($t), ztime($t);
175 # create a merged WWV spot (logger, t, sfi, a, k, forecast, orig-node)
178 my ($logger, $t, $sfi, $a, $k, $forecast, $orignode) = @_;
179 return sprintf "PC27^%s^%-2.2s^$sfi^$a^$k^$forecast^$logger^$orignode^ ^~", cldate($t), ztime($t);
182 # message start (fromnode, tonode, to, from, t, private, subject, origin)
185 my ($tonode, $fromnode, $to, $from, $t, $private, $subject, $origin, $rr) = @_;
186 my $date = cldate($t);
187 my $time = ztime($t);
188 $private = $private ? '1' : '0';
189 $rr = $rr ? '1' : '0';
190 return "PC28^$tonode^$fromnode^$to^$from^$date^$time^$private^$subject^ ^5^$rr^ ^$origin^~";
193 # message text (from and to node same way round as pc29)
196 my ($fromnode, $tonode, $stream, $text) = @_;
197 $text = ' ' unless $text && length $text > 0;
198 $text =~ s/\^/%5E/og; # remove ^
199 return "PC29^$fromnode^$tonode^$stream^$text^~";
202 # subject acknowledge (will have to and from node reversed to pc28)
205 my ($fromnode, $tonode, $stream) = @_;
206 return "PC30^$fromnode^$tonode^$stream^";
209 # acknowledge this tranche of lines (to and from nodes reversed to pc29 and pc28
212 my ($fromnode, $tonode, $stream) = @_;
213 return "PC31^$fromnode^$tonode^$stream^";
216 # end of message from the sending end (pc28 node order)
219 my ($fromnode, $tonode, $stream) = @_;
220 return "PC32^$fromnode^$tonode^$stream^";
223 # acknowledge end of message from receiving end (opposite pc28 node order)
226 my ($fromnode, $tonode, $stream) = @_;
227 return "PC33^$fromnode^$tonode^$stream^";
233 my($fromnode, $tonode, $msg) = @_;
234 return "PC34^$tonode^$fromnode^$msg^~";
240 my($fromnode, $tonode, $msg) = @_;
241 return "PC35^$tonode^$fromnode^$msg^~";
244 # send all the DX clusters I reckon are connected
247 my @nodes = map { ($_->dxchan && $_->dxchan->isolate) ? () : $_->call } DXNode->get_all();
248 return "PC38^" . join(',', @nodes) . "^~";
251 # tell the local node to discconnect
254 my ($call, $reason) = @_;
255 my $hops = get_hops(39);
256 $reason = "Gone." if !$reason;
257 return "PC39^$call^$reason^$hops^";
260 # cue up bulletin or file for transfer
263 my ($to, $from, $fn, $bull) = @_;
264 $bull = $bull ? '1' : '0';
265 return "PC40^$to^$from^$fn^$bull^5^";
271 my ($call, $sort, $info) = @_;
272 my $hops = get_hops(41);
273 $sort = $sort ? "$sort" : '0';
274 return "PC41^$call^$sort^$info^$hops^~";
280 my ($fromnode, $tonode, $stream) = @_;
281 return "PC42^$fromnode^$tonode^$stream^";
287 my ($fromnode, $tonode, $stream, $db, $req, $call) = @_;
289 return "PC44^$tonode^$fromnode^$stream^$db^$req^$call^";
295 my ($fromnode, $tonode, $stream, $data) = @_;
296 return "PC45^$tonode^$fromnode^$stream^$data^";
299 # remote db data complete
302 my ($fromnode, $tonode, $stream) = @_;
303 return "PC46^$tonode^$fromnode^$stream^";
309 my ($from, $subject) = @_;
310 my $hops = get_hops(49);
311 return "PC49^$from^$subject^$hops^~";
314 # periodic update of users, plus keep link alive device (always H99)
318 $n = 0 unless $n >= 0;
319 return "PC50^$main::mycall^$n^H99^";
325 my ($to, $from, $val) = @_;
326 return "PC51^$to^$from^$val^";
329 # clx remote cmd send
332 my($fromnode, $tonode, $call, $msg) = @_;
333 return "PC84^$tonode^$fromnode^$call^$msg^~";
336 # clx remote cmd reply
339 my($fromnode, $tonode, $call, $msg) = @_;
340 return "PC85^$tonode^$fromnode^$call^$msg^~";