|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 // INCLUDE FILES |
|
17 #include "HWRMBatteryMeasurementsAO.h" |
|
18 #include "HWRMBatteryChargeCurrentRateAO.h" |
|
19 #include "HWRMtrace.h" |
|
20 |
|
21 // ============================ MEMBER FUNCTIONS =============================== |
|
22 |
|
23 // ----------------------------------------------------------------------------- |
|
24 // CHWRMBatteryChargeRateCurrentAO::CHWRMBatteryChargeRateCurrentAO |
|
25 // C++ constructor can NOT contain any code, that |
|
26 // might leave. |
|
27 // ----------------------------------------------------------------------------- |
|
28 // |
|
29 CHWRMBatteryChargeRateCurrentAO::CHWRMBatteryChargeRateCurrentAO(MHWRMBatteryChargingCurrentObserver* aCallback, RHWRMClient& aClient) |
|
30 : CHWRMBatteryMeasurementsAttributeAO<TInt>(aClient), iCallback(aCallback) |
|
31 { |
|
32 CActiveScheduler::Add(this); |
|
33 } |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CHWRMBatteryVoltageMeasurementsObserver::NewL |
|
37 // Two-phased constructor |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CHWRMBatteryChargeRateCurrentAO* CHWRMBatteryChargeRateCurrentAO::NewL(MHWRMBatteryChargingCurrentObserver* aCallback, RHWRMClient& aClient) |
|
41 { |
|
42 |
|
43 CHWRMBatteryChargeRateCurrentAO* newInstance = new (ELeave) CHWRMBatteryChargeRateCurrentAO(aCallback, aClient); |
|
44 |
|
45 CleanupStack::PushL( newInstance ); |
|
46 |
|
47 newInstance->ConstructL(); |
|
48 |
|
49 CleanupStack::Pop(); |
|
50 |
|
51 return newInstance; |
|
52 } |
|
53 |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // Destructor |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CHWRMBatteryChargeRateCurrentAO::~CHWRMBatteryChargeRateCurrentAO() |
|
60 { |
|
61 Cancel(); |
|
62 } |
|
63 |
|
64 void CHWRMBatteryChargeRateCurrentAO::DoCancel() |
|
65 { |
|
66 SendCancel(EHWRMCancelAverageChargingCurrentReporting); |
|
67 } |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CHWRMBatteryChargeRateCurrentAO::ConstructL |
|
70 // Symbian 2nd phase constructor can leave. |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 void CHWRMBatteryChargeRateCurrentAO::ConstructL() |
|
74 { |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CHWRMBatteryChargeRateCurrentAO::RunL |
|
79 // invoked when request issued to hwrm server in AsynchGetBatch |
|
80 // completes |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 void CHWRMBatteryChargeRateCurrentAO::RunL() |
|
84 { |
|
85 TInt err = iStatus.Int(); |
|
86 |
|
87 if( (KErrNone != err) && (KErrTimedOut != err) ) |
|
88 { |
|
89 //if there is an error and it is not a timed out error |
|
90 iCallback->AverageChargingCurrentChange(err, 0); |
|
91 return; |
|
92 } |
|
93 |
|
94 iCount = iCountPckg(); |
|
95 |
|
96 //dispatch results received from server |
|
97 TUint index = 0; |
|
98 while(index < iCount) |
|
99 { |
|
100 iCallback->AverageChargingCurrentChange(KErrNone, iResultsArray[index]); |
|
101 ++index; |
|
102 } |
|
103 |
|
104 iResultsArray.Reset(); |
|
105 iCount = 0; |
|
106 |
|
107 // Re-order measurements only if reporting period has not expired on server |
|
108 if(KErrTimedOut != err) |
|
109 { |
|
110 //re-order measuremens batch from server. |
|
111 GetAsyncBatch(EHWRMGetAverageChargingCurrentMeasurements); |
|
112 } |
|
113 else |
|
114 { |
|
115 //it is a timed out error |
|
116 iCallback->AverageChargingCurrentChange(err, 0); |
|
117 } |
|
118 } |
|
119 |
|
120 void CHWRMBatteryChargeRateCurrentAO::CancelClientNotification() |
|
121 { |
|
122 iCallback->AverageChargingCurrentChange(KErrCancel, 0); |
|
123 } |
|
124 |
|
125 void CHWRMBatteryChargeRateCurrentAO::SetCallBack(TAny* aCallBack) |
|
126 { |
|
127 iCallback = (MHWRMBatteryChargingCurrentObserver*)aCallBack; |
|
128 } |
|
129 |
|
130 |
|
131 // End of File |