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 = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
24 $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ || (0,0));
25 $main::build += $VERSION;
26 $main::branch += $BRANCH;
28 use vars qw($sentencelth);
33 # All the PCxx generation routines
36 # create a talk string ($from, $to, $via, $text)
39 my ($from, $to, $via, $text, $origin) = @_;
41 if ($via && $via ne $to) {
48 $origin ||= $main::mycall;
50 $text = ' ' unless $text && length $text > 0;
52 return "PC10^$from^$user1^$text^*^$user2^$origin^~";
55 # create a dx message (call, freq, dxcall, text)
58 my ($mycall, $freq, $dxcall, $text) = @_;
59 my $hops = get_hops(11);
61 $text = ' ' if !$text;
63 return sprintf "PC11^%.1f^$dxcall^%s^%s^$text^$mycall^$main::mycall^$hops^~", $freq, cldate($t), ztime($t);
66 # create an announce message
69 my ($call, $text, $tonode, $sysop, $wx, $origin) = @_;
70 my $hops = get_hops(12);
71 $origin ||= $main::mycall;
77 return "PC12^$call^$tonode^$text^$sysop^$origin^$wx^$hops^~";
81 # add one or more users (I am expecting references that have 'call',
82 # 'conf' & 'here' method)
84 # this will create a list of PC16 with up pc16_max_users in each
85 # called $self->pc16(..)
90 my $ncall = $node->call;
97 my $str = sprintf "^%s %s %d", $ref->call, $ref->conf ? '*' : '-', $ref->here;
98 if (length($s) + length($str) > $sentencelth) {
99 push @out, "PC16^$ncall" . $s . sprintf "^%s^", get_hops(16);
104 push @out, "PC16^$ncall" . $s . sprintf "^%s^", get_hops(16);
108 # remove a local user
115 my $hops = get_hops(17);
116 my $ncall = $node->call;
117 my $ucall = $ref->call;
118 push @out, "PC17^$ucall^$ncall^$hops^";
123 # Request init string
126 return "PC18^DXSpider Version: $main::version Build: $main::build^$DXProt::myprot_version^";
130 # add one or more nodes
141 my $call = $ref->call;
142 my $here = $ref->here;
143 my $conf = $ref->conf;
144 my $version = $ref->version;
145 my $str = "^$here^$call^$conf^$version";
146 if (length($s) + length($str) > $sentencelth) {
147 push @out, "PC19" . $s . sprintf "^%s^", get_hops(19);
152 push @out, "PC19" . $s . sprintf "^%s^", get_hops(19);
168 my $hops = get_hops(21);
169 my $call = $node->call;
170 push @out, "PC21^$call^Gone^$hops^";
185 my $call = $self->call;
186 my $flag = $self->here ? '1' : '0';
187 my $hops = shift || get_hops(24);
189 return "PC24^$call^$flag^$hops^";
193 # create a merged dx message (freq, dxcall, t, text, spotter, orig-node)
196 my ($freq, $dxcall, $t, $text, $spotter, $orignode) = @_;
197 $text = ' ' unless $text;
198 $orignode = $main::mycall unless $orignode;
199 return sprintf "PC26^%.1f^$dxcall^%s^%s^$text^$spotter^$orignode^ ^~", $freq, cldate($t), ztime($t);
202 # create a merged WWV spot (logger, t, sfi, a, k, forecast, orig-node)
205 my ($logger, $t, $sfi, $a, $k, $forecast, $orignode) = @_;
206 return sprintf "PC27^%s^%-2.2s^$sfi^$a^$k^$forecast^$logger^$orignode^ ^~", cldate($t), ztime($t);
209 # message start (fromnode, tonode, to, from, t, private, subject, origin)
212 my ($tonode, $fromnode, $to, $from, $t, $private, $subject, $origin, $rr) = @_;
213 my $date = cldate($t);
214 my $time = ztime($t);
215 $private = $private ? '1' : '0';
216 $rr = $rr ? '1' : '0';
218 return "PC28^$tonode^$fromnode^$to^$from^$date^$time^$private^$subject^ ^5^$rr^ ^$origin^~";
221 # message text (from and to node same way round as pc29)
224 my ($fromnode, $tonode, $stream, $text) = @_;
225 $text = ' ' unless defined $text && length $text > 0;
226 $text =~ s/\^/%5E/og; # remove ^
227 return "PC29^$fromnode^$tonode^$stream^$text^~";
230 # subject acknowledge (will have to and from node reversed to pc28)
233 my ($fromnode, $tonode, $stream) = @_;
234 return "PC30^$fromnode^$tonode^$stream^";
237 # acknowledge this tranche of lines (to and from nodes reversed to pc29 and pc28
240 my ($fromnode, $tonode, $stream) = @_;
241 return "PC31^$fromnode^$tonode^$stream^";
244 # end of message from the sending end (pc28 node order)
247 my ($fromnode, $tonode, $stream) = @_;
248 return "PC32^$fromnode^$tonode^$stream^";
251 # acknowledge end of message from receiving end (opposite pc28 node order)
254 my ($fromnode, $tonode, $stream) = @_;
255 return "PC33^$fromnode^$tonode^$stream^";
261 my($fromnode, $tonode, $msg) = @_;
262 return "PC34^$tonode^$fromnode^$msg^~";
268 my($fromnode, $tonode, $msg) = @_;
269 return "PC35^$tonode^$fromnode^$msg^~";
272 # send all the DX clusters I reckon are connected
275 return join '^', "PC38", map {$_->call} Route::Node::get_all();
278 # tell the local node to discconnect
281 my ($call, $reason) = @_;
282 my $hops = get_hops(39);
283 $reason = "Gone." if !$reason;
284 return "PC39^$call^$reason^$hops^";
287 # cue up bulletin or file for transfer
290 my ($to, $from, $fn, $bull) = @_;
291 $bull = $bull ? '1' : '0';
292 return "PC40^$to^$from^$fn^$bull^5^";
299 $call = shift if ref $call;
301 my $sort = shift || '0';
302 my $info = shift || ' ';
303 my $hops = shift || get_hops(41);
304 return "PC41^$call^$sort^$info^$hops^~";
310 my ($fromnode, $tonode, $stream) = @_;
311 return "PC42^$fromnode^$tonode^$stream^";
317 my ($fromnode, $tonode, $stream, $db, $req, $call) = @_;
319 return "PC44^$tonode^$fromnode^$stream^$db^$req^$call^";
325 my ($fromnode, $tonode, $stream, $data) = @_;
326 return "PC45^$tonode^$fromnode^$stream^$data^";
329 # remote db data complete
332 my ($fromnode, $tonode, $stream) = @_;
333 return "PC46^$tonode^$fromnode^$stream^";
339 my ($from, $subject) = @_;
340 my $hops = get_hops(49);
341 return "PC49^$from^$subject^$hops^~";
344 # periodic update of users, plus keep link alive device (always H99)
348 my $call = $self->call;
349 my $n = shift || '0';
350 my $hops = shift || 'H99';
351 return "PC50^$call^$n^$hops^";
357 my ($to, $from, $val) = @_;
358 return "PC51^$to^$from^$val^";
361 # clx remote cmd send
364 my($fromnode, $tonode, $call, $msg) = @_;
365 return "PC84^$tonode^$fromnode^$call^$msg^~";
368 # clx remote cmd reply
371 my($fromnode, $tonode, $call, $msg) = @_;
372 return "PC85^$tonode^$fromnode^$call^$msg^~";
375 # spider route broadcast