33#include <NDEVR/Device.h>
virtual fltp04 batteryLevel(BatteryCapacityType type) const
Returns the current battery level for a given capacity type.
virtual void forceBatteryState(const BatteryState &state)
Forces the battery into a specific state, overriding automatic state determination.
Vector< 3, BatteryCapacityInfo > m_capacity_info
Capacity info indexed by BatteryCapacityType.
virtual BatteryState batteryState() const
Returns the current state of this individual battery.
virtual void autoUpdateBatteryState(BatteryCapacityType mode)
Re-evaluates the battery state based on the current level and thresholds for the given mode.
BatteryState m_bat_state
Current state of this individual battery.
virtual void setBatteryLevel(BatteryCapacityType type, fltp04 value, bool update_state=true)
Sets the current battery level for a given capacity type.
Buffer< Battery * > m_battery_group_members
Other batteries in this battery's group.
BatteryState m_bat_group_state
Aggregate state of the battery group.
void setCapacityInfo(BatteryCapacityType type, const BatteryCapacityInfo &info)
Sets the capacity info for a given capacity type.
bool m_is_charging
Whether the battery is currently charging.
BatteryState m_forced_bat_state
Manually forced state, if any.
fltp04 percent() const
Returns the battery charge as a percentage, using the best available capacity type.
void addBatteryGroupMember(Battery *battery)
Adds another Battery to this battery's group for aggregate state tracking.
void showWarning(const TranslatedString &warning) const override
Displays a warning message associated with this battery device.
void batteryStateChangedSignal()
Emitted when this battery's state changes.
void setIsCharging(bool is_charging)
Sets whether the battery is currently charging.
Time m_last_state_stable_time
Timestamp of the last stable state transition.
bool isCharging() const
Checks whether the battery is currently charging.
Battery(const Model &name, LogPtr log, QObject *parent=nullptr)
Constructs a Battery device.
virtual BatteryState batteryGroupState() const
Returns the worst state among all batteries in this battery's group.
BatteryCapacityInfo capacityInfo(BatteryCapacityType type) const
Returns the capacity info for a given capacity type.
void batteryGroupStateChangedSignal(bool originator)
Emitted when the aggregate battery group state changes.
The equivelent of std::vector but with a bit more control.
Device(const Model &model, LogPtr log, QObject *parent=nullptr)
Constructs a Device from a Model with the given log and optional Qt parent.
JavaScript Object Notation or JSON is an open - standard file format that uses human - readable text ...
A light-weight wrapper that will be a no-op if there is not a valid log reference,...
Serves as the primary program interface for processes to report issues and allows any number of LogSt...
A core class that represents a node on model hierarchy.
Represents a timestamp with utilities for manipulation and conversion.
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
BatteryState
An indication of what state a Battery object is in.
@ e_shutdown_voltage
Battery voltage is at or below the shutdown threshold.
@ e_no_battery
No battery is present.
@ e_critical_voltage
Battery voltage has reached a critical level.
@ e_low_voltage
Battery voltage has dropped below the warning threshold.
@ e_invalid
No fix available or fix is invalid.
BatteryCapacityType
The various types of capacity information a Battery may have.
@ e_watt_hours
Capacity expressed in watt-hours.
@ e_voltage
Capacity expressed as a raw voltage reading.
@ e_percentage
Capacity expressed as a percentage of full charge.
@ e_normal
Normal map channel for per-pixel lighting.
For a given BatteryCapacityType, the limits that define the state of the battery.
void fromJSONNode(const JSONNode &node)
Deserializes capacity info from a JSON node.
bool operator!=(const BatteryCapacityInfo &info) const
Inequality comparison operator.
fltp04 percent() const
Computes the capacity as a percentage of the maximum level.
fltp04 max_level
The maximum capacity level when fully charged.
fltp04 shutdown_level
The threshold at or below which the device should shut down.
fltp04 critical_level
The threshold at which the battery state becomes critical.
void toJSONNode(JSONNode &node) const
Serializes this capacity info into a JSON node.
fltp04 current_level
The current capacity level.
bool canChangeBatteryState() const
Checks whether this capacity info has enough valid data to determine battery state.
fltp04 discharge_rate
The rate at which capacity is being consumed.
fltp04 warning_level
The threshold at which a low-battery warning is issued.