FOperatingSystemBattery
#include <OperatingSystemSimulator/Public/OperatingSystemBattery.h>Collaboration diagram
Section titled “Collaboration diagram”---
config:
class:
hideEmptyMembersBox: true
---
classDiagram
class FOperatingSystemBattery["FOperatingSystemBattery"]
class EOperatingSystemBatteryEfficiencyLoss["EOperatingSystemBatteryEfficiencyLoss"]
FOperatingSystemBattery ..> EOperatingSystemBatteryEfficiencyLoss
Class detail
Section titled “Class detail”---
config:
class:
hideEmptyMembersBox: true
---
classDiagram
class FOperatingSystemBattery {
+BatteryName : FText
+BatteryBrand : FText
+BatteryCapacity : float
+ChargeRate : float
+EfficiencyLoss : EOperatingSystemBatteryEfficiencyLoss()
+Validate(FGenericError &OutError) const
+GetEfficiencyLossValue() const float
+GetBatteryHealth(const bool bNormalize) const float
+GetTimeToFullyRechargeInSeconds() const float
+GetHealthState() const EOperatingSystemBatteryHealthState()
+GetHealthStateString() const FString
+operator==(const FOperatingSystemBattery &Other) const bool
+FOperatingSystemBattery()
+FOperatingSystemBattery(const FText &BatteryName, const FText &Batt
}
Caller impact — Validate
Section titled “Caller impact — Validate”Documented call sites inside the plugin (3):
flowchart LR FOperatingSystemBattery__Validate["FOperatingSystemBattery::Validate"] AOperatingSystemPortableDeviceActor__BeginChargingBattery["AOperatingSystemPortableDeviceActor::BeginChargingBattery"] AOperatingSystemPortableDeviceActor__BeginChargingBattery --> FOperatingSystemBattery__Validate AOperatingSystemPortableDeviceActor__OnValidate["AOperatingSystemPortableDeviceActor::OnValidate"] AOperatingSystemPortableDeviceActor__OnValidate --> FOperatingSystemBattery__Validate AOperatingSystemPortableDeviceActor__SetBattery["AOperatingSystemPortableDeviceActor::SetBattery"] AOperatingSystemPortableDeviceActor__SetBattery --> FOperatingSystemBattery__Validate
struct FOperatingSystemBatteryDefined in OperatingSystemBattery.h:87 Represents the save/load data for a portable device battery.
FOperatingSystemBattery is a struct that represents the properties and behavior of an operating system battery.
This struct stores the save/load data for a portable device battery. It includes information such as whether the battery is present, the battery level, and whether the device is a portable device or not.
See also: FOperatingSystemDeviceSaveLoad
Public Attributes
Section titled “Public Attributes”| Return | Name | Description |
|---|---|---|
FText | BatteryName | Battery Name |
FText | BatteryBrand | Brand name of this battery. |
float | BatteryCapacity | Total battery power. In milli-amp Hour units |
float | ChargeRate | Speed at which this battery should charge. Higher rate charges battery faster. |
EOperatingSystemBatteryEfficiencyLoss | EfficiencyLoss | Simulates energy loss while charging. Higher loss means more time to charge. This can also be considered as battery health. Higher loss means less healthy. For example: A battery with 3200 mAh and charge rate of 1000 mA will take 3.2 hours to fully charge without energy loss. With 40% energy loss it would take 4.5 hours to fully charge. |
BatteryName
Section titled “BatteryName”FText BatteryNameDefined in OperatingSystemBattery.h:93 Battery Name
Referenced by
Section titled “Referenced by”BatteryBrand
Section titled “BatteryBrand”FText BatteryBrandDefined in OperatingSystemBattery.h:97 Brand name of this battery.
Referenced by
Section titled “Referenced by”BatteryCapacity
Section titled “BatteryCapacity”float BatteryCapacityDefined in OperatingSystemBattery.h:101 Total battery power. In milli-amp Hour units
Referenced by
Section titled “Referenced by”ChargeRate
Section titled “ChargeRate”float ChargeRateDefined in OperatingSystemBattery.h:105 Speed at which this battery should charge. Higher rate charges battery faster.
Referenced by
Section titled “Referenced by”EfficiencyLoss
Section titled “EfficiencyLoss”EOperatingSystemBatteryEfficiencyLoss EfficiencyLossDefined in OperatingSystemBattery.h:111 Simulates energy loss while charging. Higher loss means more time to charge. This can also be considered as battery health. Higher loss means less healthy. For example: A battery with 3200 mAh and charge rate of 1000 mA will take 3.2 hours to fully charge without energy loss. With 40% energy loss it would take 4.5 hours to fully charge.
Referenced by
Section titled “Referenced by”Public Methods
Section titled “Public Methods”| Return | Name | Description |
|---|---|---|
void | Validate const inline | Validates the battery properties. |
float | GetEfficiencyLossValue const inline | Get the efficiency loss value based on the current efficiency loss setting. |
float | GetBatteryHealth const inline | Get the battery health value. |
float | GetTimeToFullyRechargeInSeconds const inline | Calculate the time required to fully recharge the battery in seconds. |
EOperatingSystemBatteryHealthState | GetHealthState const inline | Gets the health state of the battery. |
FString | GetHealthStateString const inline | Get the health state of the battery as a string representation. |
bool | operator== const inline | |
FOperatingSystemBattery inline | ||
FOperatingSystemBattery inline |
Validate
Section titled “Validate”const inline
inline void Validate(FGenericError & OutError) constDefined in OperatingSystemBattery.h:127 Validates the battery properties.
Parameters
Section titled “Parameters”OutErrorThe error object to store the validation error.
This method validates the battery properties and sets the OutError object with the validation error if any. The battery properties that are validated include:
-
BatteryName: The battery name should not be empty or consist of only whitespace.
-
BatteryBrand: The battery must have a valid brand set which is not empty or consist of only whitespace.
-
BatteryCapacity: The battery capacity must be 1000 or higher.
-
ChargeRate: The charge rate must be 1000 or higher.
If any of the above validations fail, the OutError object is set with the corresponding error message and the method returns early.
Referenced by
Section titled “Referenced by”References
Section titled “References”BatteryBrandBatteryCapacityBatteryNameChargeRateMAKE_ERROR
GetEfficiencyLossValue
Section titled “GetEfficiencyLossValue”const inline
inline float GetEfficiencyLossValue() constDefined in OperatingSystemBattery.h:183 Get the efficiency loss value based on the current efficiency loss setting.
Returns
Section titled “Returns”The efficiency loss value.
This will return a float value that represents the percentage of energy loss while charging the battery.
The possible efficiency loss settings and their corresponding efficiency loss values are as follows:
-
TenPercent: 11.0
-
TwentyPercent: 12.0
-
ThirtyPercent: 13.0
-
FortyPercent: 14.0
-
FiftyPercent: 15.0
-
SixtyPercent: 16.0
-
SeventyPercent: 17.0
-
EightyPercent: 18.0
-
NinetyPercent: 19.0
-
NoLoss (Default): 10.0
If the efficiency loss setting is not recognized, the method returns the default efficiency loss value of 10.0.
Example usage:
FOperatingSystemBattery Battery;Battery.EfficiencyLoss = EOperatingSystemBatteryEfficiencyLoss::FiftyPercent;float LossValue = Battery.GetEfficiencyLossValue(); // Returns 15.0Referenced by
Section titled “Referenced by”References
Section titled “References”EfficiencyLossEightyPercentFiftyPercentFortyPercentNinetyPercentNoLossSeventyPercentSixtyPercentTenPercentThirtyPercentTwentyPercent
GetBatteryHealth
Section titled “GetBatteryHealth”const inline
inline float GetBatteryHealth(const bool bNormalize) constDefined in OperatingSystemBattery.h:235 Get the battery health value.
Parameters
Section titled “Parameters”bNormalizeFlag indicating whether to normalize the battery health value.
Returns
Section titled “Returns”The battery health value.
This method returns the battery health value as a float. The battery health value represents the percentage of energy loss while charging the battery. By default, the efficiency loss value is calculated using the formula ((static_cast<uint8>(EfficiencyLoss) + 1) * 100.f) / 10.f. If bNormalize is true, the efficiency loss value is normalized to a range of [0, 1] using the formula (static_cast<uint8>(EfficiencyLoss) + 1) / 10.f.
Example usage:
FOperatingSystemBattery Battery;Battery.EfficiencyLoss = EOperatingSystemBatteryEfficiencyLoss::FiftyPercent;
// Returns the default battery health valuefloat HealthValue = Battery.GetBatteryHealth(false);
// Returns the battery health value normalized to [0, 1]float NormalizedHealthValue = Battery.GetBatteryHealth(true);References
Section titled “References”GetTimeToFullyRechargeInSeconds
Section titled “GetTimeToFullyRechargeInSeconds”const inline
inline float GetTimeToFullyRechargeInSeconds() constDefined in OperatingSystemBattery.h:261 Calculate the time required to fully recharge the battery in seconds.
Returns
Section titled “Returns”The time required to fully recharge the battery in seconds.
This method calculates the time required to fully recharge the battery in seconds based on the battery capacity, charge rate, and efficiency loss value. The formula used to calculate the time is: ((BatteryCapacity / ChargeRate) * GetEfficiencyLossValue()) / 10.f) * 3600.f
Please note that the efficiency loss value is obtained by calling the GetEfficiencyLossValue() method. The efficiency loss value represents the percentage of energy loss while charging the battery.
Example usage:
FOperatingSystemBattery Battery;Battery.BatteryCapacity = 3200.f;Battery.ChargeRate = 1000.f;Battery.EfficiencyLoss = EOperatingSystemBatteryEfficiencyLoss::FortyPercent;float TimeToFullyRecharge = Battery.GetTimeToFullyRechargeInSeconds(); // Returns the time required to fully recharge the battery in secondsReferences
Section titled “References”GetHealthState
Section titled “GetHealthState”const inline
inline EOperatingSystemBatteryHealthState GetHealthState() constDefined in OperatingSystemBattery.h:279 Gets the health state of the battery.
This method returns the current health state of the battery based on the efficiency loss value. The efficiency loss value is compared to predefined thresholds to determine the health state.
Returns
Section titled “Returns”The health state of the battery:
-
Unhealthyif the efficiency loss is 10%, 20%, or 30% -
Poorif the efficiency loss is 40%, 50%, or 60% -
Criticalif the efficiency loss is 70%, 80%, or 90% -
Healthyif the efficiency loss does not match any predefined thresholds
Referenced by
Section titled “Referenced by”References
Section titled “References”CriticalEfficiencyLossEightyPercentFiftyPercentFortyPercentHealthyNinetyPercentPoorSeventyPercentSixtyPercentTenPercentThirtyPercentTwentyPercentUnhealthy
GetHealthStateString
Section titled “GetHealthStateString”const inline
inline FString GetHealthStateString() constDefined in OperatingSystemBattery.h:317 Get the health state of the battery as a string representation.
This method returns a string that represents the health state of the battery. The health state is determined by the value returned by the GetHealthState() method. The possible health states and their corresponding string representations are as follows:
-
EOperatingSystemBatteryHealthState::Healthy: “Healthy”
-
EOperatingSystemBatteryHealthState::Unhealthy: “Unhealthy”
-
EOperatingSystemBatteryHealthState::Poor: “Poor”
-
EOperatingSystemBatteryHealthState::Critical: “Critical”
If the health state does not match any of the above values, the method will return “Unknown”.
Returns
Section titled “Returns”A string that represents the health state of the battery.
Referenced by
Section titled “Referenced by”References
Section titled “References”CriticalGetHealthStateHealthyPoorUnhealthy
operator==
Section titled “operator==”const inline
inline bool operator==(const FOperatingSystemBattery & Other) constDefined in OperatingSystemBattery.h:336
References
Section titled “References”FOperatingSystemBattery
Section titled “FOperatingSystemBattery”inline
inline FOperatingSystemBattery()Defined in OperatingSystemBattery.h:345
Section titled “Defined in OperatingSystemBattery.h:345”FOperatingSystemBattery
Section titled “FOperatingSystemBattery”inline
inline FOperatingSystemBattery(const FText & BatteryName, const FText & BatteryBrand)Defined in OperatingSystemBattery.h:354