|
1 // Copyright (c) 2006-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 |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "HWRMServer.h" |
|
21 #include "HWRMService.h" |
|
22 #include "HWRMPowerService.h" |
|
23 #include "HWRMPluginHandler.h" |
|
24 #include "HWRMPowerCommands.h" |
|
25 #include "HWRMPowerClientServer.h" |
|
26 #include "HWRMPower.h" |
|
27 #include "HWRMtrace.h" |
|
28 |
|
29 // CONSTANTS |
|
30 _LIT( KPanicCategory, "HWRMPowerService" ); |
|
31 |
|
32 #ifdef SYMBIAN_HWRM_EXTPOWERINFO |
|
33 |
|
34 //All the measurements from the plugin are sent to client. |
|
35 const TUint KRemainingChargingTimeInterval(1); |
|
36 |
|
37 #endif |
|
38 // ============================ MEMBER FUNCTIONS =============================== |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CHWRMPowerService::CHWRMPowerService |
|
42 // C++ constructor |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 CHWRMPowerService::CHWRMPowerService(CHWRMPowerCommonData& aPowerCommonData) |
|
46 : iPowerCommonData(aPowerCommonData) |
|
47 { |
|
48 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::CHWRMPowerService()" )); |
|
49 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::CHWRMPowerService - return" )); |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CHWRMPowerService::ConstructL |
|
54 // Symbian 2nd phase constructor can leave. |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 void CHWRMPowerService::ConstructL(CHWRMPluginHandler* aPluginHandler) |
|
58 { |
|
59 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMPowerService::ConstructL(0x%x)" ), aPluginHandler); |
|
60 |
|
61 __ASSERT_ALWAYS(aPluginHandler, User::Panic(KPanicCategory, EPanicBadHandle)); |
|
62 |
|
63 BaseConstructL(aPluginHandler, NULL); |
|
64 |
|
65 iPowerVoltageCurrentMeasurementsClientData = new(ELeave) TPowerVoltageCurrentMeasurementsClientData(); |
|
66 |
|
67 #ifdef SYMBIAN_HWRM_EXTPOWERINFO |
|
68 iPowerChargingCurrentMeasurementsClientData = new(ELeave) TPowerIntMeasurementsClientData(); |
|
69 |
|
70 iPowerChargingTimeMeasurementsClientData = new(ELeave)TPowerIntMeasurementsClientData(); |
|
71 iPowerChargingTimeMeasurementsClientData->iRequestedIntervalMultiple = KRemainingChargingTimeInterval; |
|
72 #endif //SYMBIAN_HWRM_EXTPOWERINFO |
|
73 |
|
74 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::ConstructL - return " ) ); |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CHWRMPowerService::NewL |
|
79 // Two-phased constructor. |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 CHWRMPowerService* CHWRMPowerService::NewL(CHWRMPluginHandler* aPluginHandler, CHWRMPowerCommonData& aPowerCommonData) |
|
83 { |
|
84 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMPowerService::NewL(0x%x)" ), aPluginHandler); |
|
85 |
|
86 CHWRMPowerService* self = new( ELeave ) CHWRMPowerService(aPowerCommonData); |
|
87 |
|
88 CleanupStack::PushL( self ); |
|
89 self->ConstructL(aPluginHandler); |
|
90 CleanupStack::Pop( self ); |
|
91 |
|
92 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMPowerService::NewL - return 0x%x" ), self ); |
|
93 |
|
94 return self; |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------- |
|
98 // Destructor |
|
99 // --------------------------------------------------------- |
|
100 // |
|
101 CHWRMPowerService::~CHWRMPowerService() |
|
102 { |
|
103 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::~CHWRMPowerService()" ) ); |
|
104 |
|
105 iPowerCommonData.CancelPendingGetBatteryInfo(*this); |
|
106 iPowerCommonData.CancelPendingGetBatteryVoltageInfo(*this); |
|
107 |
|
108 if (iPowerVoltageCurrentMeasurementsClientData) |
|
109 { |
|
110 iPowerVoltageCurrentMeasurementsClientData->CancelPendingGetMeasurementsMessage(); |
|
111 iPowerCommonData.iPowerReportClientsData->RemoveMeasurementsClientData(iPowerVoltageCurrentMeasurementsClientData); |
|
112 |
|
113 delete iPowerVoltageCurrentMeasurementsClientData; |
|
114 iPowerVoltageCurrentMeasurementsClientData = NULL; |
|
115 |
|
116 if (iPowerCommonData.iPowerReportClientsData->IsClientsQueEmpty() && |
|
117 iPowerCommonData.iPowerReportClientsData->IsMeasuringOn()) |
|
118 { |
|
119 TRAPD(err, iPowerCommonData.DoStopPowerMeasurementsL()); |
|
120 if (err != KErrNone) |
|
121 { |
|
122 // Cannot do anything here. Just trace it |
|
123 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMPowerService::~CHWRMPowerService() - Stopping power(currentAndvoltage) measurement failed: %d" ), err); |
|
124 } |
|
125 } |
|
126 } |
|
127 |
|
128 |
|
129 #ifdef SYMBIAN_HWRM_EXTPOWERINFO |
|
130 |
|
131 if (iPowerChargingCurrentMeasurementsClientData) |
|
132 { |
|
133 iPowerChargingCurrentMeasurementsClientData->CancelPendingGetMeasurementsMessage(); |
|
134 iPowerCommonData.iChargingCurrentClientsData->RemoveMeasurementsClientData(iPowerChargingCurrentMeasurementsClientData); |
|
135 |
|
136 delete iPowerChargingCurrentMeasurementsClientData; |
|
137 iPowerChargingCurrentMeasurementsClientData = NULL; |
|
138 |
|
139 if (iPowerCommonData.iChargingCurrentClientsData->IsClientsQueEmpty() && |
|
140 iPowerCommonData.iChargingCurrentClientsData->IsMeasuringOn()) |
|
141 { |
|
142 TRAPD(err, iPowerCommonData.DoStopChargingCurrentMeasurementsL()); |
|
143 if (err != KErrNone) |
|
144 { |
|
145 // Cannot do anything here. Just trace it |
|
146 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMPowerService::~CHWRMPowerService() - Stopping charging current measurement failed: %d" ), err); |
|
147 } |
|
148 } |
|
149 } |
|
150 |
|
151 |
|
152 if (iPowerChargingTimeMeasurementsClientData) |
|
153 { |
|
154 iPowerChargingTimeMeasurementsClientData->CancelPendingGetMeasurementsMessage(); |
|
155 iPowerCommonData.iChargingTimeClientsData->RemoveMeasurementsClientData(iPowerChargingTimeMeasurementsClientData); |
|
156 |
|
157 delete iPowerChargingTimeMeasurementsClientData; |
|
158 iPowerChargingTimeMeasurementsClientData = NULL; |
|
159 |
|
160 if (iPowerCommonData.iChargingTimeClientsData->IsClientsQueEmpty() && |
|
161 iPowerCommonData.iChargingTimeClientsData->IsMeasuringOn()) |
|
162 { |
|
163 TRAPD(err, iPowerCommonData.DoStopChargingTimeMeasurementsL()); |
|
164 if (err != KErrNone) |
|
165 { |
|
166 // Cannot do anything here. Just trace it |
|
167 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMPowerService::~CHWRMPowerService() - Stopping charging time measurement failed: %d" ), err); |
|
168 } |
|
169 } |
|
170 } |
|
171 |
|
172 #endif //SYMBIAN_HWRM_EXTPOWERINFO |
|
173 |
|
174 // Base class cleanup |
|
175 BaseDestruct(); |
|
176 |
|
177 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::~CHWRMPowerService - return" ) ); |
|
178 } |
|
179 |
|
180 // ----------------------------------------------------------------------------- |
|
181 // CHWRMPowerService::ExecuteMessageL |
|
182 // Handles Power requests. Called from the client session via CSession2::ServiceL |
|
183 // ----------------------------------------------------------------------------- |
|
184 // |
|
185 TBool CHWRMPowerService::ExecuteMessageL( const RMessage2& aMessage ) |
|
186 { |
|
187 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMPowerService::ExecuteMessageL(0x%x)" ), aMessage.Function()); |
|
188 |
|
189 if ( aMessage.IsNull() ) |
|
190 { |
|
191 User::Leave(KErrBadHandle); |
|
192 } |
|
193 |
|
194 // All messages are by default asynchronous because of the nature of the plugin API |
|
195 TBool completeMessage(EFalse); |
|
196 |
|
197 switch ( aMessage.Function() ) |
|
198 { |
|
199 case EHWRMCleanupBattery: |
|
200 { |
|
201 COMPONENT_TRACE1( _L("HWRM Server - CHWRMPowerService::ExecuteMessageL - EHWRMCleanupBattery") ); |
|
202 |
|
203 CleanupPowerL(); |
|
204 completeMessage = ETrue; |
|
205 |
|
206 break; |
|
207 } |
|
208 |
|
209 case EHWRMGetBatteryInfo: |
|
210 { |
|
211 COMPONENT_TRACE1( _L("HWRM Server - CHWRMPowerService::ExecuteMessageL - EHWRMGetBatteryInfo") ); |
|
212 |
|
213 // The plugin command will be issued by the service belonging to the PowerCommonData. The PowerCommonData |
|
214 // keep a list of all the pending requests. A plugin command is issued only for the first request. If a client |
|
215 // requests the same data and finds that there is a pending plugin request it won't issue a new one. |
|
216 // Will be completed all together when the plugin responds to the service. |
|
217 |
|
218 iPowerCommonData.DoGetBatteryInfoL(aMessage, *this); |
|
219 |
|
220 break; |
|
221 } |
|
222 |
|
223 case EHWRMGetBatteryVoltageInfo: |
|
224 { |
|
225 COMPONENT_TRACE1( _L("HWRM Server - CHWRMPowerService::ExecuteMessageL - EHWRMGetBatteryVoltageInfo") ); |
|
226 |
|
227 // The plugin command will be issued by the service belonging to the PowerCommonData. The PowerCommonData |
|
228 // keep a list of all the pending requests. A plugin command is issued only for the first request. If a client |
|
229 // requests the same data and finds that there is a pending plugin request it won't issue a new one. |
|
230 // Will be completed all together when the plugin responds to the service. |
|
231 |
|
232 iPowerCommonData.DoGetBatteryVoltageInfoL(aMessage, *this); |
|
233 |
|
234 break; |
|
235 } |
|
236 |
|
237 case EHWRMStartAverageBatteryPowerReporting: |
|
238 { |
|
239 COMPONENT_TRACE1( _L("HWRM Server - CHWRMPowerService::ExecuteMessageL - EHWRMStartAverageBatteryPowerReporting") ); |
|
240 |
|
241 if (iPowerVoltageCurrentMeasurementsClientData->IsMeasuringOn() || |
|
242 iPowerVoltageCurrentMeasurementsClientData->iRequestedStartMessage.Handle()) |
|
243 { |
|
244 User::Leave(KErrAlreadyExists); |
|
245 } |
|
246 |
|
247 TPckgBuf<TUint> intervalMultiplePckg; |
|
248 aMessage.ReadL(0,intervalMultiplePckg); |
|
249 |
|
250 iPowerVoltageCurrentMeasurementsClientData->iRequestedIntervalMultiple = intervalMultiplePckg(); |
|
251 |
|
252 if (iPowerCommonData.iPowerReportClientsData->IsMeasuringOn()) |
|
253 { |
|
254 COMPONENT_TRACE1( _L("HWRM Server - CHWRMPowerService::ExecuteMessageL - EHWRMStartAverageBatteryPowerReporting: Power Reporting is already On") ); |
|
255 |
|
256 // plugin is already ON. |
|
257 // Just add it to the list and (if needed) update the plugin Interval Multiple |
|
258 |
|
259 if (iPowerCommonData.iPowerReportClientsData->NeedPluginIntervalAdjustment(iPowerVoltageCurrentMeasurementsClientData->iRequestedIntervalMultiple)) |
|
260 { |
|
261 TUint currentPluginIntervalMultiple; |
|
262 iPowerCommonData.iPowerReportClientsData->GetPluginIntervalMultiple(currentPluginIntervalMultiple); |
|
263 TUint currentGCD = currentPluginIntervalMultiple; |
|
264 |
|
265 TUint newPluginIntervalMultiple; |
|
266 TUint clientsInterval = intervalMultiplePckg(); |
|
267 TUint newGCD = iPowerCommonData.iPowerReportClientsData->CalculateGCD(currentGCD, clientsInterval); |
|
268 |
|
269 newPluginIntervalMultiple = newGCD; |
|
270 |
|
271 // save the message so that the message is completed when the plugin responds |
|
272 iPowerVoltageCurrentMeasurementsClientData->iRequestedStartMessage = aMessage; |
|
273 |
|
274 SetPluginIntervalMultipleL(HWRMPowerCommand::ESetPowerReportingIntervalMultipleCmdId, newPluginIntervalMultiple); |
|
275 } |
|
276 else |
|
277 { |
|
278 iPowerCommonData.iPowerReportClientsData->AddMeasurementsClientL(*iPowerVoltageCurrentMeasurementsClientData); |
|
279 iPowerVoltageCurrentMeasurementsClientData->SetMeasuringOn(); |
|
280 |
|
281 completeMessage = ETrue; // won't issue a plugin request. Accesses the common data |
|
282 } |
|
283 } |
|
284 else |
|
285 { |
|
286 // send command to the plugin to start Average Battery measurements |
|
287 // if successful client will be added on the plugin response |
|
288 iPowerVoltageCurrentMeasurementsClientData->iRequestedStartMessage = aMessage; |
|
289 |
|
290 StartAverageBatteryPowerReportingL(aMessage); |
|
291 } |
|
292 break; |
|
293 } |
|
294 |
|
295 |
|
296 #ifdef SYMBIAN_HWRM_EXTPOWERINFO |
|
297 |
|
298 case EHWRMStartAverageChargingCurrentReporting: |
|
299 { |
|
300 COMPONENT_TRACE1( _L("HWRM Server - CHWRMPowerService::ExecuteMessageL - EHWRMStartAverageChargingCurrentReporting") ); |
|
301 |
|
302 if (iPowerChargingCurrentMeasurementsClientData->IsMeasuringOn() || |
|
303 iPowerChargingCurrentMeasurementsClientData->iRequestedStartMessage.Handle()) |
|
304 { |
|
305 User::Leave(KErrAlreadyExists); |
|
306 } |
|
307 |
|
308 TPckgBuf<TUint> intervalPckg; |
|
309 aMessage.ReadL(0,intervalPckg); |
|
310 |
|
311 iPowerChargingCurrentMeasurementsClientData->iRequestedIntervalMultiple = intervalPckg(); |
|
312 |
|
313 if (iPowerCommonData.iChargingCurrentClientsData->IsMeasuringOn()) |
|
314 { |
|
315 COMPONENT_TRACE1( _L("HWRM Server - CHWRMPowerService::ExecuteMessageL - EHWRMStartAverageChargingCurrentReporting: is already On") ); |
|
316 |
|
317 // plugin is already ON. |
|
318 // Just add it to the list and (if needed) update the plugin Interval Multiple |
|
319 |
|
320 if (iPowerCommonData.iChargingCurrentClientsData->NeedPluginIntervalAdjustment(iPowerChargingCurrentMeasurementsClientData->iRequestedIntervalMultiple)) |
|
321 { |
|
322 TUint currentPluginIntervalMultiple; |
|
323 iPowerCommonData.iChargingCurrentClientsData->GetPluginIntervalMultiple(currentPluginIntervalMultiple); |
|
324 TUint currentGCD = currentPluginIntervalMultiple; |
|
325 |
|
326 TUint newPluginIntervalMultiple; |
|
327 TUint clientsInterval = intervalPckg(); |
|
328 TUint newGCD = iPowerCommonData.iChargingCurrentClientsData->CalculateGCD(currentGCD, clientsInterval); |
|
329 |
|
330 newPluginIntervalMultiple = newGCD; |
|
331 |
|
332 // save the message so that the message is completed when the plugin responds |
|
333 iPowerChargingCurrentMeasurementsClientData->iRequestedStartMessage = aMessage; |
|
334 |
|
335 SetPluginIntervalMultipleL(HWRMPowerCommand::ESetChargeCurrentIntervalMultipleCmdId, newPluginIntervalMultiple); |
|
336 } |
|
337 else |
|
338 { |
|
339 iPowerCommonData.iChargingCurrentClientsData->AddMeasurementsClientL(*iPowerChargingCurrentMeasurementsClientData); |
|
340 iPowerChargingCurrentMeasurementsClientData->SetMeasuringOn(); |
|
341 |
|
342 completeMessage = ETrue; // won't issue a plugin request. Accesses the common data |
|
343 } |
|
344 } |
|
345 else |
|
346 { |
|
347 // send command to the plugin to start Average Battery measurements |
|
348 // if successful client will be added on the plugin response |
|
349 iPowerChargingCurrentMeasurementsClientData->iRequestedStartMessage = aMessage; |
|
350 |
|
351 StartAverageChargingCurrentReportingL(aMessage); |
|
352 } |
|
353 break; |
|
354 } |
|
355 |
|
356 |
|
357 case EHWRMStartBatteryFullChargingTimeReporting: |
|
358 { |
|
359 COMPONENT_TRACE1( _L("HWRM Server - CHWRMPowerService::ExecuteMessageL - EHWRMStartBatteryFullChargingTimeReporting") ); |
|
360 |
|
361 if (iPowerChargingTimeMeasurementsClientData->IsMeasuringOn() || |
|
362 iPowerChargingTimeMeasurementsClientData->iRequestedStartMessage.Handle()) |
|
363 { |
|
364 User::Leave(KErrAlreadyExists); |
|
365 } |
|
366 |
|
367 //Set to 1, as all measurements are sent to client. |
|
368 //The time interval is determined by plugin. |
|
369 iPowerChargingTimeMeasurementsClientData->iRequestedIntervalMultiple = 1; |
|
370 |
|
371 if (iPowerCommonData.iChargingTimeClientsData->IsMeasuringOn()) |
|
372 { |
|
373 COMPONENT_TRACE1( _L("HWRM Server - CHWRMPowerService::ExecuteMessageL - EHWRMStartBatteryFullChargingTimeReporting: Charging Time Reporting is already On") ); |
|
374 |
|
375 // plugin is already ON. |
|
376 // Just add it to the list as no plugin interval update is required. |
|
377 |
|
378 iPowerCommonData.iChargingTimeClientsData->AddMeasurementsClientL(*iPowerChargingTimeMeasurementsClientData); |
|
379 iPowerChargingTimeMeasurementsClientData->SetMeasuringOn(); |
|
380 |
|
381 completeMessage = ETrue; // won't issue a plugin request. Accesses the common data |
|
382 |
|
383 } |
|
384 else |
|
385 { |
|
386 // send command to the plugin to start Battery Full Charging Time reporting |
|
387 // if successful client will be added on the plugin response |
|
388 iPowerChargingTimeMeasurementsClientData->iRequestedStartMessage = aMessage; |
|
389 |
|
390 StartChargingTimeReportingL(aMessage); |
|
391 } |
|
392 break; |
|
393 } |
|
394 |
|
395 #endif //SYMBIAN_HWRM_EXTPOWERINFO |
|
396 |
|
397 case EHWRMGetPowerMeasurements: |
|
398 { |
|
399 COMPONENT_TRACE1( _L("HWRM Server - CHWRMPowerService::ExecuteMessageL - EHWRMGetPowerMeasurements") ); |
|
400 |
|
401 if (iPowerVoltageCurrentMeasurementsClientData->iRequestedBatchMessage.Handle()) |
|
402 { |
|
403 // Not allowed to have more than one pending getBatch messages. |
|
404 User::Leave(KErrServerBusy); |
|
405 } |
|
406 |
|
407 if (iPowerVoltageCurrentMeasurementsClientData->IsMeasuringOn()) |
|
408 { |
|
409 // if there is a measurement ready the message is completed. |
|
410 // if not the commondata will complete the message when ready |
|
411 completeMessage = iPowerVoltageCurrentMeasurementsClientData->GetMeasurementsL( aMessage ); |
|
412 } |
|
413 else if (iPowerVoltageCurrentMeasurementsClientData->iRequestedStartMessage.Handle()) |
|
414 { |
|
415 // else waiting for plugin to start measurements. Don't complete message just save it. |
|
416 iPowerVoltageCurrentMeasurementsClientData->iRequestedBatchMessage = aMessage; |
|
417 } |
|
418 else |
|
419 { |
|
420 // Measurements have been stoped by client or because Max Reporting period was reached |
|
421 // Need to issue a start before retrieving measurements |
|
422 User::Leave(KErrNotReady); |
|
423 } |
|
424 |
|
425 break; |
|
426 } |
|
427 |
|
428 |
|
429 #ifdef SYMBIAN_HWRM_EXTPOWERINFO |
|
430 |
|
431 case EHWRMGetAverageChargingCurrentMeasurements: |
|
432 { |
|
433 COMPONENT_TRACE1( _L("HWRM Server - CHWRMPowerService::ExecuteMessageL - EHWRMGetAverageChargingCurrentMeasurements") ); |
|
434 |
|
435 if (iPowerChargingCurrentMeasurementsClientData->iRequestedBatchMessage.Handle()) |
|
436 { |
|
437 // Not allowed to have more than one pending getBatch messages. |
|
438 User::Leave(KErrServerBusy); |
|
439 } |
|
440 |
|
441 if (iPowerChargingCurrentMeasurementsClientData->IsMeasuringOn()) |
|
442 { |
|
443 // if there is a measurement ready the message is completed. |
|
444 // if not the commondata will complete the message when ready |
|
445 completeMessage = iPowerChargingCurrentMeasurementsClientData->GetMeasurementsL( aMessage ); |
|
446 } |
|
447 else if (iPowerChargingCurrentMeasurementsClientData->iRequestedStartMessage.Handle()) |
|
448 { |
|
449 // else waiting for plugin to start measurements. Don't complete message just save it. |
|
450 iPowerChargingCurrentMeasurementsClientData->iRequestedBatchMessage = aMessage; |
|
451 } |
|
452 else |
|
453 { |
|
454 // Measurements have been stoped by client or because Max Reporting period was reached |
|
455 // Need to issue a start before retrieving measurements |
|
456 User::Leave(KErrNotReady); |
|
457 } |
|
458 |
|
459 break; |
|
460 } |
|
461 |
|
462 |
|
463 case EHWRMGetBatteryFullChargingTimeMeasurements: |
|
464 { |
|
465 COMPONENT_TRACE1( _L("HWRM Server - CHWRMPowerService::ExecuteMessageL - EHWRMGetBatteryFullChargingTimeMeasurements") ); |
|
466 |
|
467 if (iPowerChargingTimeMeasurementsClientData->iRequestedBatchMessage.Handle()) |
|
468 { |
|
469 // Not allowed to have more than one pending getBatch messages. |
|
470 User::Leave(KErrServerBusy); |
|
471 } |
|
472 |
|
473 if (iPowerChargingTimeMeasurementsClientData->IsMeasuringOn()) |
|
474 { |
|
475 // if there is a measurement ready the message is completed. |
|
476 // if not the commondata will complete the message when ready |
|
477 completeMessage = iPowerChargingTimeMeasurementsClientData->GetMeasurementsL( aMessage ); |
|
478 } |
|
479 else if (iPowerChargingTimeMeasurementsClientData->iRequestedStartMessage.Handle()) |
|
480 { |
|
481 // else waiting for plugin to start measurements. Don't complete message just save it. |
|
482 iPowerChargingTimeMeasurementsClientData->iRequestedBatchMessage = aMessage; |
|
483 } |
|
484 else |
|
485 { |
|
486 // Measurements have been stoped by client or because Max Reporting period was reached |
|
487 // Need to issue a start before retrieving measurements |
|
488 User::Leave(KErrNotReady); |
|
489 } |
|
490 |
|
491 break; |
|
492 } |
|
493 |
|
494 #endif //SYMBIAN_HWRM_EXTPOWERINFO |
|
495 |
|
496 case EHWRMStopAverageBatteryPowerReporting: |
|
497 { |
|
498 if (iPowerVoltageCurrentMeasurementsClientData->IsMeasuringOn() || |
|
499 iPowerVoltageCurrentMeasurementsClientData->iRequestedStartMessage.Handle()) |
|
500 { |
|
501 // will leave if client is not found in the list. Hence, no client that has not issued |
|
502 // a start can call stop for a measurements session |
|
503 iPowerCommonData.iPowerReportClientsData->RemoveMeasurementsClientL(iPowerVoltageCurrentMeasurementsClientData); |
|
504 |
|
505 iPowerVoltageCurrentMeasurementsClientData->CompleteGetMeasurementsMessage(KErrNone); |
|
506 iPowerVoltageCurrentMeasurementsClientData->CompletePendingStart(KErrNone); |
|
507 |
|
508 //if there are no registered clients stop the plugin measurements |
|
509 if(iPowerCommonData.iPowerReportClientsData->IsClientsQueEmpty()) |
|
510 { |
|
511 // send command to the plugin to stop Average Battery power measurements |
|
512 iPowerCommonData.DoStopPowerMeasurementsL(); |
|
513 } |
|
514 else |
|
515 { |
|
516 TUint newIntervalMultiple; |
|
517 TUint currentIntervalMultiple; |
|
518 |
|
519 iPowerCommonData.iPowerReportClientsData->RecalculatePluginInterval(newIntervalMultiple); |
|
520 TUint newGCD = newIntervalMultiple; |
|
521 |
|
522 iPowerCommonData.iPowerReportClientsData->GetPluginIntervalMultiple(currentIntervalMultiple); |
|
523 TUint currentGCD = currentIntervalMultiple; |
|
524 |
|
525 if( newGCD != currentGCD) |
|
526 { |
|
527 iPowerCommonData.DoSetPluginIntervalMultipleL(HWRMPowerCommand::ESetPowerReportingIntervalMultipleCmdId, newIntervalMultiple); |
|
528 } |
|
529 } |
|
530 } |
|
531 |
|
532 completeMessage = ETrue; // plugin request. is issued by the common data service |
|
533 |
|
534 iPowerVoltageCurrentMeasurementsClientData->Reset(); |
|
535 |
|
536 break; |
|
537 } |
|
538 |
|
539 #ifdef SYMBIAN_HWRM_EXTPOWERINFO |
|
540 |
|
541 case EHWRMStopAverageChargingCurrentReporting: |
|
542 { |
|
543 if (iPowerChargingCurrentMeasurementsClientData->IsMeasuringOn() || |
|
544 iPowerChargingCurrentMeasurementsClientData->iRequestedStartMessage.Handle()) |
|
545 { |
|
546 // will leave if client is not found in the list. Hence, no client that has not issued |
|
547 // a start can call stop for a measurements session |
|
548 iPowerCommonData.iChargingCurrentClientsData->RemoveMeasurementsClientL(iPowerChargingCurrentMeasurementsClientData); |
|
549 |
|
550 iPowerChargingCurrentMeasurementsClientData->CompleteGetMeasurementsMessage(KErrNone); |
|
551 iPowerChargingCurrentMeasurementsClientData->CompletePendingStart(KErrNone); |
|
552 |
|
553 //if there are no registered clients stop the plugin measurements |
|
554 if(iPowerCommonData.iChargingCurrentClientsData->IsClientsQueEmpty()) |
|
555 { |
|
556 // send command to the plugin to stop Average charge current measurements |
|
557 iPowerCommonData.DoStopChargingCurrentMeasurementsL(); |
|
558 } |
|
559 else |
|
560 { |
|
561 TUint newIntervalMultiple; |
|
562 TUint currentIntervalMultiple; |
|
563 |
|
564 iPowerCommonData.iChargingCurrentClientsData->RecalculatePluginInterval(newIntervalMultiple); |
|
565 TUint newGCD = newIntervalMultiple; |
|
566 |
|
567 iPowerCommonData.iChargingCurrentClientsData->GetPluginIntervalMultiple(currentIntervalMultiple); |
|
568 TUint currentGCD = currentIntervalMultiple; |
|
569 |
|
570 if( newGCD != currentGCD) |
|
571 { |
|
572 iPowerCommonData.DoSetPluginIntervalMultipleL(HWRMPowerCommand::ESetChargeCurrentIntervalMultipleCmdId, newIntervalMultiple); |
|
573 } |
|
574 } |
|
575 } |
|
576 |
|
577 completeMessage = ETrue; // plugin request. is issued by the common data service |
|
578 |
|
579 iPowerChargingCurrentMeasurementsClientData->Reset(); |
|
580 |
|
581 break; |
|
582 } |
|
583 |
|
584 |
|
585 case EHWRMStopBatteryFullChargingTimeReporting: |
|
586 { |
|
587 if (iPowerChargingTimeMeasurementsClientData->IsMeasuringOn() || |
|
588 iPowerChargingTimeMeasurementsClientData->iRequestedStartMessage.Handle()) |
|
589 { |
|
590 // will leave if client is not found in the list. Hence, no client that has not issued |
|
591 // a start can call stop for a measurements session |
|
592 iPowerCommonData.iChargingTimeClientsData->RemoveMeasurementsClientL(iPowerChargingTimeMeasurementsClientData); |
|
593 |
|
594 iPowerChargingTimeMeasurementsClientData->CompleteGetMeasurementsMessage(KErrNone); |
|
595 iPowerChargingTimeMeasurementsClientData->CompletePendingStart(KErrNone); |
|
596 |
|
597 //if there are no registered clients stop the plugin measurements |
|
598 if(iPowerCommonData.iChargingTimeClientsData->IsClientsQueEmpty()) |
|
599 { |
|
600 // send command to the plugin to stop Average Battery voltage measurements |
|
601 iPowerCommonData.DoStopChargingTimeMeasurementsL(); |
|
602 } |
|
603 } |
|
604 |
|
605 completeMessage = ETrue; // plugin request. is issued by the common data service |
|
606 |
|
607 iPowerChargingTimeMeasurementsClientData->Reset(); |
|
608 |
|
609 break; |
|
610 } |
|
611 |
|
612 #endif //SYMBIAN_HWRM_EXTPOWERINFO |
|
613 |
|
614 case EHWRMCancelAveragePowerReporting: |
|
615 { |
|
616 COMPONENT_TRACE1( _L("HWRM Server - CHWRMPowerService::ExecuteMessageL - EHWRMCancelAveragePowerReporting") ); |
|
617 |
|
618 if (iPowerVoltageCurrentMeasurementsClientData->IsMeasuringOn() || |
|
619 iPowerVoltageCurrentMeasurementsClientData->iRequestedStartMessage.Handle()) |
|
620 { |
|
621 iPowerVoltageCurrentMeasurementsClientData->CancelPendingGetMeasurementsMessage(); |
|
622 } |
|
623 |
|
624 completeMessage = ETrue; // no responses from plugin cancel commands |
|
625 break; |
|
626 } |
|
627 |
|
628 #ifdef SYMBIAN_HWRM_EXTPOWERINFO |
|
629 |
|
630 case EHWRMCancelAverageChargingCurrentReporting: |
|
631 { |
|
632 COMPONENT_TRACE1( _L("HWRM Server - CHWRMPowerService::ExecuteMessageL - EHWRMCancelAverageChargingCurrentReporting") ); |
|
633 |
|
634 if (iPowerChargingCurrentMeasurementsClientData->IsMeasuringOn() || |
|
635 iPowerChargingCurrentMeasurementsClientData->iRequestedStartMessage.Handle()) |
|
636 { |
|
637 iPowerChargingCurrentMeasurementsClientData->CancelPendingGetMeasurementsMessage(); |
|
638 } |
|
639 |
|
640 completeMessage = ETrue; // no responses from plugin cancel commands |
|
641 break; |
|
642 } |
|
643 |
|
644 |
|
645 case EHWRMCancelBatteryFullChargingTimeReporting: |
|
646 { |
|
647 COMPONENT_TRACE1( _L("HWRM Server - CHWRMPowerService::ExecuteMessageL - EHWRMCancelBatteryFullChargingTimeReporting") ); |
|
648 |
|
649 if (iPowerChargingTimeMeasurementsClientData->IsMeasuringOn() || |
|
650 iPowerChargingTimeMeasurementsClientData->iRequestedStartMessage.Handle()) |
|
651 { |
|
652 iPowerChargingTimeMeasurementsClientData->CancelPendingGetMeasurementsMessage(); |
|
653 } |
|
654 |
|
655 completeMessage = ETrue; // no responses from plugin cancel commands |
|
656 break; |
|
657 } |
|
658 |
|
659 case EHWRMGetBatteryChargerType: |
|
660 { |
|
661 COMPONENT_TRACE1( _L("HWRM Server - CHWRMPowerService::ExecuteMessageL - EHWRMGetBatteryChargerType") ); |
|
662 |
|
663 // The plugin command will be issued by the service belonging to the PowerCommonData. The PowerCommonData |
|
664 // keep a list of all the pending requests. A plugin command is issued only for the first request. If a client |
|
665 // requests the same data and finds that there is a pending plugin request it won't issue a new one. |
|
666 // Will be completed all together when the plugin responds to the service. |
|
667 |
|
668 iPowerCommonData.DoGetChargerTypeL(aMessage, *this); |
|
669 |
|
670 |
|
671 break; |
|
672 } |
|
673 |
|
674 #endif //SYMBIAN_HWRM_EXTPOWERINFO |
|
675 |
|
676 // Cannot identify the message, panic the client |
|
677 default: |
|
678 { |
|
679 CHWRMServer::PanicClient(aMessage, EPanicIllegalFunction); |
|
680 |
|
681 break; |
|
682 } |
|
683 } |
|
684 |
|
685 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMPowerService::ExecuteMessageL - return 0x%x" ), completeMessage ); |
|
686 |
|
687 return completeMessage; |
|
688 } |
|
689 |
|
690 // ----------------------------------------------------------------------------- |
|
691 // CHWRMPowerService::GetBatteryInfoL |
|
692 // Sends a plug-in command to query the battery info |
|
693 // ----------------------------------------------------------------------------- |
|
694 // |
|
695 void CHWRMPowerService::GetBatteryInfoL(const RMessage2& aMessage) |
|
696 { |
|
697 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::GetBatteryInfoL" ) ); |
|
698 |
|
699 ExecutePluginCommandL(aMessage, HWRMPowerCommand::EGetBatteryInfoCmdId, EFalse/*not split*/ ); |
|
700 |
|
701 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::GetBatteryInfoL - return" ) ); |
|
702 } |
|
703 |
|
704 // ----------------------------------------------------------------------------- |
|
705 // CHWRMPowerService::GetBatteryVoltageInfoL |
|
706 // Sends a plug-in command to query the battery voltage info |
|
707 // ----------------------------------------------------------------------------- |
|
708 // |
|
709 void CHWRMPowerService::GetBatteryVoltageInfoL(const RMessage2& aMessage) |
|
710 { |
|
711 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::GetBatteryVoltageInfoL" ) ); |
|
712 |
|
713 ExecutePluginCommandL(aMessage, HWRMPowerCommand::EGetBatteryVoltageInfoCmdId, EFalse/*not split*/ ); |
|
714 |
|
715 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::GetBatteryVoltageInfoL - return" ) ); |
|
716 } |
|
717 |
|
718 // ----------------------------------------------------------------------------- |
|
719 // CHWRMPowerService::StartAverageBatteryVoltageReportingL |
|
720 // Sends a plug-in command to start the average charge rate reporting |
|
721 // ----------------------------------------------------------------------------- |
|
722 // |
|
723 void CHWRMPowerService::StartAverageBatteryPowerReportingL(const RMessage2& aMessage) |
|
724 { |
|
725 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::StartAverageBatteryPowerReportingL" ) ); |
|
726 |
|
727 |
|
728 TPckgBuf<TUint> intervalMultiplePckg; |
|
729 aMessage.ReadL(0,intervalMultiplePckg); |
|
730 |
|
731 ExecutePluginCommandL(aMessage, HWRMPowerCommand::EStartAverageBatteryPowerReportingCmdId, EFalse, intervalMultiplePckg); |
|
732 |
|
733 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::StartAverageBatteryPowerReportingL - return" ) ); |
|
734 } |
|
735 |
|
736 |
|
737 // ----------------------------------------------------------------------------- |
|
738 // CHWRMPowerService::StopAverageBatteryPowerReportingL |
|
739 // Sends a plug-in command to stop the average power reporting |
|
740 // ----------------------------------------------------------------------------- |
|
741 // |
|
742 void CHWRMPowerService::StopAverageBatteryPowerReportingL(const RMessage2& aMessage) |
|
743 { |
|
744 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::StopAverageBatteryPowerReportingL" ) ); |
|
745 |
|
746 ExecutePluginCommandL(aMessage, HWRMPowerCommand::EStopAverageBatteryPowerReportingCmdId, EFalse/*not split*/ ); |
|
747 |
|
748 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::StopAverageBatteryPowerReportingL - return" ) ); |
|
749 } |
|
750 |
|
751 |
|
752 #ifdef SYMBIAN_HWRM_EXTPOWERINFO |
|
753 // ----------------------------------------------------------------------------- |
|
754 // CHWRMPowerService::StartAverageBatteryVoltageReportingL |
|
755 // Sends a plug-in command to start the average charge rate reporting |
|
756 // ----------------------------------------------------------------------------- |
|
757 // |
|
758 void CHWRMPowerService::StartAverageChargingCurrentReportingL(const RMessage2& aMessage) |
|
759 { |
|
760 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::StartAverageChargingCurrentReportingL" ) ); |
|
761 |
|
762 |
|
763 TPckgBuf<TUint> intervalMultiplePckg; |
|
764 aMessage.ReadL(0,intervalMultiplePckg); |
|
765 |
|
766 ExecutePluginCommandL(aMessage, HWRMPowerCommand::EStartAverageBatteryChargingCurrentReportingCmdId, EFalse, intervalMultiplePckg); |
|
767 |
|
768 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::StartAverageChargingCurrentReportingL - return" ) ); |
|
769 } |
|
770 |
|
771 |
|
772 |
|
773 // ----------------------------------------------------------------------------- |
|
774 // CHWRMPowerService::StopAverageChargingCurrentReportingL |
|
775 // Sends a plug-in command to stop the average battery voltage reporting |
|
776 // ----------------------------------------------------------------------------- |
|
777 // |
|
778 void CHWRMPowerService::StopAverageChargingCurrentReportingL(const RMessage2& aMessage) |
|
779 { |
|
780 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::StopAverageChargingCurrentReportingL" ) ); |
|
781 |
|
782 ExecutePluginCommandL(aMessage, HWRMPowerCommand::EStopAverageBatteryChargingCurrentReportingCmdId, EFalse/*not split*/ ); |
|
783 |
|
784 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::StopAverageChargingCurrentReportingL - return" ) ); |
|
785 } |
|
786 |
|
787 |
|
788 // ----------------------------------------------------------------------------- |
|
789 // CHWRMPowerService::StartChargingTimeReportingL |
|
790 // Sends a plug-in command to start the battery full charging time reporing |
|
791 // ----------------------------------------------------------------------------- |
|
792 // |
|
793 void CHWRMPowerService::StartChargingTimeReportingL(const RMessage2& aMessage) |
|
794 { |
|
795 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::StartChargingTimeReportingL" ) ); |
|
796 |
|
797 ExecutePluginCommandL(aMessage, HWRMPowerCommand::EStartBatteryFullChargingTimeReportingCmdId, EFalse); |
|
798 |
|
799 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::StartChargingTimeReportingL - return" ) ); |
|
800 } |
|
801 |
|
802 |
|
803 // ----------------------------------------------------------------------------- |
|
804 // CHWRMPowerService::StopChargingTimeReportingL |
|
805 // Sends a plug-in command to stop the battery full charging time reporing |
|
806 // ----------------------------------------------------------------------------- |
|
807 // |
|
808 void CHWRMPowerService::StopChargingTimeReportingL(const RMessage2& aMessage) |
|
809 { |
|
810 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::StopChargingTimeReportingL" ) ); |
|
811 |
|
812 ExecutePluginCommandL(aMessage, HWRMPowerCommand::EStopBatteryFullChargingTimeReportingCmdId, EFalse/*not split*/ ); |
|
813 |
|
814 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::StopChargingTimeReportingL - return" ) ); |
|
815 } |
|
816 |
|
817 #endif //SYMBIAN_HWRM_EXTPOWERINFO |
|
818 |
|
819 // ----------------------------------------------------------------------------- |
|
820 // CHWRMPowerService::ProcessResponseL |
|
821 // Handles responses to Power requests. |
|
822 // ----------------------------------------------------------------------------- |
|
823 // |
|
824 void CHWRMPowerService::ProcessResponseL( TInt aCommandId, TUint8 aTransId, TDesC8& aData, TBool aTimeout ) |
|
825 { |
|
826 COMPONENT_TRACE4( _L( "HWRM Server - CHWRMPowerService::ProcessResponseL(%d , %d, <data>, %d)" ), aCommandId, aTransId, aTimeout ); |
|
827 |
|
828 TInt pluginErr(KErrNone); // Error came from plugin as data (or timeout). Used to complete RMessage. |
|
829 TInt contextErr(KErrNone); // Error in context, i.e. bad handle or descriptor. Used to leave. |
|
830 TBool completeRequest(ETrue); // All messages by default are completed by the HWRMService. The data stored |
|
831 // in the transaction list for each plugin request are also deleted by |
|
832 // the HWRMService.In the case that the request was not initiated by a client |
|
833 // but by the PowerCommonData (using a dummy RMessage2) we handle the |
|
834 // completion of the request and destruction of the data locally. |
|
835 if ( aTimeout) |
|
836 { |
|
837 pluginErr = KErrTimedOut; |
|
838 } |
|
839 else if ( CheckResponseDataSize(aCommandId, aData) == EFalse ) |
|
840 { |
|
841 pluginErr = KErrBadDescriptor; |
|
842 } |
|
843 else |
|
844 { |
|
845 // Handle the response |
|
846 switch ( aCommandId ) |
|
847 { |
|
848 case HWRMPowerCommand::EGetBatteryInfoCmdId: |
|
849 { |
|
850 completeRequest = EFalse; |
|
851 // The message will be completed here so remove and delete the data from the transaction list. |
|
852 THWRMPluginRequestData* data = static_cast<THWRMPluginRequestData*>(iTransactionList->FindTransaction(aTransId, ETrue)); |
|
853 if (data) |
|
854 { |
|
855 delete data; |
|
856 data = NULL; |
|
857 } |
|
858 |
|
859 // Unpack the battery info |
|
860 HWRMPowerCommand::TBatteryConsumptionResponsePackage consumptionDataPckg; |
|
861 consumptionDataPckg.Copy(aData); |
|
862 HWRMPowerCommand::TBatteryConsumptionResponseData consumptionData = consumptionDataPckg(); |
|
863 |
|
864 pluginErr = consumptionData.iErrorCode; |
|
865 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMPowerService::ProcessResponseL, EGetBatteryConsumptionInfoCmdId error = %d" ), pluginErr ); |
|
866 |
|
867 if ( pluginErr == KErrNone ) |
|
868 { |
|
869 CHWRMPower::TBatteryConsumptionData clientConsumptionData; |
|
870 clientConsumptionData.iNominalCapacity = consumptionData.iNominalCapacity; |
|
871 clientConsumptionData.iRemainingCapacity = consumptionData.iRemainingCapacity; |
|
872 clientConsumptionData.iRemainingPercentageCapacity = consumptionData.iRemainingPercentageCapacity; |
|
873 |
|
874 TPckg<CHWRMPower::TBatteryConsumptionData> clientConsumptionPckg(clientConsumptionData); |
|
875 |
|
876 // Complete and remove from the respective list all the clients (if any, beacuse some may have closed the session) |
|
877 // that have requested Battery Info. |
|
878 iPowerCommonData.CompletePendingGetBatteryInfo(pluginErr, clientConsumptionPckg); |
|
879 } |
|
880 else |
|
881 { |
|
882 // Complete the the clients with the plugin error |
|
883 CHWRMPower::TBatteryConsumptionData clientConsumptionData; |
|
884 TPckg<CHWRMPower::TBatteryConsumptionData> emptyDes(clientConsumptionData); |
|
885 iPowerCommonData.CompletePendingGetBatteryInfo(pluginErr, emptyDes); |
|
886 } |
|
887 } |
|
888 break; |
|
889 |
|
890 case HWRMPowerCommand::EGetBatteryVoltageInfoCmdId: |
|
891 { |
|
892 completeRequest = EFalse; |
|
893 // The message will be completed here so remove and delete the data from the transaction list. |
|
894 THWRMPluginRequestData* data = static_cast<THWRMPluginRequestData*>(iTransactionList->FindTransaction(aTransId, ETrue)); |
|
895 if (data) |
|
896 { |
|
897 delete data; |
|
898 data = NULL; |
|
899 } |
|
900 |
|
901 // Unpack the battery info |
|
902 HWRMPowerCommand::TBatteryVoltageResponsePackage voltageDataPckg; |
|
903 voltageDataPckg.Copy(aData); |
|
904 HWRMPowerCommand::TBatteryVoltageResponseData voltageData = voltageDataPckg(); |
|
905 |
|
906 pluginErr = voltageData.iErrorCode; |
|
907 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMPowerService::ProcessResponseL, EGetBatteryVoltageInfoCmdId error = %d" ), pluginErr ); |
|
908 |
|
909 if ( pluginErr == KErrNone ) |
|
910 { |
|
911 CHWRMPower::TBatteryVoltageData clientVoltageData; |
|
912 clientVoltageData.iMaximumVoltage = voltageData.iMaximumVoltage; |
|
913 clientVoltageData.iMinimumVoltage = voltageData.iMinimumVoltage; |
|
914 clientVoltageData.iRemainingVoltage = voltageData.iRemainingVoltage; |
|
915 |
|
916 TPckg<CHWRMPower::TBatteryVoltageData> clientVoltagePckg(clientVoltageData); |
|
917 |
|
918 // Complete and remove from the respective list all the clients (if any, beacuse some may have closed the session) |
|
919 // that have requested Battery Info. |
|
920 iPowerCommonData.CompletePendingGetBatteryVoltageInfo(pluginErr, clientVoltagePckg); |
|
921 } |
|
922 else |
|
923 { |
|
924 // Complete the the clients with the plugin error |
|
925 CHWRMPower::TBatteryVoltageData clientVoltageData; |
|
926 TPckg<CHWRMPower::TBatteryVoltageData> emptyDes(clientVoltageData); |
|
927 iPowerCommonData.CompletePendingGetBatteryVoltageInfo(pluginErr, emptyDes); |
|
928 } |
|
929 } |
|
930 break; |
|
931 |
|
932 case HWRMPowerCommand::EStartAverageBatteryPowerReportingCmdId: |
|
933 { |
|
934 HWRMPowerCommand::TErrorCodeResponsePackage respPckg; |
|
935 respPckg.Copy(aData); |
|
936 pluginErr = respPckg(); |
|
937 |
|
938 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMPowerService::ProcessResponseL, EStartAverageBatteryPowerReportingCmdId error = %d" ), pluginErr ); |
|
939 |
|
940 if (pluginErr == KErrNone) |
|
941 { |
|
942 iPowerCommonData.iPowerReportClientsData->SetMeasuringOn(); |
|
943 |
|
944 THWRMPluginRequestData* data = static_cast<THWRMPluginRequestData*>(iTransactionList->FindTransaction(aTransId, EFalse)); |
|
945 |
|
946 if ( data ) |
|
947 { |
|
948 // client is added to the voltage clients' list |
|
949 iPowerCommonData.iPowerReportClientsData->AddMeasurementsClientL(*iPowerVoltageCurrentMeasurementsClientData); |
|
950 iPowerCommonData.iPowerReportClientsData->UpdatePluginIntervalMultiple(iPowerVoltageCurrentMeasurementsClientData->iRequestedIntervalMultiple); |
|
951 iPowerVoltageCurrentMeasurementsClientData->SetMeasuringOn(); |
|
952 |
|
953 // Ignore Coverity false positive as uninitialized variable. |
|
954 // Since no response is sent back to the client, only a empty message is created here. |
|
955 // Message handle of this will be initialized to NULL in the default constructor. |
|
956 // coverity[var_decl] |
|
957 RMessage2 dummy; |
|
958 iPowerVoltageCurrentMeasurementsClientData->iRequestedStartMessage = dummy; |
|
959 } |
|
960 } |
|
961 else |
|
962 { |
|
963 // complete any pending GetMeasurement request with KErrGeneral |
|
964 if (iPowerVoltageCurrentMeasurementsClientData->iRequestedBatchMessage.Handle()) |
|
965 { |
|
966 iPowerVoltageCurrentMeasurementsClientData->CompleteGetMeasurementsMessage(KErrGeneral); |
|
967 |
|
968 iPowerVoltageCurrentMeasurementsClientData->Reset(); |
|
969 } |
|
970 } |
|
971 } |
|
972 break; |
|
973 |
|
974 #ifdef SYMBIAN_HWRM_EXTPOWERINFO |
|
975 |
|
976 case HWRMPowerCommand::EStartAverageBatteryChargingCurrentReportingCmdId: |
|
977 { |
|
978 HWRMPowerCommand::TErrorCodeResponsePackage respPckg; |
|
979 respPckg.Copy(aData); |
|
980 pluginErr = respPckg(); |
|
981 |
|
982 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMPowerService::ProcessResponseL, EStartAverageBatteryVoltageReportingCmdId error = %d" ), pluginErr ); |
|
983 |
|
984 if (pluginErr == KErrNone) |
|
985 { |
|
986 iPowerCommonData.iChargingCurrentClientsData->SetMeasuringOn(); |
|
987 |
|
988 THWRMPluginRequestData* data = static_cast<THWRMPluginRequestData*>(iTransactionList->FindTransaction(aTransId, EFalse)); |
|
989 |
|
990 if ( data ) |
|
991 { |
|
992 // client is added to the voltage clients' list |
|
993 iPowerCommonData.iChargingCurrentClientsData->AddMeasurementsClientL(*iPowerChargingCurrentMeasurementsClientData); |
|
994 iPowerCommonData.iChargingCurrentClientsData->UpdatePluginIntervalMultiple(iPowerChargingCurrentMeasurementsClientData->iRequestedIntervalMultiple); |
|
995 iPowerChargingCurrentMeasurementsClientData->SetMeasuringOn(); |
|
996 |
|
997 // Ignore Coverity false positive as uninitialized variable. |
|
998 // Since no response is sent back to the client, only a empty message is created here. |
|
999 // Message handle of this will be initialized to NULL in the default constructor. |
|
1000 // coverity[var_decl] |
|
1001 RMessage2 dummy; |
|
1002 iPowerChargingCurrentMeasurementsClientData->iRequestedStartMessage = dummy; |
|
1003 } |
|
1004 } |
|
1005 else |
|
1006 { |
|
1007 // complete any pending GetMeasurement request with KErrGeneral |
|
1008 if (iPowerChargingCurrentMeasurementsClientData->iRequestedBatchMessage.Handle()) |
|
1009 { |
|
1010 iPowerChargingCurrentMeasurementsClientData->CompleteGetMeasurementsMessage(KErrGeneral); |
|
1011 |
|
1012 iPowerChargingCurrentMeasurementsClientData->Reset(); |
|
1013 } |
|
1014 } |
|
1015 } |
|
1016 break; |
|
1017 |
|
1018 |
|
1019 case HWRMPowerCommand::EStartBatteryFullChargingTimeReportingCmdId: |
|
1020 { |
|
1021 HWRMPowerCommand::TErrorCodeResponsePackage respPckg; |
|
1022 respPckg.Copy(aData); |
|
1023 pluginErr = respPckg(); |
|
1024 |
|
1025 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMPowerService::ProcessResponseL, EStartBatteryFullChargingTimeReportingCmdId error = %d" ), pluginErr ); |
|
1026 |
|
1027 if (pluginErr == KErrNone) |
|
1028 { |
|
1029 iPowerCommonData.iChargingTimeClientsData->SetMeasuringOn(); |
|
1030 |
|
1031 THWRMPluginRequestData* data = static_cast<THWRMPluginRequestData*>(iTransactionList->FindTransaction(aTransId, EFalse)); |
|
1032 |
|
1033 if ( data ) |
|
1034 { |
|
1035 // client is added to the voltage clients' list |
|
1036 iPowerCommonData.iChargingTimeClientsData->AddMeasurementsClientL(*iPowerChargingTimeMeasurementsClientData); |
|
1037 iPowerCommonData.iChargingTimeClientsData->UpdatePluginIntervalMultiple(iPowerChargingTimeMeasurementsClientData->iRequestedIntervalMultiple); |
|
1038 iPowerChargingTimeMeasurementsClientData->SetMeasuringOn(); |
|
1039 |
|
1040 // Ignore Coverity false positive as uninitialized variable. |
|
1041 // Since no response is sent back to the client, only a empty message is created here. |
|
1042 // Message handle of this will be initialized to NULL in the default constructor. |
|
1043 // coverity[var_decl] |
|
1044 RMessage2 dummy; |
|
1045 iPowerChargingTimeMeasurementsClientData->iRequestedStartMessage = dummy; |
|
1046 } |
|
1047 } |
|
1048 else |
|
1049 { |
|
1050 // complete any pending GetMeasurement request with KErrGeneral |
|
1051 if (iPowerChargingTimeMeasurementsClientData->iRequestedBatchMessage.Handle()) |
|
1052 { |
|
1053 iPowerChargingTimeMeasurementsClientData->CompleteGetMeasurementsMessage(KErrGeneral); |
|
1054 |
|
1055 iPowerChargingTimeMeasurementsClientData->Reset(); |
|
1056 } |
|
1057 } |
|
1058 } |
|
1059 break; |
|
1060 |
|
1061 #endif //SYMBIAN_HWRM_EXTPOWERINFO |
|
1062 |
|
1063 case HWRMPowerCommand::EStopAverageBatteryPowerReportingCmdId: |
|
1064 { |
|
1065 HWRMPowerCommand::TErrorCodeResponsePackage respPckg; |
|
1066 respPckg.Copy(aData); |
|
1067 pluginErr = respPckg(); |
|
1068 |
|
1069 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMPowerService::ProcessResponseL, EStopAverageBatteryPowerReportingCmdId error = %d" ), pluginErr); |
|
1070 |
|
1071 if (pluginErr == KErrNone) |
|
1072 { |
|
1073 iPowerCommonData.iPowerReportClientsData->SetMeasuringOff(); |
|
1074 } |
|
1075 } |
|
1076 break; |
|
1077 |
|
1078 #ifdef SYMBIAN_HWRM_EXTPOWERINFO |
|
1079 |
|
1080 case HWRMPowerCommand::EStopAverageBatteryChargingCurrentReportingCmdId: |
|
1081 { |
|
1082 HWRMPowerCommand::TErrorCodeResponsePackage respPckg; |
|
1083 respPckg.Copy(aData); |
|
1084 pluginErr = respPckg(); |
|
1085 |
|
1086 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMPowerService::ProcessResponseL, EStopAverageBatteryChargingCurrentReportingCmdId error = %d" ), pluginErr); |
|
1087 |
|
1088 if (pluginErr == KErrNone) |
|
1089 { |
|
1090 iPowerCommonData.iChargingCurrentClientsData->SetMeasuringOff(); |
|
1091 } |
|
1092 } |
|
1093 break; |
|
1094 |
|
1095 |
|
1096 case HWRMPowerCommand::EStopBatteryFullChargingTimeReportingCmdId: |
|
1097 { |
|
1098 HWRMPowerCommand::TErrorCodeResponsePackage respPckg; |
|
1099 respPckg.Copy(aData); |
|
1100 pluginErr = respPckg(); |
|
1101 |
|
1102 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMPowerService::ProcessResponseL, EStopBatteryFullChargingTimeReportingCmdId error = %d" ), pluginErr); |
|
1103 |
|
1104 if (pluginErr == KErrNone) |
|
1105 { |
|
1106 iPowerCommonData.iChargingTimeClientsData->SetMeasuringOff(); |
|
1107 } |
|
1108 } |
|
1109 break; |
|
1110 |
|
1111 #endif //SYMBIAN_HWRM_EXTPOWERINFO |
|
1112 |
|
1113 case HWRMPowerCommand::ESetPowerReportingIntervalMultipleCmdId: |
|
1114 { |
|
1115 completeRequest = EFalse; |
|
1116 |
|
1117 HWRMPowerCommand::TErrorCodeResponsePackage respPckg; |
|
1118 respPckg.Copy(aData); |
|
1119 pluginErr = respPckg(); |
|
1120 |
|
1121 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMPowerService::ProcessResponseL, ESetPowerReportingIntervalMultipleCmdId error = %d" ), pluginErr); |
|
1122 |
|
1123 TUint prevIntervalMultiple; |
|
1124 iPowerCommonData.iPowerReportClientsData->GetPluginIntervalMultiple(prevIntervalMultiple); |
|
1125 |
|
1126 THWRMPluginPowerIntervalRequestData* data = static_cast<THWRMPluginPowerIntervalRequestData*>(iTransactionList->FindTransaction(aTransId, ETrue)); |
|
1127 |
|
1128 if (data) |
|
1129 { |
|
1130 if (pluginErr == KErrNone) |
|
1131 { |
|
1132 // the new interval is smaller ==> client was added that caused a drop of the GCD. |
|
1133 // Else no message needs to be completed since the client's stop command was |
|
1134 // completed earlier |
|
1135 if (prevIntervalMultiple >= data->iRequestedPluginIntervalMultiple) |
|
1136 { |
|
1137 iPowerVoltageCurrentMeasurementsClientData->SetMeasuringOn(); |
|
1138 iPowerVoltageCurrentMeasurementsClientData->CompletePendingStart(KErrNone); |
|
1139 if(iPowerVoltageCurrentMeasurementsClientData->iMeasurementsCount > 0) |
|
1140 { |
|
1141 iPowerVoltageCurrentMeasurementsClientData->CompleteGetMeasurementsMessage(KErrNone); |
|
1142 } |
|
1143 iPowerCommonData.iPowerReportClientsData->AddMeasurementsClientL(*iPowerVoltageCurrentMeasurementsClientData); |
|
1144 |
|
1145 // Ignore Coverity false positive as uninitialized variable. |
|
1146 // Since no response is sent back to the client, only a empty message is created here. |
|
1147 // Message handle of this will be initialized to NULL in the default constructor. |
|
1148 // coverity[var_decl] |
|
1149 RMessage2 dummy; |
|
1150 iPowerVoltageCurrentMeasurementsClientData->iRequestedStartMessage = dummy; |
|
1151 } |
|
1152 // in all cases update the plugin interval |
|
1153 iPowerCommonData.iPowerReportClientsData->UpdatePluginIntervalMultiple(data->iRequestedPluginIntervalMultiple); |
|
1154 } |
|
1155 else |
|
1156 { |
|
1157 if (prevIntervalMultiple >= data->iRequestedPluginIntervalMultiple) |
|
1158 { |
|
1159 //Complete both the pending Start and GetMeasurements with Error |
|
1160 iPowerVoltageCurrentMeasurementsClientData->CompletePendingStart(pluginErr); |
|
1161 iPowerVoltageCurrentMeasurementsClientData->CompleteGetMeasurementsMessage(KErrGeneral); |
|
1162 |
|
1163 iPowerVoltageCurrentMeasurementsClientData->Reset(); |
|
1164 } |
|
1165 } |
|
1166 |
|
1167 delete data; |
|
1168 data = NULL; |
|
1169 } |
|
1170 } |
|
1171 break; |
|
1172 |
|
1173 #ifdef SYMBIAN_HWRM_EXTPOWERINFO |
|
1174 |
|
1175 case HWRMPowerCommand::ESetChargeCurrentIntervalMultipleCmdId: |
|
1176 { |
|
1177 completeRequest = EFalse; |
|
1178 |
|
1179 HWRMPowerCommand::TErrorCodeResponsePackage respPckg; |
|
1180 respPckg.Copy(aData); |
|
1181 pluginErr = respPckg(); |
|
1182 |
|
1183 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMPowerService::ProcessResponseL, ESetChargeCurrentIntervalMultipleCmdId error = %d" ), pluginErr); |
|
1184 |
|
1185 TUint prevIntervalMultiple; |
|
1186 iPowerCommonData.iChargingCurrentClientsData->GetPluginIntervalMultiple(prevIntervalMultiple); |
|
1187 |
|
1188 THWRMPluginPowerIntervalRequestData* data = static_cast<THWRMPluginPowerIntervalRequestData*>(iTransactionList->FindTransaction(aTransId, ETrue)); |
|
1189 |
|
1190 if (data) |
|
1191 { |
|
1192 if (pluginErr == KErrNone) |
|
1193 { |
|
1194 // the new interval is smaller ==> client was added that caused a drop of the GCD. |
|
1195 // Else no message needs to be completed since the client's stop command was |
|
1196 // completed earlier |
|
1197 if (prevIntervalMultiple >= data->iRequestedPluginIntervalMultiple) |
|
1198 { |
|
1199 iPowerChargingCurrentMeasurementsClientData->SetMeasuringOn(); |
|
1200 iPowerChargingCurrentMeasurementsClientData->CompletePendingStart(KErrNone); |
|
1201 if(iPowerChargingCurrentMeasurementsClientData->iMeasurementsCount > 0) |
|
1202 { |
|
1203 iPowerChargingCurrentMeasurementsClientData->CompleteGetMeasurementsMessage(KErrNone); |
|
1204 } |
|
1205 iPowerCommonData.iChargingCurrentClientsData->AddMeasurementsClientL(*iPowerChargingCurrentMeasurementsClientData); |
|
1206 |
|
1207 // Ignore Coverity false positive as uninitialized variable. |
|
1208 // Since no response is sent back to the client, only a empty message is created here. |
|
1209 // Message handle of this will be initialized to NULL in the default constructor. |
|
1210 // coverity[var_decl] |
|
1211 RMessage2 dummy; |
|
1212 iPowerChargingCurrentMeasurementsClientData->iRequestedStartMessage = dummy; |
|
1213 } |
|
1214 // in all cases update the plugin interval |
|
1215 iPowerCommonData.iChargingCurrentClientsData->UpdatePluginIntervalMultiple(data->iRequestedPluginIntervalMultiple); |
|
1216 } |
|
1217 else |
|
1218 { |
|
1219 if (prevIntervalMultiple >= data->iRequestedPluginIntervalMultiple) |
|
1220 { |
|
1221 //Complete both the pending Start and GetMeasurements with Error |
|
1222 iPowerChargingCurrentMeasurementsClientData->CompletePendingStart(pluginErr); |
|
1223 iPowerChargingCurrentMeasurementsClientData->CompleteGetMeasurementsMessage(KErrGeneral); |
|
1224 |
|
1225 iPowerChargingCurrentMeasurementsClientData->Reset(); |
|
1226 } |
|
1227 } |
|
1228 |
|
1229 delete data; |
|
1230 data = NULL; |
|
1231 } |
|
1232 } |
|
1233 break; |
|
1234 |
|
1235 case HWRMPowerCommand::EGetBatteryChargerTypeCmdId: |
|
1236 { |
|
1237 completeRequest = EFalse; |
|
1238 // The message will be completed here so remove and delete the data from the transaction list. |
|
1239 THWRMPluginRequestData* data = static_cast<THWRMPluginRequestData*>(iTransactionList->FindTransaction(aTransId, ETrue)); |
|
1240 if (data) |
|
1241 { |
|
1242 delete data; |
|
1243 data = NULL; |
|
1244 } |
|
1245 |
|
1246 HWRMPowerCommand::TBatteryChargerTypeResponsePackage chargerTypePckg; |
|
1247 chargerTypePckg.Copy(aData); |
|
1248 HWRMPowerCommand::TBatteryChargerTypeData chargerTypeData = chargerTypePckg(); |
|
1249 |
|
1250 pluginErr = chargerTypeData.iErrorCode; |
|
1251 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMPowerService::ProcessResponseL, EGetBatteryConsumptionInfoCmdId error = %d" ), pluginErr ); |
|
1252 |
|
1253 if ( pluginErr == KErrNone ) |
|
1254 { |
|
1255 CHWRMPower::TBatteryChargerType chargerType; |
|
1256 |
|
1257 //client interface and plugin interface are same. |
|
1258 chargerType = (CHWRMPower::TBatteryChargerType)chargerTypeData.iChargerType; |
|
1259 |
|
1260 TPckg<CHWRMPower::TBatteryChargerType> clientChargerTypePckg(chargerType); |
|
1261 |
|
1262 // Complete and remove from the respective list all the clients (if any, beacuse some may have closed the session) |
|
1263 // that have requested charger type Info. |
|
1264 iPowerCommonData.CompletePendingGetChargerType(pluginErr, clientChargerTypePckg); |
|
1265 } |
|
1266 else |
|
1267 { |
|
1268 // Complete the the clients with the plugin error |
|
1269 CHWRMPower::TBatteryChargerType chargerType(CHWRMPower::EBatteryChargerUnKnown); |
|
1270 TPckg<CHWRMPower::TBatteryChargerType> emptyDes(chargerType); |
|
1271 iPowerCommonData.CompletePendingGetChargerType(pluginErr, emptyDes); |
|
1272 } |
|
1273 } |
|
1274 break; |
|
1275 |
|
1276 #endif //SYMBIAN_HWRM_EXTPOWERINFO |
|
1277 |
|
1278 default: |
|
1279 { |
|
1280 } |
|
1281 break; |
|
1282 } |
|
1283 } |
|
1284 |
|
1285 if (completeRequest) |
|
1286 { |
|
1287 contextErr = CompleteRequest(aTransId, pluginErr); |
|
1288 } |
|
1289 |
|
1290 // Leave if there is error in context |
|
1291 User::LeaveIfError(contextErr); |
|
1292 |
|
1293 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::ProcessResponseL - return" ) ); |
|
1294 } |
|
1295 |
|
1296 // ----------------------------------------------------------------------------- |
|
1297 // CHWRMPowerService::CheckResponseDataSize |
|
1298 // Helper for ProcessResponseL. Checks data size returned in plugin responses. |
|
1299 // ----------------------------------------------------------------------------- |
|
1300 // |
|
1301 TBool CHWRMPowerService::CheckResponseDataSize( TInt aCommandId, TDesC8& aData ) |
|
1302 { |
|
1303 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMPowerService::CheckResponseDataSize(0x%x)" ), aCommandId); |
|
1304 |
|
1305 TInt requiredDataSize; |
|
1306 |
|
1307 switch ( aCommandId ) |
|
1308 { |
|
1309 case HWRMPowerCommand::EStartAverageBatteryPowerReportingCmdId: |
|
1310 case HWRMPowerCommand::EStopAverageBatteryPowerReportingCmdId: |
|
1311 case HWRMPowerCommand::ESetPowerReportingIntervalMultipleCmdId: |
|
1312 |
|
1313 #ifdef SYMBIAN_HWRM_EXTPOWERINFO |
|
1314 case HWRMPowerCommand::EStartAverageBatteryChargingCurrentReportingCmdId: |
|
1315 case HWRMPowerCommand::EStartBatteryFullChargingTimeReportingCmdId: |
|
1316 case HWRMPowerCommand::EStopAverageBatteryChargingCurrentReportingCmdId: |
|
1317 case HWRMPowerCommand::EStopBatteryFullChargingTimeReportingCmdId: |
|
1318 case HWRMPowerCommand::ESetChargeCurrentIntervalMultipleCmdId: |
|
1319 #endif //SYMBIAN_HWRM_EXTPOWERINFO |
|
1320 |
|
1321 { |
|
1322 requiredDataSize = sizeof(TInt); // TErrorCodeResponseData |
|
1323 } |
|
1324 break; |
|
1325 |
|
1326 case HWRMPowerCommand::EGetBatteryInfoCmdId: |
|
1327 requiredDataSize = sizeof(HWRMPowerCommand::TBatteryConsumptionResponseData); |
|
1328 break; |
|
1329 |
|
1330 case HWRMPowerCommand::EGetBatteryVoltageInfoCmdId: |
|
1331 requiredDataSize = sizeof(HWRMPowerCommand::TBatteryVoltageResponseData); |
|
1332 break; |
|
1333 |
|
1334 #ifdef SYMBIAN_HWRM_EXTPOWERINFO |
|
1335 |
|
1336 case HWRMPowerCommand::EGetBatteryChargerTypeCmdId: |
|
1337 requiredDataSize = sizeof(HWRMPowerCommand::TBatteryChargerTypeData); |
|
1338 break; |
|
1339 #endif //SYMBIAN_HWRM_EXTPOWERINFO |
|
1340 |
|
1341 case HWRMPowerCommand::ENoCommandId: |
|
1342 default: |
|
1343 requiredDataSize = 0; |
|
1344 break; |
|
1345 } |
|
1346 |
|
1347 if ( aData.Size() != requiredDataSize ) |
|
1348 { |
|
1349 COMPONENT_TRACE3( _L( "HWRM Server - CHWRMPowerService::CheckResponseDataSize error 0x%x, 0x%x" ), aData.Size(), requiredDataSize ); |
|
1350 return EFalse; // Data size is invalid |
|
1351 } |
|
1352 |
|
1353 return ETrue; // Data size is ok |
|
1354 } |
|
1355 |
|
1356 // ----------------------------------------------------------------------------- |
|
1357 // CHWRMPowerService::StopPowerMeasurementsL |
|
1358 // Issues a plugin command to stop the power measurements. |
|
1359 // Used when we need to stop the plugin without associating the plugin command |
|
1360 // with a client message. |
|
1361 // ----------------------------------------------------------------------------- |
|
1362 // |
|
1363 void CHWRMPowerService::StopPowerMeasurementsL() |
|
1364 { |
|
1365 COMPONENT_TRACE1(_L( "HWRM Server - CHWRMLightService::StopPowerMeasurementsL()" ) ); |
|
1366 |
|
1367 RMessage2 dummy; |
|
1368 StopAverageBatteryPowerReportingL(dummy ); |
|
1369 |
|
1370 COMPONENT_TRACE1(_L( "HWRM Server - CHWRMPowerService::StopPowerMeasurementsL - return" ) ); |
|
1371 } |
|
1372 |
|
1373 #ifdef SYMBIAN_HWRM_EXTPOWERINFO |
|
1374 |
|
1375 // ----------------------------------------------------------------------------- |
|
1376 // CHWRMPowerService::StopChargingCurrentMeasurementsL |
|
1377 // Issues a plugin command to stop the Charging Current measurements. |
|
1378 // Used when we need to stop the plugin without associating the plugin command |
|
1379 // with a client message. |
|
1380 // ----------------------------------------------------------------------------- |
|
1381 // |
|
1382 void CHWRMPowerService::StopChargingCurrentMeasurementsL() |
|
1383 { |
|
1384 COMPONENT_TRACE1(_L( "HWRM Server - CHWRMPowerService::StopChargingCurrentMeasurementsL()" ) ); |
|
1385 |
|
1386 RMessage2 dummy; |
|
1387 StopAverageChargingCurrentReportingL(dummy ); |
|
1388 |
|
1389 COMPONENT_TRACE1(_L( "HWRM Server - CHWRMPowerService::StopChargingCurrentMeasurementsL - return" ) ); |
|
1390 } |
|
1391 |
|
1392 // ----------------------------------------------------------------------------- |
|
1393 // CHWRMPowerService::StopChargingTimeMeasurementsL |
|
1394 // Issues a plugin command to stop the BatteryFull charging time measurements. |
|
1395 // Used when we need to stop the plugin without associating the plugin command |
|
1396 // with a client message. |
|
1397 // ----------------------------------------------------------------------------- |
|
1398 // |
|
1399 void CHWRMPowerService::StopChargingTimeMeasurementsL() |
|
1400 { |
|
1401 COMPONENT_TRACE1(_L( "HWRM Server - CHWRMPowerService::StopChargingTimeMeasurementsL()" ) ); |
|
1402 |
|
1403 RMessage2 dummy; |
|
1404 StopChargingTimeReportingL(dummy ); |
|
1405 |
|
1406 COMPONENT_TRACE1(_L( "HWRM Server - CHWRMPowerService::StopChargingTimeMeasurementsL - return" ) ); |
|
1407 } |
|
1408 |
|
1409 #endif //SYMBIAN_HWRM_EXTPOWERINFO |
|
1410 |
|
1411 // ----------------------------------------------------------------------------- |
|
1412 // CHWRMPowerService::SetPluginIntervalMultipleL |
|
1413 // Sets the Measurements Interval Multiple at the plugin |
|
1414 // Used when we need to stop the plugin without associating the plugin command |
|
1415 // with a client message. |
|
1416 // ----------------------------------------------------------------------------- |
|
1417 // |
|
1418 void CHWRMPowerService::SetPluginIntervalMultipleL(HWRMPowerCommand::TPowerCmd aCommandId, TUint aIntervalMultiple) |
|
1419 { |
|
1420 COMPONENT_TRACE2(_L( "HWRM Server - CHWRMPowerService::SetPluginIntervalMultipleL(0x%x)" ), aIntervalMultiple); |
|
1421 |
|
1422 TPckgBuf<TUint> intervalMultiplePackage(aIntervalMultiple); |
|
1423 |
|
1424 // Create new data |
|
1425 THWRMPluginPowerIntervalRequestData* data = new (ELeave) THWRMPluginPowerIntervalRequestData(aIntervalMultiple, aCommandId); |
|
1426 CleanupStack::PushL( data ); |
|
1427 |
|
1428 data->iTransId = iPluginHandler->ProcessCommandL(aCommandId, intervalMultiplePackage, this); |
|
1429 |
|
1430 // data still needed, do not destroy, just pop |
|
1431 CleanupStack::Pop( data ); |
|
1432 |
|
1433 // Add data to list |
|
1434 iTransactionList->AddTransaction( data ); |
|
1435 |
|
1436 COMPONENT_TRACE1(_L( "HWRM Server - CHWRMPowerService::SetPluginIntervalMultipleL - return" ) ); |
|
1437 } |
|
1438 |
|
1439 // ----------------------------------------------------------------------------- |
|
1440 // CHWRMPowerService::SuspendSubResource |
|
1441 // Suspends Power target |
|
1442 // ----------------------------------------------------------------------------- |
|
1443 // |
|
1444 void CHWRMPowerService::SuspendSubResource(TInt /*aSubResource*/) |
|
1445 { |
|
1446 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::SuspendSubResource" ) ); |
|
1447 iSuspended = ETrue; |
|
1448 } |
|
1449 |
|
1450 // ----------------------------------------------------------------------------- |
|
1451 // CHWRMPowerService::ResumeSubResource |
|
1452 // Resumes suspended Power target |
|
1453 // ----------------------------------------------------------------------------- |
|
1454 // |
|
1455 void CHWRMPowerService::ResumeSubResource(TInt /*aSubResource*/) |
|
1456 { |
|
1457 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::ResumeSubResource" ) ); |
|
1458 iSuspended = EFalse; |
|
1459 } |
|
1460 |
|
1461 // ----------------------------------------------------------------------------- |
|
1462 // CHWRMPowerService::ActivateSubResource |
|
1463 // ----------------------------------------------------------------------------- |
|
1464 // |
|
1465 void CHWRMPowerService::ActivateSubResource(TInt /*aSubResource*/, TBool /*aActivate*/) |
|
1466 { |
|
1467 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::ActivateSubResource" ) ); |
|
1468 } |
|
1469 |
|
1470 // ----------------------------------------------------------------------------- |
|
1471 // CHWRMPowerService::DoRelease |
|
1472 // Helper for releasing Power resource |
|
1473 // ----------------------------------------------------------------------------- |
|
1474 // |
|
1475 void CHWRMPowerService::CleanupPowerL() //DoRelease |
|
1476 { |
|
1477 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::CleanupPowerL" ) ); |
|
1478 // Cancel any pending requests of the client and remove all the |
|
1479 // related data |
|
1480 |
|
1481 iPowerCommonData.CancelPendingGetBatteryInfo(*this); |
|
1482 iPowerCommonData.CancelPendingGetBatteryVoltageInfo(*this); |
|
1483 #ifdef SYMBIAN_HWRM_EXTPOWERINFO |
|
1484 iPowerCommonData.CancelPendingGetChargerType(*this); |
|
1485 #endif //SYMBIAN_HWRM_EXTPOWERINFO |
|
1486 |
|
1487 iPowerVoltageCurrentMeasurementsClientData->CancelPendingGetMeasurementsMessage(); |
|
1488 iPowerCommonData.iPowerReportClientsData->RemoveMeasurementsClientData(iPowerVoltageCurrentMeasurementsClientData); |
|
1489 |
|
1490 iPowerVoltageCurrentMeasurementsClientData->Reset(); |
|
1491 |
|
1492 if (iPowerCommonData.iPowerReportClientsData->IsClientsQueEmpty() && |
|
1493 iPowerCommonData.iPowerReportClientsData->IsMeasuringOn()) |
|
1494 { |
|
1495 iPowerCommonData.DoStopPowerMeasurementsL(); |
|
1496 } |
|
1497 |
|
1498 |
|
1499 #ifdef SYMBIAN_HWRM_EXTPOWERINFO |
|
1500 |
|
1501 iPowerChargingCurrentMeasurementsClientData->CancelPendingGetMeasurementsMessage(); |
|
1502 iPowerCommonData.iChargingCurrentClientsData->RemoveMeasurementsClientData(iPowerChargingCurrentMeasurementsClientData); |
|
1503 |
|
1504 iPowerChargingCurrentMeasurementsClientData->Reset(); |
|
1505 |
|
1506 if (iPowerCommonData.iChargingCurrentClientsData->IsClientsQueEmpty() && |
|
1507 iPowerCommonData.iChargingCurrentClientsData->IsMeasuringOn()) |
|
1508 { |
|
1509 iPowerCommonData.DoStopChargingCurrentMeasurementsL(); |
|
1510 } |
|
1511 |
|
1512 |
|
1513 iPowerChargingTimeMeasurementsClientData->CancelPendingGetMeasurementsMessage(); |
|
1514 iPowerCommonData.iChargingTimeClientsData->RemoveMeasurementsClientData(iPowerChargingTimeMeasurementsClientData); |
|
1515 |
|
1516 iPowerChargingTimeMeasurementsClientData->Reset(); |
|
1517 |
|
1518 if (iPowerCommonData.iChargingTimeClientsData->IsClientsQueEmpty() && |
|
1519 iPowerCommonData.iChargingTimeClientsData->IsMeasuringOn()) |
|
1520 { |
|
1521 iPowerCommonData.DoStopChargingTimeMeasurementsL(); |
|
1522 } |
|
1523 |
|
1524 #endif //SYMBIAN_HWRM_EXTPOWERINFO |
|
1525 |
|
1526 iSuspended = EFalse; |
|
1527 |
|
1528 COMPONENT_TRACE1(_L( "HWRM Server - CHWRMPowerService::CleanupPowerL - return" ) ); |
|
1529 } |
|
1530 |
|
1531 // ----------------------------------------------------------------------------- |
|
1532 // CHWRMPowerService::ExecutePluginCommandL |
|
1533 // Executes a plugin command and handles related transaction. |
|
1534 // ----------------------------------------------------------------------------- |
|
1535 // |
|
1536 void CHWRMPowerService::ExecutePluginCommandL(const RMessage2& aMessage, |
|
1537 HWRMPowerCommand::TPowerCmd aCommandId, |
|
1538 TBool aSplitCommand ) |
|
1539 { |
|
1540 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::ExecutePluginCommandL" ) ); |
|
1541 |
|
1542 // Create new data (TransId is updated later) |
|
1543 THWRMPluginRequestData* data = new (ELeave) THWRMPluginRequestData(aMessage, 0, aCommandId, aSplitCommand); |
|
1544 CleanupStack::PushL( data ); |
|
1545 |
|
1546 TBuf8<1> emptyDes; |
|
1547 data->iTransId = iPluginHandler->ProcessCommandL(aCommandId, emptyDes, this); |
|
1548 |
|
1549 // data still needed, do not destroy, just pop |
|
1550 CleanupStack::Pop( data ); |
|
1551 |
|
1552 // Add data to list |
|
1553 iTransactionList->AddTransaction( data ); |
|
1554 |
|
1555 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::ExecutePluginCommandL - return" ) ); |
|
1556 } |
|
1557 |
|
1558 // ----------------------------------------------------------------------------- |
|
1559 // CHWRMPowerService::ExecutePluginCommandL |
|
1560 // Executes a plugin command and handles related transaction. |
|
1561 // ----------------------------------------------------------------------------- |
|
1562 // |
|
1563 void CHWRMPowerService::ExecutePluginCommandL(const RMessage2& aMessage, |
|
1564 HWRMPowerCommand::TPowerCmd aCommandId, |
|
1565 TBool aSplitCommand, |
|
1566 TDesC8& aPckg ) |
|
1567 { |
|
1568 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::ExecutePluginCommandL with pckg" ) ); |
|
1569 |
|
1570 // Create new data (TransId is updated later) |
|
1571 THWRMPluginRequestData* data = new (ELeave) THWRMPluginRequestData(aMessage, 0, aCommandId, aSplitCommand); |
|
1572 CleanupStack::PushL( data ); |
|
1573 |
|
1574 data->iTransId = iPluginHandler->ProcessCommandL(aCommandId, aPckg, this); |
|
1575 |
|
1576 // data still needed, do not destroy, just pop |
|
1577 CleanupStack::Pop( data ); |
|
1578 |
|
1579 // Add data to list |
|
1580 iTransactionList->AddTransaction( data ); |
|
1581 |
|
1582 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::ExecutePluginCommandL - return" ) ); |
|
1583 } |
|
1584 |
|
1585 #ifdef SYMBIAN_HWRM_EXTPOWERINFO |
|
1586 |
|
1587 // ----------------------------------------------------------------------------- |
|
1588 // CHWRMPowerService::GetChargerTypeL |
|
1589 // Sends a plug-in command to query the charger type. |
|
1590 // ----------------------------------------------------------------------------- |
|
1591 // |
|
1592 void CHWRMPowerService::GetChargerTypeL(const RMessage2& aMessage) |
|
1593 { |
|
1594 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::GetChargerTypeL" ) ); |
|
1595 |
|
1596 ExecutePluginCommandL(aMessage, HWRMPowerCommand::EGetBatteryChargerTypeCmdId, EFalse/*not split*/ ); |
|
1597 |
|
1598 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::GetChargerTypeL - return" ) ); |
|
1599 } |
|
1600 |
|
1601 #endif //SYMBIAN_HWRM_EXTPOWERINFO |
|
1602 |
|
1603 // ----------------------------------------------------------------------------- |
|
1604 // TPowerMeasurementsClientData::TPowerMeasurementsClientData |
|
1605 // C++ Constructor |
|
1606 // ----------------------------------------------------------------------------- |
|
1607 // |
|
1608 TPowerMeasurementsClientData::TPowerMeasurementsClientData() |
|
1609 { |
|
1610 COMPONENT_TRACE1(_L( "HWRM Server - TPowerMeasurementsClientData::TPowerMeasurementsClientData()" ) ); |
|
1611 |
|
1612 iNumOfBaseIntervalsPassed = 0; |
|
1613 iMeasuring = EFalse; |
|
1614 iMeasurementsCount = 0; |
|
1615 // Ignore Coverity false positive as uninitialized variable. |
|
1616 // Since no response is sent back to the client, only a empty message is created here. |
|
1617 // Message handle of this will be initialized to NULL in the default constructor. |
|
1618 // coverity[var_decl] |
|
1619 RMessage2 dummy; |
|
1620 iRequestedBatchMessage= dummy; |
|
1621 |
|
1622 COMPONENT_TRACE1(_L( "HWRM Server - TPowerMeasurementsClientData::TPowerMeasurementsClientData - return" ) ); |
|
1623 } |
|
1624 |
|
1625 // ----------------------------------------------------------------------------- |
|
1626 // TPowerMeasurementsClientData::~TPowerMeasurementsClientData |
|
1627 // Destructor |
|
1628 // ----------------------------------------------------------------------------- |
|
1629 // |
|
1630 TPowerMeasurementsClientData::~TPowerMeasurementsClientData() |
|
1631 { |
|
1632 COMPONENT_TRACE1(_L( "HWRM Server - TPowerMeasurementsClientData::~TPowerMeasurementsClientData()" ) ); |
|
1633 |
|
1634 COMPONENT_TRACE1(_L( "HWRM Server - TPowerMeasurementsClientData::~TPowerMeasurementsClientData - return" ) ); |
|
1635 } |
|
1636 |
|
1637 |
|
1638 |
|
1639 // ----------------------------------------------------------------------------- |
|
1640 // TPowerMeasurementsClientData::IsMeasuringOn |
|
1641 // Check if voltage measuring is on. |
|
1642 // ----------------------------------------------------------------------------- |
|
1643 // |
|
1644 TBool TPowerMeasurementsClientData::IsMeasuringOn() |
|
1645 { |
|
1646 COMPONENT_TRACE1(_L( "HWRM Server - TPowerMeasurementsClientData::IsMeasuringOn()" ) ); |
|
1647 |
|
1648 COMPONENT_TRACE2( _L( "HWRM Server - TPowerMeasurementsClientData::IsMeasuringOn - return %d" ), iMeasuring ); |
|
1649 |
|
1650 return iMeasuring; |
|
1651 } |
|
1652 |
|
1653 // ----------------------------------------------------------------------------- |
|
1654 // TPowerMeasurementsClientData::SetMeasuringOn |
|
1655 // Set the measuring flag on. |
|
1656 // ----------------------------------------------------------------------------- |
|
1657 // |
|
1658 void TPowerMeasurementsClientData::SetMeasuringOn() |
|
1659 { |
|
1660 COMPONENT_TRACE1(_L( "HWRM Server - TPowerMeasurementsClientData::SetMeasuringOn()" ) ); |
|
1661 |
|
1662 iMeasuring = ETrue; |
|
1663 |
|
1664 COMPONENT_TRACE1(_L( "HWRM Server - TPowerMeasurementsClientData::SetMeasuringOn - return" ) ); |
|
1665 } |
|
1666 |
|
1667 // ----------------------------------------------------------------------------- |
|
1668 // TPowerMeasurementsClientData::SetMeasuringOff |
|
1669 // Set the measuring flag off. |
|
1670 // ----------------------------------------------------------------------------- |
|
1671 // |
|
1672 void TPowerMeasurementsClientData::SetMeasuringOff() |
|
1673 { |
|
1674 COMPONENT_TRACE1(_L( "HWRM Server - TPowerMeasurementsClientData::SetMeasuringOff()" ) ); |
|
1675 |
|
1676 iMeasuring = EFalse; |
|
1677 |
|
1678 COMPONENT_TRACE1(_L( "HWRM Server - TPowerMeasurementsClientData::SetMeasuringOff - return" ) ); |
|
1679 } |
|
1680 |
|
1681 |
|
1682 // ----------------------------------------------------------------------------- |
|
1683 // TPowerMeasurementsClientData::CompleteGetMeasurementsMessage |
|
1684 // If there exists a cached message of the client requesting measuremnts, |
|
1685 // it is completed with Error code aReason |
|
1686 // ----------------------------------------------------------------------------- |
|
1687 // |
|
1688 void TPowerMeasurementsClientData::CompleteGetMeasurementsMessage(TInt aReason) |
|
1689 { |
|
1690 TInt err = KErrNone; |
|
1691 COMPONENT_TRACE1(_L( "HWRM Server - TPowerMeasurementsClientData::CompleteGetMeasurementsMessage()" ) ); |
|
1692 |
|
1693 if (iRequestedBatchMessage.Handle()) |
|
1694 { |
|
1695 TRAP(err, WriteMeasurementsInMessageL()); |
|
1696 if (err != KErrNone) |
|
1697 { |
|
1698 // Error in updating the reply. Pass it to the client |
|
1699 aReason = err; |
|
1700 } |
|
1701 iRequestedBatchMessage.Complete(aReason); |
|
1702 |
|
1703 // Ignore Coverity false positive as uninitialized variable. |
|
1704 // Since no response is sent back to the client, only a empty message is created here. |
|
1705 // Message handle of this will be initialized to NULL in the default constructor. |
|
1706 // coverity[var_decl] |
|
1707 RMessage2 dummy; |
|
1708 iRequestedBatchMessage = dummy; |
|
1709 |
|
1710 //reset the data to be ready for gathering the next batch pf measurements |
|
1711 iMeasurementsCount = 0; |
|
1712 } |
|
1713 |
|
1714 COMPONENT_TRACE1(_L( "HWRM Server - TPowerMeasurementsClientData::CompleteGetMeasurementsMessage - return" ) ); |
|
1715 } |
|
1716 |
|
1717 // ----------------------------------------------------------------------------- |
|
1718 // TPowerMeasurementsClientData::CancelPendingGetMeasurementsMessage |
|
1719 // Cancels a pending GetMeasurements requests that belongs to the client that sent aMessage. |
|
1720 // ----------------------------------------------------------------------------- |
|
1721 // |
|
1722 void TPowerMeasurementsClientData::CancelPendingGetMeasurementsMessage() |
|
1723 { |
|
1724 COMPONENT_TRACE1(_L( "HWRM Server - TPowerMeasurementsClientData::CancelPendingGetMeasurementsMessage()" ) ); |
|
1725 |
|
1726 if (iRequestedBatchMessage.Handle()) |
|
1727 { |
|
1728 iRequestedBatchMessage.Complete(KErrCancel); |
|
1729 |
|
1730 //reset the data to be ready for gathering the next batch pf measurements |
|
1731 iMeasurementsCount = 0; |
|
1732 |
|
1733 // Ignore Coverity false positive as uninitialized variable. |
|
1734 // Since no response is sent back to the client, only a empty message is created here. |
|
1735 // Message handle of this will be initialized to NULL in the default constructor. |
|
1736 // coverity[var_decl] |
|
1737 RMessage2 dummy; |
|
1738 iRequestedBatchMessage = dummy; |
|
1739 } |
|
1740 |
|
1741 COMPONENT_TRACE1(_L( "HWRM Server - TPowerMeasurementsClientData::CancelPendingGetMeasurementsMessage - return" ) ); |
|
1742 } |
|
1743 |
|
1744 // ----------------------------------------------------------------------------- |
|
1745 // CClientsData::CompletePendingStartWithError |
|
1746 // If there exists a cached message of the client requesting to Start measuremnts, |
|
1747 // it is completed with Error code aReason |
|
1748 // ----------------------------------------------------------------------------- |
|
1749 // |
|
1750 void TPowerMeasurementsClientData::CompletePendingStart(TInt aReason) |
|
1751 { |
|
1752 COMPONENT_TRACE1(_L( "HWRM Server - TPowerMeasurementsClientData::CompletePendingStart()" ) ); |
|
1753 |
|
1754 if (iRequestedStartMessage.Handle()) |
|
1755 { |
|
1756 iRequestedStartMessage.Complete(aReason); |
|
1757 |
|
1758 // Ignore Coverity false positive as uninitialized variable. |
|
1759 // Since no response is sent back to the client, only a empty message is created here. |
|
1760 // Message handle of this will be initialized to NULL in the default constructor. |
|
1761 // coverity[var_decl] |
|
1762 RMessage2 dummy; |
|
1763 iRequestedStartMessage = dummy; |
|
1764 } |
|
1765 |
|
1766 COMPONENT_TRACE1(_L( "HWRM Server - TPowerMeasurementsClientData::CompletePendingStart - return" ) ); |
|
1767 } |
|
1768 |
|
1769 // ----------------------------------------------------------------------------- |
|
1770 // CClientsData::CompletePendingStartWithError |
|
1771 // Resets the object in order to be ready for a new measurements session. |
|
1772 // ----------------------------------------------------------------------------- |
|
1773 // |
|
1774 void TPowerMeasurementsClientData::Reset() |
|
1775 { |
|
1776 COMPONENT_TRACE1(_L( "HWRM Server - TPowerMeasurementsClientData::Reset()" ) ); |
|
1777 |
|
1778 iNumOfBaseIntervalsPassed = 0; |
|
1779 iMeasuring = EFalse; |
|
1780 iMeasurementsCount = 0; |
|
1781 // Ignore Coverity false positive as uninitialized variable. |
|
1782 // Since no response is sent back to the client, only a empty message is created here. |
|
1783 // Message handle of this will be initialized to NULL in the default constructor. |
|
1784 // coverity[var_decl] |
|
1785 RMessage2 dummy; |
|
1786 iRequestedBatchMessage= dummy; |
|
1787 |
|
1788 COMPONENT_TRACE1(_L( "HWRM Server - TPowerMeasurementsClientData::Reset - return" ) ); |
|
1789 } |
|
1790 |
|
1791 // ----------------------------------------------------------------------------- |
|
1792 // TPowerIntMeasurementsClientData::TPowerIntMeasurementsClientData |
|
1793 // C++ Constructor |
|
1794 // ----------------------------------------------------------------------------- |
|
1795 // |
|
1796 TPowerIntMeasurementsClientData::TPowerIntMeasurementsClientData() |
|
1797 :iMeasurementsQue(_FOFF(TPowerIntMeasurement,iSglQueLink)), |
|
1798 iMeasurementsQueIter(iMeasurementsQue) |
|
1799 { |
|
1800 iAccumulator = 0; |
|
1801 } |
|
1802 |
|
1803 // ----------------------------------------------------------------------------- |
|
1804 // TPowerIntMeasurementsClientData::~TPowerIntMeasurementsClientData |
|
1805 // Destructor |
|
1806 // ----------------------------------------------------------------------------- |
|
1807 // |
|
1808 TPowerIntMeasurementsClientData::~TPowerIntMeasurementsClientData() |
|
1809 { |
|
1810 COMPONENT_TRACE1(_L( "HWRM Server - TPowerIntMeasurementsClientData::~TPowerIntMeasurementsClientData()" ) ); |
|
1811 |
|
1812 TPowerIntMeasurement* powerMeasurement; |
|
1813 iMeasurementsQueIter.SetToFirst(); |
|
1814 while ((powerMeasurement = iMeasurementsQueIter++) != NULL) |
|
1815 { |
|
1816 iMeasurementsQue.Remove(*powerMeasurement); |
|
1817 delete powerMeasurement; |
|
1818 }; |
|
1819 |
|
1820 COMPONENT_TRACE1(_L( "HWRM Server - TPowerIntMeasurementsClientData::~TPowerIntMeasurementsClientData - return" ) ); |
|
1821 } |
|
1822 |
|
1823 |
|
1824 // ----------------------------------------------------------------------------- |
|
1825 // TPowerIntMeasurementsClientData::AddMeasurementL |
|
1826 // Adds an integer measurement to the Measurements List. If list is full it |
|
1827 // overwrites the oldest value. |
|
1828 // ----------------------------------------------------------------------------- |
|
1829 // |
|
1830 void TPowerIntMeasurementsClientData::AddMeasurementL(TDesC8& aMeasurement) |
|
1831 { |
|
1832 COMPONENT_TRACE1(_L( "HWRM Server - TPowerIntMeasurementsClientData::AddMeasurement()" ) ); |
|
1833 |
|
1834 TPowerIntMeasurement* powerMeasurement; |
|
1835 |
|
1836 TIntMeasurementsPckg intMeasurementPckg; |
|
1837 intMeasurementPckg.Copy(aMeasurement); |
|
1838 TInt measurement = intMeasurementPckg(); |
|
1839 |
|
1840 if(IsMeasuringOn()) |
|
1841 { |
|
1842 if (iMeasurementsCount < KHWRMPowerMaxMeasurementsBatchSize) |
|
1843 { |
|
1844 iMeasurementsCount++; |
|
1845 powerMeasurement = new(ELeave) TPowerIntMeasurement(); |
|
1846 powerMeasurement->iAverageValue = measurement; |
|
1847 iMeasurementsQue.AddLast(*powerMeasurement); |
|
1848 } |
|
1849 else |
|
1850 { |
|
1851 powerMeasurement = iMeasurementsQue.First(); |
|
1852 iMeasurementsQue.Remove(*powerMeasurement); |
|
1853 powerMeasurement->iAverageValue = measurement; |
|
1854 iMeasurementsQue.AddLast(*powerMeasurement); |
|
1855 } |
|
1856 CompleteGetMeasurementsMessage(KErrNone); |
|
1857 } |
|
1858 |
|
1859 COMPONENT_TRACE1(_L( "HWRM Server - TPowerIntMeasurementsClientData::AddMeasurement - return" ) ); |
|
1860 } |
|
1861 |
|
1862 // ----------------------------------------------------------------------------- |
|
1863 // CHWRMPowerCommonData::CClientsData::WriteMeasurementsInMessageL |
|
1864 // The Measurements collected are written in the message area of the message. |
|
1865 // ----------------------------------------------------------------------------- |
|
1866 // |
|
1867 void TPowerIntMeasurementsClientData::WriteMeasurementsInMessageL() |
|
1868 { |
|
1869 COMPONENT_TRACE1(_L( "HWRM Server - TPowerIntMeasurementsClientData::WriteMeasurementsInMessageL()" ) ); |
|
1870 |
|
1871 typedef TFixedArray<TInt,KHWRMPowerMaxMeasurementsBatchSize> TMeasurementsArray; |
|
1872 TMeasurementsArray measurementsArray; |
|
1873 |
|
1874 TransferMeasurementsToFixedArrayL(measurementsArray); |
|
1875 |
|
1876 TPckg<TMeasurementsArray> measurementsArrayPckg(measurementsArray); |
|
1877 User::LeaveIfError(iRequestedBatchMessage.Write(0,measurementsArrayPckg)); |
|
1878 |
|
1879 TPckg<TUint> countPckg( iMeasurementsCount ); |
|
1880 User::LeaveIfError(iRequestedBatchMessage.Write(1,countPckg)); |
|
1881 |
|
1882 COMPONENT_TRACE1(_L( "HWRM Server - TPowerIntMeasurementsClientData::WriteMeasurementsInMessageL - return" ) ); |
|
1883 } |
|
1884 |
|
1885 // ----------------------------------------------------------------------------- |
|
1886 // TPowerIntMeasurementsClientData::Reset |
|
1887 // Resets the object in order to be ready for a new measurements session. |
|
1888 // ----------------------------------------------------------------------------- |
|
1889 // |
|
1890 void TPowerIntMeasurementsClientData::Reset() |
|
1891 { |
|
1892 TPowerMeasurementsClientData::Reset(); |
|
1893 |
|
1894 iAccumulator = 0; |
|
1895 |
|
1896 TPowerIntMeasurement* powerMeasurement; |
|
1897 iMeasurementsQueIter.SetToFirst(); |
|
1898 while ((powerMeasurement = iMeasurementsQueIter++) != NULL) |
|
1899 { |
|
1900 iMeasurementsQue.Remove(*powerMeasurement); |
|
1901 delete powerMeasurement; |
|
1902 }; |
|
1903 } |
|
1904 |
|
1905 // ----------------------------------------------------------------------------- |
|
1906 // TPowerIntMeasurementsClientData::NewBatteryMeasurementL |
|
1907 // Called if the client has registerd for measurements and a new measurement |
|
1908 // is sent by the plugin. |
|
1909 // ----------------------------------------------------------------------------- |
|
1910 // |
|
1911 void TPowerIntMeasurementsClientData::NewBatteryMeasurementL(TDesC8& aValue, TUint aPluginInterval) |
|
1912 { |
|
1913 COMPONENT_TRACE1(_L( "HWRM Server - TPowerIntMeasurementsClientData::NewBatteryMeasurementL()" ) ); |
|
1914 |
|
1915 // Example of the way tuples are used. Assume the client receives the following tuples: |
|
1916 // (100,2), (101,2), (100, 8) and has requested Interval = 9 |
|
1917 // then it calculatesfor the first 2 measurements: |
|
1918 // iNumOfBaseIntervalsPassed = 2 + 2 = 4 |
|
1919 // iAccumulator = 100*2 + 101*2 = 402 |
|
1920 // |
|
1921 // For the final measurement: |
|
1922 // numIntervalsNeeded = iRequestedIntervalMultiple - iNumOfBaseIntervalsPassed = 9 - 4 = 5 |
|
1923 // numIntervalsNeeded(5) < aPluginInterval(8) |
|
1924 // iAccumulator += aValue * numIntervalsNeeded = 402 + 100 * 5 = 902 |
|
1925 // iAverage = iAccumulator / iRequestedIntervalMultiple = 902 / 9 = 100.222222 |
|
1926 |
|
1927 TPckgBuf<TPluginIntMeasurementFormat> pluginMeasurementPckg; |
|
1928 pluginMeasurementPckg.Copy(aValue); |
|
1929 |
|
1930 TInt measurement = pluginMeasurementPckg().iMeasurement; |
|
1931 |
|
1932 TInt numIntervalsNeeded = iRequestedIntervalMultiple - iNumOfBaseIntervalsPassed; |
|
1933 |
|
1934 if (numIntervalsNeeded <= aPluginInterval) |
|
1935 { |
|
1936 iAccumulator += measurement * numIntervalsNeeded; |
|
1937 |
|
1938 TInt average = iAccumulator / iRequestedIntervalMultiple; |
|
1939 TIntMeasurementsPckg measurementPckg(average); |
|
1940 AddMeasurementL(measurementPckg); |
|
1941 |
|
1942 iAccumulator = 0; |
|
1943 iNumOfBaseIntervalsPassed = 0; |
|
1944 } |
|
1945 else |
|
1946 { |
|
1947 iNumOfBaseIntervalsPassed += aPluginInterval; |
|
1948 iAccumulator += measurement * aPluginInterval; |
|
1949 } |
|
1950 |
|
1951 COMPONENT_TRACE1(_L( "HWRM Server - TPowerIntMeasurementsClientData::NewBatteryMeasurementL - return" ) ); |
|
1952 } |
|
1953 |
|
1954 // ----------------------------------------------------------------------------- |
|
1955 // TPowerIntMeasurementsClientData::GetMeasurementsL |
|
1956 // If at least one measurement is collected the data is written to |
|
1957 // the messasge and the client is completed. If not the |
|
1958 // message hanlde is stored and the client is completed |
|
1959 // when data is ready |
|
1960 // ----------------------------------------------------------------------------- |
|
1961 // |
|
1962 TBool TPowerIntMeasurementsClientData::GetMeasurementsL(RMessage2 aMessage) |
|
1963 { |
|
1964 COMPONENT_TRACE1(_L( "HWRM Server - TPowerIntMeasurementsClientData::GetMeasurementsL()" ) ); |
|
1965 |
|
1966 TBool complete(EFalse); |
|
1967 |
|
1968 if (IsMeasuringOn() == EFalse) |
|
1969 { |
|
1970 User::Leave(KErrNotFound); |
|
1971 } |
|
1972 else if(iMeasurementsCount > 0) |
|
1973 { |
|
1974 // if measurements are ready write to message and let ExecuteMessageL complete it |
|
1975 typedef TFixedArray<TInt,KHWRMPowerMaxMeasurementsBatchSize> TMeasurementsArray; |
|
1976 |
|
1977 TMeasurementsArray measurementsArray; |
|
1978 TransferMeasurementsToFixedArrayL(measurementsArray); |
|
1979 TPckg<TMeasurementsArray> measurementsArrayPckg(measurementsArray); |
|
1980 |
|
1981 User::LeaveIfError(aMessage.Write(0,measurementsArrayPckg)); |
|
1982 |
|
1983 TPckg<TUint> countPckg( iMeasurementsCount ); |
|
1984 User::LeaveIfError(aMessage.Write(1,countPckg)); |
|
1985 |
|
1986 iMeasurementsCount = 0; |
|
1987 |
|
1988 // Ignore Coverity false positive as uninitialized variable. |
|
1989 // Since no response is sent back to the client, only a empty message is created here. |
|
1990 // Message handle of this will be initialized to NULL in the default constructor. |
|
1991 // coverity[var_decl] |
|
1992 RMessage2 dummy; |
|
1993 iRequestedBatchMessage = dummy; |
|
1994 |
|
1995 complete = ETrue; |
|
1996 } |
|
1997 else |
|
1998 { |
|
1999 // if not ready save message handle and complete it when data is ready |
|
2000 iRequestedBatchMessage = aMessage; |
|
2001 complete = EFalse; |
|
2002 } |
|
2003 |
|
2004 COMPONENT_TRACE2( _L( "HWRM Server - TPowerIntMeasurementsClientData::GetMeasurementsL - return %d" ), complete ); |
|
2005 |
|
2006 return complete; |
|
2007 } |
|
2008 |
|
2009 // ----------------------------------------------------------------------------- |
|
2010 // TPowerMeasurementsClientData::TransferMeasurementsToFixedArrayL |
|
2011 // Trasnfers the measurements from the list to a TFixedArray (used to trasnfer |
|
2012 // the data to the client). |
|
2013 // ----------------------------------------------------------------------------- |
|
2014 // |
|
2015 void TPowerIntMeasurementsClientData::TransferMeasurementsToFixedArrayL(TFixedArray<TInt,KHWRMPowerMaxMeasurementsBatchSize> &aFixedArray) |
|
2016 { |
|
2017 COMPONENT_TRACE1(_L( "HWRM Server - TPowerMeasurementsClientData::TransferMeasurementsToFixedArrayL()" ) ); |
|
2018 |
|
2019 TPowerIntMeasurement* powerMeasurement; |
|
2020 |
|
2021 aFixedArray.Reset(); |
|
2022 |
|
2023 for(TInt i=0;(i<KHWRMPowerMaxMeasurementsBatchSize && iMeasurementsQue.IsEmpty() == EFalse);i++) |
|
2024 { |
|
2025 powerMeasurement = iMeasurementsQue.First(); |
|
2026 iMeasurementsQue.Remove(*powerMeasurement); |
|
2027 aFixedArray[i] = powerMeasurement->iAverageValue; |
|
2028 delete powerMeasurement; |
|
2029 } |
|
2030 |
|
2031 COMPONENT_TRACE1(_L( "HWRM Server - TPowerMeasurementsClientData::TransferMeasurementsToFixedArrayL - return" ) ); |
|
2032 } |
|
2033 |
|
2034 |
|
2035 // ----------------------------------------------------------------------------- |
|
2036 // TPowerVoltageCurrentMeasurementsClientData::TPowerVoltageCurrentMeasurementsClientData |
|
2037 // C++ Constructor |
|
2038 // ----------------------------------------------------------------------------- |
|
2039 // |
|
2040 TPowerVoltageCurrentMeasurementsClientData::TPowerVoltageCurrentMeasurementsClientData() |
|
2041 :iMeasurementsQue(_FOFF(TPowerVoltageCurrentMeasurement,iSglQueLink)), |
|
2042 iMeasurementsQueIter(iMeasurementsQue) |
|
2043 { |
|
2044 iVoltageAccumulator = 0; |
|
2045 iCurrentAccumulator = 0; |
|
2046 } |
|
2047 |
|
2048 // ----------------------------------------------------------------------------- |
|
2049 // TPowerVoltageCurrentMeasurementsClientData::~TPowerVoltageCurrentMeasurementsClientData |
|
2050 // Destructor |
|
2051 // ----------------------------------------------------------------------------- |
|
2052 // |
|
2053 TPowerVoltageCurrentMeasurementsClientData::~TPowerVoltageCurrentMeasurementsClientData() |
|
2054 { |
|
2055 COMPONENT_TRACE1(_L( "HWRM Server - TPowerVoltageCurrentMeasurementsClientData::~TPowerVoltageCurrentMeasurementsClientData()" ) ); |
|
2056 |
|
2057 TPowerVoltageCurrentMeasurement* powerMeasurement; |
|
2058 iMeasurementsQueIter.SetToFirst(); |
|
2059 while ((powerMeasurement = iMeasurementsQueIter++) != NULL) |
|
2060 { |
|
2061 iMeasurementsQue.Remove(*powerMeasurement); |
|
2062 delete powerMeasurement; |
|
2063 }; |
|
2064 |
|
2065 COMPONENT_TRACE1(_L( "HWRM Server - TPowerVoltageCurrentMeasurementsClientData::~TPowerVoltageCurrentMeasurementsClientData - return" ) ); |
|
2066 } |
|
2067 |
|
2068 |
|
2069 // ----------------------------------------------------------------------------- |
|
2070 // TPowerVoltageCurrentMeasurementsClientData::AddMeasurementL |
|
2071 // Adds an voltage and current measurement to the Measurements List. If list is full it |
|
2072 // overwrites the oldest value. |
|
2073 // ----------------------------------------------------------------------------- |
|
2074 // |
|
2075 void TPowerVoltageCurrentMeasurementsClientData::AddMeasurementL(TDesC8& aMeasurement) |
|
2076 { |
|
2077 COMPONENT_TRACE1(_L( "HWRM Server - TPowerVoltageCurrentMeasurementsClientData::AddMeasurement()" ) ); |
|
2078 |
|
2079 TPowerVoltageCurrentMeasurement* powerMeasurement; |
|
2080 |
|
2081 TVoltageCurrentMeasurementsPckg voltageCurrentMeasurementPckg; |
|
2082 voltageCurrentMeasurementPckg.Copy(aMeasurement); |
|
2083 TInt voltageMeasurement = voltageCurrentMeasurementPckg().iAverageVoltage; |
|
2084 TInt currentMeasurement = voltageCurrentMeasurementPckg().iAverageCurrent; |
|
2085 |
|
2086 if(IsMeasuringOn()) |
|
2087 { |
|
2088 if (iMeasurementsCount < KHWRMPowerMaxMeasurementsBatchSize) |
|
2089 { |
|
2090 iMeasurementsCount++; |
|
2091 powerMeasurement = new(ELeave) TPowerVoltageCurrentMeasurement(); |
|
2092 powerMeasurement->iAverageVoltageValue = voltageMeasurement; |
|
2093 powerMeasurement->iAverageCurrentValue = currentMeasurement; |
|
2094 iMeasurementsQue.AddLast(*powerMeasurement); |
|
2095 } |
|
2096 else |
|
2097 { |
|
2098 powerMeasurement = iMeasurementsQue.First(); |
|
2099 iMeasurementsQue.Remove(*powerMeasurement); |
|
2100 powerMeasurement->iAverageVoltageValue = voltageMeasurement; |
|
2101 powerMeasurement->iAverageCurrentValue = currentMeasurement; |
|
2102 iMeasurementsQue.AddLast(*powerMeasurement); |
|
2103 } |
|
2104 CompleteGetMeasurementsMessage(KErrNone); |
|
2105 } |
|
2106 |
|
2107 COMPONENT_TRACE1(_L( "HWRM Server - TPowerVoltageCurrentMeasurementsClientData::AddMeasurement - return" ) ); |
|
2108 } |
|
2109 |
|
2110 // ----------------------------------------------------------------------------- |
|
2111 // CHWRMPowerCommonData::CClientsData::WriteMeasurementsInMessageL |
|
2112 // The Measurements collected are written in the message area of the message. |
|
2113 // ----------------------------------------------------------------------------- |
|
2114 // |
|
2115 void TPowerVoltageCurrentMeasurementsClientData::WriteMeasurementsInMessageL() |
|
2116 { |
|
2117 COMPONENT_TRACE1(_L( "HWRM Server - TPowerIntMeasurementsClientData::WriteMeasurementsInMessageL()" ) ); |
|
2118 |
|
2119 typedef TFixedArray<TPowerVoltageCurrent,KHWRMPowerMaxMeasurementsBatchSize> TMeasurementsArray; |
|
2120 TMeasurementsArray measurementsArray; |
|
2121 |
|
2122 TransferMeasurementsToFixedArrayL(measurementsArray); |
|
2123 |
|
2124 TPckg<TMeasurementsArray> measurementsArrayPckg(measurementsArray); |
|
2125 User::LeaveIfError(iRequestedBatchMessage.Write(0,measurementsArrayPckg)); |
|
2126 |
|
2127 TPckg<TUint> countPckg( iMeasurementsCount ); |
|
2128 User::LeaveIfError(iRequestedBatchMessage.Write(1,countPckg)); |
|
2129 |
|
2130 COMPONENT_TRACE1(_L( "HWRM Server - TPowerIntMeasurementsClientData::WriteMeasurementsInMessageL - return" ) ); |
|
2131 } |
|
2132 |
|
2133 // ----------------------------------------------------------------------------- |
|
2134 // TPowerVoltageCurrentMeasurementsClientData::Reset |
|
2135 // Resets the object in order to be ready for a new measurements session. |
|
2136 // ----------------------------------------------------------------------------- |
|
2137 // |
|
2138 void TPowerVoltageCurrentMeasurementsClientData::Reset() |
|
2139 { |
|
2140 TPowerMeasurementsClientData::Reset(); |
|
2141 |
|
2142 iVoltageAccumulator = 0; |
|
2143 iCurrentAccumulator = 0; |
|
2144 |
|
2145 TPowerVoltageCurrentMeasurement* powerMeasurement; |
|
2146 iMeasurementsQueIter.SetToFirst(); |
|
2147 while ((powerMeasurement = iMeasurementsQueIter++) != NULL) |
|
2148 { |
|
2149 iMeasurementsQue.Remove(*powerMeasurement); |
|
2150 delete powerMeasurement; |
|
2151 }; |
|
2152 } |
|
2153 |
|
2154 // ----------------------------------------------------------------------------- |
|
2155 // TPowerVoltageCurrentMeasurementsClientData::NewBatteryMeasurementL |
|
2156 // Called if the client has registerd for measurements and a new measurement |
|
2157 // is sent by the plugin. |
|
2158 // ----------------------------------------------------------------------------- |
|
2159 // |
|
2160 void TPowerVoltageCurrentMeasurementsClientData::NewBatteryMeasurementL(TDesC8& aValue, TUint aPluginInterval) |
|
2161 { |
|
2162 COMPONENT_TRACE1(_L( "HWRM Server - TPowerVoltageCurrentMeasurementsClientData::NewBatteryMeasurementL()" ) ); |
|
2163 |
|
2164 // Example of the way tuples are used. Assume the client receives the following tuples: |
|
2165 // (100,2), (101,2), (100, 8) and has requested Interval = 9 |
|
2166 // then it calculatesfor the first 2 measurements: |
|
2167 // iNumOfBaseIntervalsPassed = 2 + 2 = 4 |
|
2168 // iAccumulator = 100*2 + 101*2 = 402 |
|
2169 // |
|
2170 // For the final measurement: |
|
2171 // numIntervalsNeeded = iRequestedIntervalMultiple - iNumOfBaseIntervalsPassed = 9 - 4 = 5 |
|
2172 // numIntervalsNeeded(5) < aPluginInterval(8) |
|
2173 // iAccumulator += aValue * numIntervalsNeeded = 402 + 100 * 5 = 902 |
|
2174 // iAverage = iAccumulator / iRequestedIntervalMultiple = 902 / 9 = 100.222222 |
|
2175 |
|
2176 TPckgBuf<TPluginVoltageCurrentMeasurementFormat> pluginMeasurementPckg; |
|
2177 pluginMeasurementPckg.Copy(aValue); |
|
2178 |
|
2179 TInt voltageMeasurement = pluginMeasurementPckg().iAverageVoltageMeasurement; |
|
2180 TInt currentMeasurement = pluginMeasurementPckg().iAverageCurrentMeasurement; |
|
2181 |
|
2182 TInt numIntervalsNeeded = iRequestedIntervalMultiple - iNumOfBaseIntervalsPassed; |
|
2183 |
|
2184 if (numIntervalsNeeded <= aPluginInterval) |
|
2185 { |
|
2186 iVoltageAccumulator += voltageMeasurement * numIntervalsNeeded; |
|
2187 iCurrentAccumulator += currentMeasurement * numIntervalsNeeded; |
|
2188 |
|
2189 TPowerVoltageCurrent averagePowerMeasurement; |
|
2190 averagePowerMeasurement.iAverageVoltage = iVoltageAccumulator / iRequestedIntervalMultiple; |
|
2191 averagePowerMeasurement.iAverageCurrent = iCurrentAccumulator / iRequestedIntervalMultiple; |
|
2192 |
|
2193 TVoltageCurrentMeasurementsPckg measurementPckg(averagePowerMeasurement); |
|
2194 AddMeasurementL(measurementPckg); |
|
2195 |
|
2196 iVoltageAccumulator = 0; |
|
2197 iCurrentAccumulator = 0; |
|
2198 iNumOfBaseIntervalsPassed = 0; |
|
2199 } |
|
2200 else |
|
2201 { |
|
2202 iNumOfBaseIntervalsPassed += aPluginInterval; |
|
2203 iVoltageAccumulator += voltageMeasurement * aPluginInterval; |
|
2204 iCurrentAccumulator += currentMeasurement * aPluginInterval; |
|
2205 } |
|
2206 |
|
2207 COMPONENT_TRACE1(_L( "HWRM Server - TPowerVoltageCurrentMeasurementsClientData::NewBatteryMeasurementL - return" ) ); |
|
2208 } |
|
2209 |
|
2210 // ----------------------------------------------------------------------------- |
|
2211 // TPowerVoltageCurrentMeasurementsClientData::GetMeasurementsL |
|
2212 // If at least one measurement is collected the data is written to |
|
2213 // the messasge and the client is completed. If not the |
|
2214 // message hanlde is stored and the client is completed |
|
2215 // when data is ready |
|
2216 // ----------------------------------------------------------------------------- |
|
2217 // |
|
2218 TBool TPowerVoltageCurrentMeasurementsClientData::GetMeasurementsL(RMessage2 aMessage) |
|
2219 { |
|
2220 COMPONENT_TRACE1(_L( "HWRM Server - TPowerVoltageCurrentMeasurementsClientData::GetMeasurementsL()" ) ); |
|
2221 |
|
2222 TBool complete(EFalse); |
|
2223 |
|
2224 if (IsMeasuringOn() == EFalse) |
|
2225 { |
|
2226 User::Leave(KErrNotFound); |
|
2227 } |
|
2228 else if(iMeasurementsCount > 0) |
|
2229 { |
|
2230 // if measurements are ready write to message and let ExecuteMessageL complete it |
|
2231 typedef TFixedArray<TPowerVoltageCurrent,KHWRMPowerMaxMeasurementsBatchSize> TMeasurementsArray; |
|
2232 |
|
2233 TMeasurementsArray measurementsArray; |
|
2234 TransferMeasurementsToFixedArrayL(measurementsArray); |
|
2235 TPckg<TMeasurementsArray> measurementsArrayPckg(measurementsArray); |
|
2236 |
|
2237 User::LeaveIfError(aMessage.Write(0,measurementsArrayPckg)); |
|
2238 |
|
2239 TPckg<TUint> countPckg( iMeasurementsCount ); |
|
2240 User::LeaveIfError(aMessage.Write(1,countPckg)); |
|
2241 |
|
2242 iMeasurementsCount = 0; |
|
2243 |
|
2244 // Ignore Coverity false positive as uninitialized variable. |
|
2245 // Since no response is sent back to the client, only a empty message is created here. |
|
2246 // Message handle of this will be initialized to NULL in the default constructor. |
|
2247 // coverity[var_decl] |
|
2248 RMessage2 dummy; |
|
2249 iRequestedBatchMessage = dummy; |
|
2250 |
|
2251 complete = ETrue; |
|
2252 } |
|
2253 else |
|
2254 { |
|
2255 // if not ready save message handle and complete it when data is ready |
|
2256 iRequestedBatchMessage = aMessage; |
|
2257 complete = EFalse; |
|
2258 } |
|
2259 |
|
2260 COMPONENT_TRACE2( _L( "HWRM Server - TPowerVoltageCurrentMeasurementsClientData::GetMeasurementsL - return %d" ), complete ); |
|
2261 |
|
2262 return complete; |
|
2263 } |
|
2264 |
|
2265 // ----------------------------------------------------------------------------- |
|
2266 // TPowerVoltageCurrentMeasurementsClientData::TransferMeasurementsToFixedArrayL |
|
2267 // Trasnfers the measurements from the list to a TFixedArray (used to trasnfer |
|
2268 // the data to the client). |
|
2269 // ----------------------------------------------------------------------------- |
|
2270 // |
|
2271 void TPowerVoltageCurrentMeasurementsClientData::TransferMeasurementsToFixedArrayL(TFixedArray<TPowerVoltageCurrent,KHWRMPowerMaxMeasurementsBatchSize> &aFixedArray) |
|
2272 { |
|
2273 COMPONENT_TRACE1(_L( "HWRM Server - TPowerVoltageCurrentMeasurementsClientData::TransferMeasurementsToFixedArrayL()" ) ); |
|
2274 |
|
2275 TPowerVoltageCurrentMeasurement* powerMeasurement; |
|
2276 |
|
2277 aFixedArray.Reset(); |
|
2278 |
|
2279 for(TInt i=0;(i<KHWRMPowerMaxMeasurementsBatchSize && iMeasurementsQue.IsEmpty() == EFalse);i++) |
|
2280 { |
|
2281 powerMeasurement = iMeasurementsQue.First(); |
|
2282 iMeasurementsQue.Remove(*powerMeasurement); |
|
2283 aFixedArray[i].iAverageVoltage = powerMeasurement->iAverageVoltageValue; |
|
2284 aFixedArray[i].iAverageCurrent = powerMeasurement->iAverageCurrentValue; |
|
2285 delete powerMeasurement; |
|
2286 } |
|
2287 |
|
2288 COMPONENT_TRACE1(_L( "HWRM Server - TPowerVoltageCurrentMeasurementsClientData::TransferMeasurementsToFixedArrayL - return" ) ); |
|
2289 } |
|
2290 |
|
2291 /* |
|
2292 * For Future Use |
|
2293 * |
|
2294 // ----------------------------------------------------------------------------- |
|
2295 // CHWRMPowerService::CancelPluginCommandL |
|
2296 // Cancels a plugin command and handles the related transaction(s). |
|
2297 // Note that plug-in handler CancelCommandL's will not cause client requests to complete |
|
2298 // ----------------------------------------------------------------------------- |
|
2299 // |
|
2300 void CHWRMPowerService::CancelPluginCommandL(HWRMPowerCommand::TPowerCmd aCommandId) |
|
2301 { |
|
2302 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::CancelPluginCommandL" ) ); |
|
2303 |
|
2304 THWRMPluginRequestData* data = static_cast<THWRMPluginRequestData*>(iTransactionList->GetFirstItem()); |
|
2305 |
|
2306 // Cancel each transaction with the cancelled command ID |
|
2307 while ( data ) |
|
2308 { |
|
2309 if ( data->iCommandId == aCommandId && |
|
2310 data->iRequestMessage.Handle() ) |
|
2311 { |
|
2312 // Cancel transaction |
|
2313 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMService::CancelPluginCommandL() - Canceling pending message" ) ); |
|
2314 data->iRequestMessage.Complete(KErrCancel); |
|
2315 |
|
2316 // Record transaction ID, and move to next item |
|
2317 TUint8 cancelTransId = data->iTransId; |
|
2318 data = static_cast<THWRMPluginRequestData*>(data->iNextData); |
|
2319 |
|
2320 // Remove cancelled transaction items |
|
2321 // First cancel plugin command. If successful, then no call to ProcessResponseL |
|
2322 iPluginHandler->CancelCommandL( cancelTransId ); |
|
2323 iTransactionList->FindTransaction( cancelTransId, ETrue); |
|
2324 } |
|
2325 else |
|
2326 { |
|
2327 // Move to next item |
|
2328 data = static_cast<THWRMPluginRequestData*>(data->iNextData); |
|
2329 } |
|
2330 } |
|
2331 |
|
2332 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMPowerService::CancelPluginCommandL - return" ) ); |
|
2333 } |
|
2334 */ |
|
2335 |
|
2336 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
2337 |
|
2338 // End of File |