Acme-FishFarm

 view release on metacpan or  search on metacpan

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


    if ( $water_filter->is_cylinder_dirty ) {
        print "  !! Filtering cylinder is dirty!\n";
        $water_filter->turn_on_spatulas;
        print "  Cleaning spatulas turned on.\n";
        $water_filter->clean_cylinder( $reduce_waste_by );
        print "  Cleaning the cylinder...Done!\n";
        print "Current waste count: ", $water_filter->current_waste_count, "\n";
    } else {
        print "  Filtering cylinder is still clean.\n";
    }
    1;
}

=head2 check_water_level ( $water_level_maintainer, $current_water_level )

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

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_water_level {
    my $water_level = shift;
    my $current_reading = shift;
    my $height_increase = $water_level->water_level_increase_height; # for output
    my $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, " m\n";
    } 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 {
    my ( $feeder, $verbose ) = @_;
    if ( $feeder->timer_is_up ) {
        print "Timer is up, time to feed the fish!\n";
        
        if ( $verbose) {
            $feeder->feed_fish( verbose => 1 );        
        } else {
            $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 )

Outputs which LEDs are lighted up. Returns 1 upon success.

Currently this subroutine only shows the LEDs present in the  C<Acme::FishFarm::WaterConditionMonitor> object. See that module for more details about the available LEDs.

More LEDs will be available in the future.

=cut

sub render_leds {
    my $water_monitor = shift;

    # must check condition first! If not it won't work
        # this process will update the LEDs status
    $water_monitor->ph_is_normal;
    $water_monitor->temperature_is_normal;
    $water_monitor->lacking_oxygen;    
    $water_monitor->water_dirty;
        
    print "Total LEDs up: ", $water_monitor->lighted_LED_count, "\n";

    if ( $water_monitor->is_on_LED_pH ) {
        print "  pH LED: on\n";
    } else {
        print "  pH LED: off\n";
    }
    
    if ( $water_monitor->is_on_LED_temperature ) {
        print "  Temperature LED: on\n";
    } else {
        print "  Temperature LED: off\n";
    }
    
    if ( $water_monitor->is_on_LED_DO ) {



( run in 1.251 second using v1.01-cache-2.11-cpan-39bf76dae61 )