RFXCOM/Decoder/OregonScale.pm

filter: Statementstmt 100% 40 / 40 Branchbran 100% 8 / 8 Conditioncond 100% 6 / 6 MC/DCmcdc 100% 4 / 4 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 100% 68 / 68 SCAR 19.5
CC
7
Cov
100%
decode
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 7.0
« RFXCOM/Decoder/CM119.pm ↑ Summary W800.pm »
1 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package Device::RFXCOM::Decoder::OregonScale;
4 3 $Device::RFXCOM::Decoder::OregonScale::VERSION = '1.142010';
5 # ABSTRACT: Device::RFXCOM::Decoder::OregonScale decode Oregon Scale RF messages
6  
7  
8 3 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use constant DEBUG => $ENV{DEVICE_RFXCOM_DECODER_OREGON_SCALE_DEBUG};
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use Device::RFXCOM::Decoder qw/hi_nibble lo_nibble/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 our @ISA = qw(Device::RFXCOM::Decoder);
13  
14  
15 sub decode {
16 58 ▶ my ($self, $parent, $message, $bytes, $bits, $result) = @_;
Subroutine decode: called CC=7 SCAR=19.5
Pod documented
17 58 ▶ if ($bits == 64 && lo_nibble($bytes->[0]) == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bits == 64 and lo_nibble($bytes->[0]) == 3) 1 57 58
Condition100%3/3
$bits == 64 and lo_nibble($bytes->[0]) == 3
!ll&&!rl&&r
5611
MC/DC100%2/2
$bits == 64 and lo_nibble($bytes->[0]) == 3
$bits == 64 lo_nibble($bytes->[0]) == 3
Truth table100%3/3
A and B
A= $bits == 64B= lo_nibble($bytes->[0]) == 3
ABresult
0X0
100
111
18 1 return parse_gr101($self, $parent, $message, $bytes, $bits, $result);
19 }
20 57 ▶ return unless (scalar @$bytes == 7);
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @$bytes == 7 53 4 57
21 4 ▶ return unless (($bytes->[0]&0xf0) == ($bytes->[5]&0xf0) &&
Branch: 1 branch
BranchTrueFalseTotal
unless ($bytes->[0] & 240) == ($bytes->[5] & 240) and ($bytes->[1] & 15) == ($bytes->[6] & 15) 2 2 4
Condition100%3/3
($bytes->[0] & 240) == ($bytes->[5] & 240) and ($bytes->[1] & 15) == ($bytes->[6] & 15)
!ll&&!rl&&r
112
MC/DC100%2/2
($bytes->[0] & 240) == ($bytes->[5] & 240) and ($bytes->[1] & 15) == ($bytes->[6] & 15)
($bytes->[0] & 240) == ($bytes->[5] & 240) ($bytes->[1] & 15) == ($bytes->[6] & 15)
Truth table100%3/3
A and B
A= ($bytes->[0] & 240) == ($bytes->[5] & 240)B= ($bytes->[1] & 15) == ($bytes->[6] & 15)
ABresult
0X0
100
111
22 ($bytes->[1]&0xf) == ($bytes->[6]&0xf));
23 2 my $weight =
24 sprintf "%x%02x%x", $bytes->[5]&0x1, $bytes->[4], hi_nibble($bytes->[3]);
25 2 ▶ return unless ($weight =~ /^\d+$/);
Branch: 1 branch
BranchTrueFalseTotal
unless $weight =~ /^\d+$/ 1 1 2
26 1 $weight /= 10;
27 1 my $dev_str = sprintf 'bwr102.%02x', hi_nibble($bytes->[1]);
28 1 my $unknown = sprintf "%x%x", lo_nibble($bytes->[3]), hi_nibble($bytes->[2]);
29 1 push @{$result->{messages}},
30 Device::RFXCOM::Response::Sensor->new(device => $dev_str,
31 measurement => 'weight',
32 value => $weight,
33 unknown => $unknown,
34 );
35 1 return 1;
36 }
37  
38  
39 sub parse_gr101 {
40 1 ▶ my ($self, $parent, $message, $bytes, $bits, $result) = @_;
Subroutine parse_gr101: called CC=1 SCAR=0.0
Pod documented
41  
42 1 my $weight =
43 (lo_nibble($bytes->[4])<<12) + ($bytes->[3]<<4) + ($bytes->[2]>>4);
44 1 $weight = sprintf "%.1f", $weight/400.8;
45 1 my $dev_str = sprintf 'gr101.%02x', $bytes->[1];
46 1 push @{$result->{messages}},
47 Device::RFXCOM::Response::Sensor->new(device => $dev_str,
48 measurement => 'weight',
49 value => $weight);
50 1 return 1;
51 }
52  
53 3 1;
54  
55 __END__
« RFXCOM/Decoder/CM119.pm ↑ Summary W800.pm »