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, $origin) = @_;
37 if ($via && $via ne $to) {
44 $origin ||= $main::mycall;
46 $text = ' ' unless $text && length $text > 0;
48 return "PC10^$from^$user1^$text^*^$user2^$origin^~";
51 # create a dx message (call, freq, dxcall, text)
54 my ($mycall, $freq, $dxcall, $text) = @_;
55 my $hops = get_hops(11);
57 $text = ' ' if !$text;
59 return sprintf "PC11^%.1f^$dxcall^%s^%s^$text^$mycall^$main::mycall^$hops^~", $freq, cldate($t), ztime($t);
62 # create an announce message
65 my ($call, $text, $tonode, $sysop, $wx) = @_;
66 my $hops = get_hops(12);
67 $sysop = ' ' if !$sysop;
68 $text = ' ' if !$text;
70 $tonode = '*' if !$tonode;
72 return "PC12^$call^$tonode^$text^$sysop^$main::mycall^$wx^$hops^~";
76 # add one or more users (I am expecting references that have 'call',
77 # 'conf' & 'here' method)
79 # this will create a list of PC16 with up pc16_max_users in each
80 # called $self->pc16(..)
85 my $ncall = $node->call;
89 my $str = "PC16^$ncall";
90 for ( ; @_ && length $str < 200; ) {
92 $str .= sprintf "^%s %s %d", $ref->call, $ref->conf ? '*' : '-', $ref->here;
94 $str .= sprintf "^%s^", get_hops(16);
100 # remove a local user
107 my $hops = get_hops(17);
108 my $ncall = $node->call;
109 my $ucall = $ref->call;
110 push @out, "PC17^$ucall^$ncall^$hops^";
115 # Request init string
118 return "PC18^DXSpider Version: $main::version Build: $main::build^$DXProt::myprot_version^";
122 # add one or more nodes
130 for (; @_ && length $str < 200;) {
132 my $call = $ref->call;
133 my $here = $ref->here;
134 my $conf = $ref->conf;
135 my $version = $ref->version;
136 $str .= "^$here^$call^$conf^$version";
138 $str .= sprintf "^%s^", get_hops(19);
156 my $hops = get_hops(21);
157 my $call = $node->call;
158 push @out, "PC21^$call^Gone^$hops^";
173 my $call = $self->call;
174 my $flag = $self->here ? '1' : '0';
175 my $hops = shift || get_hops(24);
177 return "PC24^$call^$flag^$hops^";
181 # create a merged dx message (freq, dxcall, t, text, spotter, orig-node)
184 my ($freq, $dxcall, $t, $text, $spotter, $orignode) = @_;
185 $text = ' ' unless $text;
186 $orignode = $main::mycall unless $orignode;
187 return sprintf "PC26^%.1f^$dxcall^%s^%s^$text^$spotter^$orignode^ ^~", $freq, cldate($t), ztime($t);
190 # create a merged WWV spot (logger, t, sfi, a, k, forecast, orig-node)
193 my ($logger, $t, $sfi, $a, $k, $forecast, $orignode) = @_;
194 return sprintf "PC27^%s^%-2.2s^$sfi^$a^$k^$forecast^$logger^$orignode^ ^~", cldate($t), ztime($t);
197 # message start (fromnode, tonode, to, from, t, private, subject, origin)
200 my ($tonode, $fromnode, $to, $from, $t, $private, $subject, $origin, $rr) = @_;
201 my $date = cldate($t);
202 my $time = ztime($t);
203 $private = $private ? '1' : '0';
204 $rr = $rr ? '1' : '0';
206 return "PC28^$tonode^$fromnode^$to^$from^$date^$time^$private^$subject^ ^5^$rr^ ^$origin^~";
209 # message text (from and to node same way round as pc29)
212 my ($fromnode, $tonode, $stream, $text) = @_;
213 $text = ' ' unless $text && length $text > 0;
214 $text =~ s/\^/%5E/og; # remove ^
215 return "PC29^$fromnode^$tonode^$stream^$text^~";
218 # subject acknowledge (will have to and from node reversed to pc28)
221 my ($fromnode, $tonode, $stream) = @_;
222 return "PC30^$fromnode^$tonode^$stream^";
225 # acknowledge this tranche of lines (to and from nodes reversed to pc29 and pc28
228 my ($fromnode, $tonode, $stream) = @_;
229 return "PC31^$fromnode^$tonode^$stream^";
232 # end of message from the sending end (pc28 node order)
235 my ($fromnode, $tonode, $stream) = @_;
236 return "PC32^$fromnode^$tonode^$stream^";
239 # acknowledge end of message from receiving end (opposite pc28 node order)
242 my ($fromnode, $tonode, $stream) = @_;
243 return "PC33^$fromnode^$tonode^$stream^";
249 my($fromnode, $tonode, $msg) = @_;
250 return "PC34^$tonode^$fromnode^$msg^~";
256 my($fromnode, $tonode, $msg) = @_;
257 return "PC35^$tonode^$fromnode^$msg^~";
260 # send all the DX clusters I reckon are connected
263 return join '^', "PC38", map {$_->call} Route::Node::get_all();
266 # tell the local node to discconnect
269 my ($call, $reason) = @_;
270 my $hops = get_hops(39);
271 $reason = "Gone." if !$reason;
272 return "PC39^$call^$reason^$hops^";
275 # cue up bulletin or file for transfer
278 my ($to, $from, $fn, $bull) = @_;
279 $bull = $bull ? '1' : '0';
280 return "PC40^$to^$from^$fn^$bull^5^";
287 $call = shift if ref $call;
289 my $sort = shift || '0';
290 my $info = shift || ' ';
291 my $hops = shift || get_hops(41);
292 return "PC41^$call^$sort^$info^$hops^~";
298 my ($fromnode, $tonode, $stream) = @_;
299 return "PC42^$fromnode^$tonode^$stream^";
305 my ($fromnode, $tonode, $stream, $db, $req, $call) = @_;
307 return "PC44^$tonode^$fromnode^$stream^$db^$req^$call^";
313 my ($fromnode, $tonode, $stream, $data) = @_;
314 return "PC45^$tonode^$fromnode^$stream^$data^";
317 # remote db data complete
320 my ($fromnode, $tonode, $stream) = @_;
321 return "PC46^$tonode^$fromnode^$stream^";
327 my ($from, $subject) = @_;
328 my $hops = get_hops(49);
329 return "PC49^$from^$subject^$hops^~";
332 # periodic update of users, plus keep link alive device (always H99)
336 my $call = $self->call;
337 my $n = shift || '0';
338 my $hops = shift || 'H99';
339 return "PC50^$call^$n^$hops^";
345 my ($to, $from, $val) = @_;
346 return "PC51^$to^$from^$val^";
349 # clx remote cmd send
352 my($fromnode, $tonode, $call, $msg) = @_;
353 return "PC84^$tonode^$fromnode^$call^$msg^~";
356 # clx remote cmd reply
359 my($fromnode, $tonode, $call, $msg) = @_;
360 return "PC85^$tonode^$fromnode^$call^$msg^~";