Acme-FishFarm

 view release on metacpan or  search on metacpan

lib/Acme/FishFarm/WaterConditionMonitor.pm  view on Meta::CPAN

package Acme::FishFarm::WaterConditionMonitor;

use 5.006;
use strict;
use warnings;
use Carp "croak";

=head1 NAME

Acme::FishFarm::WaterConditionMonitor - Water Condition Monitor for Acme::FishFarm

=head1 VERSION

Version 1.01

=cut

our $VERSION = '1.01';


=head1 SYNOPSIS

    use 5.010;

    use Acme::FishFarm::WaterConditionMonitor;
    use Acme::FishFarm::OxygenMaintainer;

    my $water_monitor = Acme::FishFarm::WaterConditionMonitor->install;
    my $oxygen = Acme::FishFarm::OxygenMaintainer->install( DO_generation_volume => 1.92 );

    $water_monitor->add_oxygen_maintainer( $oxygen );
    
    # always check water conditions before checking LEDs and buzzers
    # also, these four method will return 1 or 0, upon calling them, the status of LEDs and buzzers will also be updated
    $water_monitor->ph_is_normal;
    $water_monitor->temperature_is_normal;
    $water_monitor->lacking_oxygen;
    $water_monitor->water_dirty;
    
    if ( $water_monitor->is_on_LED_DO ) {
        # do something, same goes to the rest of the LEDs
    }

    if ( $water_monitor->is_on_buzzer_short ) {
        # do something
    } elsif ( $water_monitor->is_on_buzzer_long ) {
        # do something
    }

=head1 EXPORT

None

=head1 NOTES

Some of the methods in this module can be confusing expecially when it comes to checking abnormal water conditions.

B<Please always always always check the water condition before checking the LEDs and buzzers status.>

C<Acme::FishFarm> contains subroutines to check all the abnormal water conditions to ease this job.

=head1 CREATION RELATED SUBROUTINES/METHODS

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.

More sockets might be available in the future.

=head2 install ( %sensors )

Installs a water condition monitoring system.

The C<%sensors> included are:

=over 4

=item pH

Optional. The default threshold range is C<[6.5, 7.5]> and the default pH is C<7.0>.

This will set the threshold value of the water pH. Please pass in an array reference to this key
in the form of C<[min_pH, max_pH]>

The values are in the range of C<1-14>. However, this range is not checked for incorrect values.

=item temperature

Optional. The default threshold range is C<[20, 25]> degree celcius and the default temprature is C<25>.

This will set the threshold value of the water temperature. Please pass in an array reference to this key
in the form of C<[min_temperature, max_temperature]>

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.

=item turbidity



( run in 0.935 second using v1.01-cache-2.11-cpan-bbe5e583499 )