Acme-FishFarm

 view release on metacpan or  search on metacpan

docs/Acme-FishFarm-1.01.html  view on Meta::CPAN

<p>The <code>:all</code> tag can be used to import all the subroutines available in this module.</p>

<h1 id="NOTES">NOTES</h1>

<p>Almost all the subroutines in this module will give output. The unit measurements used will be according to the ones mentioned in <code>Acme::FishFarm::WaterConditionMonitor</code>.</p>

<h1 id="SYSTEM-INSTALLATION-RELATED-SUBROUTINES">SYSTEM INSTALLATION RELATED SUBROUTINES</h1>

<h2 id="install_all_systems">install_all_systems</h2>

<p>Installs all the available systems the default way and returns them as a list of <code>Acme::FishFarm::*</code> objects in the following sequence:</p>

<pre><code>  (Feeder, OxygenMaintainer, WaterConditionMonitor, WaterLevelMaintainer, WaterFiltration)</code></pre>

<h1 id="SENSOR-READING-RELATED-SUBROUTINES">SENSOR READING RELATED SUBROUTINES</h1>

<h2 id="reduce_precision-decimal">reduce_precision ( $decimal )</h2>

<p>Reduces positive or negative <code>$decimal</code> to a 3-decimal value. Make sure to pass in a decimal with more than 3 decimal points.</p>

<p>Returns the reduced precision value.</p>

docs/Acme-FishFarm-1.01.html  view on Meta::CPAN

<p>This checks, performs necessary actions and outputs the condition of the current waste count in the filtering cylinder.</p>

<p>Take note that this process <b>DOES NOT</b> trigger the LED and buzzer if abnormal condition is present.</p>

<p>Returns 1 upon success.</p>

<h2 id="check_feeder-feeder-verbose">check_feeder ( $feeder, $verbose )</h2>

<p>This checks, performs necessary actions and outputs the condition of the feeder. Each call will tick the clock inside the feeder. See <code>Acme::FishFarm::Feeder</code> for more info.</p>

<p>If the food tank is empty, it will be filled to the default. So if you want to fill a different amount, please set the amount before hand. See <code>Acme::FishFarm::Feeder</code>.</p>

<p>Setting <code>$verbose</code> to 1 will give more output about the empty food tank.</p>

<p>Take note that this process <b>DOES NOT</b> trigger the LED and buzzer if abnormal condition is present.</p>

<p>Returns 1 upon success.</p>

<h2 id="render_leds-water_monitor">render_leds ( $water_monitor )</h2>

<p>Outputs which LEDs are lighted up. Returns 1 upon success.</p>

docs/Acme-FishFarm-Feeder-1.01.html  view on Meta::CPAN

        if ( $feeder-&gt;timer_is_up ) {
            say &quot;\nTimer is up, time to feed the fish!&quot;;
            say &quot;Feeding &quot;, $feeder-&gt;feeding_volume, &quot; cm^3 of fish food to the fish...&quot;;
            
            $feeder-&gt;feed_fish;
            
            say $feeder-&gt;food_remaining, &quot; cm^3 of fish food remaining in the tank.\n&quot;;
        }
        
        if ( $feeder-&gt;food_remaining &lt;= 0  ) {
            $feeder-&gt;refill; # default back to 500 cm^3
            say &quot;Refilled food tank back to &quot;, $feeder-&gt;food_tank_capacity, &quot; cm^3.\n&quot;;
        }
        
        say $feeder-&gt;time_remaining, &quot; hours left until it&#39;s time to feed the fish.&quot;;

        sleep(1);
        $feeder-&gt;tick_clock;
    }

    say &quot;&quot;;

docs/Acme-FishFarm-Feeder-1.01.html  view on Meta::CPAN

<h2 id="install-options">install ( %options )</h2>

<p>Installs an automated fish feeder.</p>

<p>The following are available for <code>%options</code>:</p>

<ul>

<li><p>timer</p>

<p>The default is <code>8</code>.</p>

<p>This is used as a threshold to identify that the time is up to feed the fish or not.</p>

<p>The clock will be set to this value for countdown.</p>

</li>
<li><p>feeding_volume</p>

<p>The default is <code>50 cm^3</code>.</p>

</li>
<li><p>food_tank_capacity</p>

