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 # All the PCxx generation routines
25 # create a talk string ($from, $to, $via, $text)
28 my ($from, $to, $via, $text) = @_;
29 my $user2 = $via ? $to : ' ';
30 my $user1 = $via ? $via : $to;
32 $text = ' ' if !$text;
33 return "PC10^$from^$user1^$text^*^$user2^$main::mycall^~";
36 # create a dx message (call, freq, dxcall, text)
39 my ($mycall, $freq, $dxcall, $text) = @_;
40 my $hops = get_hops(11);
42 $text = ' ' if !$text;
43 return sprintf "PC11^%.1f^$dxcall^%s^%s^$text^$mycall^$hops^~", $freq, cldate($t), ztime($t);
46 # create an announce message
49 my ($call, $text, $tonode, $sysop, $wx) = @_;
50 my $hops = get_hops(12);
51 $sysop = ' ' if !$sysop;
52 $text = ' ' if !$text;
54 $tonode = '*' if !$tonode;
55 return "PC12^$call^$tonode^$text^$sysop^$main::mycall^$wx^$hops^~";
59 # add one or more users (I am expecting references that have 'call',
60 # 'confmode' & 'here' method)
62 # this will create a list of PC16 with up pc16_max_users in each
63 # called $self->pc16(..)
71 my $str = "PC16^$self->{call}";
74 for ($i = 0; @_ > 0 && $i < $DXProt::pc16_max_users; $i++) {
76 $str .= sprintf "^%s %s %d", $ref->call, $ref->confmode ? '*' : '-', $ref->here;
78 $str .= sprintf "^%s^", get_hops(16);
87 my ($self, $ref) = @_;
88 my $hops = get_hops(17);
89 return "PC17^$self->{call}^$ref->{call}^$hops^";
95 return "PC18^wot a load of twaddle^$DXProt::myprot_version^~";
99 # add one or more nodes
110 for ($i = 0; @_ && $i < $DXProt::pc19_max_nodes; $i++) {
112 my $here = $ref->{here} ? '1' : '0';
113 my $confmode = $ref->{confmode} ? '1' : '0';
114 $str .= "^$here^$ref->{call}^$confmode^$ref->{pcversion}";
116 $str .= sprintf "^%s^", get_hops(19);
131 my ($call, $reason) = @_;
132 my $hops = get_hops(21);
133 $reason = "Gone." if !$reason;
134 return "PC21^$call^$reason^$hops^";
147 my $call = $self->call;
148 my $flag = $self->here ? '1' : '0';
149 my $hops = get_hops(24);
151 return "PC24^$call^$flag^$hops^";
154 # message start (fromnode, tonode, to, from, t, private, subject, origin)
157 my ($fromnode, $tonode, $to, $from, $t, $private, $subject, $origin) = @_;
158 my $date = cldate($t);
159 my $time = ztime($t);
160 $private = $private ? '1' : '0';
161 return "PC28^$fromnode^$tonode^$to^from^$date^$time^$private^$subject^ ^5^0^ ^$origin^~";
164 # message text (from and to node same way round as pc29)
167 my ($fromnode, $tonode, $stream, $text) = @_;
168 $text =~ s/\^//og; # remove ^
169 return "PC29^$fromnode^$tonode^$stream^text^~";
172 # subject acknowledge (will have to and from node reversed to pc28)
175 my ($fromnode, $tonode, $stream) = @_;
176 return "PC30^$fromnode^$tonode^$stream^";
179 # acknowledge this tranche of lines (to and from nodes reversed to pc29 and pc28
182 my ($fromnode, $tonode, $stream) = @_;
183 return "PC31^$fromnode^$tonode^$stream^";
186 # end of message from the sending end (pc28 node order)
189 my ($fromnode, $tonode, $stream) = @_;
190 return "PC32^$fromnode^$tonode^$stream^";
193 # acknowledge end of message from receiving end (opposite pc28 node order)
196 my ($fromnode, $tonode, $stream) = @_;
197 return "PC33^$fromnode^$tonode^$stream^";
201 # send all the DX clusters I reckon are connected
204 my @list = DXNode->get_all();
208 foreach $list (@list) {
209 push @nodes, $list->call;
211 return "PC38^" . join(',', @nodes) . "^~";
214 # tell the local node to discconnect
217 my ($ref, $reason) = @_;
218 my $call = $ref->call;
219 my $hops = get_hops(21);
220 $reason = "Gone." if !$reason;
221 return "PC39^$call^$reason^";
224 # periodic update of users, plus keep link alive device (always H99)
227 my $me = DXCluster->get($main::mycall);
228 my $n = $me->users ? $me->users : '0';
229 return "PC50^$main::mycall^$n^H99^";
235 my ($self, $to, $from, $val) = @_;
236 return "PC51^$to^$from^$val^";