FishFarm/WaterConditionMonitor.pm

filter: Statementstmt 92.5% 124 / 134 Branchbran 62.0% 62 / 100 Conditioncond 83.3% 5 / 6 MC/DCmcdc 75.0% 3 / 4 Subroutinesub 87.1% 27 / 31 Podpod 100% 26 / 26 totaltotal 82.0% 247 / 301 CC 53 SCAR 13.2
CC
53
Cov
80%
lighted_LED_count
6.0
on_LED_pH
6.0
on_LED_temperature
6.0
CRAP 3.7
↑ Summary FishFarm/Feeder.pm »
1 package Acme::FishFarm::WaterConditionMonitor;
2  
3 3 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Carp "croak";
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 Acme::FishFarm::WaterConditionMonitor - Water Condition Monitor for Acme::FishFarm
11  
12 =head1 VERSION
13  
14 Version 1.00
15  
16 =cut
17  
18 3 our $VERSION = '1.00';
19  
20  
21 =head1 SYNOPSIS
22  
23 use Acme::FishFarm::WaterConditionMonitor;
24 # missing stuff will be added in the next release
25  
26 =head1 EXPORT
27  
28 None
29  
30 =head1 CREATION RELATED SUBROUTINES/METHODS
31  
32 Only 3 sensors are built-in. However, there is a 4th socket for the oxygen maintainer. For this socket, you'll need to manuall connect an Acme::FishFarm::OxygenMaintainer object by calling the C<add_oxygen_maintainer> method.
33  
34 More sockets might be available in the future.
35  
36 =head2 install ( %sensors )
37  
38 Installs a water condition monitoring system.
39  
40 The C<%sensors> included are:
41  
42 =over 4
43  
44 =item pH
45  
46 Optional. The default threshold range is C<[6.5, 7.5]> and the default pH is C<7.0>.
47  
48 This will set the threshold value of the water pH. Please pass in an array reference to this key
49 in the form of C<[min_pH, max_pH]>
50  
51 The values are in the range of C<1-14>.
52  
53 =item temperature
54  
55 Optional. The default threshold range is C<[20, 25]> degree celcius and the default temprature is C<25>.
56  
57 This will set the threshold value of the water temperature. Please pass in an array reference to this key
58 in the form of C<[min_temperature, max_temperature]>
59  
60 The ranges of values are between 0 and 50 degree B<celciuls>
61  
62 =item turbidity
63  
64 Optional. The default threshold is C<180 ntu> and the default turbidity is set to C<10 ntu>.
65  
66 This will set the threshold of the turbidity of the water.
67  
68 The range of values are between 0 and 300 ntu.
69  
70 =back
71  
72 =cut
73  
74 sub install {
75 3 ▶ my $class = shift;
Subroutine install: called CC=4 SCAR=13.9
Pod documented
76 3 my %sensors = @_;
77
78 3 ▶ if ( not $sensors{pH} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($sensors{"pH"}) 3 0 3
79 3 $sensors{pH_range} = [6.5, 7.5];
80 3 $sensors{current_pH} = 7.0;
81 3 $sensors{pH_LED_on} = 0;
82 }
83
84 3 ▶ if ( not $sensors{temperature} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($sensors{"temperature"}) 3 0 3
85 3 $sensors{temperature_range} = [20, 25];
86 3 $sensors{current_temperature} = 23;
87 3 $sensors{temperature_LED_on} = 0;
88 }
89
90 3 ▶ if ( not $sensors{turbidity} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($sensors{"turbidity"}) 3 0 3
91 3 $sensors{turbidity_threshold} = 180;
92 3 $sensors{current_turbidity} = 10;
93 3 $sensors{turbidity_LED_on} = 0;
94 }
95
96 # low DO led, use Acme::FishFarm::OxygenMaintainer to determine
97 3 $sensors{DO_LED_on} = 0;
98
99 3 $sensors{lighted_LED_count} = 0;
100 3 $sensors{short_buzzer_on} = 0;
101 3 $sensors{long_buzzer_on} = 0;
102
103 3 bless \%sensors, "Acme::FishFarm::WaterConditionMonitor";
104 }
105  
106  
107 =head2 add_oxygen_maintainer ( $oxygen_maintainer )
108  
109 Connects the oxygen maintainer to this monitoring system.
110  
111 For now, this module can only check if the oxygen is lacking or not. This module contains a user friendly method compared to the standard terminology used in the C<Acme::FishFarm::OxygenMaintainer> module. Other user friendly methods will be added in the future.
112  
113 =cut
114  
115 sub add_oxygen_maintainer {
116 3 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine add_oxygen_maintainer: called CC=3 SCAR=12.5
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 3 3
117 3 ▶ if ( ref( my $oxygen_maintainer = shift ) ne "Acme::FishFarm::OxygenMaintainer") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref(my $oxygen_maintainer = shift()) ne 'Acme::FishFarm::OxygenMaintainer') { } 0 3 3
118 0 croak "Please pass in an Acme::FishFarm::OxygenMaintainer object!";
119 } else {
120 3 $self->{oxygen_maintainer} = $oxygen_maintainer;
121 }
122 }
123  
124 =head1 WATER CONDITIONS RELATED SUBROUTINES/METHODS
125  
126 =head2 current_ph ( $new_ph )
127  
128 Sets / returns the current pH of the water.
129  
130 C<$new_pH> is optional. If present, the current pH will be set to C<$new_ph>. Otherwise, returns the current pH reading.
131  
132 =cut
133  
134 sub current_ph {
135 7 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine current_ph: called CC=3 SCAR=11.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 7 7
136 7 ▶ if ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 4 3 7
137 4 $self->{current_pH} = shift;
138 } else {
139 3 $self->{current_pH};
140 }
141 }
142  
143 =head2 ph_threshold
144  
145 Returns the pH threshold as an array ref.
146  
147 =cut
148  
149 sub ph_threshold {
150 3 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine ph_threshold: called CC=2 SCAR=7.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 3 3
151 3 $self->{pH_range};
152 }
153  
154 =head2 set_ph_threshold ( $ph_value )
155  
156 Sets the pH threshold.
157  
158 =cut
159  
160 sub set_ph_threshold {
161 1 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine set_ph_threshold: called CC=3 SCAR=11.4
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 1 1
162 1 my $new_ph_range_ref = shift;
163 1 ▶ croak "Please supply an array ref to set new pH range" if ref( $new_ph_range_ref ) ne ref( [] );
Branch: 1 branch
BranchTrueFalseTotal
if ref $new_ph_range_ref ne ref [] 0 1 1
164 1 $self->{pH_range} = $new_ph_range_ref;
165 }
166  
167 =head2 ph_is_normal
168  
169 Returns true if the current pH is within the set range of threshold.
170  
171 The pH LED will light up and a short buzzer will be turned on if the pH is not normal.
172  
173 The long buzzer will not be affected, you'll need to turn it on yourself.
174 =cut
175  
176 sub ph_is_normal {
177 7 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine ph_is_normal: called CC=5 SCAR=16.1
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 7 7
178  
179 7 _tweak_buzzers( $self );
180
181 7 ▶ if ( $self->{current_pH} >= $self->{pH_range}[0] and $self->{current_pH} <= $self->{pH_range}[1] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'current_pH'} >= $self->{'pH_range'}[0] and $self->{'current_pH'} <= $self->{'pH_range'}[1]) { } 2 5 7
Condition100%3/3
$self->{"current_pH"} >= $self->{"pH_range"}[0] and $self->{"current_pH"} <= $self->{"pH_range"}[1]
!ll&&!rl&&r
322
MC/DC100%2/2
$self->{"current_pH"} >= $self->{"pH_range"}[0] and $self->{"current_pH"} <= $self->{"pH_range"}[1]
$self->{"current_pH"} >= $self->{"pH_range"}[0] $self->{"current_pH"} <= $self->{"pH_range"}[1]
Truth table100%3/3
A and B
A= $self->{"current_pH"} >= $self->{"pH_range"}[0]B= $self->{"current_pH"} <= $self->{"pH_range"}[1]
ABresult
0X0
100
111
182
183 # if still on, switch it off, it's normal now
184 2 ▶ if ( $self->is_on_LED_pH ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_on_LED_pH) 1 1 2
185 1 $self->{pH_LED_on} = 0;
186 }
187
188 2 return 1;
189 } else {
190 5 $self->{pH_LED_on} = 1;
191 5 return 0;
192 }
193 }
194  
195 =head2 current_temperature ( $new_temperature )
196  
197 Sets / returns the current temperature of the water.
198  
199 C<$new_temperature> is optional. If present, the current temperature will be set to C<$new_temperature>. Otherwise, returns the current temperature reading.
200  
201 =cut
202  
203 sub current_temperature {
204 5 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine current_temperature: called CC=3 SCAR=11.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 5 5
205
206 5 ▶ if ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 3 2 5
207 3 $self->{current_temperature} = shift;
208 } else {
209 2 $self->{current_temperature};
210 }
211
212 }
213  
214 =head2 temperature_threshold
215  
216 Returns the acceptable temperature range as an array ref.
217  
218 =cut
219  
220 sub temperature_threshold {
221 3 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine temperature_threshold: called CC=2 SCAR=7.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 3 3
222 3 $self->{temperature_range};
223 }
224  
225 =head2 set_temperature_threshold ( $celcius )
226  
227 Sets the water temperature threshold.
228  
229 =cut
230  
231 sub set_temperature_threshold {
232 1 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine set_temperature_threshold: called CC=3 SCAR=11.4
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 1 1
233 1 my $new_temperature_range_ref = shift;
234 1 ▶ croak "Please supply an array ref to set new temperature range"
Branch: 1 branch
BranchTrueFalseTotal
if ref $new_temperature_range_ref ne ref [] 0 1 1
235 if ref( $new_temperature_range_ref ) ne ref( [] );
236 1 $self->{temperature_range} = $new_temperature_range_ref;
237 }
238  
239 =head2 temperature_is_normal
240  
241 Returns true if the current temperature is within the set range of threshold.
242  
243 =cut
244  
245 sub temperature_is_normal {
246 6 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine temperature_is_normal: called CC=5 SCAR=16.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 6 6
247  
248 6 _tweak_buzzers( $self );
249
250 6 ▶ if ( $self->{current_temperature} >= $self->{temperature_range}[0]
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'current_temperature'} >= $self->{'temperature_range'}[0] and $self->{'current_temperature'} <= $self->{'temperature_range'}[1]) { } 4 2 6
Condition66%2/3
$self->{"current_temperature"} >= $self->{"temperature_range"}[0] and $self->{"current_temperature"} <= $self->{"temperature_range"}[1]
!ll&&!rl&&r
024
MC/DC50%1/2
$self->{"current_temperature"} >= $self->{"temperature_range"}[0] and $self->{"current_temperature"} <= $self->{"temperature_range"}[1]
$self->{"current_temperature"} >= $self->{"temperature_range"}[0] $self->{"current_temperature"} <= $self->{"temperature_range"}[1]
Truth table66%2/3
A and B
A= $self->{"current_temperature"} >= $self->{"temperature_range"}[0]B= $self->{"current_temperature"} <= $self->{"temperature_range"}[1]
ABresult
0X0
100
111
251 and $self->{current_temperature} <= $self->{temperature_range}[1] ) {
252
253 # if still on, switch it off, it's normal now
254 4 ▶ if ( $self->is_on_LED_temperature ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_on_LED_temperature) 1 3 4
255 1 $self->{temperature_LED_on} = 0;
256 }
257
258 4 return 1;
259 } else {
260 2 $self->{temperature_LED_on} = 1;
261 2 return 0;
262 }
263 }
264  
265 =head2 lacking_oxygen
266  
267 Returns true if the current DO content is lower then the threshold.
268  
269 =cut
270  
271 sub lacking_oxygen {
272 4 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine lacking_oxygen: called CC=4 SCAR=13.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 4 4
273
274 4 _tweak_buzzers( $self );
275
276 4 ▶ if ( $self->{oxygen_maintainer}->is_low_DO) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'oxygen_maintainer'}->is_low_DO) { } 2 2 4
277 2 $self->{DO_LED_on} = 1;
278 2 return 1;
279 } else {
280 # if still on, switch it off, it's normal now
281 2 ▶ if ( $self->is_on_LED_DO ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_on_LED_DO) 1 1 2
282 1 $self->{DO_LED_on} = 0;
283 }
284
285 2 return 0;
286 }
287
288 }
289  
290 =head2 current_turbidity ( $new_turbidity )
291  
292 Sets / returns the current turbidity of the water.
293  
294 C<$new_turbidity> is optional. If present, the current turbidity will be set to C<$new_turbidity>. Otherwise, returns the current turbidity reading.
295  
296 =cut
297  
298 sub current_turbidity {
299 7 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine current_turbidity: called CC=3 SCAR=11.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 7 7
300
301 7 ▶ if ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 4 3 7
302 4 $self->{current_turbidity} = shift;
303 } else {
304 3 $self->{current_turbidity};
305 }
306
307 }
308  
309 =head2 turbidity_threshold
310  
311 Returns the turbidity threshold.
312  
313 =cut
314  
315 sub turbidity_threshold {
316 3 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine turbidity_threshold: called CC=2 SCAR=7.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 3 3
317 3 $self->{turbidity_threshold};
318 }
319  
320 =head2 set_turbidity_threshold ( $new_turbidity_threshold )
321  
322 Sets the turbidity threshold to C<$new_turbidity_threshold>.
323  
324 =cut
325  
326 sub set_turbidity_threshold {
327 2 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine set_turbidity_threshold: called CC=2 SCAR=7.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 2 2
328  
329 2 $self->{turbidity_threshold} = shift;
330 }
331  
332 =head2 water_dirty
333  
334 Returns true if the current turbidity is highter then the threshold.
335  
336 =cut
337  
338 sub water_dirty {
339 5 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine water_dirty: called CC=4 SCAR=14.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 5 5
340
341 5 _tweak_buzzers( $self );
342
343 5 ▶ if ( $self->{current_turbidity} >= $self->{turbidity_threshold} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'current_turbidity'} >= $self->{'turbidity_threshold'}) { } 4 1 5
344
345 4 $self->{turbidity_LED_on} = 1;
346 4 return 1;
347 } else {
348  
349 # if still on, switch it off, it's normal now
350 1 ▶ if ( $self->is_on_LED_turbidity ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_on_LED_turbidity) 1 0 1
351 1 $self->{turbidity_LED_on} = 0;
352 }
353
354 1 return 0;
355 }
356 }
357  
358  
359 # these 2 should be wrappers of something in the future
360 =head1 BUZZER RELATED SUBROUTINES/METHODS
361  
362 =head2 is_on_buzzer_short
363  
364 Returns true if the short buzzer is turned on.
365  
366 A short buzzer will buzz if there is 1 abnormal condition. If more than 1 abnormal conditions are present, the long buzzer will be turned on and this short buzzer will be turned off so that it's not too noisy :)
367  
368 =cut
369  
370 sub is_on_buzzer_short {
371 12 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine is_on_buzzer_short: called CC=2 SCAR=7.1
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 12 12
372 12 _tweak_buzzers( $self );
373 12 return $self->{short_buzzer_on};
374 }
375  
376  
377 =head2 is_on_buzzer_long
378  
379 Returns true if the long buzzer is turned on and also turns off the short buzzer to reduce noise.
380  
381 =cut
382  
383 sub is_on_buzzer_long {
384 13 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine is_on_buzzer_long: called CC=2 SCAR=7.1
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 13 13
385 13 _tweak_buzzers( $self );
386 13 return $self->{long_buzzer_on};
387 }
388  
389 =head1 Private Methods for Buzzers
390  
391 =over 4
392  
393 =item &_tweak_buzzers ( $self )
394  
395 Tweak the buzzers. It's either the short buzzer or the long buzzer switched on only.
396  
397 =back
398  
399 =cut
400  
401 sub _tweak_buzzers {
402 47 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine _tweak_buzzers: called CC=5 SCAR=16.4
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 47 47
403
404 # short buzzer
405 47 ▶ if ( $self->lighted_LED_count == 1 ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->lighted_LED_count == 1) { } 13 34 47
elsif ($self->lighted_LED_count > 1) { } 27 7 34
elsif ($self->lighted_LED_count == 0) { } 7 0 7
406 13 $self->{short_buzzer_on} = 1;
407 13 $self->{long_buzzer_on} = 0;
408
409 # long buzzer
410 } elsif ( $self->lighted_LED_count > 1 ) {
411 27 $self->{short_buzzer_on} = 0;
412 27 $self->{long_buzzer_on} = 1;
413
414 # no buzzer
415 } elsif ( $self->lighted_LED_count == 0 ) {
416 7 $self->{short_buzzer_on} = 0;
417 7 $self->{long_buzzer_on} = 0;
418
419 # somthing's wrong
420 } else {
421 0 die "Something's wrong with LED count";
422 }
423 }
424  
425 =head1 LED LIGHTS RELATED SUBROUTINES/METHODS
426  
427 An LED is lighted up if the corresponding parameter are in an abnormal state.
428 This action is to be done in through the main script.
429  
430 =head2 on_LED_pH
431  
432 Lights up the LED for pH sensor, indicating abnormal pH.
433  
434 =head2 is_on_LED_pH
435  
436 Returns true if the LED of pH is lighted up.
437  
438 =cut
439  
440 sub on_LED_pH {
441 0 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine on_LED_pH: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 0 0
442 0 $self->{pH_LED_on} = 1;
443 }
444  
445 sub is_on_LED_pH {
446 5 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine is_on_LED_pH: called CC=2 SCAR=7.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 5 5
447 5 return $self->{pH_LED_on};
448 }
449  
450 =head2 on_LED_temperature
451  
452 Lights up the LED for temperature sensor, indicating abnormal water temperature.
453  
454 =head2 is_on_LED_temperature
455  
456 Returns true if the LED of temperature is lighted up.
457  
458 =cut
459  
460 sub on_LED_temperature {
461 0 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine on_LED_temperature: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 0 0
462 0 $self->{temperature_LED_on} = 1;
463 }
464  
465 sub is_on_LED_temperature {
466 6 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine is_on_LED_temperature: called CC=2 SCAR=7.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 6 6
467 6 return $self->{temperature_LED_on};
468 }
469  
470 =head2 on_LED_DO
471  
472 Lights up the LED for dissolved oxygen sensor, indicating low DO content. You fish might die :)
473  
474 =head2 is_on_LED_DO
475  
476 Returns true if the LED of DO is lighted up.
477  
478 =cut
479  
480 sub on_LED_DO {
481 0 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine on_LED_DO: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 0 0
482 0 $self->{DO_LED_on} = 1;
483 }
484  
485 sub is_on_LED_DO {
486 3 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine is_on_LED_DO: called CC=2 SCAR=7.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 3 3
487 3 return $self->{DO_LED_on};
488 }
489  
490 =head2 on_LED_turbidity
491  
492 Light up the LED for turbidity sensor, indicating high level of waste etc. Fish might die :)
493  
494 =head2 is_on_LED_turbidity
495  
496 Returns true if the LED of DO is lighted up.
497  
498 =cut
499  
500 sub on_LED_turbidity {
501 0 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine on_LED_turbidity: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 0 0
502 0 $self->{turbidity_LED_on} = 1;
503 }
504  
505 sub is_on_LED_turbidity {
506 4 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine is_on_LED_turbidity: called CC=2 SCAR=7.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 4 4
507 4 return $self->{turbidity_LED_on};
508 }
509  
510 =head2 lighted_LED_count
511  
512 Returns the number of LEDs lighted up currently
513  
514 =cut
515  
516 sub lighted_LED_count {
517 101 ▶ ref( my $self = shift ) or croak "Please use this the OO way";
Subroutine lighted_LED_count: called CC=6 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref(my $self = shift()) or croak("Please use this the OO way") 0 101 101
518
519 101 my $total_led = 0;
520 101 ▶ $total_led++ if $self->{pH_LED_on};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"pH_LED_on"} 60 41 101
521 101 ▶ $total_led++ if $self->{temperature_LED_on};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"temperature_LED_on"} 53 48 101
522 101 ▶ $total_led++ if $self->{DO_LED_on};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"DO_LED_on"} 28 73 101
523 101 ▶ $total_led++ if $self->{turbidity_LED_on};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"turbidity_LED_on"} 42 59 101
524
525 101 return $total_led;
526 }
527  
528 =head1 AUTHOR
529  
530 Raphael Jong Jun Jie, C<< <ellednera at cpan.org> >>
531  
532 =head1 BUGS
533  
534 Please report any bugs or feature requests to C<bug-. at rt.cpan.org>, or through
535 the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=.>. I will be notified, and then you'll
536 automatically be notified of progress on your bug as I make changes.
537  
538  
539  
540  
541 =head1 SUPPORT
542  
543 You can find documentation for this module with the perldoc command.
544  
545 perldoc Acme::FishFarm::WaterConditionMonitor
546  
547  
548 You can also look for information at:
549  
550 =over 4
551  
552 =item * RT: CPAN's request tracker (report bugs here)
553  
554 L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=.>
555  
556 =item * CPAN Ratings
557  
558 L<https://cpanratings.perl.org/d/.>
559  
560 =item * Search CPAN
561  
562 L<https://metacpan.org/release/.>
563  
564 =back
565  
566  
567 =head1 ACKNOWLEDGEMENTS
568  
569 Besiyata d'shmaya
570  
571 =head1 LICENSE AND COPYRIGHT
572  
573 This software is Copyright (c) 2021 by Raphael Jong Jun Jie.
574  
575 This is free software, licensed under:
576  
577 The Artistic License 2.0 (GPL Compatible)
578  
579  
580 =cut
581  
582 3 1; # End of Acme::FishFarm::WaterConditionMonitor
↑ Summary FishFarm/Feeder.pm »