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 (called $self->pc10(...)
28 my ($self, $to, $via, $text) = @_;
29 my $user2 = $via ? $to : ' ';
30 my $user1 = $via ? $via : $to;
31 my $from = $self->call();
33 $text = ' ' if !$text;
34 return "PC10^$from^$user1^$text^*^$user2^$main::mycall^~";
37 # create a dx message (called $self->pc11(...)
40 my ($self, $freq, $dxcall, $text) = @_;
41 my $mycall = $self->call;
42 my $hops = get_hops(11);
44 $text = ' ' if !$text;
45 return sprintf "PC11^%.1f^$dxcall^%s^%s^$text^$mycall^$hops^~", $freq, cldate($t), ztime($t);
48 # create an announce message
51 my ($self, $text, $tonode, $sysop, $wx) = @_;
52 my $hops = get_hops(12);
53 $sysop = $sysop ? '*' : ' ';
54 $text = ' ' if !$text;
56 $tonode = '*' if !$tonode;
57 return "PC12^$self->{call}^$tonode^$text^$sysop^$main::mycall^$wx^$hops^~";
61 # add one or more users (I am expecting references that have 'call',
62 # 'confmode' & 'here' method)
64 # this will create a list of PC16 with up pc16_max_users in each
65 # called $self->pc16(..)
73 my $str = "PC16^$self->{call}";
76 for ($i = 0; @_ > 0 && $i < $DXProt::pc16_max_users; $i++) {
78 $str .= sprintf "^%s %s %d", $ref->call, $ref->confmode ? '*' : '-', $ref->here;
80 $str .= sprintf "^%s^", get_hops(16);
89 my ($self, $ref) = @_;
90 my $hops = get_hops(17);
91 return "PC17^$self->{call}^$ref->{call}^$hops^";
97 return "PC18^wot a load of twaddle^$DXProt::myprot_version^~";
101 # add one or more nodes
112 for ($i = 0; @_ && $i < $DXProt::pc19_max_nodes; $i++) {
114 my $here = $ref->{here} ? '1' : '0';
115 my $confmode = $ref->{confmode} ? '1' : '0';
116 $str .= "^$here^$ref->{call}^$confmode^$ref->{pcversion}";
118 $str .= sprintf "^%s^", get_hops(19);
133 my ($ref, $reason) = @_;
134 my $call = $ref->call;
135 my $hops = get_hops(21);
136 $reason = "Gone." if !$reason;
137 return "PC21^$call^$reason^$hops^";
146 # send all the DX clusters I reckon are connected
149 my @list = DXNode->get_all();
153 foreach $list (@list) {
154 push @nodes, $list->call;
156 return "PC38^" . join(',', @nodes) . "^~";
159 # periodic update of users, plus keep link alive device (always H99)
162 my $me = DXCluster->get($main::mycall);
163 my $n = $me->users ? $me->users : '0';
164 return "PC50^$main::mycall^$n^H99^";
170 my ($self, $to, $from, $val) = @_;
171 return "PC51^$to^$from^$val^";