RFXCOM/Decoder/Electrisave.pm

filter: Statementstmt 100% 39 / 39 Branchbran 100% 8 / 8 Conditioncond 100% 6 / 6 MC/DCmcdc 100% 3 / 3 Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 100% 65 / 65 SCAR 20.8
CC
8
Cov
100%
decode
8.0
BEGIN
1.0
BEGIN
1.0
CRAP 8.0
« RFXCOM/Decoder/HomeEasy.pm ↑ Summary RFXCOM/Encoder/X10.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::Electrisave;
4 3 $Device::RFXCOM::Decoder::Electrisave::VERSION = '1.142010';
5 # ABSTRACT: Device::RFXCOM::Decoder::Electrisave decode Electrisave 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_ELECTRISAVE_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::Sensor;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15 sub decode {
16 83 ▶ my ($self, $parent, $message, $bytes, $bits, $result) = @_;
Subroutine decode: called CC=8 SCAR=20.8
Pod documented
17 83 ▶ $bits == 120 or return;
Branch: 1 branch
BranchTrueFalseTotal
$bits == 120 or return 75 8 83
18  
19 8 ▶ ($bytes->[0]==0xea && $bytes->[9]==0xff && $bytes->[10]==0x5f) or return;
Branch: 1 branch
BranchTrueFalseTotal
$bytes->[0] == 234 and $bytes->[9] == 255 and $bytes->[10] == 95 or return 5 2 7
Condition100%6/6
$bytes->[0] == 234 and $bytes->[9] == 255 and $bytes->[10] == 95
!ll&&!rl&&r
242
$bytes->[0] == 234 and $bytes->[9] == 255
!ll&&!rl&&r
116
MC/DC100%3/3
$bytes->[0] == 234 and $bytes->[9] == 255 and $bytes->[10] == 95
$bytes->[0] == 234 $bytes->[9] == 255 $bytes->[10] == 95
Truth table100%4/4
A and B and C
A= $bytes->[0] == 234B= $bytes->[9] == 255C= $bytes->[10] == 95
ABCresult
0XX0
10X0
1100
1111
20  
21 2 my $device = sprintf "%02x", $bytes->[2];
22 2 my @ct = ();
23 2 $ct[1] = ( (($bytes->[3] ) )+(($bytes->[4]&0x3 )<<8) ) / 10;
24 2 $ct[2] = ( (($bytes->[4]&0xFC)>>2)+(($bytes->[5]&0xF )<<6) ) / 10;
25 2 $ct[3] = ( (($bytes->[5]&0xF0)>>4)+(($bytes->[6]&0x3F)<<4) ) / 10;
26 2 $ct[0] = $ct[1] + $ct[2] + $ct[3];
27 2 foreach my $index (0..3) {
28 8 ▶ my $dev = $device.($index ? '.'.$index : '');
Branch: 1 branch
BranchTrueFalseTotal
$index ? : 6 2 8
29 8 printf "electrisave d=%s current=%.2f\n", $dev, $ct[$index] if DEBUG;
30 8 push @{$result->{messages}},
31 Device::RFXCOM::Response::Sensor->new(device => 'electrisave.'.$dev,
32 measurement => 'current',
33 value => $ct[$index]);
34 }
35 2 ▶ push @{$result->{messages}},
Branch: 1 branch
BranchTrueFalseTotal
$bytes->[1] & 16 ? : 1 1 2
36 Device::RFXCOM::Response::Sensor->new(device => 'electrisave.'.$device,
37 measurement => 'battery',
38 value => (($bytes->[1]&0x10)
39 ? 10 : 90),
40 units => '%');
41 2 return 1;
42 }
43  
44 3 1;
45  
46 __END__
« RFXCOM/Decoder/HomeEasy.pm ↑ Summary RFXCOM/Encoder/X10.pm »