line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Device::USB::PCSensor::HidTEMPer::Sensor; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
15752
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use Scalar::Util qw/ weaken /; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
154
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Device::USB::PCSensor::HidTEMPer::Sensor - Generic sensor class |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Version 0.0301 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = 0.0301; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
None |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
This module contains a generic class that all HidTEMPer sensors should inherit |
27
|
|
|
|
|
|
|
from keeping the implemented methods consistent, and making it possible to |
28
|
|
|
|
|
|
|
use the same code to contact every supported device. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 CONSTANTS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=over 3 |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=item * MAX_TEMPERATURE |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
The highest temperature(Celsius) this sensor can detect. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
1
|
|
5
|
use constant MAX_TEMPERATURE => 0; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
82
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=item * MIN_TEMPERATURE |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
The lowest temperature(Celsius) this sensor can detect. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=back |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
1
|
|
5
|
use constant MIN_TEMPERATURE => 0; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
254
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 METHODS |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=over 3 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item * new( $device ) |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Generic initializing method, creating a sensor object. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Input parameter |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$device = A pre-initialized Device::USB::PCSensor::HidTEMPer::Device that |
63
|
|
|
|
|
|
|
the sensor is connected to. This device will be used to handle communication. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub new |
68
|
|
|
|
|
|
|
{ |
69
|
1
|
|
|
1
|
1
|
1637
|
my $class = shift; |
70
|
1
|
|
|
|
|
5
|
my ( $unit ) = @_; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# All devices are required to spesify the temperature range |
73
|
1
|
|
|
|
|
5
|
my $self = { |
74
|
|
|
|
|
|
|
unit => $unit, |
75
|
|
|
|
|
|
|
}; |
76
|
|
|
|
|
|
|
|
77
|
1
|
|
|
|
|
9
|
weaken $self->{unit}; |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
4
|
bless $self, $class; |
80
|
1
|
|
|
|
|
5
|
return $self; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item * fahrenheit() |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Reads the current temperature and returns the corresponding value in |
86
|
|
|
|
|
|
|
fahrenheit degrees. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub fahrenheit |
91
|
|
|
|
|
|
|
{ |
92
|
1
|
|
|
1
|
1
|
509
|
my $self = shift; |
93
|
1
|
|
|
|
|
5
|
my $celsius = $self->celsius(); |
94
|
1
|
50
|
|
|
|
8
|
$celsius = 0 unless defined $celsius; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# Calculate and return the newly created degrees |
97
|
1
|
|
|
|
|
8
|
return ( ( $celsius * 9 ) / 5 ) + 32; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item * max() |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Returns the highest temperature(Celsius) the sensor can detect. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub max |
107
|
|
|
|
|
|
|
{ |
108
|
1
|
|
|
1
|
1
|
12
|
return $_[0]->MAX_TEMPERATURE; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item * min() |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Returns the lowest temperature(Celsius) the sensor can detect. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub min |
118
|
|
|
|
|
|
|
{ |
119
|
1
|
|
|
1
|
1
|
9
|
return $_[0]->MIN_TEMPERATURE; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item * celsius() |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Empty method that should be implemented in each sensor, returing the |
125
|
|
|
|
|
|
|
current degrees in celsius. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub celsius { |
130
|
1
|
|
|
1
|
1
|
3
|
return undef; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=back |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
This module internally includes and takes use of the following packages: |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
use Scalar::Util qw/ weaken /; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
This module uses the strict and warning pragmas. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 BUGS |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Please report any bugs or missing features using the CPAN RT tool. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 FOR MORE INFORMATION |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
None |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 AUTHOR |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Magnus Sulland < msulland@cpan.org > |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Thanks to Elan Ruusamäe for fixing some compatibility issues with perl 5.8 |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Copyright (c) 2010-2011 Magnus Sulland |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
164
|
|
|
|
|
|
|
under the same terms as Perl itself. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
1; |