Class FreeBsdPowerSource
java.lang.Object
oshi.hardware.common.AbstractPowerSource
oshi.hardware.common.platform.unix.freebsd.FreeBsdPowerSource
- All Implemented Interfaces:
PowerSource
Shared FreeBSD power-source logic. Subclasses provide the sysctl backend (JNA or FFM) via
queryBattery(String, BiFunction, PowerSourceFactory).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceFactory for creating platform-specific FreeBsdPowerSource instances.Nested classes/interfaces inherited from interface PowerSource
PowerSource.CapacityUnitsModifier and TypeInterfaceDescriptionstatic enumUnits of Battery Capacity -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFreeBsdPowerSource(String psName, String psDeviceName, double psRemainingCapacityPercent, double psTimeRemainingEstimated, double psTimeRemainingInstant, double psPowerUsageRate, double psVoltage, double psAmperage, boolean psPowerOnLine, boolean psCharging, boolean psDischarging, PowerSource.CapacityUnits psCapacityUnits, int psCurrentCapacity, int psMaxCapacity, int psDesignCapacity, int psCycleCount, String psChemistry, LocalDate psManufactureDate, String psManufacturer, String psSerialNumber, double psTemperature) -
Method Summary
Modifier and TypeMethodDescriptionprotected static <T extends FreeBsdPowerSource>
List<PowerSource> queryBattery(String name, BiFunction<String, Integer, Integer> sysctlInt, FreeBsdPowerSource.PowerSourceFactory<T> factory) Queries battery information and constructs a power source instance using the provided sysctl accessor and factory.Methods inherited from class AbstractPowerSource
getAmperage, getCapacityUnits, getChemistry, getCurrentCapacity, getCycleCount, getDesignCapacity, getDeviceName, getManufactureDate, getManufacturer, getMaxCapacity, getName, getPowerUsageRate, getRemainingCapacityPercent, getSerialNumber, getTemperature, getTimeRemainingEstimated, getTimeRemainingInstant, getVoltage, isCharging, isDischarging, isPowerOnLine, queryPowerSources, toString, updateAttributesModifier 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.protected abstract List<PowerSource> Returns a fresh list of power sources for this platform, used byAbstractPowerSource.updateAttributes().toString()booleanUpdates statistics on this battery.
-
Constructor Details
-
FreeBsdPowerSource
protected FreeBsdPowerSource(String psName, String psDeviceName, double psRemainingCapacityPercent, double psTimeRemainingEstimated, double psTimeRemainingInstant, double psPowerUsageRate, double psVoltage, double psAmperage, boolean psPowerOnLine, boolean psCharging, boolean psDischarging, PowerSource.CapacityUnits psCapacityUnits, int psCurrentCapacity, int psMaxCapacity, int psDesignCapacity, int psCycleCount, String psChemistry, LocalDate psManufactureDate, String psManufacturer, String psSerialNumber, double psTemperature)
-
-
Method Details
-
queryBattery
protected static <T extends FreeBsdPowerSource> List<PowerSource> queryBattery(String name, BiFunction<String, Integer, Integer> sysctlInt, FreeBsdPowerSource.PowerSourceFactory<T> factory) Queries battery information and constructs a power source instance using the provided sysctl accessor and factory.- Type Parameters:
T- the concrete power source type- Parameters:
name- the battery name (e.g. "BAT0")sysctlInt- reads an integer sysctl given (name, default)factory- constructs the platform-specific instance- Returns:
- a list containing the power source
-