Acpi

 view release on metacpan or  search on metacpan

Battery.pm  view on Meta::CPAN

sub nbBattery{
	my($self) = shift;
	my($dir) = "/proc/acpi/battery";
	my($nb) = 0;
	
	opendir(BATTERYDIR,$dir) || die "Impossible d'ouvrir $dir : $!";
	while(readdir(BATTERYDIR)){
		$nb++;	
	}

	$nb -= 2; #SOUSTRACT "." and ".."

	closedir(BATTERYDIR);
	return $nb;
}

sub getLastFull{
	my($self) = shift;

	return $self->getBatteryInfo("last full capacity");
}

sub getLastFullTotal{
	my($self) = shift;
	my($lastfulltotal) = undef;
	my($i) = 0;
	my($numbatt) = $self->nbBattery;
	
	for($i=1;$i<=$numbatt;$i++){
		$lastfulltotal += $rfield->getValueField("/proc/acpi/battery/BAT".$i."/info","last full capacity");
	}

	return $lastfulltotal;

}

sub getPresent{
	my($self) = shift;
	my(%value);
	my($i) = 0;
	my($numbatt) = $self->nbBattery;
	
	
	for($i=1;$i<=$numbatt;$i++){
		if($rfield->getValueField("/proc/acpi/battery/BAT".$i."/state","present") eq "yes"){
			$value{"BAT".$i} = 0;
		}
		else{
			$value{"BAT".$i} = -1;
		}
	}
	return (%value);
}

sub getDesignCapacity{
	my($self) = shift;

	return $self->getBatteryInfo("design capacity");
}

sub getBatteryTechnology{
	my($self) = shift;
	
	return $self->getBatteryInfo("battery technology");
}

sub getBatteryType{
	my($self) = shift;

	return $self->getBatteryInfo("battery type");
}

sub getOEMInfo{
	my($self) = shift;

	return $self->getBatteryInfo("OEM info");
}

sub getChargingState{
	my($self) = shift;
	my(%value);
        my($i) = 0;
	my($numbatt) = $self->nbBattery;


	for($i=1;$i<=$numbatt;$i++){
	        if($rfield->getValueField("/proc/acpi/battery/BAT".$i."/state","charging state") eq "charging"){
			$value{"BAT".$i} = 0;
		}
		else{
			$value{"BAT".$i} = -1;
		}
	}

	return (%value);
}

sub getCapacityState{
	my($self) = shift;
	my(%value);
	my($i) = 0;
	my($numbatt) = $self->nbBattery;

	for($i=1;$i<=$numbatt;$i++){
		if($rfield->getValueField("/proc/acpi/battery/BAT".$i."/state","capacity state") eq "ok"){
			$value{"BAT".$i} = 0;
		}
		else{
			$value{"BAT".$i} = -1;
		}
	}

	return (%value);
}

sub getRemaining{
	my($self) = shift;

	return $self->getBatteryState("remaining capacity");
}

sub getRemainingTotal{
        my($self) = shift;
	my($remainingtotal) = undef;

Battery.pm  view on Meta::CPAN

The information that you would find !!

=back

=item *

batteryOnLine();

Return 0 if the battery is online else -1.

=item *

nbBattery();

Return the number of battery present.

=item *

getCharge();

Return the pourcentage of the battery.

=item *

getHoursLeft();

Return the hours left behind the battery will be down.

=item *

getMinutesLeft();

Return the minutes left behind the battery will be down.

=item * 

getLastFull();

Return a hash composed by the name of the battery and the last full capacity.

=item *

getLastFullTotal();

Return the last full capacity of all batteries.

=item *

getPresent();

Return a hash composed by the name of the battery and 0 or -1 if it's present or not.

=item *

getDesignCapacity();

Return a hash composed by the name of the battery and the design capacity.

=item *

getBatteryTechnology();

Return a hash composed by the name of the battery and the technology.

=item *

getBatteryType();

Return a hash composed by the name of the battery and the type.

=item *

getOEMInfo();

Return a hash composed by the name of the battery and the oem info.

=item *

getChargingState();

Return a hash composed by the name of the battery and 0 or -1 if it's charging or not.

=item *

getCapacityState();

Return a hash composed by the name of the battery and 0 or -1 if if the capacity state is ok or not.

=item *

getRemainingTotal();

Return the remaining capacity of all batteries.

=item * 

getPresentRateTotal();

Return the present rate of all batteries.

=item *

getPresentVoltageTotal();

Return the present voltage of all batteries.

=over

=back

=head1 AUTHORS

=over

=item *

Developed by Shy <shy@cpan.org>.

=back

=cut



( run in 0.620 second using v1.01-cache-2.11-cpan-63c85eba8c4 )