CHWRMPower Class Reference

#include <hwrmpower.h>

Link against: hwrmpowerclient.lib

class CHWRMPower : public CBase, public CBase

Inherits from

Detailed Description

HW Resource Manager Power API is a library API providing the ability to request detailed information regarding the battery capacity, voltage and current consumption.

The API consists of the classes CHWRMPower, MHWRMBatteryConsumptionObserver and MHWRMBatteryVoltageObserver. If the client requires periodical measurements of the Average Voltage and/or Average Consumption, it should also provide callback pointer of the MHWRMBatteryConsumptionObserver and/or MHWRMBatteryVoltageObserver implementing class for the NewL() method.

Usage:

 #include <hwrmpower.h> 

 // A CHWRMPower instance can be created by using NewL() or NewLC() methods. 
 // Periodical measurements are required so callbacks are provided. Assume 
 // the calling object implements  both interfaces.
 CHWRMPower* power = CHWRMPower::NewL(this, this);

 // Get battery info.
 TRequestStatus& status;
 TBatteryConsumptionData batteryConsumptionData;
 power->GetBatteryInfo(status, batteryConsumptionData); 
 
 User::WaitForRequest(status);
 User::LeaveIfError(status.Int());
 
 // Start receiving periodical power measurements.
 //
 // Note: There is a maximum reporting period defined for each product through the
 //       CenRep Key KPowerMaxReportingPeriod defined in HWRMPowerDomainCRKeys.h.
 //       The reporting will stop after this maximum reporting period by default.
 //       The application can configure this dynamically.
 //       Setting maximum report period to zero results in infinite notifications.
 //
 TRequestStatus& statusStart;
 TInt intervalMultiple = 3; // Three times the base time interval.
 //
 // Note: The base time interval is different for each product.
 //       GetBaseTimeIntervalL API returns this value.
 //
 power->StartAverageVoltageReporting(statusStart, intervalMultiple);
  
 User::WaitForRequest(statusStart);
 User::LeaveIfError(statusStart.Int());
 
 // Measurements are being when the ProcessVoltageMeasurement() method 
 // of the MHWRMBatteryVoltageObserver interface is called.
  
 // Stop receiving measurements when done
 power->StopAverageVoltageReportingL(); 

 // To clean up, delete the created object:
 delete power;

Constructor & Destructor Documentation

~CHWRMPower ( )

IMPORT_C~CHWRMPower()

C++ Destructor

Member Function Documentation

GetBaseTimeIntervalL ( TInt & )

IMPORT_C voidGetBaseTimeIntervalL(TInt &aBaseTimeInterval)

Get the Base Time interval used by the plugin

Parameters
aBaseTimeIntervalThe Base Time Interval is returned in this parameter.

GetBatteryInfo ( TRequestStatus &, TBatteryConsumptionData & )

IMPORT_C voidGetBatteryInfo(TRequestStatus &aStatus,
TBatteryConsumptionData &aBatteryConsumptionData
)

Asynch

Get the Battery Info

See also: CHWRMPower::TBatteryConsumptionData

Parameters
aStatusThis will be completed when the data are ready or an error occurs.
aBatteryConsumptionDataThe nominal battery info is returned in this parameter. Valid only when aStatus.Int() == KErrNone

GetBatteryVoltageInfo ( TRequestStatus &, TBatteryVoltageData & )

IMPORT_C voidGetBatteryVoltageInfo(TRequestStatus &aStatus,
TBatteryVoltageData &aBatteryVoltageData
)

Asynch

Get the Battery Voltage Info

See also: CHWRMPower::TBatteryVoltageData

Parameters
aStatusThis will be completed when the data are ready or an error occurs.
aBatteryVoltageDataThe nominal battery info is returned in this parameter. Valid only when aStatus.Int() == KErrNone

NewL ( )

IMPORT_C CHWRMPower *NewL()[static]

Two-phased constructor for creating a CHWRMPower client.

NewLC ( )

IMPORT_C CHWRMPower *NewLC()[static]

Two-phased constructor for creating a CHWRMPower client. Leaves instance to CleanupStack.

SetPowerReportObserver ( MHWRMBatteryPowerObserver * )

IMPORT_C TIntSetPowerReportObserver(MHWRMBatteryPowerObserver *aPowerReportCallback)

StartAveragePowerReporting ( TRequestStatus &, const TUint & )

IMPORT_C TIntStartAveragePowerReporting(TRequestStatus &aStatus,
const TUint &aInterval
)

Post Start request to HWRM Server to start battery Power measurements

Parameters
aStatusThis will be completed when measurements start or an error occurs.

StopAveragePowerReportingL ( )

IMPORT_C voidStopAveragePowerReportingL()

Synchronous

Post stop request to HWRM Server to stop battery power measurements

success/failure for stopping measurements.