The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Acme::FishFarm::WaterLevelMaintainer - Water Level Maintainer for Acme::FishFarm

VERSION

Version 1.01

SYNOPSIS

use 5.010;

use Acme::FishFarm qw( reduce_precision );
use Acme::FishFarm::WaterFiltration;

my $water_level = Acme::FishFarm::WaterLevelMaintainer->install;

say "Water level maintainer installed and switched on!\n";

my $height_increase;
my $water_level_threshold;
my $current_reading;

while ( "Fish are living under the water..." ) {

    $current_reading = reduce_precision( rand(10) );
    $height_increase = $water_level->water_level_increase_height;
    $water_level_threshold = $water_level->low_water_level_threshold;
    
    $water_level->current_water_level( $current_reading ); # input by user
    print "Current Water Level: ", $current_reading, " m (low: < ", $water_level_threshold, " m)\n";

    if ( $water_level->is_low_water_level ) {
        print "  !! Water level is low!\n";
        $water_level->pump_water_in;
        print "  Pumping in ", $height_increase, " m of water...\n";
        print "Current Water Level: ", $water_level->current_water_level, "\n";
    } else {
        print "  Water level is still normal.\n";
    }
    
    sleep(1);
    say "";
}

EXPORT

None

CREATION RELATED MEHODS

install ( %options )

Installs a water level maintainer system. This system only pumps water in if the water level is lower than the threshold value.

The supported %options are:

current_water_level

The default water level is to 5 unit.

low_water_level_threshold

The default threshold is 2 unit.

If the current water level is lower than this threshold, then you need to pump water into the tank.

increase_water_level_by

This is the height of the water level to increase when the water is pumped in.

The default value is 0.5 unit.

WATER LEVEL DETECTION RELATED METHODS

current_water_level ( $new_water_level )

Sets / returns the current water level of the water.

$new_water_level is optional. If present, the current water level will be set to $new_water_level. Otherwise, returns the current water level (depth).

low_water_level_threshold

Returns the low water level threshold.

set_low_water_level_threshold ( $new_threshold )

Sets the low water level threshold.

is_low_water_level

Returns 1 if the DO level is less than the threshold value. Otherwise, returns 0.

PUMPS RELATED METHODS

For the pumping mechanism, just assume that the pumps can actually pump in certain metres of water each time :)

water_level_increase_height

Returns the height of water level to increase each water pumping action. See pump_water_in below.

set_water_level_increase_height ( $new_height )

Sets the height of water level to increase to $new_height.

pump_water_in

Pumps water into the tank to increase the height of the water level.

AUTHOR

Raphael Jong Jun Jie, <ellednera at cpan.org>

BUGS

Please report any bugs or feature requests to bug-. at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=.. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Acme::FishFarm::WaterLevelMaintainer

You can also look for information at:

ACKNOWLEDGEMENTS

Besiyata d'shmaya

LICENSE AND COPYRIGHT

This software is Copyright (c) 2021 by Raphael Jong Jun Jie.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)