| 1 | package Acme::FishFarm::OxygenMaintainer; | ||||||||||
| 2 | |||||||||||
| 3 | 4 | ▶ | use 5.006; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 4 | ▶ | use Carp "croak"; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | =head1 NAME | ||||||||||
| 9 | |||||||||||
| 10 | Acme::FishFarm::OxygenMaintainer - Oxygen Maintainer for Acme::FishFarm | ||||||||||
| 11 | |||||||||||
| 12 | =head1 VERSION | ||||||||||
| 13 | |||||||||||
| 14 | Version 1.00 | ||||||||||
| 15 | |||||||||||
| 16 | =cut | ||||||||||
| 17 | |||||||||||
| 18 | 4 | our $VERSION = '1.00'; | |||||||||
| 19 | |||||||||||
| 20 | |||||||||||
| 21 | =head1 SYNOPSIS | ||||||||||
| 22 | |||||||||||
| 23 | use Acme::FishFarm::OxygenMaintainer; | ||||||||||
| 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 | =head2 install ( %options ) | ||||||||||
| 33 | |||||||||||
| 34 | Installs an oxygen maintainer system. | ||||||||||
| 35 | |||||||||||
| 36 | The supported C<%options> are: | ||||||||||
| 37 | |||||||||||
| 38 | =over 4 | ||||||||||
| 39 | |||||||||||
| 40 | =item current_DO | ||||||||||
| 41 | |||||||||||
| 42 | The default DO is to C<8 mg/L>. | ||||||||||
| 43 | |||||||||||
| 44 | =item DO_threshold | ||||||||||
| 45 | |||||||||||
| 46 | The default threshold is C<5 mg/L>. | ||||||||||
| 47 | |||||||||||
| 48 | If the current DO level is lower than this threshold, then your fish is lacking oxygen. | ||||||||||
| 49 | |||||||||||
| 50 | =item DO_generation_volume | ||||||||||
| 51 | |||||||||||
| 52 | This is the rate of oxygen generation. | ||||||||||
| 53 | |||||||||||
| 54 | The default value is C<0.2 mg/L per unit time> | ||||||||||
| 55 | |||||||||||
| 56 | =back | ||||||||||
| 57 | |||||||||||
| 58 | =cut | ||||||||||
| 59 | |||||||||||
| 60 | sub install { | ||||||||||
| 61 | 5 | ▶ | my $class = shift; | ||||||||
|
Subroutine
install: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||
| 62 | 5 | my %options = @_; | |||||||||
| 63 | |||||||||||
| 64 | 5 | ▶ | if ( not $options{current_DO} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 65 | 2 | $options{current_DO} = 8; | |||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | 5 | ▶ | if ( not $options{DO_threshold} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 69 | 4 | $options{DO_threshold} = 5; | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | 5 | ▶ | if ( not $options{DO_generation_volume} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 73 | 5 | $options{DO_generation_volume} = 0.2; | |||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | 5 | $options{is_DO_low} = 0; # might be useless :) | |||||||||
| 77 | |||||||||||
| 78 | 5 | bless \%options, "Acme::FishFarm::OxygenMaintainer"; | |||||||||
| 79 | } | ||||||||||
| 80 | |||||||||||
| 81 | |||||||||||
| 82 | =head1 DISSOLVED OXYGEN SENSOR RELATED METHODS | ||||||||||
| 83 | |||||||||||
| 84 | =head2 current_DO ( $new_DO ) | ||||||||||
| 85 | |||||||||||
| 86 | Sets / returns the current DO level of the water. | ||||||||||
| 87 | |||||||||||
| 88 | C<$new_DO> is optional. If present, the current DO will be set to C<$new_DO>. Otherwise, returns the current DO reading. | ||||||||||
| 89 | |||||||||||
| 90 | =cut | ||||||||||
| 91 | |||||||||||
| 92 | sub current_DO { | ||||||||||
| 93 | 13 | ▶ | ref( my $self = shift ) or croak "Please use this the OO way"; | ||||||||
|
Subroutine
current_DO: called CC=3 SCAR=11.0
Pod
documented
Branch: 1 branch
| |||||||||||
| 94 | 13 | ▶ | if ( @_ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 95 | 6 | $self->{current_DO} = shift; | |||||||||
| 96 | } else { | ||||||||||
| 97 | 7 | $self->{current_DO}; | |||||||||
| 98 | } | ||||||||||
| 99 | |||||||||||
| 100 | } | ||||||||||
| 101 | |||||||||||
| 102 | =head2 DO_threshold | ||||||||||
| 103 | |||||||||||
| 104 | Returns the DO threshold. | ||||||||||
| 105 | |||||||||||
| 106 | =cut | ||||||||||
| 107 | |||||||||||
| 108 | sub DO_threshold { | ||||||||||
| 109 | 5 | ▶ | ref( my $self = shift ) or croak "Please use this the OO way"; | ||||||||
|
Subroutine
DO_threshold: called CC=2 SCAR=7.2
Pod
documented
Branch: 1 branch
| |||||||||||
| 110 | 5 | $self->{DO_threshold}; | |||||||||
| 111 | } | ||||||||||
| 112 | |||||||||||
| 113 | =head2 set_DO_threshold ( $new_DO_threshold ) | ||||||||||
| 114 | |||||||||||
| 115 | Sets the DO threshold. | ||||||||||
| 116 | |||||||||||
| 117 | =cut | ||||||||||
| 118 | |||||||||||
| 119 | sub set_DO_threshold { | ||||||||||
| 120 | 2 | ▶ | ref( my $self = shift ) or croak "Please use this the OO way"; | ||||||||
|
Subroutine
set_DO_threshold: called CC=2 SCAR=7.1
Pod
documented
Branch: 1 branch
| |||||||||||
| 121 | 2 | my $new_do_threshold = shift; | |||||||||
| 122 | 2 | $self->{DO_threshold} = $new_do_threshold; | |||||||||
| 123 | } | ||||||||||
| 124 | |||||||||||
| 125 | =head2 is_low_DO | ||||||||||
| 126 | |||||||||||
| 127 | Returns C<1> if the DO level is less than the threshold value. Otherwise, returns C<0>. | ||||||||||
| 128 | |||||||||||
| 129 | =cut | ||||||||||
| 130 | |||||||||||
| 131 | sub is_low_DO { | ||||||||||
| 132 | 10 | ▶ | ref( my $self = shift ) or croak "Please use this the OO way"; | ||||||||
|
Subroutine
is_low_DO: called CC=3 SCAR=11.0
Pod
documented
Branch: 1 branch
| |||||||||||
| 133 | 10 | ▶ | if ( $self->{current_DO} < $self->{DO_threshold} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 134 | 5 | return 1; | |||||||||
| 135 | } else { | ||||||||||
| 136 | 5 | return 0; | |||||||||
| 137 | } | ||||||||||
| 138 | } | ||||||||||
| 139 | |||||||||||
| 140 | |||||||||||
| 141 | =head1 OXYGEN GENERATING RELATED METHODS | ||||||||||
| 142 | |||||||||||
| 143 | =head2 oxygen_generation_volume | ||||||||||
| 144 | |||||||||||
| 145 | Returns the oxygen generation rate. | ||||||||||
| 146 | |||||||||||
| 147 | =cut | ||||||||||
| 148 | |||||||||||
| 149 | sub oxygen_generation_volume { | ||||||||||
| 150 | 3 | ▶ | ref( my $self = shift ) or croak "Please use this the OO way"; | ||||||||
|
Subroutine
oxygen_generation_volume: called CC=2 SCAR=7.2
Pod
documented
Branch: 1 branch
| |||||||||||
| 151 | 3 | $self->{DO_generation_volume}; | |||||||||
| 152 | } | ||||||||||
| 153 | |||||||||||
| 154 | =head2 set_oxygen_generation_volume ( $new_rate ) | ||||||||||
| 155 | |||||||||||
| 156 | Sets the new oxygen generation rate to C<$new_rate>. | ||||||||||
| 157 | |||||||||||
| 158 | =cut | ||||||||||
| 159 | |||||||||||
| 160 | sub set_oxygen_generation_volume { | ||||||||||
| 161 | 1 | ▶ | ref( my $self = shift ) or croak "Please use this the OO way"; | ||||||||
|
Subroutine
set_oxygen_generation_volume: called CC=2 SCAR=7.2
Pod
documented
Branch: 1 branch
| |||||||||||
| 162 | 1 | $self->{DO_generation_volume} = shift; | |||||||||
| 163 | } | ||||||||||
| 164 | |||||||||||
| 165 | =head2 generate_oxygen | ||||||||||
| 166 | |||||||||||
| 167 | Pumps oxygen into the water based on the diffusion rate. The current DO value will increase every time this action is invoked. | ||||||||||
| 168 | |||||||||||
| 169 | Take note that this will generate oxygen no matter what. Make sure you check the DO content before pumping oxygen into your tank. See C<is_low_DO> for more info. | ||||||||||
| 170 | |||||||||||
| 171 | =cut | ||||||||||
| 172 | |||||||||||
| 173 | sub generate_oxygen { | ||||||||||
| 174 | 2 | ▶ | ref( my $self = shift ) or croak "Please use this the OO way"; | ||||||||
|
Subroutine
generate_oxygen: called CC=2 SCAR=7.2
Pod
documented
Branch: 1 branch
| |||||||||||
| 175 | 2 | $self->{current_DO} += $self->{DO_generation_volume}; | |||||||||
| 176 | } | ||||||||||
| 177 | |||||||||||
| 178 | =head1 AUTHOR | ||||||||||
| 179 | |||||||||||
| 180 | Raphael Jong Jun Jie, C<< <ellednera at cpan.org> >> | ||||||||||
| 181 | |||||||||||
| 182 | =head1 BUGS | ||||||||||
| 183 | |||||||||||
| 184 | Please report any bugs or feature requests to C<bug-. at rt.cpan.org>, or through | ||||||||||
| 185 | the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=.>. I will be notified, and then you'll | ||||||||||
| 186 | automatically be notified of progress on your bug as I make changes. | ||||||||||
| 187 | |||||||||||
| 188 | |||||||||||
| 189 | |||||||||||
| 190 | |||||||||||
| 191 | =head1 SUPPORT | ||||||||||
| 192 | |||||||||||
| 193 | You can find documentation for this module with the perldoc command. | ||||||||||
| 194 | |||||||||||
| 195 | perldoc Acme::FishFarm::OxygenMaintainer | ||||||||||
| 196 | |||||||||||
| 197 | |||||||||||
| 198 | You can also look for information at: | ||||||||||
| 199 | |||||||||||
| 200 | =over 4 | ||||||||||
| 201 | |||||||||||
| 202 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||
| 203 | |||||||||||
| 204 | L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=.> | ||||||||||
| 205 | |||||||||||
| 206 | =item * CPAN Ratings | ||||||||||
| 207 | |||||||||||
| 208 | L<https://cpanratings.perl.org/d/.> | ||||||||||
| 209 | |||||||||||
| 210 | =item * Search CPAN | ||||||||||
| 211 | |||||||||||
| 212 | L<https://metacpan.org/release/.> | ||||||||||
| 213 | |||||||||||
| 214 | =back | ||||||||||
| 215 | |||||||||||
| 216 | |||||||||||
| 217 | =head1 ACKNOWLEDGEMENTS | ||||||||||
| 218 | |||||||||||
| 219 | Besiyata d'shmaya | ||||||||||
| 220 | |||||||||||
| 221 | =head1 LICENSE AND COPYRIGHT | ||||||||||
| 222 | |||||||||||
| 223 | This software is Copyright (c) 2021 by Raphael Jong Jun Jie. | ||||||||||
| 224 | |||||||||||
| 225 | This is free software, licensed under: | ||||||||||
| 226 | |||||||||||
| 227 | The Artistic License 2.0 (GPL Compatible) | ||||||||||
| 228 | |||||||||||
| 229 | |||||||||||
| 230 | =cut | ||||||||||
| 231 | |||||||||||
| 232 | 4 | 1; # End of Acme::FishFarm::OxygenMaintainer | |||||||||