Operating System Simulator Plugin  3.5.1
Unreal Engine plugin that simulates an Operating System Environment
Loading...
Searching...
No Matches
FOperatingSystemBattery Struct Reference

Represents the save/load data for a portable device battery. More...

#include "OperatingSystemSaveLoad.h"

Public Member Functions

FORCEINLINE void Validate (FGenericError &OutError) const
 
FORCEINLINE float GetEfficiencyLossValue () const
 
FORCEINLINE float GetBatteryHealth (const bool bNormalize) const
 
FORCEINLINE float GetTimeToFullyRechargeInSeconds () const
 
FORCEINLINE EOperatingSystemBatteryHealthState GetHealthState () const
 
FORCEINLINE FString GetHealthStateString () const
 
FORCEINLINE bool operator== (const FOperatingSystemBattery &Other) const
 
 FOperatingSystemBattery ()
 
 FOperatingSystemBattery (const FText &BatteryName, const FText &BatteryBrand)
 

Public Attributes

FText BatteryName
 
FText BatteryBrand
 
float BatteryCapacity
 
float ChargeRate
 
EOperatingSystemBatteryEfficiencyLoss EfficiencyLoss
 

Detailed Description

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

Constructor & Destructor Documentation

◆ FOperatingSystemBattery() [1/2]

FOperatingSystemBattery::FOperatingSystemBattery ( )
inline

◆ FOperatingSystemBattery() [2/2]

FOperatingSystemBattery::FOperatingSystemBattery ( const FText & BatteryName,
const FText & BatteryBrand )
inline

Member Function Documentation

◆ GetBatteryHealth()

FORCEINLINE float FOperatingSystemBattery::GetBatteryHealth ( const bool bNormalize) const
inline

Get the battery health value.

Parameters
bNormalizeFlag indicating whether to normalize the battery health value.
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:

Battery.EfficiencyLoss = EOperatingSystemBatteryEfficiencyLoss::FiftyPercent;
// Returns the default battery health value
float HealthValue = Battery.GetBatteryHealth(false);
// Returns the battery health value normalized to [0, 1]
float NormalizedHealthValue = Battery.GetBatteryHealth(true);
Represents the save/load data for a portable device battery.
EOperatingSystemBatteryEfficiencyLoss EfficiencyLoss
Definition OperatingSystemBattery.h:111
FORCEINLINE float GetBatteryHealth(const bool bNormalize) const
Definition OperatingSystemBattery.h:235

◆ GetEfficiencyLossValue()

FORCEINLINE float FOperatingSystemBattery::GetEfficiencyLossValue ( ) const
inline

Get the efficiency loss value based on the current efficiency loss setting.

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:

Battery.EfficiencyLoss = EOperatingSystemBatteryEfficiencyLoss::FiftyPercent;
float LossValue = Battery.GetEfficiencyLossValue(); // Returns 15.0
FORCEINLINE float GetEfficiencyLossValue() const
Definition OperatingSystemBattery.h:183
Here is the caller graph for this function:

◆ GetHealthState()

FORCEINLINE EOperatingSystemBatteryHealthState FOperatingSystemBattery::GetHealthState ( ) const
inline

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
The health state of the battery:
  • Unhealthy if the efficiency loss is 10%, 20%, or 30%
  • Poor if the efficiency loss is 40%, 50%, or 60%
  • Critical if the efficiency loss is 70%, 80%, or 90%
  • Healthy if the efficiency loss does not match any predefined thresholds
Here is the caller graph for this function:

◆ GetHealthStateString()

FORCEINLINE FString FOperatingSystemBattery::GetHealthStateString ( ) const
inline

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:

If the health state does not match any of the above values, the method will return "Unknown".

Returns
A string that represents the health state of the battery.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTimeToFullyRechargeInSeconds()

FORCEINLINE float FOperatingSystemBattery::GetTimeToFullyRechargeInSeconds ( ) const
inline

Calculate the time required to fully recharge the battery in seconds.

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:

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 seconds
float BatteryCapacity
Definition OperatingSystemBattery.h:101
float ChargeRate
Definition OperatingSystemBattery.h:105
FORCEINLINE float GetTimeToFullyRechargeInSeconds() const
Definition OperatingSystemBattery.h:261
Here is the call graph for this function:

◆ operator==()

FORCEINLINE bool FOperatingSystemBattery::operator== ( const FOperatingSystemBattery & Other) const
inline

◆ Validate()

FORCEINLINE void FOperatingSystemBattery::Validate ( FGenericError & OutError) const
inline

Validates the battery properties.

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.

Here is the caller graph for this function:

Member Data Documentation

◆ BatteryBrand

FText FOperatingSystemBattery::BatteryBrand

Brand name of this battery.

◆ BatteryCapacity

float FOperatingSystemBattery::BatteryCapacity

Total battery power. In milli-amp Hour units

◆ BatteryName

FText FOperatingSystemBattery::BatteryName

Battery Name

◆ ChargeRate

float FOperatingSystemBattery::ChargeRate

Speed at which this battery should charge. Higher rate charges battery faster.

◆ EfficiencyLoss

EOperatingSystemBatteryEfficiencyLoss FOperatingSystemBattery::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.


The documentation for this struct was generated from the following files: