Acme-FishFarm
view release on metacpan or search on metacpan
lib/Acme/FishFarm.pm view on Meta::CPAN
package Acme::FishFarm;
use 5.008;
use strict;
use warnings;
use Carp "croak";
use Acme::FishFarm::Feeder;
use Acme::FishFarm::OxygenMaintainer;
use Acme::FishFarm::WaterConditionMonitor;
use Acme::FishFarm::WaterLevelMaintainer;
use Acme::FishFarm::WaterFiltration;
=head1 NAME
Acme::FishFarm - A Fish Farm with Automated Systems
=head1 VERSION
Version 1.01
=cut
our $VERSION = '1.01';
=head1 SYNOPSIS
use 5.010;
use Acme::FishFarm ":all";
my $water_monitor = Acme::FishFarm::WaterConditionMonitor->install;
my $oxygen = Acme::FishFarm::OxygenMaintainer->install( DO_generation_volume => 1.92 );
$water_monitor->add_oxygen_maintainer( $oxygen );
say "Water condition monitor installed...";
say "Oxygen maintainer installed and connected to water condition monitor...";
say "Water condition monitor switched on!";
say "";
while ( "fish are swimming happily" ) {
### DO
check_DO( $oxygen, reduce_precision( rand(8) ) );
say "";
### pH
check_pH( $water_monitor, 6.912 );
#check_pH( $water_monitor, 5.9 );
say "" ;
## temperature
#check_temperature( $water_monitor, 23 );
check_temperature( $water_monitor, 26 );
say "";
## turbidity
check_turbidity( $water_monitor, 120 );
#check_turbidity( $water_monitor, 190 );
say "";
# all LEDs
render_leds( $water_monitor );
say "";
# buzzers
render_buzzer( $water_monitor );
sleep(3);
say "-----------------------------";
}
=head1 EXPORT
The C<:all> tag can be used to import all the subroutines available in this module.
=cut
use Exporter qw( import );
our @EXPORT_OK = qw(
install_all_systems
reduce_precision consume_oxygen
check_DO check_pH check_temperature check_turbidity check_water_filter check_water_level check_feeder
render_leds render_buzzer
);
our %EXPORT_TAGS = (
all => [ qw( install_all_systems reduce_precision consume_oxygen check_DO check_pH check_temperature
check_turbidity check_water_filter check_water_level check_feeder render_leds
render_buzzer ) ],
);
=head1 NOTES
Almost all the subroutines in this module will give output. The unit measurements used will be according to the ones mentioned in C<Acme::FishFarm::WaterConditionMonitor>.
=head1 SYSTEM INSTALLATION RELATED SUBROUTINES
=head2 install_all_systems
Installs all the available systems the default way and returns them as a list of C<Acme::FishFarm::*> objects in the following sequence:
(Feeder, OxygenMaintainer, WaterConditionMonitor, WaterLevelMaintainer, WaterFiltration)
=cut
sub install_all_systems {
my $feeder = Acme::FishFarm::Feeder->install;
my $oxygen_maintainer = Acme::FishFarm::OxygenMaintainer->install;
my $water_monitor = Acme::FishFarm::WaterConditionMonitor->install;
my $water_level = Acme::FishFarm::WaterLevelMaintainer->install;
my $water_filter = Acme::FishFarm::WaterFiltration->install;
# remember to connect water oxygem maintainer to water condition monitoring :)
$water_monitor->add_oxygen_maintainer( $oxygen_maintainer );
( $feeder, $oxygen_maintainer, $water_monitor, $water_level, $water_filter );
}
=head1 SENSOR READING RELATED SUBROUTINES
=head2 reduce_precision ( $decimal )
Reduces positive or negative C<$decimal> to a 3-decimal value. Make sure to pass in a decimal with more than 3 decimal points.
Returns the reduced precision value.
This subroutine is useful if you are trying to set the current sensor readings randomly using the built-in C<rand> function as you do not want to end up with too many decimals on the screen.
=cut
( run in 1.322 second using v1.01-cache-2.11-cpan-8dfa8b56332 )