<p>The maximum volume of fish food. Default is <code>500 cm^3</code>.</p>

</li>
<li><p>current_food_amount</p>

<p>The initial amount of food to be filled into the food tank. Default is max ie <code>500 cm^3</code>.</p>

docs/Acme-FishFarm-Feeder-1.01.html  view on Meta::CPAN

<p>Check if the timer is up. If timer is up, please remember to feed your fish. See <code>feed_fish</code> for more info.</p>

<h2 id="time_remaining">time_remaining</h2>

<p>Returns the time remaining to feed the fish.</p>

<p>This method might not be really useful, but anyway :)</p>

<h2 id="tick_clock-custom_tick">tick_clock ( $custom_tick )</h2>

<p><code>$custom_tick</code> is optional and the default is <code>1</code>.</p>

<p>This will cause the timer of the feeder to increase by <code>1</code> (default) or by <code>$custom_tick</code>.</p>

<h1 id="FOOD-TANK-RELATED-SUBROUTINE-METHODS">FOOD TANK RELATED SUBROUTINE/METHODS</h1>

<h2 id="food_tank_capacity">food_tank_capacity</h2>

<p>Returns the current food tank capacity.</p>

<h2 id="set_food_tank_capacity-new_capacity">set_food_tank_capacity ( $new_capacity )</h2>

<p>Set the new food tank capacity to <code>$new_capacity</code>.</p>

docs/Acme-FishFarm-OxygenMaintainer-1.01.html  view on Meta::CPAN


<p>Installs an oxygen maintainer system.</p>

<p>The supported <code>%options</code> are:</p>

<dl>

<dt id="current_DO">current_DO</dt>
<dd>

<p>The default DO is to <code>8 mg/L</code>.</p>

</dd>
<dt id="DO_threshold">DO_threshold</dt>
<dd>

<p>The default threshold is <code>5 mg/L</code>.</p>

<p>If the current DO level is lower than this threshold, then your fish is lacking oxygen.</p>

</dd>
<dt id="DO_generation_volume">DO_generation_volume</dt>
<dd>

<p>This is the rate of oxygen generation.</p>

<p>The default value is <code>0.2 mg/L per unit time</code></p>

</dd>
</dl>

<p>The unit <code>mg/L</code> is just a unit, it doesn&#39;t show up if you call any of it&#39;s related getters.</p>

<h1 id="DISSOLVED-OXYGEN-SENSOR-RELATED-METHODS">DISSOLVED OXYGEN SENSOR RELATED METHODS</h1>

<h2 id="current_DO-new_DO">current_DO ( $new_DO )</h2>

docs/Acme-FishFarm-WaterConditionMonitor-1.01.html  view on Meta::CPAN


<p>Installs a water condition monitoring system.</p>

<p>The <code>%sensors</code> included are:</p>

<dl>

<dt id="pH">pH</dt>
<dd>

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

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

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

</dd>
<dt id="temperature">temperature</dt>
<dd>

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

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

<p>The ranges of values are between <code>0</code> and <code>50</code> degree <b>celcius</b>. However, this range is not checked for incorrect values. The unit <code>celcius</code> is just a unit, it doesn&#39;t show up if you call any of it&#39;s re...

</dd>
<dt id="turbidity">turbidity</dt>
<dd>

<p>Optional. The default threshold is <code>180 ntu</code> and the default turbidity is set to <code>10 ntu</code>.</p>

<p>This will set the threshold of the turbidity of the water.</p>

<p>The range of values are between <code>0 ntu</code> and <code>300 ntu</code>. However, this range is not checked for incorrect values. The unit <code>ntu</code> is just a unit, it doesn&#39;t show up if you call any of it&#39;s related getters.</p>

</dd>
</dl>

<h2 id="add_oxygen_maintainer-oxygen_maintainer">add_oxygen_maintainer ( $oxygen_maintainer )</h2>

docs/Acme-FishFarm-WaterLevelMaintainer-1.01.html  view on Meta::CPAN


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

<p>The supported <code>%options</code> are:</p>

<dl>

<dt id="current_water_level">current_water_level</dt>
<dd>

<p>The default water level is to <code>5 unit</code>.</p>

</dd>
<dt id="low_water_level_threshold">low_water_level_threshold</dt>
<dd>

