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);
22 use vars qw($VERSION $BRANCH);
23 ($VERSION, $BRANCH) = dxver(q$Revision$);
25 use vars qw($sentencelth);
30 # All the PCxx generation routines
33 # create a talk string ($from, $to, $via, $text)
36 my ($from, $to, $via, $text, $origin) = @_;
38 if ($via && $via ne $to) {
45 $origin ||= $main::mycall;
47 $text = ' ' unless $text && length $text > 0;
49 return "PC10^$from^$user1^$text^*^$user2^$origin^~";
52 # create a dx message (call, freq, dxcall, text)
55 my ($mycall, $freq, $dxcall, $text) = @_;
56 my $hops = get_hops(11);
58 $text = ' ' if !$text;
60 return sprintf "PC11^%.1f^$dxcall^%s^%s^$text^$mycall^$main::mycall^$hops^~", $freq, cldate($t), ztime($t);
63 # create an announce message
66 my ($call, $text, $tonode, $sysop, $wx, $origin) = @_;
67 my $hops = get_hops(12);
73 $origin ||= $main::mycall;
74 return "PC12^$call^$tonode^$text^$sysop^$origin^$wx^$hops^~";
78 # add one or more users (I am expecting references that have 'call',
79 # 'conf' & 'here' method)
81 # this will create a list of PC16 with up pc16_max_users in each
82 # called $self->pc16(..)
87 my $ncall = $node->call;
94 my $str = sprintf "^%s %s %d", $ref->call, $ref->conf ? '*' : '-', $ref->here;
95 if (length($s) + length($str) > $sentencelth) {
96 push @out, "PC16^$ncall" . $s . sprintf "^%s^", get_hops(16);
101 push @out, "PC16^$ncall" . $s . sprintf "^%s^", get_hops(16);
105 # remove a local user
112 my $hops = get_hops(17);
113 my $ncall = $node->call;
114 my $ucall = $ref->call;
115 push @out, "PC17^$ucall^$ncall^$hops^";
120 # Request init string
123 my $flags = " pc9[2]";
124 $flags .= " xml" if DXXml::available();
125 return "PC18^DXSpider Version: $main::version Build: $main::build$flags^$DXProt::myprot_version^";
129 # add one or more nodes
140 my $call = $ref->call;
141 my $here = $ref->here;
142 my $conf = $ref->conf;
143 my $version = $ref->version;
144 my $str = "^$here^$call^$conf^$version";
145 if (length($s) + length($str) > $sentencelth) {
146 push @out, "PC19" . $s . sprintf "^%s^", get_hops(19);
151 push @out, "PC19" . $s . sprintf "^%s^", get_hops(19);
167 my $hops = get_hops(21);
168 my $call = $node->call;
169 push @out, "PC21^$call^Gone^$hops^";
184 my $call = $self->call;
185 my $flag = $self->here ? '1' : '0';
186 my $hops = shift || get_hops(24);
188 return "PC24^$call^$flag^$hops^";
192 # create a merged dx message (freq, dxcall, t, text, spotter, orig-node)
195 my ($freq, $dxcall, $t, $text, $spotter, $orignode) = @_;
196 $text = ' ' unless $text;
197 $orignode = $main::mycall unless $orignode;
198 return sprintf "PC26^%.1f^$dxcall^%s^%s^$text^$spotter^$orignode^ ^~", $freq, cldate($t), ztime($t);
201 # create a merged WWV spot (logger, t, sfi, a, k, forecast, orig-node)
204 my ($logger, $t, $sfi, $a, $k, $forecast, $orignode) = @_;
205 return sprintf "PC27^%s^%-2.2s^$sfi^$a^$k^$forecast^$logger^$orignode^ ^~", cldate($t), ztime($t);
208 # message start (fromnode, tonode, to, from, t, private, subject, origin)
211 my ($tonode, $fromnode, $to, $from, $t, $private, $subject, $origin, $rr) = @_;
212 my $date = cldate($t);
213 my $time = ztime($t);
214 $private = $private ? '1' : '0';
215 $rr = $rr ? '1' : '0';
217 return "PC28^$tonode^$fromnode^$to^$from^$date^$time^$private^$subject^ ^5^$rr^ ^$origin^~";
220 # message text (from and to node same way round as pc29)
223 my ($fromnode, $tonode, $stream, $text) = @_;
224 $text = ' ' unless defined $text && length $text > 0;
225 $text =~ s/\^/%5E/og; # remove ^
226 return "PC29^$fromnode^$tonode^$stream^$text^~";
229 # subject acknowledge (will have to and from node reversed to pc28)
232 my ($fromnode, $tonode, $stream) = @_;
233 return "PC30^$fromnode^$tonode^$stream^";
236 # acknowledge this tranche of lines (to and from nodes reversed to pc29 and pc28
239 my ($fromnode, $tonode, $stream) = @_;
240 return "PC31^$fromnode^$tonode^$stream^";
243 # end of message from the sending end (pc28 node order)
246 my ($fromnode, $tonode, $stream) = @_;
247 return "PC32^$fromnode^$tonode^$stream^";
250 # acknowledge end of message from receiving end (opposite pc28 node order)
253 my ($fromnode, $tonode, $stream) = @_;
254 return "PC33^$fromnode^$tonode^$stream^";
260 my($fromnode, $tonode, $msg) = @_;
261 return "PC34^$tonode^$fromnode^$msg^~";
267 my($fromnode, $tonode, $msg) = @_;
268 return "PC35^$tonode^$fromnode^$msg^~";
271 # send all the DX clusters I reckon are connected
274 return join '^', "PC38", map {$_->call} Route::Node::get_all();
277 # tell the local node to discconnect
280 my ($call, $reason) = @_;
281 my $hops = get_hops(39);
282 $reason = "Gone." if !$reason;
283 return "PC39^$call^$reason^$hops^";
286 # cue up bulletin or file for transfer
289 my ($to, $from, $fn, $bull) = @_;
290 $bull = $bull ? '1' : '0';
291 return "PC40^$to^$from^$fn^$bull^5^";
298 $call = shift if ref $call;
300 my $sort = shift || '0';
301 my $info = shift || ' ';
302 my $hops = shift || get_hops(41);
303 return "PC41^$call^$sort^$info^$hops^~";
309 my ($fromnode, $tonode, $stream) = @_;
310 return "PC42^$fromnode^$tonode^$stream^";
316 my ($fromnode, $tonode, $stream, $db, $req, $call) = @_;
318 return "PC44^$tonode^$fromnode^$stream^$db^$req^$call^";
324 my ($fromnode, $tonode, $stream, $data) = @_;
325 return "PC45^$tonode^$fromnode^$stream^$data^";
328 # remote db data complete
331 my ($fromnode, $tonode, $stream) = @_;
332 return "PC46^$tonode^$fromnode^$stream^";
338 my ($from, $subject) = @_;
339 my $hops = get_hops(49);
340 return "PC49^$from^$subject^$hops^~";
343 # periodic update of users, plus keep link alive device (always H99)
347 my $call = $self->call;
348 my $n = shift || '0';
349 my $hops = shift || 'H99';
350 return "PC50^$call^$n^$hops^";
356 my ($to, $from, $val) = @_;
357 return "PC51^$to^$from^$val^";
360 # clx remote cmd send
363 my($fromnode, $tonode, $call, $msg) = @_;
364 return "PC84^$tonode^$fromnode^$call^$msg^~";
367 # clx remote cmd reply
370 my($fromnode, $tonode, $call, $msg) = @_;
371 return "PC85^$tonode^$fromnode^$call^$msg^~";
374 # spider route broadcasts
382 my $s = "PC92^$main::mycall^" . gen_pc9x_t() . "^$sort";
384 $s .= "^" . _encode_pc92_call($_, $ext);
389 sub gen_pc92_with_time
395 my $s = "PC92^$call^$t^$sort";
397 $s .= "^" . _encode_pc92_call($_, $ext);
405 return _gen_pc92('A', 0, @_);
411 return _gen_pc92('D', 0, @_);
417 return _gen_pc92('C', 1, @_);