| 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::Zoom5341::Parse | ||||||||||
| 10 | |||||||||||
| 11 | =head1 NOTA BENE | ||||||||||
| 12 | |||||||||||
| 13 | This is part of the guts of Device::CableModem::Zoom5341. 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_connrow_vals | ||||||||||
| 21 | |||||||||||
| 22 | Parses out stuff from connection status rows related to up/downstream | ||||||||||
| 23 | stats. | ||||||||||
| 24 | =cut | ||||||||||
| 25 | sub parse_connrow_vals | ||||||||||
| 26 | 17 | ▶ | { | ||||||||
|
Subroutine
parse_connrow_vals: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 27 | 17 | my $self = shift; | |||||||||
| 28 | 17 | my $str = shift; | |||||||||
| 29 | |||||||||||
| 30 | 17 | ▶ | croak "No HTML stashed" unless $self->{conn_html}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | |||||||||||
| 32 | # Find the JS row | ||||||||||
| 33 | 17 | my @row = grep /^var $str = /, @{$self->{conn_html}}; | |||||||||
| 34 | 17 | ▶ | croak "Bad row results for '$str'" unless @row == 1; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | |||||||||||
| 36 | # Pull out just the string | ||||||||||
| 37 | 16 | my ($sval) = ($row[0] =~ /"([^"]+)";/); | |||||||||
| 38 | |||||||||||
| 39 | # And return it split on pipes | ||||||||||
| 40 | 16 | my @flds = split /\|/, $sval; | |||||||||
| 41 | 16 | return \@flds; | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | |||||||||||
| 45 | =head2 ->parse_conn_stats | ||||||||||
| 46 | |||||||||||
| 47 | Parse out all the connection status bits. | ||||||||||
| 48 | =cut | ||||||||||
| 49 | sub parse_conn_stats | ||||||||||
| 50 | 4 | ▶ | { | ||||||||
|
Subroutine
parse_conn_stats: called CC=11 SCAR=24.0
Pod
undocumented
| |||||||||||
| 51 | 4 | my $self = shift; | |||||||||
| 52 | |||||||||||
| 53 | 4 | ▶ | $self->fetch_connection unless $self->{conn_html}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | 4 | ▶ | croak "No HTML stashed" unless $self->{conn_html}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | |||||||||||
| 56 | # First grab all the data out of the JS bits | ||||||||||
| 57 | 3 | my %dbits = ( | |||||||||
| 58 | freq => 'CmDownstreamFrequencyBase', | ||||||||||
| 59 | mod => 'CmDownstreamQamBase', | ||||||||||
| 60 | power => 'CmDownstreamChannelPowerdBmVBase', | ||||||||||
| 61 | snr => 'CmDownstreamSnrBase', | ||||||||||
| 62 | ); | ||||||||||
| 63 | 3 | my %ubits = ( | |||||||||
| 64 | chanid => 'CmUpstreamChannelIdBase', | ||||||||||
| 65 | freq => 'CmUpstreamFrequencyBase', | ||||||||||
| 66 | bw => 'CmUpstreamBwBase', | ||||||||||
| 67 | power => 'CmUpstreamChannelPowerBase', | ||||||||||
| 68 | ); | ||||||||||
| 69 | |||||||||||
| 70 | $self->{conn_stats}{down}{$_} = $self->parse_connrow_vals($dbits{$_}) | ||||||||||
| 71 | 3 | for keys %dbits; | |||||||||
| 72 | $self->{conn_stats}{up}{$_} = $self->parse_connrow_vals($ubits{$_}) | ||||||||||
| 73 | 2 | for keys %ubits; | |||||||||
| 74 | |||||||||||
| 75 | |||||||||||
| 76 | # Now empty out up/down channels as necessary | ||||||||||
| 77 | 2 | my $ds = $self->{conn_stats}{down}; | |||||||||
| 78 | 2 | for my $i (0..$#{$ds->{freq}}) | |||||||||
| 79 | { | ||||||||||
| 80 | 16 | ▶ | unless($ds->{freq}[$i] > 0) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 81 | { | ||||||||||
| 82 | 10 | undef($ds->{$_}[$i]) for keys %dbits | |||||||||
| 83 | } | ||||||||||
| 84 | } | ||||||||||
| 85 | |||||||||||
| 86 | 2 | my $us = $self->{conn_stats}{up}; | |||||||||
| 87 | 2 | for my $i (0..$#{$us->{chanid}}) | |||||||||
| 88 | { | ||||||||||
| 89 | 8 | ▶ | unless($us->{chanid}[$i] > 0) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 90 | { | ||||||||||
| 91 | 4 | undef($us->{$_}[$i]) for keys %ubits | |||||||||
| 92 | } | ||||||||||
| 93 | } | ||||||||||
| 94 | |||||||||||
| 95 | 2 | return; | |||||||||
| 96 | } | ||||||||||
| 97 | |||||||||||
| 98 | |||||||||||
| 99 | 7 | 1; | |||||||||
| 100 | __END__ | ||||||||||