<p>The default threshold is <code>2 unit</code>.</p>

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

</dd>
<dt id="increase_water_level_by">increase_water_level_by</dt>
<dd>

<p>This is the height of the water level to increase when the water is pumped in.</p>

<p>The default value is <code>0.5 unit</code>.</p>

</dd>
</dl>

<h1 id="WATER-LEVEL-DETECTION-RELATED-METHODS">WATER LEVEL DETECTION RELATED METHODS</h1>

<h2 id="current_water_level-new_water_level">current_water_level ( $new_water_level )</h2>

<p>Sets / returns the current water level of the water.</p>

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

);

=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;

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

    } else {
        print "  Water level is still normal.\n";
    }
    1;
}

=head2 check_feeder ( $feeder, $verbose )

This checks, performs necessary actions and outputs the condition of the feeder. Each call will tick the clock inside the feeder. See C<Acme::FishFarm::Feeder> for more info.

If the food tank is empty, it will be filled to the default. So if you want to fill a different amount, please set the amount before hand. See C<Acme::FishFarm::Feeder>.

Setting C<$verbose> to 1 will give more output about the empty food tank.

Take note that this process B<DOES NOT> trigger the LED and buzzer if abnormal condition is present.

Returns 1 upon success.

=cut

sub check_feeder {

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

            $feeder->feed_fish;
        }
        print "  Feeding ", $feeder->feeding_volume, " cm^3 of fish food to the fish...\n";
        
    } else {
        print $feeder->time_remaining, " hours left until it's time to feed the fish.\n";
    }
    
    if ( $feeder->food_remaining <= 0  ) {
        print "  !! Food tank empty!\n";
        $feeder->refill; # default back to 500 cm^3
        print "  Refilled food tank back to ", $feeder->food_tank_capacity, " cm^3.\n";
    }

    print "  Food Remaining: ", $feeder->food_remaining, "cm^3.\n";
    
    $feeder->tick_clock;
    1;
}

=head2 render_leds ( $water_monitor )

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

        if ( $feeder->timer_is_up ) {
            say "\nTimer is up, time to feed the fish!";
            say "Feeding ", $feeder->feeding_volume, " cm^3 of fish food to the fish...";
            
            $feeder->feed_fish;
            
            say $feeder->food_remaining, " cm^3 of fish food remaining in the tank.\n";
        }
        
        if ( $feeder->food_remaining <= 0  ) {
            $feeder->refill; # default back to 500 cm^3
            say "Refilled food tank back to ", $feeder->food_tank_capacity, " cm^3.\n";
        }
        
        say $feeder->time_remaining, " hours left until it's time to feed the fish.";

        sleep(1);
        $feeder->tick_clock;
    }

    say "";

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

=head2 install ( %options )

Installs an automated fish feeder.

The following are available for C<%options>:

=over 4

=item * timer

The default is C<8>.

This is used as a threshold to identify that the time is up to feed the fish or not.

The clock will be set to this value for countdown.

=item * feeding_volume

The default is C<50 cm^3>.

=item * food_tank_capacity

The maximum volume of fish food. Default is C<500 cm^3>.

=item * current_food_amount

The initial amount of food to be filled into the food tank. Default is max ie C<500 cm^3>.

=back

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


=cut

sub time_remaining {
    ref (my $self = shift) or croak "Please use this the OO way";
    $self->{timer} - $self->{clock};
}

=head2 tick_clock ( $custom_tick )

C<$custom_tick> is optional and the default is C<1>.

This will cause the timer of the feeder to increase by C<1> (default) or by C<$custom_tick>.

=cut

sub tick_clock {
    ref (my $self = shift) or croak "Please use this the OO way";
    ++$self->{clock};
}


=head1 FOOD TANK RELATED SUBROUTINE/METHODS

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

=head2 install ( %options )

Installs an oxygen maintainer system.

The supported C<%options> are:

=over 4

=item current_DO

The default DO is to C<8 mg/L>.

=item DO_threshold

The default threshold is C<5 mg/L>.

If the current DO level is lower than this threshold, then your fish is lacking oxygen.

=item DO_generation_volume

This is the rate of oxygen generation.

The default value is C<0.2 mg/L per unit time>

=back

The unit C<mg/L> is just a unit, it doesn't show up if you call any of it's related getters.

