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) = @_;
70 my $hops = get_hops(12);
71 $sysop = ' ' if !$sysop;
72 $text = ' ' if !$text;
74 $tonode = '*' if !$tonode;
76 return "PC12^$call^$tonode^$text^$sysop^$main::mycall^$wx^$hops^~";
80 # add one or more users (I am expecting references that have 'call',
81 # 'conf' & 'here' method)
83 # this will create a list of PC16 with up pc16_max_users in each
84 # called $self->pc16(..)
89 my $ncall = $node->call;
96 my $str = sprintf "^%s %s %d", $ref->call, $ref->conf ? '*' : '-', $ref->here;
97 if (length($s) + length($str) > $sentencelth) {
98 push @out, "PC16^$ncall" . $s . sprintf "^%s^", get_hops(16);
103 push @out, "PC16^$ncall" . $s . sprintf "^%s^", get_hops(16);
107 # remove a local user
114 my $hops = get_hops(17);
115 my $ncall = $node->call;
116 my $ucall = $ref->call;
117 push @out, "PC17^$ucall^$ncall^$hops^";
122 # Request init string
125 return "PC18^DXSpider Version: $main::version Build: $main::build^$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 broadcast