| 1 | package Acme::FishFarm::WaterLevelMaintainer; | ||||||||||
| 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::WaterLevelMaintainer - Water Level Maintainer for Acme::FishFarm | ||||||||||
| 11 | |||||||||||
| 12 | =head1 VERSION | ||||||||||
| 13 | |||||||||||
| 14 | Version 0.01 | ||||||||||
| 15 | |||||||||||
| 16 | =cut | ||||||||||
| 17 | |||||||||||
| 18 | 3 | our $VERSION = '0.01'; | |||||||||
| 19 | |||||||||||
| 20 | |||||||||||
| 21 | =head1 SYNOPSIS | ||||||||||
| 22 | |||||||||||
| 23 | use Acme::FishFarm::WaterLevelMaintainer; | ||||||||||
| 24 | |||||||||||
| 25 | =head1 EXPORT | ||||||||||
| 26 | |||||||||||
| 27 | None | ||||||||||
| 28 | |||||||||||
| 29 | =head1 CREATION RELATED MEHODS | ||||||||||
| 30 | |||||||||||
| 31 | =head2 install ( %options ) | ||||||||||
| 32 | |||||||||||
| 33 | Installs a water level maintainer system. This system only pumps water in if the water level is lower than the threshold value. | ||||||||||
| 34 | |||||||||||
| 35 | The supported C<%options> are: | ||||||||||
| 36 | |||||||||||
| 37 | =over 4 | ||||||||||
| 38 | |||||||||||
| 39 | =item current_water_level | ||||||||||
| 40 | |||||||||||
| 41 | The default water level is to C<5 m>. | ||||||||||
| 42 | |||||||||||
| 43 | =item low_water_level_threshold | ||||||||||
| 44 | |||||||||||
| 45 | The default threshold is C<2 m>. | ||||||||||
| 46 | |||||||||||
| 47 | If the current water level is lower than this threshold, then you need to pump water into the tank. | ||||||||||
| 48 | |||||||||||
| 49 | =item increase_water_level_by | ||||||||||
| 50 | |||||||||||
| 51 | This is the height of the water level to increase when the water is pumped in. | ||||||||||
| 52 | |||||||||||
| 53 | The default value is C<0.5 m>. | ||||||||||
| 54 | |||||||||||
| 55 | =back | ||||||||||
| 56 | |||||||||||
| 57 | =cut | ||||||||||
| 58 | |||||||||||
| 59 | sub install { | ||||||||||
| 60 | 2 | ▶ | my $class = shift; | ||||||||
|
Subroutine
install: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||
| 61 | 2 | my %options = @_; | |||||||||
| 62 | |||||||||||
| 63 | 2 | ▶ | if ( not $options{current_water_level} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | 2 | $options{current_water_level} = 5; | |||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | 2 | ▶ | if ( not $options{low_water_level_threshold} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 68 | 2 | $options{low_water_level_threshold} = 2; | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | 2 | ▶ | if ( not $options{increase_water_level_by} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 72 | 2 | $options{increase_water_level_by} = 0.5; | |||||||||
| 73 | } | ||||||||||
| 74 | |||||||||||
| 75 | 2 | $options{is_low_water_level} = 0; # might be useless :) | |||||||||
| 76 | |||||||||||
| 77 | 2 | bless \%options, "Acme::FishFarm::WaterLevelMaintainer"; | |||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | =head1 WATER LEVEL DETECTION RELATED METHODS | ||||||||||
| 81 | |||||||||||
| 82 | =head2 current_water_level ( $new_water_level ) | ||||||||||
| 83 | |||||||||||
| 84 | Sets / returns the current water level of the water. | ||||||||||
| 85 | |||||||||||
| 86 | C<$new_water_level> is optional. If present, the current water level will be set to C<$new_water_level>. Otherwise, returns the current water level (depth) in C<metres>. | ||||||||||
| 87 | |||||||||||
| 88 | =cut | ||||||||||
| 89 | |||||||||||
| 90 | sub current_water_level { | ||||||||||
| 91 | 7 | ▶ | ref( my $self = shift ) or croak "Please use this the OO way"; | ||||||||
|
Subroutine
current_water_level: called CC=3 SCAR=11.0
Pod
documented
Branch: 1 branch
| |||||||||||
| 92 | 7 | ▶ | if ( @_ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 93 | 3 | $self->{current_water_level} = shift; | |||||||||
| 94 | } else { | ||||||||||
| 95 | 4 | $self->{current_water_level}; | |||||||||
| 96 | } | ||||||||||
| 97 | } | ||||||||||
| 98 | |||||||||||
| 99 | =head2 low_water_level_threshold | ||||||||||
| 100 | |||||||||||
| 101 | Returns the low water level threshold. | ||||||||||
| 102 | |||||||||||
| 103 | =cut | ||||||||||
| 104 | |||||||||||
| 105 | sub low_water_level_threshold { | ||||||||||
| 106 | 3 | ▶ | ref( my $self = shift ) or croak "Please use this the OO way"; | ||||||||
|
Subroutine
low_water_level_threshold: called CC=2 SCAR=7.2
Pod
documented
Branch: 1 branch
| |||||||||||
| 107 | 3 | $self->{low_water_level_threshold}; | |||||||||
| 108 | } | ||||||||||
| 109 | |||||||||||
| 110 | =head2 set_low_water_level_threshold ( $new_threshold ) | ||||||||||
| 111 | |||||||||||
| 112 | Sets the low water level threshold. | ||||||||||
| 113 | |||||||||||
| 114 | =cut | ||||||||||
| 115 | |||||||||||
| 116 | sub set_low_water_level_threshold { | ||||||||||
| 117 | 1 | ▶ | ref( my $self = shift ) or croak "Please use this the OO way"; | ||||||||
|
Subroutine
set_low_water_level_threshold: called CC=2 SCAR=7.2
Pod
documented
Branch: 1 branch
| |||||||||||
| 118 | 1 | $self->{low_water_level_threshold} = shift; | |||||||||
| 119 | } | ||||||||||
| 120 | |||||||||||
| 121 | =head2 is_low_water_level | ||||||||||
| 122 | |||||||||||
| 123 | Returns C<1> if the DO level is less than the threshold value. Otherwise, returns C<0>. | ||||||||||
| 124 | |||||||||||
| 125 | =cut | ||||||||||
| 126 | |||||||||||
| 127 | sub is_low_water_level { | ||||||||||
| 128 | 3 | ▶ | ref( my $self = shift ) or croak "Please use this the OO way"; | ||||||||
|
Subroutine
is_low_water_level: called CC=3 SCAR=11.0
Pod
documented
Branch: 1 branch
| |||||||||||
| 129 | 3 | ▶ | if ( $self->{current_water_level} < $self->{low_water_level_threshold} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 130 | 2 | return 1; | |||||||||
| 131 | } else { | ||||||||||
| 132 | 1 | return 0; | |||||||||
| 133 | } | ||||||||||
| 134 | } | ||||||||||
| 135 | |||||||||||
| 136 | =head1 PUMPS RELATED METHODS | ||||||||||
| 137 | |||||||||||
| 138 | For the pumping mechanism, just assume that the pumps can actually pump in certain metres of water each time :) | ||||||||||
| 139 | |||||||||||
| 140 | =head2 water_level_increase_height | ||||||||||
| 141 | |||||||||||
| 142 | Returns the height of water level to increase each time the C<pump_water_in> is called. | ||||||||||
| 143 | |||||||||||
| 144 | =cut | ||||||||||
| 145 | |||||||||||
| 146 | sub water_level_increase_height { | ||||||||||
| 147 | 3 | ▶ | ref( my $self = shift ) or croak "Please use this the OO way"; | ||||||||
|
Subroutine
water_level_increase_height: called CC=2 SCAR=7.2
Pod
documented
Branch: 1 branch
| |||||||||||
| 148 | 3 | $self->{increase_water_level_by}; | |||||||||
| 149 | } | ||||||||||
| 150 | |||||||||||
| 151 | =head2 set_water_level_increase_height ( $new_height ) | ||||||||||
| 152 | |||||||||||
| 153 | Sets the height of water level to increase to C<$new_height>. | ||||||||||
| 154 | |||||||||||
| 155 | =cut | ||||||||||
| 156 | |||||||||||
| 157 | sub set_water_level_increase_height { | ||||||||||
| 158 | 1 | ▶ | ref( my $self = shift ) or croak "Please use this the OO way"; | ||||||||
|
Subroutine
set_water_level_increase_height: called CC=2 SCAR=7.2
Pod
documented
Branch: 1 branch
| |||||||||||
| 159 | 1 | $self->{increase_water_level_by} = shift; | |||||||||
| 160 | } | ||||||||||
| 161 | |||||||||||
| 162 | =head2 pump_water_in | ||||||||||
| 163 | |||||||||||
| 164 | Pumps water into the tank to increase the height of the water level. | ||||||||||
| 165 | |||||||||||
| 166 | =cut | ||||||||||
| 167 | |||||||||||
| 168 | sub pump_water_in { | ||||||||||
| 169 | 2 | ▶ | ref( my $self = shift ) or croak "Please use this the OO way"; | ||||||||
|
Subroutine
pump_water_in: called CC=2 SCAR=7.2
Pod
documented
Branch: 1 branch
| |||||||||||
| 170 | 2 | $self->{current_water_level} += $self->{increase_water_level_by}; | |||||||||
| 171 | } | ||||||||||
| 172 | |||||||||||
| 173 | =head1 AUTHOR | ||||||||||
| 174 | |||||||||||
| 175 | Raphael Jong Jun Jie, C<< <ellednera at cpan.org> >> | ||||||||||
| 176 | |||||||||||
| 177 | =head1 BUGS | ||||||||||
| 178 | |||||||||||
| 179 | Please report any bugs or feature requests to C<bug-. at rt.cpan.org>, or through | ||||||||||
| 180 | the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=.>. I will be notified, and then you'll | ||||||||||
| 181 | automatically be notified of progress on your bug as I make changes. | ||||||||||
| 182 | |||||||||||
| 183 | |||||||||||
| 184 | |||||||||||
| 185 | |||||||||||
| 186 | =head1 SUPPORT | ||||||||||
| 187 | |||||||||||
| 188 | You can find documentation for this module with the perldoc command. | ||||||||||
| 189 | |||||||||||
| 190 | perldoc Acme::FishFarm::WaterLevelMaintainer | ||||||||||
| 191 | |||||||||||
| 192 | |||||||||||
| 193 | You can also look for information at: | ||||||||||
| 194 | |||||||||||
| 195 | =over 4 | ||||||||||
| 196 | |||||||||||
| 197 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||
| 198 | |||||||||||
| 199 | L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=.> | ||||||||||
| 200 | |||||||||||
| 201 | =item * CPAN Ratings | ||||||||||
| 202 | |||||||||||
| 203 | L<https://cpanratings.perl.org/d/.> | ||||||||||
| 204 | |||||||||||
| 205 | =item * Search CPAN | ||||||||||
| 206 | |||||||||||
| 207 | L<https://metacpan.org/release/.> | ||||||||||
| 208 | |||||||||||
| 209 | =back | ||||||||||
| 210 | |||||||||||
| 211 | |||||||||||
| 212 | =head1 ACKNOWLEDGEMENTS | ||||||||||
| 213 | |||||||||||
| 214 | |||||||||||
| 215 | =head1 LICENSE AND COPYRIGHT | ||||||||||
| 216 | |||||||||||
| 217 | This software is Copyright (c) 2021 by Raphael Jong Jun Jie. | ||||||||||
| 218 | |||||||||||
| 219 | This is free software, licensed under: | ||||||||||
| 220 | |||||||||||
| 221 | The Artistic License 2.0 (GPL Compatible) | ||||||||||
| 222 | |||||||||||
| 223 | |||||||||||
| 224 | =cut | ||||||||||
| 225 | |||||||||||
| 226 | 3 | 1; # End of Acme::FishFarm::WaterLevelMaintainer | |||||||||