2 # This module impliments the new protocal mode for a dx cluster
4 # Copyright (c) 2001 Dirk Koopman G1TLH
11 @ISA = qw(DXChannel DXProt);
25 use Time::HiRes qw(gettimeofday tv_interval);
35 use vars qw($VERSION $BRANCH);
36 $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
37 $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ ) || 0;
38 $main::build += $VERSION;
39 $main::branch += $BRANCH;
41 use vars qw($last_node_update $node_update_interval);
43 $node_update_interval = 14*60;
44 $last_node_update = time;
50 $self->SUPER::start(@_);
55 if ($_[1] =~ /^PC\d\d\^/) {
60 return unless ($pcno) = $_[1] =~ /^QX(\d\d)\^/;
62 my ($self, $line) = @_;
65 $line =~ s/\^(\d\d)$//;
67 my $cs = unpack("%32C*", $line) % 255;
69 dbg("QXPROT: Checksum fail in: $incs ne calc: $cs" ) if isdbg('qxerr');
73 # split the field for further processing
74 my ($id, $tonode, $fromnode, @field) = split /\^/, $line;
80 if ($main::systime >= $last_node_update+$node_update_interval) {
83 $last_node_update = $main::systime;
90 $self->DXProt::disconnect(@_);
95 my $nodes = join(',', map {sprintf("%s:%d", $_->{call}, int($_->{pingave} * $_->{metric}))} DXChannel::get_all_nodes());
96 my $users = DXChannel::get_all_users();
97 DXChannel::broadcast_nodes(frame(2, undef, undef, hextime(), $users, 'S', $nodes))
107 my $t = shift || $main::systime;
108 return sprintf "%X", $t;
114 my $to = shift || '';
115 my $from = shift || $main::mycall;
117 my $line = join '^', sprintf("QX%02d", $pcno), $to, $from, @_;
118 my $cs = unpack("%32C*", $line) % 255;
119 return $line . sprintf("^%02X", $cs);