17 |
17 |
18 #include "PwrPlugin.h" |
18 #include "PwrPlugin.h" |
19 #include <piprofiler/ProfilerTraces.h> |
19 #include <piprofiler/ProfilerTraces.h> |
20 |
20 |
21 #include <centralrepository.h> |
21 #include <centralrepository.h> |
22 #include <HWRMPower.h> |
22 #include <hwrmpower.h> |
23 #include <HWRMLight.h> |
23 #include <hwrmlight.h> |
24 #include <hwrm/hwrmpowerdomaincrkeys.h> |
24 #include <hwrm/hwrmpowerdomaincrkeys.h> |
25 |
25 |
26 |
26 |
27 // texts for notes |
27 // texts for notes |
28 _LIT(KPowerTextLine1, "Power sampler:"); |
28 _LIT(KPowerTextLine1, "Power sampler:"); |
322 iPwrSamplingPeriod(0), |
322 iPwrSamplingPeriod(0), |
323 iOriginalReportingPeriod(0), |
323 iOriginalReportingPeriod(0), |
324 iNominalCapa(0), |
324 iNominalCapa(0), |
325 iVoltage(0), |
325 iVoltage(0), |
326 iCurrent(0), |
326 iCurrent(0), |
327 iPowerAPI(0) |
327 iPowerAPI(0), |
328 #ifdef PWR_SAMPLER_BACKLIGHT |
328 iLightAPI(0), |
329 ,iLightAPI(0), |
|
330 iBackLightStatus(CHWRMLight::ELightStatusUnknown) |
329 iBackLightStatus(CHWRMLight::ELightStatusUnknown) |
331 #endif |
|
332 |
330 |
333 { |
331 { |
334 LOGTEXT(_L("CProfilerPowerListener::CProfilerPowerListener() - konstuktori")); |
332 LOGTEXT(_L("CProfilerPowerListener::CProfilerPowerListener() - konstuktori")); |
335 this->iSampler = aSampler; |
333 this->iSampler = aSampler; |
336 LOGTEXT(_L("CProfilerPowerListener::CProfilerPowerListener() - konstuktori exit")); |
334 LOGTEXT(_L("CProfilerPowerListener::CProfilerPowerListener() - konstuktori exit")); |
427 iPowerAPI = CHWRMPower::NewL(); |
424 iPowerAPI = CHWRMPower::NewL(); |
428 iPowerAPI->SetPowerReportObserver(this); |
425 iPowerAPI->SetPowerReportObserver(this); |
429 |
426 |
430 // Read HWRM reporting settings from central repository |
427 // Read HWRM reporting settings from central repository |
431 CRepository* centRep = CRepository::NewL(KCRUidPowerSettings); |
428 CRepository* centRep = CRepository::NewL(KCRUidPowerSettings); |
|
429 CleanupStack::PushL( centRep ); |
|
430 |
432 TInt baseInterval(0); |
431 TInt baseInterval(0); |
433 User::LeaveIfError(centRep->Get(KPowerBaseTimeInterval, baseInterval)); |
432 User::LeaveIfError(centRep->Get(KPowerBaseTimeInterval, baseInterval)); |
434 User::LeaveIfError(centRep->Get(KPowerMaxReportingPeriod, iOriginalReportingPeriod)); |
433 User::LeaveIfError(centRep->Get(KPowerMaxReportingPeriod, iOriginalReportingPeriod)); |
435 |
434 |
436 LOGSTRING2("CProfilerPowerListener::StartL() - HWRM base power report interval: %d", baseInterval); |
435 LOGSTRING2("CProfilerPowerListener::StartL() - HWRM base power report interval: %d", baseInterval); |
437 LOGSTRING2("CProfilerPowerListener::StartL() - Original HWRM max power reporting period: %d", iOriginalReportingPeriod); |
436 LOGSTRING2("CProfilerPowerListener::StartL() - Original HWRM max power reporting period: %d", iOriginalReportingPeriod); |
438 |
437 |
439 User::LeaveIfError(centRep->Set(KPowerMaxReportingPeriod, KReportingPeriodInfinite)); |
438 User::LeaveIfError(centRep->Set(KPowerMaxReportingPeriod, KReportingPeriodInfinite)); |
|
439 CleanupStack::PopAndDestroy(); |
440 |
440 |
441 // Power reporting interval reading may return too low value sometimes. Minimum value expected to be 250ms. |
441 // Power reporting interval reading may return too low value sometimes. Minimum value expected to be 250ms. |
442 if ( baseInterval < KMinSampleInterval ) |
442 if ( baseInterval < KMinSampleInterval ) |
443 { |
443 { |
444 baseInterval = KMinSampleInterval; |
444 baseInterval = KMinSampleInterval; |
503 TUint32 sampleTime = User::NTickCount() - iSampleStartTime; |
501 TUint32 sampleTime = User::NTickCount() - iSampleStartTime; |
504 LOGSTRING2("CProfilerPowerListener::Sample() - Sample time: %d", sampleTime); |
502 LOGSTRING2("CProfilerPowerListener::Sample() - Sample time: %d", sampleTime); |
505 LOGSTRING2("CProfilerPowerListener::Sample() - Nominal capacitance: %d", iNominalCapa); |
503 LOGSTRING2("CProfilerPowerListener::Sample() - Nominal capacitance: %d", iNominalCapa); |
506 LOGSTRING2("CProfilerPowerListener::Sample() - Voltage: %d", iVoltage); |
504 LOGSTRING2("CProfilerPowerListener::Sample() - Voltage: %d", iVoltage); |
507 LOGSTRING2("CProfilerPowerListener::Sample() - Current: %d", iCurrent); |
505 LOGSTRING2("CProfilerPowerListener::Sample() - Current: %d", iCurrent); |
508 #ifdef PWR_SAMPLER_BACKLIGHT |
|
509 LOGSTRING2("CProfilerPowerListener::Sample() - Backlight status: %d", (TUint8)iBackLightStatus); |
506 LOGSTRING2("CProfilerPowerListener::Sample() - Backlight status: %d", (TUint8)iBackLightStatus); |
510 #endif |
|
511 |
507 |
512 iSample[0] = iNominalCapa; |
508 iSample[0] = iNominalCapa; |
513 iSample[1] = iNominalCapa >> 8; |
509 iSample[1] = iNominalCapa >> 8; |
514 iSample[2] = iVoltage; |
510 iSample[2] = iVoltage; |
515 iSample[3] = iVoltage >> 8; |
511 iSample[3] = iVoltage >> 8; |
516 iSample[4] = iCurrent; |
512 iSample[4] = iCurrent; |
517 iSample[5] = iCurrent >> 8; |
513 iSample[5] = iCurrent >> 8; |
518 iSample[6] = iCurrent >> 16; |
514 iSample[6] = iCurrent >> 16; |
519 iSample[7] = iCurrent >> 24; |
515 iSample[7] = iCurrent >> 24; |
520 #ifdef PWR_SAMPLER_BACKLIGHT |
|
521 iSample[8] = (TUint8)iBackLightStatus; |
516 iSample[8] = (TUint8)iBackLightStatus; |
522 iSample[9] = sampleTime; |
517 iSample[9] = sampleTime; |
523 iSample[10] = sampleTime >> 8; |
518 iSample[10] = sampleTime >> 8; |
524 iSample[11] = sampleTime >> 16; |
519 iSample[11] = sampleTime >> 16; |
525 iSample[12] = sampleTime >> 24; |
520 iSample[12] = sampleTime >> 24; |
526 |
521 |
527 iSampler->AddSample(iSample, 13, 0); |
522 iSampler->AddSample(iSample, 13, 0); |
528 #else |
|
529 iSample[8] = sampleTime; |
|
530 iSample[9] = sampleTime >> 8; |
|
531 iSample[10] = sampleTime >> 16; |
|
532 iSample[11] = sampleTime >> 24; |
|
533 |
|
534 iSampler->AddSample(iSample, 12, 0); |
|
535 #endif |
|
536 |
523 |
537 LOGTEXT(_L("CProfilerPowerListener::Sample() - exit")); |
524 LOGTEXT(_L("CProfilerPowerListener::Sample() - exit")); |
538 } |
525 } |
539 |
526 |
540 TInt CProfilerPowerListener::Stop() |
527 TInt CProfilerPowerListener::Stop() |
602 DisplayNotifierL(KPowerTextLine1, KPowerTextErrorSampling, KButtonOk, KNullDesC); |
592 DisplayNotifierL(KPowerTextLine1, KPowerTextErrorSampling, KButtonOk, KNullDesC); |
603 } |
593 } |
604 LOGTEXT(_L("CProfilerPowerListener::PowerMeasurement - exit")); |
594 LOGTEXT(_L("CProfilerPowerListener::PowerMeasurement - exit")); |
605 } |
595 } |
606 |
596 |
607 #ifdef PWR_SAMPLER_BACKLIGHT |
|
608 void CProfilerPowerListener::LightStatusChanged(TInt aTarget, CHWRMLight::TLightStatus aStatus) |
597 void CProfilerPowerListener::LightStatusChanged(TInt aTarget, CHWRMLight::TLightStatus aStatus) |
609 { |
598 { |
610 LOGTEXT(_L("CProfilerPowerListener::LightStatusChanged - entry")); |
599 LOGTEXT(_L("CProfilerPowerListener::LightStatusChanged - entry")); |
611 LOGSTRING3("CProfilerPowerListener::LightStatusChanged - Target: %d Status: %d", aTarget, aStatus); |
600 LOGSTRING3("CProfilerPowerListener::LightStatusChanged - Target: %d Status: %d", aTarget, aStatus); |
612 |
601 |