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;
25 $main::build += $VERSION;
26 $main::branch += $BRANCH;
29 # All the PCxx generation routines
32 # create a talk string ($from, $to, $via, $text)
35 my ($from, $to, $via, $text) = @_;
37 if ($via && $via ne $to) {
45 $text = ' ' unless $text && length $text > 0;
47 return "PC10^$from^$user1^$text^*^$user2^$main::mycall^~";
50 # create a dx message (call, freq, dxcall, text)
53 my ($mycall, $freq, $dxcall, $text) = @_;
54 my $hops = get_hops(11);
56 $text = ' ' if !$text;
58 return sprintf "PC11^%.1f^$dxcall^%s^%s^$text^$mycall^$main::mycall^$hops^~", $freq, cldate($t), ztime($t);
61 # create an announce message
64 my ($call, $text, $tonode, $sysop, $wx) = @_;
65 my $hops = get_hops(12);
66 $sysop = ' ' if !$sysop;
67 $text = ' ' if !$text;
69 $tonode = '*' if !$tonode;
71 return "PC12^$call^$tonode^$text^$sysop^$main::mycall^$wx^$hops^~";
75 # add one or more users (I am expecting references that have 'call',
76 # 'conf' & 'here' method)
78 # this will create a list of PC16 with up pc16_max_users in each
79 # called $self->pc16(..)
84 my $ncall = $node->call;
88 my $str = "PC16^$ncall";
89 for ( ; @_ && length $str < 200; ) {
91 $str .= sprintf "^%s %s %d", $ref->call, $ref->conf ? '*' : '-', $ref->here;
93 $str .= sprintf "^%s^", get_hops(16);
106 my $hops = get_hops(17);
107 my $ncall = $node->call;
108 my $ucall = $ref->call;
109 push @out, "PC17^$ucall^$ncall^$hops^";
114 # Request init string
117 return "PC18^DXSpider Version: $main::version Build: $main::build^$DXProt::myprot_version^";
121 # add one or more nodes
129 for (; @_ && length $str < 200;) {
131 my $call = $ref->call;
132 my $here = $ref->here;
133 my $conf = $ref->conf;
134 my $version = $ref->version;
135 $str .= "^$here^$call^$conf^$version";
137 $str .= sprintf "^%s^", get_hops(19);
155 my $hops = get_hops(21);
156 my $call = $node->call;
157 push @out, "PC21^$call^Gone^$hops^";
172 my $call = $self->call;
173 my $flag = $self->here ? '1' : '0';
174 my $hops = shift || get_hops(24);
176 return "PC24^$call^$flag^$hops^";
180 # create a merged dx message (freq, dxcall, t, text, spotter, orig-node)
183 my ($freq, $dxcall, $t, $text, $spotter, $orignode) = @_;
184 $text = ' ' unless $text;
185 $orignode = $main::mycall unless $orignode;
186 return sprintf "PC26^%.1f^$dxcall^%s^%s^$text^$spotter^$orignode^ ^~", $freq, cldate($t), ztime($t);
189 # create a merged WWV spot (logger, t, sfi, a, k, forecast, orig-node)
192 my ($logger, $t, $sfi, $a, $k, $forecast, $orignode) = @_;
193 return sprintf "PC27^%s^%-2.2s^$sfi^$a^$k^$forecast^$logger^$orignode^ ^~", cldate($t), ztime($t);
196 # message start (fromnode, tonode, to, from, t, private, subject, origin)
199 my ($tonode, $fromnode, $to, $from, $t, $private, $subject, $origin, $rr) = @_;
200 my $date = cldate($t);
201 my $time = ztime($t);
202 $private = $private ? '1' : '0';
203 $rr = $rr ? '1' : '0';
205 return "PC28^$tonode^$fromnode^$to^$from^$date^$time^$private^$subject^ ^5^$rr^ ^$origin^~";
208 # message text (from and to node same way round as pc29)
211 my ($fromnode, $tonode, $stream, $text) = @_;
212 $text = ' ' unless $text && length $text > 0;
213 $text =~ s/\^/%5E/og; # remove ^
214 return "PC29^$fromnode^$tonode^$stream^$text^~";
217 # subject acknowledge (will have to and from node reversed to pc28)
220 my ($fromnode, $tonode, $stream) = @_;
221 return "PC30^$fromnode^$tonode^$stream^";
224 # acknowledge this tranche of lines (to and from nodes reversed to pc29 and pc28
227 my ($fromnode, $tonode, $stream) = @_;
228 return "PC31^$fromnode^$tonode^$stream^";
231 # end of message from the sending end (pc28 node order)
234 my ($fromnode, $tonode, $stream) = @_;
235 return "PC32^$fromnode^$tonode^$stream^";
238 # acknowledge end of message from receiving end (opposite pc28 node order)
241 my ($fromnode, $tonode, $stream) = @_;
242 return "PC33^$fromnode^$tonode^$stream^";
248 my($fromnode, $tonode, $msg) = @_;
249 return "PC34^$tonode^$fromnode^$msg^~";
255 my($fromnode, $tonode, $msg) = @_;
256 return "PC35^$tonode^$fromnode^$msg^~";
259 # send all the DX clusters I reckon are connected
262 return join '^', "PC38", map {$_->call} Route::Node::get_all();
265 # tell the local node to discconnect
268 my ($call, $reason) = @_;
269 my $hops = get_hops(39);
270 $reason = "Gone." if !$reason;
271 return "PC39^$call^$reason^$hops^";
274 # cue up bulletin or file for transfer
277 my ($to, $from, $fn, $bull) = @_;
278 $bull = $bull ? '1' : '0';
279 return "PC40^$to^$from^$fn^$bull^5^";
286 $call = shift if ref $call;
288 my $sort = shift || '0';
289 my $info = shift || ' ';
290 my $hops = shift || get_hops(41);
291 return "PC41^$call^$sort^$info^$hops^~";
297 my ($fromnode, $tonode, $stream) = @_;
298 return "PC42^$fromnode^$tonode^$stream^";
304 my ($fromnode, $tonode, $stream, $db, $req, $call) = @_;
306 return "PC44^$tonode^$fromnode^$stream^$db^$req^$call^";
312 my ($fromnode, $tonode, $stream, $data) = @_;
313 return "PC45^$tonode^$fromnode^$stream^$data^";
316 # remote db data complete
319 my ($fromnode, $tonode, $stream) = @_;
320 return "PC46^$tonode^$fromnode^$stream^";
326 my ($from, $subject) = @_;
327 my $hops = get_hops(49);
328 return "PC49^$from^$subject^$hops^~";
331 # periodic update of users, plus keep link alive device (always H99)
335 my $call = $self->call;
336 my $n = shift || '0';
337 my $hops = shift || 'H99';
338 return "PC50^$call^$n^$hops^";
344 my ($to, $from, $val) = @_;
345 return "PC51^$to^$from^$val^";
348 # clx remote cmd send
351 my($fromnode, $tonode, $call, $msg) = @_;
352 return "PC84^$tonode^$fromnode^$call^$msg^~";
355 # clx remote cmd reply
358 my($fromnode, $tonode, $call, $msg) = @_;
359 return "PC85^$tonode^$fromnode^$call^$msg^~";