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 # 'conf' & 'here' method)
72 # this will create a list of PC16 with up pc16_max_users in each
73 # called $self->pc16(..)
78 my $ncall = $node->call;
82 my $str = "PC16^$ncall";
83 for ( ; @_ && length $str < 200; ) {
85 $str .= sprintf "^%s %s %d", $ref->call, $ref->conf ? '*' : '-', $ref->here;
87 $str .= sprintf "^%s^", get_hops(16);
100 my $hops = get_hops(17);
101 my $ncall = $node->call;
102 my $ucall = $ref->call;
103 push @out, "PC17^$ucall^$ncall^$hops^";
108 # Request init string
111 return "PC18^DXSpider Version: $main::version Build: $main::build^$DXProt::myprot_version^";
115 # add one or more nodes
123 for (; @_ && length $str < 200;) {
125 my $call = $ref->call;
126 my $here = $ref->here;
127 my $conf = $ref->conf;
128 my $version = $ref->version;
129 $str .= "^$here^$call^$conf^$version";
131 $str .= sprintf "^%s^", get_hops(19);
149 my $hops = get_hops(21);
150 my $call = $node->call;
151 push @out, "PC21^$call^Gone^$hops^";
166 my $call = $self->call;
167 my $flag = $self->here ? '1' : '0';
168 my $hops = shift || get_hops(24);
170 return "PC24^$call^$flag^$hops^";
174 # create a merged dx message (freq, dxcall, t, text, spotter, orig-node)
177 my ($freq, $dxcall, $t, $text, $spotter, $orignode) = @_;
178 $text = ' ' unless $text;
179 $orignode = $main::mycall unless $orignode;
180 return sprintf "PC26^%.1f^$dxcall^%s^%s^$text^$spotter^$orignode^ ^~", $freq, cldate($t), ztime($t);
183 # create a merged WWV spot (logger, t, sfi, a, k, forecast, orig-node)
186 my ($logger, $t, $sfi, $a, $k, $forecast, $orignode) = @_;
187 return sprintf "PC27^%s^%-2.2s^$sfi^$a^$k^$forecast^$logger^$orignode^ ^~", cldate($t), ztime($t);
190 # message start (fromnode, tonode, to, from, t, private, subject, origin)
193 my ($tonode, $fromnode, $to, $from, $t, $private, $subject, $origin, $rr) = @_;
194 my $date = cldate($t);
195 my $time = ztime($t);
196 $private = $private ? '1' : '0';
197 $rr = $rr ? '1' : '0';
198 return "PC28^$tonode^$fromnode^$to^$from^$date^$time^$private^$subject^ ^5^$rr^ ^$origin^~";
201 # message text (from and to node same way round as pc29)
204 my ($fromnode, $tonode, $stream, $text) = @_;
205 $text = ' ' unless $text && length $text > 0;
206 $text =~ s/\^/%5E/og; # remove ^
207 return "PC29^$fromnode^$tonode^$stream^$text^~";
210 # subject acknowledge (will have to and from node reversed to pc28)
213 my ($fromnode, $tonode, $stream) = @_;
214 return "PC30^$fromnode^$tonode^$stream^";
217 # acknowledge this tranche of lines (to and from nodes reversed to pc29 and pc28
220 my ($fromnode, $tonode, $stream) = @_;
221 return "PC31^$fromnode^$tonode^$stream^";
224 # end of message from the sending end (pc28 node order)
227 my ($fromnode, $tonode, $stream) = @_;
228 return "PC32^$fromnode^$tonode^$stream^";
231 # acknowledge end of message from receiving end (opposite pc28 node order)
234 my ($fromnode, $tonode, $stream) = @_;
235 return "PC33^$fromnode^$tonode^$stream^";
241 my($fromnode, $tonode, $msg) = @_;
242 return "PC34^$tonode^$fromnode^$msg^~";
248 my($fromnode, $tonode, $msg) = @_;
249 return "PC35^$tonode^$fromnode^$msg^~";
252 # send all the DX clusters I reckon are connected
255 return join '^', "PC38", map {$_->call} Route::Node::get_all();
258 # tell the local node to discconnect
261 my ($call, $reason) = @_;
262 my $hops = get_hops(39);
263 $reason = "Gone." if !$reason;
264 return "PC39^$call^$reason^$hops^";
267 # cue up bulletin or file for transfer
270 my ($to, $from, $fn, $bull) = @_;
271 $bull = $bull ? '1' : '0';
272 return "PC40^$to^$from^$fn^$bull^5^";
279 $call = shift if ref $call;
281 my ($sort, $info) = @_;
284 my $hops = shift || get_hops(41);
285 return "PC41^$call^$sort^$info^$hops^~";
291 my ($fromnode, $tonode, $stream) = @_;
292 return "PC42^$fromnode^$tonode^$stream^";
298 my ($fromnode, $tonode, $stream, $db, $req, $call) = @_;
300 return "PC44^$tonode^$fromnode^$stream^$db^$req^$call^";
306 my ($fromnode, $tonode, $stream, $data) = @_;
307 return "PC45^$tonode^$fromnode^$stream^$data^";
310 # remote db data complete
313 my ($fromnode, $tonode, $stream) = @_;
314 return "PC46^$tonode^$fromnode^$stream^";
320 my ($from, $subject) = @_;
321 my $hops = get_hops(49);
322 return "PC49^$from^$subject^$hops^~";
325 # periodic update of users, plus keep link alive device (always H99)
329 my $call = $self->call;
330 my $n = shift || '0';
331 my $hops = shift || 'H99';
332 return "PC50^$call^$n^$hops^";
338 my ($to, $from, $val) = @_;
339 return "PC51^$to^$from^$val^";
342 # clx remote cmd send
345 my($fromnode, $tonode, $call, $msg) = @_;
346 return "PC84^$tonode^$fromnode^$call^$msg^~";
349 # clx remote cmd reply
352 my($fromnode, $tonode, $call, $msg) = @_;
353 return "PC85^$tonode^$fromnode^$call^$msg^~";