File indexing completed on 2024-05-12 04:01:52
0001 /* 0002 SPDX-FileCopyrightText: 2006 Kevin Ottens <ervin@kde.org> 0003 SPDX-FileCopyrightText: 2012 Lukas Tinkl <ltinkl@redhat.com> 0004 SPDX-FileCopyrightText: 2014 Kai Uwe Broulik <kde@privat.broulik.de> 0005 0006 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 0009 #ifndef SOLID_IFACES_BATTERY_H 0010 #define SOLID_IFACES_BATTERY_H 0011 0012 #include <solid/battery.h> 0013 #include <solid/devices/ifaces/deviceinterface.h> 0014 0015 namespace Solid 0016 { 0017 namespace Ifaces 0018 { 0019 /** 0020 * This device interface is available on batteries. 0021 */ 0022 class Battery : virtual public DeviceInterface 0023 { 0024 public: 0025 /** 0026 * Destroys a Battery object. 0027 */ 0028 ~Battery() override; 0029 0030 /** 0031 * Indicates if this battery is currently present in its bay. 0032 * 0033 * @return true if the battery is present, false otherwise 0034 */ 0035 virtual bool isPresent() const = 0; 0036 0037 /** 0038 * Retrieves the type of device holding this battery. 0039 * 0040 * @return the type of device holding this battery 0041 * @see Solid::Battery::BatteryType 0042 */ 0043 virtual Solid::Battery::BatteryType type() const = 0; 0044 0045 /** 0046 * Retrieves the current charge level of the battery normalised 0047 * to percent. 0048 * 0049 * @return the current charge level normalised to percent 0050 */ 0051 virtual int chargePercent() const = 0; 0052 0053 /** 0054 * Retrieves the battery capacity normalised to percent, 0055 * meaning how much energy can it hold compared to what it is designed to. 0056 * The capacity of the battery will reduce with age. 0057 * A capacity value less than 75% is usually a sign that you should renew your battery. 0058 * 0059 * @since 4.11 0060 * @return the battery capacity normalised to percent 0061 */ 0062 virtual int capacity() const = 0; 0063 0064 /** 0065 * Indicates if the battery is rechargeable. 0066 * 0067 * @return true if the battery is rechargeable, false otherwise (one time usage) 0068 */ 0069 virtual bool isRechargeable() const = 0; 0070 0071 /** 0072 * Indicates if the battery is powering the machine. 0073 * 0074 * @return true if the battery is powersupply, false otherwise 0075 */ 0076 virtual bool isPowerSupply() const = 0; 0077 0078 /** 0079 * Retrieves the current charge state of the battery. It can be in a stable 0080 * state (no charge), charging or discharging. 0081 * 0082 * @return the current battery charge state 0083 * @see Solid::Battery::ChargeState 0084 */ 0085 virtual Solid::Battery::ChargeState chargeState() const = 0; 0086 0087 /** 0088 * Time (in seconds) until the battery is empty. 0089 * 0090 * @return time until the battery is empty 0091 * @since 5.0 0092 */ 0093 virtual qlonglong timeToEmpty() const = 0; 0094 0095 /** 0096 * Time (in seconds) until the battery is full. 0097 * 0098 * @return time until the battery is full 0099 * @since 5.0 0100 */ 0101 virtual qlonglong timeToFull() const = 0; 0102 0103 /** 0104 * Retrieves the technology used to manufacture the battery. 0105 * 0106 * @return the battery technology 0107 * @see Solid::Battery::Technology 0108 */ 0109 virtual Solid::Battery::Technology technology() const = 0; 0110 0111 /** 0112 * Amount of energy (measured in Wh) currently available in the power source. 0113 * 0114 * @return amount of battery energy in Wh 0115 */ 0116 virtual double energy() const = 0; 0117 0118 /** 0119 * Amount of energy (measured in Wh) the battery has when it is full. 0120 * 0121 * @return amount of battery energy when full in Wh 0122 * @since 5.7 0123 */ 0124 virtual double energyFull() const = 0; 0125 0126 /** 0127 * Amount of energy (measured in Wh) the battery should have by design hen it is full. 0128 * 0129 * @return amount of battery energy when full by design in Wh 0130 * @since 5.7 0131 */ 0132 virtual double energyFullDesign() const = 0; 0133 0134 /** 0135 * Amount of energy being drained from the source, measured in W. 0136 * If positive, the source is being discharged, if negative it's being charged. 0137 * 0138 * @return battery rate in Watts 0139 * 0140 */ 0141 virtual double energyRate() const = 0; 0142 0143 /** 0144 * Voltage in the Cell or being recorded by the meter. 0145 * 0146 * @return voltage in Volts 0147 */ 0148 virtual double voltage() const = 0; 0149 0150 /** 0151 * The temperature of the battery in degrees Celsius. 0152 * 0153 * @return the battery temperature in degrees Celsius 0154 * @since 5.0 0155 */ 0156 virtual double temperature() const = 0; 0157 0158 /** 0159 * The serial number of the battery 0160 * 0161 * @return the serial number of the battery 0162 * @since 5.0 0163 */ 0164 virtual QString serial() const = 0; 0165 0166 /** 0167 * Retrieves the current estimated remaining time of the system batteries 0168 * 0169 * @return the current global estimated remaining time in seconds 0170 * @since 5.8 0171 */ 0172 virtual qlonglong remainingTime() const = 0; 0173 0174 protected: 0175 // Q_SIGNALS: 0176 /** 0177 * This signal is emitted if the battery gets plugged in/out of the 0178 * battery bay. 0179 * 0180 * @param newState the new plugging state of the battery, type is boolean 0181 * @param udi the UDI of the battery with thew new plugging state 0182 */ 0183 virtual void presentStateChanged(bool newState, const QString &udi) = 0; 0184 0185 /** 0186 * This signal is emitted when the charge percent value of this 0187 * battery has changed. 0188 * 0189 * @param value the new charge percent value of the battery 0190 * @param udi the UDI of the battery with the new charge percent 0191 */ 0192 virtual void chargePercentChanged(int value, const QString &udi) = 0; 0193 0194 /** 0195 * This signal is emitted when the capacity of this battery has changed. 0196 * 0197 * @param value the new capacity of the battery 0198 * @param udi the UDI of the battery with the new capacity 0199 * @since 4.11 0200 */ 0201 virtual void capacityChanged(int value, const QString &udi) = 0; 0202 0203 /** 0204 * This signal is emitted when the power supply state of the battery 0205 * changes. 0206 * 0207 * @param newState the new power supply state, type is boolean 0208 * @param udi the UDI of the battery with the new power supply state 0209 * @since 4.11 0210 */ 0211 virtual void powerSupplyStateChanged(bool newState, const QString &udi) = 0; 0212 0213 /** 0214 * This signal is emitted when the charge state of this battery 0215 * has changed. 0216 * 0217 * @param newState the new charge state of the battery, it's one of 0218 * the type Solid::Battery::ChargeState 0219 * @see Solid::Battery::ChargeState 0220 * @param udi the UDI of the battery with the new charge state 0221 */ 0222 virtual void chargeStateChanged(int newState, const QString &udi = QString()) = 0; 0223 0224 /** 0225 * This signal is emitted when the time until the battery is empty 0226 * has changed. 0227 * 0228 * @param time the new remaining time 0229 * @param udi the UDI of the battery with the new remaining time 0230 * @since 5.0 0231 */ 0232 virtual void timeToEmptyChanged(qlonglong time, const QString &udi) = 0; 0233 0234 /** 0235 * This signal is emitted when the time until the battery is full 0236 * has changed. 0237 * 0238 * @param time the new remaining time 0239 * @param udi the UDI of the battery with the new remaining time 0240 * @since 5.0 0241 */ 0242 virtual void timeToFullChanged(qlonglong time, const QString &udi) = 0; 0243 0244 /** 0245 * This signal is emitted when the energy value of this 0246 * battery has changed. 0247 * 0248 * @param energy the new energy value of the battery 0249 * @param udi the UDI of the battery with the new energy value 0250 */ 0251 virtual void energyChanged(double energy, const QString &udi) = 0; 0252 0253 /** 0254 * This signal is emitted when the energy full value of this 0255 * battery has changed. 0256 * 0257 * @param energy the new energy full value of the battery 0258 * @param udi the UDI of the battery with the new energy full value 0259 */ 0260 virtual void energyFullChanged(double energy, const QString &udi) = 0; 0261 0262 /** 0263 * This signal is emitted when the energy full design value of this 0264 * battery has changed. 0265 * 0266 * @param energy the new energy full design value of the battery 0267 * @param udi the UDI of the battery with the new energy full design value 0268 */ 0269 virtual void energyFullDesignChanged(double energy, const QString &udi) = 0; 0270 0271 /** 0272 * This signal is emitted when the energy rate value of this 0273 * battery has changed. 0274 * 0275 * If positive, the source is being discharged, if negative it's being charged. 0276 * 0277 * @param energyRate the new energy rate value of the battery 0278 * @param udi the UDI of the battery with the new charge percent 0279 */ 0280 virtual void energyRateChanged(double energyRate, const QString &udi) = 0; 0281 0282 /** 0283 * This signal is emitted when the voltage in the cell has changed. 0284 * 0285 * @param voltage the new voltage of the cell 0286 * @param udi the UDI of the battery with the new voltage 0287 * @since 5.0 0288 */ 0289 virtual void voltageChanged(double voltage, const QString &udi) = 0; 0290 0291 /** 0292 * This signal is emitted when the battery temperature has changed. 0293 * 0294 * @param temperature the new temperature of the battery in degrees Celsius 0295 * @param udi the UDI of the battery with the new temperature 0296 * @since 5.0 0297 */ 0298 virtual void temperatureChanged(double temperature, const QString &udi) = 0; 0299 0300 /** 0301 * This signal is emitted when the estimated battery remaining time changes. 0302 * 0303 * @param time the new remaining time 0304 * @param udi the UDI of the battery with the new remaining time 0305 * @since 5.8 0306 */ 0307 virtual void remainingTimeChanged(qlonglong time, const QString &udi) = 0; 0308 }; 0309 } 0310 } 0311 0312 Q_DECLARE_INTERFACE(Solid::Ifaces::Battery, "org.kde.Solid.Ifaces.Battery/0.3") 0313 0314 #endif