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);
24 main::mkver($VERSION = q$Revision$);
26 use vars qw($sentencelth);
31 # All the PCxx generation routines
34 # create a talk string ($from, $to, $via, $text)
37 my ($from, $to, $via, $text, $origin) = @_;
39 if ($via && $via ne $to) {
46 $origin ||= $main::mycall;
48 $text = ' ' unless $text && length $text > 0;
50 return "PC10^$from^$user1^$text^*^$user2^$origin^~";
53 # create a dx message (call, freq, dxcall, text)
56 my ($mycall, $freq, $dxcall, $text) = @_;
57 my $hops = get_hops(11);
59 $text = ' ' if !$text;
61 return sprintf "PC11^%.1f^$dxcall^%s^%s^$text^$mycall^$main::mycall^$hops^~", $freq, cldate($t), ztime($t);
64 # create an announce message
67 my ($call, $text, $tonode, $sysop, $wx, $origin) = @_;
68 my $hops = get_hops(12);
74 $origin ||= $main::mycall;
75 return "PC12^$call^$tonode^$text^$sysop^$origin^$wx^$hops^~";
79 # add one or more users (I am expecting references that have 'call',
80 # 'conf' & 'here' method)
82 # this will create a list of PC16 with up pc16_max_users in each
83 # called $self->pc16(..)
88 my $ncall = $node->call;
95 my $str = sprintf "^%s %s %d", $ref->call, $ref->conf ? '*' : '-', $ref->here;
96 if (length($s) + length($str) > $sentencelth) {
97 push @out, "PC16^$ncall" . $s . sprintf "^%s^", get_hops(16);
102 push @out, "PC16^$ncall" . $s . sprintf "^%s^", get_hops(16);
106 # remove a local user
113 my $hops = get_hops(17);
114 my $ncall = $node->call;
115 my $ucall = $ref->call;
116 push @out, "PC17^$ucall^$ncall^$hops^";
121 # Request init string
124 my $v = $DXProt::myprot_version + $main::version;
125 return "PC18^DXSpider Version: $main::version Build: $main::build^$v^";
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 $version = 5300 + int($version*100) if $version < 2;
145 $version = 5250 + int($version*100) if $version < 3;
146 my $str = "^$here^$call^$conf^$version";
147 if (length($s) + length($str) > $sentencelth) {
148 push @out, "PC19" . $s . sprintf "^%s^", get_hops(19);
153 push @out, "PC19" . $s . sprintf "^%s^", get_hops(19);
169 my $hops = get_hops(21);
170 my $call = $node->call;
171 push @out, "PC21^$call^Gone^$hops^";
186 my $call = $self->call;
187 my $flag = $self->here ? '1' : '0';
188 my $hops = shift || get_hops(24);
190 return "PC24^$call^$flag^$hops^";
194 # create a merged dx message (freq, dxcall, t, text, spotter, orig-node)
197 my ($freq, $dxcall, $t, $text, $spotter, $orignode) = @_;
198 $text = ' ' unless $text;
199 $orignode = $main::mycall unless $orignode;
200 return sprintf "PC26^%.1f^$dxcall^%s^%s^$text^$spotter^$orignode^ ^~", $freq, cldate($t), ztime($t);
203 # create a merged WWV spot (logger, t, sfi, a, k, forecast, orig-node)
206 my ($logger, $t, $sfi, $a, $k, $forecast, $orignode) = @_;
207 return sprintf "PC27^%s^%-2.2s^$sfi^$a^$k^$forecast^$logger^$orignode^ ^~", cldate($t), ztime($t);
210 # message start (fromnode, tonode, to, from, t, private, subject, origin)
213 my ($tonode, $fromnode, $to, $from, $t, $private, $subject, $origin, $rr) = @_;
214 my $date = cldate($t);
215 my $time = ztime($t);
216 $private = $private ? '1' : '0';
217 $rr = $rr ? '1' : '0';
219 return "PC28^$tonode^$fromnode^$to^$from^$date^$time^$private^$subject^ ^5^$rr^ ^$origin^~";
222 # message text (from and to node same way round as pc29)
225 my ($fromnode, $tonode, $stream, $text) = @_;
226 $text = ' ' unless defined $text && length $text > 0;
227 $text =~ s/\^/%5E/og; # remove ^
228 return "PC29^$fromnode^$tonode^$stream^$text^~";
231 # subject acknowledge (will have to and from node reversed to pc28)
234 my ($fromnode, $tonode, $stream) = @_;
235 return "PC30^$fromnode^$tonode^$stream^";
238 # acknowledge this tranche of lines (to and from nodes reversed to pc29 and pc28
241 my ($fromnode, $tonode, $stream) = @_;
242 return "PC31^$fromnode^$tonode^$stream^";
245 # end of message from the sending end (pc28 node order)
248 my ($fromnode, $tonode, $stream) = @_;
249 return "PC32^$fromnode^$tonode^$stream^";
252 # acknowledge end of message from receiving end (opposite pc28 node order)
255 my ($fromnode, $tonode, $stream) = @_;
256 return "PC33^$fromnode^$tonode^$stream^";
262 my($fromnode, $tonode, $msg) = @_;
263 return "PC34^$tonode^$fromnode^$msg^~";
269 my($fromnode, $tonode, $msg) = @_;
270 return "PC35^$tonode^$fromnode^$msg^~";
273 # send all the DX clusters I reckon are connected
276 return join '^', "PC38", map {$_->call} Route::Node::get_all();
279 # tell the local node to discconnect
282 my ($call, $reason) = @_;
283 my $hops = get_hops(39);
284 $reason = "Gone." if !$reason;
285 return "PC39^$call^$reason^$hops^";
288 # cue up bulletin or file for transfer
291 my ($to, $from, $fn, $bull) = @_;
292 $bull = $bull ? '1' : '0';
293 return "PC40^$to^$from^$fn^$bull^5^";
300 $call = shift if ref $call;
302 my $sort = shift || '0';
303 my $info = shift || ' ';
304 my $hops = shift || get_hops(41);
305 return "PC41^$call^$sort^$info^$hops^~";
311 my ($fromnode, $tonode, $stream) = @_;
312 return "PC42^$fromnode^$tonode^$stream^";
318 my ($fromnode, $tonode, $stream, $db, $req, $call) = @_;
320 return "PC44^$tonode^$fromnode^$stream^$db^$req^$call^";
326 my ($fromnode, $tonode, $stream, $data) = @_;
327 return "PC45^$tonode^$fromnode^$stream^$data^";
330 # remote db data complete
333 my ($fromnode, $tonode, $stream) = @_;
334 return "PC46^$tonode^$fromnode^$stream^";
340 my ($from, $subject) = @_;
341 my $hops = get_hops(49);
342 return "PC49^$from^$subject^$hops^~";
345 # periodic update of users, plus keep link alive device (always H99)
349 my $call = $self->call;
350 my $n = shift || '0';
351 my $hops = shift || 'H99';
352 return "PC50^$call^$n^$hops^";
358 my ($to, $from, $val) = @_;
359 return "PC51^$to^$from^$val^";
362 # clx remote cmd send
365 my($fromnode, $tonode, $call, $msg) = @_;
366 return "PC84^$tonode^$fromnode^$call^$msg^~";
369 # clx remote cmd reply
372 my($fromnode, $tonode, $call, $msg) = @_;
373 return "PC85^$tonode^$fromnode^$call^$msg^~";
376 # spider route broadcast