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