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 ($ref, $reason) = @_;
132 my $call = $ref->call;
133 my $hops = get_hops(21);
134 $reason = "Gone." if !$reason;
135 return "PC21^$call^$reason^$hops^";
148 my $call = $self->call;
149 my $flag = $self->here ? '1' : '0';
150 my $hops = get_hops(24);
152 return "PC24^$call^$flag^$hops^";
155 # send all the DX clusters I reckon are connected
158 my @list = DXNode->get_all();
162 foreach $list (@list) {
163 push @nodes, $list->call;
165 return "PC38^" . join(',', @nodes) . "^~";
168 # tell the local node to discconnect
171 my ($ref, $reason) = @_;
172 my $call = $ref->call;
173 my $hops = get_hops(21);
174 $reason = "Gone." if !$reason;
175 return "PC39^$call^$reason^";
178 # periodic update of users, plus keep link alive device (always H99)
181 my $me = DXCluster->get($main::mycall);
182 my $n = $me->users ? $me->users : '0';
183 return "PC50^$main::mycall^$n^H99^";
189 my ($self, $to, $from, $val) = @_;
190 return "PC51^$to^$from^$val^";