=cut

sub install {
    my $class = shift;
    my %options = @_;

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

=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

Optional. The default threshold is C<180 ntu> and the default turbidity is set to C<10 ntu>.

This will set the threshold of the turbidity of the water.

The range of values are between C<0 ntu> and C<300 ntu>. However, this range is not checked for incorrect values. The unit C<ntu> is just a unit, it doesn't show up if you call any of it's related getters.

=back

=cut

sub install {

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

=head2 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 C<%options> are:

=over 4

=item current_water_level

The default water level is to C<5 unit>.

=item low_water_level_threshold

The default threshold is C<2 unit>.

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

=item increase_water_level_by

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

The default value is C<0.5 unit>.

=back

=cut

sub install {
    my $class = shift;
    my %options = @_;
    
    if ( not $options{current_water_level} ) {

scripts/feeder.pl  view on Meta::CPAN

    if ( $feeder->timer_is_up ) {
        say "\nTimer is up, time to feed the fish!";
        say "Feeding ", $feeder->feeding_volume, " cm^3 of fish food to the fish...";
        
        $feeder->feed_fish ( verbose => 1 );
        
        say $feeder->food_remaining, " cm^3 of fish food remaining in the tank.\n";
    }
    
    if ( $feeder->food_remaining <=0  ) {
        $feeder->refill; # default back to 500 cm^3
        say "Refilled food tank back to ", $feeder->food_tank_capacity, " cm^3.\n";
    }
    
    say $feeder->time_remaining, " hours left until it's time to feed the fish.";

    sleep(1);
    $feeder->tick_clock;
}

say "";

t/04-feeder.t  view on Meta::CPAN

use strict;
use warnings;
use Test::More;
use Test::Output;

BEGIN {
    use_ok( "Acme::FishFarm::Feeder" ) || BAIL_OUT;
}


ok( my $feeder_default = Acme::FishFarm::Feeder->install(), "Feeder installed" ); # timer 1 hour, 50 cm^3 fish food
#print $feeder_default, "\n";
is( ref($feeder_default), "Acme::FishFarm::Feeder", "Correct class name");

ok( my $feeder_h5_v15 = Acme::FishFarm::Feeder->install( timer => 5, feeding_volume => 15 ), "Feeder installed" );
is( ref($feeder_h5_v15), "Acme::FishFarm::Feeder", "Correct class name");

ok( my $feeder_h3 = Acme::FishFarm::Feeder->install( timer => 3 ), "Feeder installed" );
is( ref($feeder_h3), "Acme::FishFarm::Feeder", "Correct class name");

ok( my $feeder_v45 = Acme::FishFarm::Feeder->install( feeding_volume => 45 ), "Feeder installed" );
is( ref($feeder_v45), "Acme::FishFarm::Feeder", "Correct class name");

# this shuold get back the default values
ok( my $feeder_all_0 = Acme::FishFarm::Feeder->install( timer =>0, feeding_volume => 0 ), "Feeder installed" );
is( ref($feeder_all_0), "Acme::FishFarm::Feeder", "Correct class name");
is( $feeder_all_0->get_timer(), 8, "Zero hours defaults to 8 hours");
is( $feeder_all_0->feeding_volume(), 50, "Zero cm^3 defaults to 50 cm^3");


is( $feeder_default->get_timer(), 8, "Correct default timer" );


# tick_clock part will go into a loop in the actual program
isnt( $feeder_default->timer_is_up, 1, "Not feeding fish as soon as feeder is switched on" );
ok( $feeder_default->tick_clock(), "Clock ticks once ($_)" ) for (0..3);
is( $feeder_default->time_remaining(), 4, "Correct time remaining" );
isnt( $feeder_default->timer_is_up(), 1, "Time isn't up yet'" );
ok( $feeder_default->tick_clock(), "Clock ticks once ($_)" ) for (4..7);
is( $feeder_default->timer_is_up(), 1, "Time to feed the fish'" );

#print $feeder_default->tick_clock() . "\n";
#print $feeder_default->tick_clock() . "\n";
#print $feeder_default->tick_clock() . "\n";

# test food tank
is($feeder_default->food_remaining(), 500, "Correct default food level");
is($feeder_default->feeding_volume(), 50, "Correct default feeding volume");

$feeder_default->set_feeding_volume(25);
is($feeder_default->feeding_volume(), 25, "New feeding volume set");
$feeder_default->refill(10); # "downfill" :)
is($feeder_default->food_remaining(), 10, "Downfill success, please don't do this in the actual program");

$feeder_default->refill; # back to 500
is( $feeder_default->food_remaining, 500, "Strange refill value will make it max" );
$feeder_default->feed_fish; # feed 25 cm^3
is($feeder_default->food_remaining, 475, "Fed the correct amount of food to the fish");

$feeder_default->feed_fish; # feed 25 cm^3
is($feeder_default->food_remaining, 450, "Fed the correct amount of food to the fish");

{
local $@;
eval { $feeder_default->set_feeding_volume; };
like( $@, qr/Please specify feeding volume/, "Caught feeding volume missing" );
}


$feeder_default->refill(1);
stdout_like {
    $feeder_default->feed_fish( verbose => 1 );
} qr/run out of food/, "Time to refill fish food!";

# feed again :)
is( $feeder_default->food_remaining, 0, "Fish food remaining is 0 ^cm3 at the moment" );
stdout_like {     
    $feeder_default->feed_fish( verbose => 1 );
} qr/run out of food/, "Time to refill fish food!";

$feeder_default->refill(99999);
is( $feeder_default->food_remaining, $feeder_default->{food_tank_capacity}, "Some fish food got wasted" );

is( $feeder_default->food_tank_capacity, 500, "Correct food tank capacity" );
$feeder_default->set_food_tank_capacity("hello");
is( $feeder_default->food_tank_capacity, 500, "Strange food tank capacity ignored" );

$feeder_default->refill("he");

done_testing();

# besiyata d'shmaya



t/06-water_filtration.t  view on Meta::CPAN

use strict;
use warnings;
use Test::More;

BEGIN {
    use_ok( "Acme::FishFarm::WaterFiltration" ) || BAIL_OUT;
}

my $water_filter = Acme::FishFarm::WaterFiltration->install;
is( ref($water_filter), "Acme::FishFarm::WaterFiltration", "Correct class" );
is( $water_filter->current_waste_count, 0, "Correct default waste count" );
$water_filter->current_waste_count(50);
is( $water_filter->current_waste_count, 50, "Correct new waste count" );
is( $water_filter->waste_count_threshold, 75, "Correct default waste count threshold" );
$water_filter->set_waste_count_threshold(100);
is( $water_filter->waste_count_threshold, 100, "Correct new waste count threshold" );

is( $water_filter->reduce_waste_count_by, 10, "Correct waste count reduction" );
$water_filter->set_waste_count_to_reduce(15);
is( $water_filter->reduce_waste_count_by, 15, "Correct new waste count reduction" );

# turn on spatulas, if not cleaning process will not happen
$water_filter->current_waste_count(10);

t/08-water_level_maintainer.t  view on Meta::CPAN


use strict;
use warnings;
use Test::More;

BEGIN {
    use_ok( "Acme::FishFarm::WaterLevelMaintainer" ) || BAIL_OUT;
}

my $water_level = Acme::FishFarm::WaterLevelMaintainer->install;
is( $water_level->current_water_level, 5, "Correct default water level" );
$water_level->current_water_level(10);
is( $water_level->current_water_level, 10, "Correct new water level" );

is( $water_level->low_water_level_threshold, 2, "Correct default water level threshold" );
is( $water_level->water_level_increase_height, 0.5, "Correct default water level to increase" );

$water_level->set_low_water_level_threshold(5);
$water_level->set_water_level_increase_height(1.2);
is( $water_level->low_water_level_threshold, 5, "Correct new water level threshold" );
is( $water_level->water_level_increase_height, 1.2, "Correct new water level to increase" );

$water_level->pump_water_in; # 10+1.2=11.2
is( $water_level->current_water_level, 11.2, "Correct height after pumping water" );
is( $water_level->is_low_water_level, 0, "Water level not low yet" );
$water_level->current_water_level(3);

t/10-water_condition_monitor.t  view on Meta::CPAN

is( $ph_range->[0], 6.5, "Correct min pH" );
is( $ph_range->[1], 7.5, "Correct max pH" ); 

ok($water_monitor->set_ph_threshold([4, 7]), "New pH can be set");
my $new_ph_range =  $water_monitor->ph_threshold;
is( $new_ph_range->[0], 4, "Correct new min pH" );
is( $new_ph_range->[1], 7, "Correct new max pH" );
# current: 7, [4, 7]

my $current_ph = $water_monitor->current_ph;
is( $current_ph, 7, "Correct default pH value");
is( $water_monitor->ph_is_normal, 1, "pH level is normal" );
is( $water_monitor->is_on_LED_pH, 0, "pH LED is not on" );
is( $water_monitor->is_on_buzzer_short, 0, "pH sensor not making short buzzer turn on" );
# current: 7, [4, 7]

# temperature
my $temperature_range =  $water_monitor->temperature_threshold;
is( $temperature_range->[0], 20, "Correct min temperature" );
is( $temperature_range->[1], 25, "Correct max temperature" );

ok($water_monitor->set_temperature_threshold([15, 20]), "New pH can be set");
my $new_temperature_range =  $water_monitor->temperature_threshold;
is( $new_temperature_range->[0], 15, "Correct new min temperature" );
is( $new_temperature_range->[1], 20, "Correct new max temperature" );

my $current_temperature = $water_monitor->current_temperature;
is( $current_temperature, 23, "Correct default temperature value");
isnt( $water_monitor->temperature_is_normal, 1, "Temperature is not normal right now" );
is( $water_monitor->is_on_LED_temperature, 1, "Temperature LED is on" );
is( $water_monitor->is_on_buzzer_short, 1, "Temperature sensor is turning on short buzzer" );

isnt ( $water_monitor->is_on_buzzer_long , 1, "Long buzzer is not switched on yet, nice");

print "Short buzzer on: ", $water_monitor->{short_buzzer_on}, "\n";
print "Long buzzer on: ", $water_monitor->{long_buzzer_on}, "\n";
is( $water_monitor->lighted_LED_count, 1, "1 LED lighted up" );

t/10-water_condition_monitor.t  view on Meta::CPAN

is( $water_monitor->is_on_buzzer_short, 0, "More than 1 LEDs, long buzzer is enough" );

print "Short buzzer on: ", $water_monitor->{short_buzzer_on}, "\n";
print "Long buzzer on: ", $water_monitor->{long_buzzer_on}, "\n";
is( $water_monitor->lighted_LED_count, 2, "2 LEDs lighted up" );

# temperature and pH both not normal, long buzzer should go off
is( $water_monitor->is_on_buzzer_long, 1, "pH and temperature caused long buzzer to go off" );

# turbidity
is( $water_monitor->current_turbidity, 10, "Correct default current turbidity");
is( $water_monitor->turbidity_threshold, 180, "Correct default turbidity threshold");

$water_monitor->set_turbidity_threshold(300);
is( $water_monitor->turbidity_threshold, 300, "Correct new turbidity threshold");

$water_monitor->current_turbidity(130);
is( $water_monitor->current_turbidity, 130, "Correct new current turbidity");

# make LED and buzzer fire
$water_monitor->set_turbidity_threshold(100);
is( $water_monitor->water_dirty, 1, "Water is dirty");

t/12-oxygen_maintainer.t  view on Meta::CPAN

#!/usr/bin/perl

use strict;
use warnings;
use Test::More;

BEGIN {
    use_ok( "Acme::FishFarm::OxygenMaintainer" ) || BAIL_OUT;
}

# default installer
my $o2_maintainer = Acme::FishFarm::OxygenMaintainer->install;
is( ref($o2_maintainer), "Acme::FishFarm::OxygenMaintainer", "Correct class");
is( $o2_maintainer->current_DO, 8, "Correct default DO level" );
is( $o2_maintainer->DO_threshold, 5, "Correct default DO threshold");

is( $o2_maintainer->is_low_DO, 0, "Enough oxygen" );

$o2_maintainer->set_DO_threshold(10);
is( $o2_maintainer->DO_threshold, 10, "Correct new DO threshold" );

$o2_maintainer->current_DO(2);
is( $o2_maintainer->is_low_DO, 1, "Your fish is suffocating" );

# test oxygen generation rate



( run in 0.675 second using v1.01-cache-2.11-cpan-0a6323c29d9 )