X10/Device.pm untested

filter: Statementstmt 0.0% 0 / 23 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 49 CC 6 SCAR 16.2
CC
6
Cov
0%
new
6.0
on
6.0
off
6.0
CRAP 5.1
1  
2 # Copyright (c) 1999-2017 Rob Fugina <robf@fugina.com>
3 # Distributed under the terms of the GNU Public License, Version 3.0
4  
5 package X10::Device;
6  
7 sub new
8 {
9 my $type = shift;
10  
11 my $self = bless { @_ }, $type;
12  
13 $self->{house_code} = $self->{controller}->{house_code} unless $self->{house_code};
14  
15 return $self;
16 }
17  
18  
19 ### manipulating the device:
20  
21 sub on
22 {
23 my $self = shift;
24 return 0 unless $self->{controller};
25 $self->{controller}->on($self);
26 }
27  
28 sub off
29 {
30 my $self = shift;
31 return 0 unless $self->{controller};
32 $self->{controller}->off($self);
33 }
34  
35 sub dim
36 {
37 my $self = shift;
38 return 0 unless $self->{controller};
39 $self->{controller}->dim($self);
40 }
41  
42 sub bright
43 {
44 my $self = shift;
45 return 0 unless $self->{controller};
46 $self->{controller}->bright($self);
47 }
48  
49 ### access methods
50  
51 sub house_code
52 {
53 my $self = shift;
54 return $self->{house_code};
55 }
56  
57 sub unit_code
58 {
59 my $self = shift;
60 return $self->{unit_code};
61 }
62  
63 sub address
64 {
65 my $self = shift;
66 return sprintf("%s%02s", $self->house_code, $self->unit_code);
67 }
68  
69 1;
70