Interface PowerSource
- All Known Implementing Classes:
AbstractPowerSource,AixPowerSource,FreeBsdPowerSource,LinuxPowerSource,MacPowerSource,SolarisPowerSource,WindowsPowerSource
@ThreadSafe public interface PowerSource
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classPowerSource.CapacityUnitsUnits of Battery Capacity -
Method Summary
Modifier and Type Method Description doublegetAmperage()Amperage of the battery, in milliAmperes (mA).PowerSource.CapacityUnitsgetCapacityUnits()java.lang.StringgetChemistry()The battery chemistry (e.g., Lithium Ion).intgetCurrentCapacity()The current (remaining) capacity of the battery.intgetCycleCount()The cycle count of the battery, if known.intgetDesignCapacity()The design (original) capacity of the battery.java.lang.StringgetDeviceName()Name of the power source at the device level.java.time.LocalDategetManufactureDate()The battery's date of manufacture.java.lang.StringgetManufacturer()The name of the battery's manufacturer.intgetMaxCapacity()The maximum capacity of the battery.java.lang.StringgetName()Name of the power source at the Operating System level.doublegetPowerUsageRate()Power Usage Rate of the battery, in milliWatts (mW).doublegetRemainingCapacityPercent()Estimated remaining capacity as a fraction of max capacity.java.lang.StringgetSerialNumber()The battery's serial number.doublegetTemperature()The battery's temperature, in degrees Celsius.doublegetTimeRemainingEstimated()Estimated time remaining on the power source, in seconds, as reported by the operating system.doublegetTimeRemainingInstant()Estimated time remaining on the power source, in seconds, as reported by the battery.doublegetVoltage()Voltage of the battery, in Volts.booleanisCharging()Reports whether the battery is charging.booleanisDischarging()Reports whether the battery is discharging.booleanisPowerOnLine()Reports whether the device is plugged in to an external power source.booleanupdateAttributes()Updates statistics on this battery.
-
Method Details
-
getName
java.lang.String getName()Name of the power source at the Operating System level.- Returns:
- The power source name, as reported by the operating system.
-
getDeviceName
java.lang.String getDeviceName()Name of the power source at the device level.- Returns:
- The power source name, as reported by the device itself.
-
getRemainingCapacityPercent
double getRemainingCapacityPercent()Estimated remaining capacity as a fraction of max capacity.This is an estimated/smoothed value which should correspond to the Operating System's "percent power" display, and may not directly correspond to the ratio of
getCurrentCapacity()togetMaxCapacity().- Returns:
- A value between 0.0 (fully drained) and 1.0 (fully charged)
-
getTimeRemainingEstimated
double getTimeRemainingEstimated()Estimated time remaining on the power source, in seconds, as reported by the operating system.This is an estimated/smoothed value which should correspond to the Operating System's "battery time remaining" display, and will react slowly to changes in power consumption.
- Returns:
- If positive, seconds remaining. If negative, -1.0 (calculating) or -2.0 (unlimited)
-
getTimeRemainingInstant
double getTimeRemainingInstant()Estimated time remaining on the power source, in seconds, as reported by the battery. If the battery is charging, this value may represent time remaining to fully charge the battery.Note that this value is not very accurate on some battery systems. The value may vary widely depending on present power usage, which could be affected by disk activity and other factors. This value will often be a higher value than
getTimeRemainingEstimated().- Returns:
- Seconds remaining to fully discharge or fully charge the battery.
-
getPowerUsageRate
double getPowerUsageRate()Power Usage Rate of the battery, in milliWatts (mW).- Returns:
- If positive, the charge rate. If negative, the discharge rate.
-
getVoltage
double getVoltage()Voltage of the battery, in Volts.- Returns:
- the battery voltage, or -1 if unknown.
-
getAmperage
double getAmperage()Amperage of the battery, in milliAmperes (mA).- Returns:
- the battery amperage. If positive, charging the battery. If negative, discharging the battery.
-
isPowerOnLine
boolean isPowerOnLine()Reports whether the device is plugged in to an external power source.- Returns:
trueif plugged in,falseotherwise.
-
isCharging
boolean isCharging()Reports whether the battery is charging.- Returns:
trueif the battery is charging,falseotherwise.
-
isDischarging
boolean isDischarging()Reports whether the battery is discharging.- Returns:
trueif the battery is discharging,falseotherwise.
-
getCapacityUnits
PowerSource.CapacityUnits getCapacityUnits()- Returns:
- The units of battery capacity.
-
getCurrentCapacity
int getCurrentCapacity()The current (remaining) capacity of the battery.- Returns:
- The current capacity. Units are defined by
getCapacityUnits().
-
getMaxCapacity
int getMaxCapacity()The maximum capacity of the battery. When compared to design capacity, permits a measure of battery state of health. It is possible for max capacity to exceed design capacity.- Returns:
- The maximum capacity. Units are defined by
getCapacityUnits().
-
getDesignCapacity
int getDesignCapacity()The design (original) capacity of the battery. When compared to maximum capacity, permits a measure of battery state of health. It is possible for max capacity to exceed design capacity.- Returns:
- The design capacity. Units are defined by
getCapacityUnits().
-
getCycleCount
int getCycleCount()The cycle count of the battery, if known.- Returns:
- The cycle count of the battery, or -1 if unknown.
-
getChemistry
java.lang.String getChemistry()The battery chemistry (e.g., Lithium Ion).- Returns:
- the battery chemistry.
-
getManufactureDate
java.time.LocalDate getManufactureDate()The battery's date of manufacture.Some battery manufacturers encode the manufacture date in the serial number. Parsing this value is operating system and battery manufacturer dependent, and is left to the user.
- Returns:
- the manufacture date, if available. May be
null.
-
getManufacturer
java.lang.String getManufacturer()The name of the battery's manufacturer.- Returns:
- the manufacturer name.
-
getSerialNumber
java.lang.String getSerialNumber()The battery's serial number.Some battery manufacturers encode the manufacture date in the serial number. Parsing this value is operating system and battery manufacturer dependent, and is left to the user.
- Returns:
- the serial number.
-
getTemperature
double getTemperature()The battery's temperature, in degrees Celsius.- Returns:
- the battery's temperature, or 0 if uknown.
-
updateAttributes
boolean updateAttributes()Updates statistics on this battery.- Returns:
trueif the update was successful. Iffalsethe battery statistics are unchanged.
-