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 return "PC18^DXSpider Version: $main::version Build: $main::build^$DXProt::myprot_version^";
109 # add one or more nodes
120 for ($i = 0; @_ && $i < $DXProt::pc19_max_nodes; $i++) {
122 my $here = $ref->{here} ? '1' : '0';
123 my $confmode = $ref->{confmode} ? '1' : '0';
124 $str .= "^$here^$ref->{call}^$confmode^$ref->{pcversion}";
126 $str .= sprintf "^%s^", get_hops(19);
141 my ($call, $reason) = @_;
142 my $hops = get_hops(21);
143 $reason = "Gone." if !$reason;
144 return "PC21^$call^$reason^$hops^";
157 my $call = $self->call;
158 my $flag = $self->here ? '1' : '0';
159 my $hops = get_hops(24);
161 return "PC24^$call^$flag^$hops^";
165 # create a merged dx message (freq, dxcall, t, text, spotter, orig-node)
168 my ($freq, $dxcall, $t, $text, $spotter, $orignode) = @_;
169 $text = ' ' unless $text;
170 $orignode = $main::mycall unless $orignode;
171 return sprintf "PC26^%.1f^$dxcall^%s^%s^$text^$spotter^$orignode^ ^~", $freq, cldate($t), ztime($t);
174 # create a merged WWV spot (logger, t, sfi, a, k, forecast, orig-node)
177 my ($logger, $t, $sfi, $a, $k, $forecast, $orignode) = @_;
178 return sprintf "PC27^%s^%-2.2s^$sfi^$a^$k^$forecast^$logger^$orignode^ ^~", cldate($t), ztime($t);
181 # message start (fromnode, tonode, to, from, t, private, subject, origin)
184 my ($tonode, $fromnode, $to, $from, $t, $private, $subject, $origin, $rr) = @_;
185 my $date = cldate($t);
186 my $time = ztime($t);
187 $private = $private ? '1' : '0';
188 $rr = $rr ? '1' : '0';
189 return "PC28^$tonode^$fromnode^$to^$from^$date^$time^$private^$subject^ ^5^$rr^ ^$origin^~";
192 # message text (from and to node same way round as pc29)
195 my ($fromnode, $tonode, $stream, $text) = @_;
196 $text = ' ' unless $text && length $text > 0;
197 $text =~ s/\^/%5E/og; # remove ^
198 return "PC29^$fromnode^$tonode^$stream^$text^~";
201 # subject acknowledge (will have to and from node reversed to pc28)
204 my ($fromnode, $tonode, $stream) = @_;
205 return "PC30^$fromnode^$tonode^$stream^";
208 # acknowledge this tranche of lines (to and from nodes reversed to pc29 and pc28
211 my ($fromnode, $tonode, $stream) = @_;
212 return "PC31^$fromnode^$tonode^$stream^";
215 # end of message from the sending end (pc28 node order)
218 my ($fromnode, $tonode, $stream) = @_;
219 return "PC32^$fromnode^$tonode^$stream^";
222 # acknowledge end of message from receiving end (opposite pc28 node order)
225 my ($fromnode, $tonode, $stream) = @_;
226 return "PC33^$fromnode^$tonode^$stream^";
232 my($fromnode, $tonode, $msg) = @_;
233 return "PC34^$tonode^$fromnode^$msg^~";
239 my($fromnode, $tonode, $msg) = @_;
240 return "PC35^$tonode^$fromnode^$msg^~";
243 # send all the DX clusters I reckon are connected
246 my @nodes = map { ($_->dxchan && $_->dxchan->isolate) ? () : $_->call } DXNode->get_all();
247 return "PC38^" . join(',', @nodes) . "^~";
250 # tell the local node to discconnect
253 my ($call, $reason) = @_;
254 my $hops = get_hops(39);
255 $reason = "Gone." if !$reason;
256 return "PC39^$call^$reason^$hops^";
259 # cue up bulletin or file for transfer
262 my ($to, $from, $fn, $bull) = @_;
263 $bull = $bull ? '1' : '0';
264 return "PC40^$to^$from^$fn^$bull^5^";
270 my ($call, $sort, $info) = @_;
271 my $hops = get_hops(41);
272 $sort = $sort ? "$sort" : '0';
273 return "PC41^$call^$sort^$info^$hops^~";
279 my ($fromnode, $tonode, $stream) = @_;
280 return "PC42^$fromnode^$tonode^$stream^";
286 my ($fromnode, $tonode, $stream, $db, $req, $call) = @_;
288 return "PC44^$tonode^$fromnode^$stream^$db^$req^$call^";
294 my ($fromnode, $tonode, $stream, $data) = @_;
295 return "PC45^$tonode^$fromnode^$stream^$data^";
298 # remote db data complete
301 my ($fromnode, $tonode, $stream) = @_;
302 return "PC46^$tonode^$fromnode^$stream^";
308 my ($from, $subject) = @_;
309 my $hops = get_hops(49);
310 return "PC49^$from^$subject^$hops^~";
313 # periodic update of users, plus keep link alive device (always H99)
317 $n = 0 unless $n >= 0;
318 return "PC50^$main::mycall^$n^H99^";
324 my ($to, $from, $val) = @_;
325 return "PC51^$to^$from^$val^";
328 # clx remote cmd send
331 my($fromnode, $tonode, $call, $msg) = @_;
332 return "PC84^$tonode^$fromnode^$call^$msg^~";
335 # clx remote cmd reply
338 my($fromnode, $tonode, $call, $msg) = @_;
339 return "PC85^$tonode^$fromnode^$call^$msg^~";