Class AbstractPowerSource
- All Implemented Interfaces:
PowerSource
- Direct Known Subclasses:
AixPowerSource,FreeBsdPowerSource,LinuxPowerSource,MacPowerSource,OpenBsdPowerSource,SolarisPowerSource,WindowsPowerSource
-
Nested Class Summary
Nested classes/interfaces inherited from interface oshi.hardware.PowerSource
PowerSource.CapacityUnits -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractPowerSource(String name, String deviceName, double remainingCapacityPercent, double timeRemainingEstimated, double timeRemainingInstant, double powerUsageRate, double voltage, double amperage, boolean powerOnLine, boolean charging, boolean discharging, PowerSource.CapacityUnits capacityUnits, int currentCapacity, int maxCapacity, int designCapacity, int cycleCount, String chemistry, LocalDate manufactureDate, String manufacturer, String serialNumber, double temperature) -
Method Summary
Modifier and TypeMethodDescriptiondoubleAmperage of the battery, in milliAmperes (mA).Reports =the units ofPowerSource.getCurrentCapacity(),PowerSource.getMaxCapacity(), andPowerSource.getDesignCapacity()The battery chemistry (e.g., Lithium Ion).intThe current (remaining) capacity of the battery.intThe cycle count of the battery, if known.intThe design (original) capacity of the battery.Name of the power source at the device level.The battery's date of manufacture.The name of the battery's manufacturer.intThe maximum capacity of the battery.getName()Name of the power source at the Operating System level.doublePower Usage Rate of the battery, in milliWatts (mW).doubleEstimated remaining capacity as a fraction of max capacity.The battery's serial number.doubleThe battery's temperature, in degrees Celsius.doubleEstimated time remaining on the power source, in seconds, as reported by the operating system.doubleEstimated time remaining on the power source, in seconds, as reported by the battery.doubleVoltage of the battery, in Volts.booleanReports whether the battery is charging.booleanReports whether the battery is discharging.booleanReports whether the device is plugged in to an external power source.toString()booleanUpdates statistics on this battery.
-
Constructor Details
-
AbstractPowerSource
protected AbstractPowerSource(String name, String deviceName, double remainingCapacityPercent, double timeRemainingEstimated, double timeRemainingInstant, double powerUsageRate, double voltage, double amperage, boolean powerOnLine, boolean charging, boolean discharging, PowerSource.CapacityUnits capacityUnits, int currentCapacity, int maxCapacity, int designCapacity, int cycleCount, String chemistry, LocalDate manufactureDate, String manufacturer, String serialNumber, double temperature)
-
-
Method Details
-
getName
Description copied from interface:PowerSourceName of the power source at the Operating System level.- Specified by:
getNamein interfacePowerSource- Returns:
- The power source name, as reported by the operating system.
-
getDeviceName
Description copied from interface:PowerSourceName of the power source at the device level.- Specified by:
getDeviceNamein interfacePowerSource- Returns:
- The power source name, as reported by the device itself.
-
getRemainingCapacityPercent
public double getRemainingCapacityPercent()Description copied from interface:PowerSourceEstimated 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
PowerSource.getCurrentCapacity()toPowerSource.getMaxCapacity().- Specified by:
getRemainingCapacityPercentin interfacePowerSource- Returns:
- A value between 0.0 (fully drained) and 1.0 (fully charged)
-
getTimeRemainingEstimated
public double getTimeRemainingEstimated()Description copied from interface:PowerSourceEstimated 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.
- Specified by:
getTimeRemainingEstimatedin interfacePowerSource- Returns:
- If positive, seconds remaining. If negative, -1.0 (calculating) or -2.0 (unlimited)
-
getTimeRemainingInstant
public double getTimeRemainingInstant()Description copied from interface:PowerSourceEstimated 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
PowerSource.getTimeRemainingEstimated().- Specified by:
getTimeRemainingInstantin interfacePowerSource- Returns:
- Seconds remaining to fully discharge or fully charge the battery.
-
getPowerUsageRate
public double getPowerUsageRate()Description copied from interface:PowerSourcePower Usage Rate of the battery, in milliWatts (mW).- Specified by:
getPowerUsageRatein interfacePowerSource- Returns:
- If positive, the charge rate. If negative, the discharge rate.
-
getVoltage
public double getVoltage()Description copied from interface:PowerSourceVoltage of the battery, in Volts.- Specified by:
getVoltagein interfacePowerSource- Returns:
- the battery voltage, or -1 if unknown.
-
getAmperage
public double getAmperage()Description copied from interface:PowerSourceAmperage of the battery, in milliAmperes (mA).- Specified by:
getAmperagein interfacePowerSource- Returns:
- the battery amperage. If positive, charging the battery. If negative, discharging the battery.
-
isPowerOnLine
public boolean isPowerOnLine()Description copied from interface:PowerSourceReports whether the device is plugged in to an external power source.- Specified by:
isPowerOnLinein interfacePowerSource- Returns:
trueif plugged in,falseotherwise.
-
isCharging
public boolean isCharging()Description copied from interface:PowerSourceReports whether the battery is charging.- Specified by:
isChargingin interfacePowerSource- Returns:
trueif the battery is charging,falseotherwise.
-
isDischarging
public boolean isDischarging()Description copied from interface:PowerSourceReports whether the battery is discharging.- Specified by:
isDischargingin interfacePowerSource- Returns:
trueif the battery is discharging,falseotherwise.
-
getCapacityUnits
Description copied from interface:PowerSourceReports =the units ofPowerSource.getCurrentCapacity(),PowerSource.getMaxCapacity(), andPowerSource.getDesignCapacity()- Specified by:
getCapacityUnitsin interfacePowerSource- Returns:
- The units of battery capacity.
-
getCurrentCapacity
public int getCurrentCapacity()Description copied from interface:PowerSourceThe current (remaining) capacity of the battery.- Specified by:
getCurrentCapacityin interfacePowerSource- Returns:
- The current capacity. Units are defined by
PowerSource.getCapacityUnits().
-
getMaxCapacity
public int getMaxCapacity()Description copied from interface:PowerSourceThe 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.- Specified by:
getMaxCapacityin interfacePowerSource- Returns:
- The maximum capacity. Units are defined by
PowerSource.getCapacityUnits().
-
getDesignCapacity
public int getDesignCapacity()Description copied from interface:PowerSourceThe 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.- Specified by:
getDesignCapacityin interfacePowerSource- Returns:
- The design capacity. Units are defined by
PowerSource.getCapacityUnits().
-
getCycleCount
public int getCycleCount()Description copied from interface:PowerSourceThe cycle count of the battery, if known.- Specified by:
getCycleCountin interfacePowerSource- Returns:
- The cycle count of the battery, or -1 if unknown.
-
getChemistry
Description copied from interface:PowerSourceThe battery chemistry (e.g., Lithium Ion).- Specified by:
getChemistryin interfacePowerSource- Returns:
- the battery chemistry.
-
getManufactureDate
Description copied from interface:PowerSourceThe 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.
- Specified by:
getManufactureDatein interfacePowerSource- Returns:
- the manufacture date, if available. May be
null.
-
getManufacturer
Description copied from interface:PowerSourceThe name of the battery's manufacturer.- Specified by:
getManufacturerin interfacePowerSource- Returns:
- the manufacturer name.
-
getSerialNumber
Description copied from interface:PowerSourceThe 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.
- Specified by:
getSerialNumberin interfacePowerSource- Returns:
- the serial number.
-
getTemperature
public double getTemperature()Description copied from interface:PowerSourceThe battery's temperature, in degrees Celsius.- Specified by:
getTemperaturein interfacePowerSource- Returns:
- the battery's temperature, or 0 if uknown.
-
updateAttributes
public boolean updateAttributes()Description copied from interface:PowerSourceUpdates statistics on this battery.- Specified by:
updateAttributesin interfacePowerSource- Returns:
trueif the update was successful. Iffalsethe battery statistics are unchanged.
-
toString
-