RFXCOM/Decoder/Digimax.pm

filter: Statementstmt 100% 42 / 42 Branchbran 100% 8 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 100% 60 / 60 SCAR 16.1
CC
5
Cov
100%
decode
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 5.0
« RFXCOM/Response.pm ↑ Summary RFXCOM/Decoder/RFXMeter.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::Digimax;
4 3 $Device::RFXCOM::Decoder::Digimax::VERSION = '1.142010';
5 # ABSTRACT: Device::RFXCOM::Decoder::Digimax decode Digimax 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_DIGIMAX_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 base 'Device::RFXCOM::Decoder';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use Device::RFXCOM::Response::Thermostat;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 3 ▶use Device::RFXCOM::Decoder qw/hi_nibble lo_nibble nibble_sum/;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15  
16 sub decode {
17 86 ▶ my ($self, $parent, $message, $bytes, $bits, $result) = @_;
Subroutine decode: called CC=5 SCAR=16.1
Pod documented
18 86 ▶ return unless ($bits == 44);
Branch: 1 branch
BranchTrueFalseTotal
unless $bits == 44 81 5 86
19 5 my $p =
20 hi_nibble($bytes->[0]) + lo_nibble($bytes->[0]) +
21 hi_nibble($bytes->[1]) + lo_nibble($bytes->[1]) +
22 hi_nibble($bytes->[2]) + lo_nibble($bytes->[2]);
23 5 $p &= 0xf;
24 5 ▶ return unless ($p == 0xf);
Branch: 1 branch
BranchTrueFalseTotal
unless $p == 15 1 4 5
25  
26 4 $p =
27 hi_nibble($bytes->[3]) + lo_nibble($bytes->[3]) +
28 hi_nibble($bytes->[4]) + lo_nibble($bytes->[4]) +
29 hi_nibble($bytes->[5]);
30 4 $p &= 0xf;
31 4 ▶ return unless ($p == 0xf);
Branch: 1 branch
BranchTrueFalseTotal
unless $p == 15 1 3 4
32  
33 3 my $state =
34 [
35 'undef', 'demand', 'satisfied', 'init'
36 ]->[hi_nibble($bytes->[2])&0x3];
37  
38 3 my $temp = $bytes->[3];
39 3 my $set = $bytes->[4]&0x3f;
40 3 ▶ my $mode = $bytes->[4]&0x40 ? 'cool' : 'heat';
Branch: 1 branch
BranchTrueFalseTotal
$bytes->[4] & 64 ? : 1 2 3
41 3 my $device = sprintf 'digimax.%02x%02x', $bytes->[0], $bytes->[1];
42 3 printf STDERR "Thermostat: $device $state $temp $set $mode\n" if DEBUG;
43 3 push @{$result->{messages}},
44 Device::RFXCOM::Response::Thermostat->new(device => $device,
45 temp => $temp,
46 set => $set,
47 mode => $mode,
48 state => $state);
49 3 return 1;
50 }
51  
52 3 1;
53  
54 __END__
« RFXCOM/Response.pm ↑ Summary RFXCOM/Decoder/RFXMeter.pm »