| 1 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | Device::CableModem::Zoom5341J::Parse | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 NOTA BENE | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | This is part of the guts of Device::CableModem::Zoom5341J. If you're | ||||||||||||||||||||||||||||
| 14 | reading this, you're either developing the module, writing tests, or | ||||||||||||||||||||||||||||
| 15 | coloring outside the lines; consider yourself warned. | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | =cut | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | =head2 ->parse_conn_stats | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | Parse out all the connection status bits. | ||||||||||||||||||||||||||||
| 23 | =cut | ||||||||||||||||||||||||||||
| 24 | sub parse_conn_stats | ||||||||||||||||||||||||||||
| 25 | 4 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
parse_conn_stats: called CC=19 SCAR=29.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 26 | 4 | my $self = shift; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 4 | ▶ | $self->fetch_data unless $self->{conn_html}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | 4 | ▶ | croak "No HTML stashed" unless $self->{conn_html}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | # First extract out a fragment that contains all the downstream and | ||||||||||||||||||||||||||||
| 32 | # upstream data | ||||||||||||||||||||||||||||
| 33 | my ($dsfrag) = ($self->{conn_html} =~ | ||||||||||||||||||||||||||||
| 34 | 3 | m#Downstream Bonded Channels(.+?)</table>#s); | |||||||||||||||||||||||||||
| 35 | 3 | ▶ | croak "Couldn't find downstream fragment" unless $dsfrag; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 2 | chomp(my @dslines = split /\n/, $dsfrag); | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | my ($usfrag) = ($self->{conn_html} =~ | ||||||||||||||||||||||||||||
| 39 | 2 | m#Upstream Bonded Channels(.+?)</table>#s); | |||||||||||||||||||||||||||
| 40 | 2 | ▶ | croak "Couldn't find upstream fragment" unless $usfrag; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 2 | chomp(my @uslines = split /\n/, $usfrag); | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | # Make life easier on regexen | ||||||||||||||||||||||||||||
| 45 | 2 | my $td = "<td[^>]*>\\s*"; | |||||||||||||||||||||||||||
| 46 | 2 | my $etd = "\\s*</td>"; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | # Go through the downstream lines, grabbing the stat bits | ||||||||||||||||||||||||||||
| 49 | 2 | my %dsstat; | |||||||||||||||||||||||||||
| 50 | 2 | for my $l (@dslines) | |||||||||||||||||||||||||||
| 51 | { | ||||||||||||||||||||||||||||
| 52 | # Grab all the table cells in a line | ||||||||||||||||||||||||||||
| 53 | 22 | my @tds = ($l =~ m#$td(.*?)$etd#g); | |||||||||||||||||||||||||||
| 54 | 22 | ▶ | next unless @tds; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | # First should be a channel number | ||||||||||||||||||||||||||||
| 57 | 16 | ▶ | next unless $tds[0] =~ m#^\d+$#; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | # Grab the bits we care about | ||||||||||||||||||||||||||||
| 60 | 16 | my ($chanid) = $tds[0]; | |||||||||||||||||||||||||||
| 61 | 16 | my ($mod) = $tds[2]; | |||||||||||||||||||||||||||
| 62 | 16 | my ($freq) = ($tds[4] =~ m#(\d+) Hz#); | |||||||||||||||||||||||||||
| 63 | 16 | my ($power) = ($tds[5] =~ m#([\d.]+) dBmV#); | |||||||||||||||||||||||||||
| 64 | 16 | my ($snr) = ($tds[6] =~ m#([\d.]+) dB#); | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | # And stash them | ||||||||||||||||||||||||||||
| 67 | 16 | push @{$dsstat{chanid}}, $chanid; | |||||||||||||||||||||||||||
| 68 | 16 | push @{$dsstat{mod}}, $mod; | |||||||||||||||||||||||||||
| 69 | 16 | push @{$dsstat{freq}}, $freq; | |||||||||||||||||||||||||||
| 70 | 16 | push @{$dsstat{power}}, $power; | |||||||||||||||||||||||||||
| 71 | 16 | push @{$dsstat{snr}}, $snr; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 2 | $self->{conn_stats}{down} = \%dsstat; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | # Now do the same for upstream | ||||||||||||||||||||||||||||
| 78 | 2 | my %usstat; | |||||||||||||||||||||||||||
| 79 | 2 | for my $l (@uslines) | |||||||||||||||||||||||||||
| 80 | { | ||||||||||||||||||||||||||||
| 81 | # Grab all the table cells in a line | ||||||||||||||||||||||||||||
| 82 | 12 | my @tus = ($l =~ m#$td(.*?)$etd#g); | |||||||||||||||||||||||||||
| 83 | 12 | ▶ | next unless @tus; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | # First should be a channel number | ||||||||||||||||||||||||||||
| 86 | 8 | ▶ | next unless $tus[0] =~ m#^\d+$#; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | # Grab the bits we care about | ||||||||||||||||||||||||||||
| 89 | 8 | my ($chanid) = $tus[0]; | |||||||||||||||||||||||||||
| 90 | 8 | my ($bw) = ($tus[4] =~ m#(\d+) Ksym/sec#); | |||||||||||||||||||||||||||
| 91 | 8 | my ($freq) = ($tus[5] =~ m#(\d+) Hz#); | |||||||||||||||||||||||||||
| 92 | 8 | my ($power) = ($tus[6] =~ m#([\d.]+) dBmV#); | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | # And stash them | ||||||||||||||||||||||||||||
| 95 | 8 | push @{$usstat{chanid}}, $chanid; | |||||||||||||||||||||||||||
| 96 | 8 | push @{$usstat{bw}}, $bw; | |||||||||||||||||||||||||||
| 97 | 8 | push @{$usstat{freq}}, $freq; | |||||||||||||||||||||||||||
| 98 | 8 | push @{$usstat{power}}, $power; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 2 | $self->{conn_stats}{up} = \%usstat; | |||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | # Now empty out up/down channels as necessary | ||||||||||||||||||||||||||||
| 105 | 2 | my $ds = $self->{conn_stats}{down}; | |||||||||||||||||||||||||||
| 106 | 2 | for my $i (0..$#{$ds->{freq}}) | |||||||||||||||||||||||||||
| 107 | { | ||||||||||||||||||||||||||||
| 108 | 16 | ▶ | unless($ds->{freq}[$i] && $ds->{freq}[$i] > 0) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ds->{"freq"}[$i] and $ds->{"freq"}[$i] > 0
MC/DC50%1/2
$ds->{"freq"}[$i] and $ds->{"freq"}[$i] > 0
$ds->{"freq"}[$i]
$ds->{"freq"}[$i] > 0
Truth table66%2/3
A and B
A= $ds->{"freq"}[$i]B= $ds->{"freq"}[$i] > 0
| |||||||||||||||||||||||||||||
| 109 | { | ||||||||||||||||||||||||||||
| 110 | 2 | undef($ds->{$_}[$i]) for keys %$ds; | |||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 2 | my $us = $self->{conn_stats}{up}; | |||||||||||||||||||||||||||
| 115 | 2 | for my $i (0..$#{$us->{chanid}}) | |||||||||||||||||||||||||||
| 116 | { | ||||||||||||||||||||||||||||
| 117 | 8 | ▶ | unless($us->{freq}[$i] && $us->{freq}[$i] > 0) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$us->{"freq"}[$i] and $us->{"freq"}[$i] > 0
MC/DC50%1/2
$us->{"freq"}[$i] and $us->{"freq"}[$i] > 0
$us->{"freq"}[$i]
$us->{"freq"}[$i] > 0
Truth table66%2/3
A and B
A= $us->{"freq"}[$i]B= $us->{"freq"}[$i] > 0
| |||||||||||||||||||||||||||||
| 118 | { | ||||||||||||||||||||||||||||
| 119 | 4 | undef($us->{$_}[$i]) for keys %$us; | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 2 | return; | |||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 7 | 1; | |||||||||||||||||||||||||||
| 128 | __END__ | ||||||||||||||||||||||||||||