piprofiler/plugins/PWRplugin/inc/PwrPlugin.h
branchRCL_3
changeset 59 8ad140f3dd41
parent 49 7fdc9a71d314
equal deleted inserted replaced
49:7fdc9a71d314 59:8ad140f3dd41
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef BAPPEA_PWR_SAMPLER_H
       
    19 #define BAPPEA_PWR_SAMPLER_H
       
    20 
       
    21 //#define PWR_SAMPLER_BACKLIGHT
       
    22 
       
    23 //#include "PIProfilerConfigInternal.h"
       
    24 
       
    25 // system definitions
       
    26 #include <w32std.h>
       
    27 #include <e32std.h>
       
    28 
       
    29 #include <e32property.h>
       
    30 #include <HWRMPower.h>
       
    31 #include <HWRMLight.h>
       
    32 
       
    33 // user definitions
       
    34 #include <piprofiler/SamplerPluginInterface.h>
       
    35 #include <piprofiler/ProfilerGenericClassesUsr.h>
       
    36 
       
    37 // caption definitions
       
    38 _LIT8(KPWRShortName, "pwr");
       
    39 _LIT8(KPWRMediumName, "Power sampler");
       
    40 _LIT8(KPWRLongName, "Power usage sampler");
       
    41 _LIT8(KPWRDescription, "Power sampler: \nSampling power consumption on Nokia S60 devices\nHW dep: N/A\nSW dep: S60 3.0\n");
       
    42 
       
    43 // Minimum allowed sampling interval (in ms). 0 means undefined.
       
    44 const TInt KMinSampleInterval = 250;
       
    45 const TInt KReportingPeriodInfinite = 0;
       
    46 
       
    47 const TUid KGppPropertyCat={0x20201F70};
       
    48 enum TGppPropertyKeys
       
    49     {
       
    50     EGppPropertySyncSampleNumber
       
    51     };
       
    52 
       
    53 const TUid KPwrNotifierUid = { 0x2001E5B9 };
       
    54 class CProfilerPowerListener;
       
    55 
       
    56 /*
       
    57  *
       
    58  * PWR sampler plug-in definition
       
    59  *
       
    60  */
       
    61 
       
    62 class CPwrPlugin : public CSamplerPluginInterface
       
    63 {
       
    64 public:
       
    65     static  CPwrPlugin* NewL(const TUid aImplementationUid, TAny* aInitParams);
       
    66             ~CPwrPlugin();
       
    67 
       
    68     TInt    ResetAndActivateL(CProfilerSampleStream& aStream);
       
    69     TInt    StopSampling();
       
    70     TBool   Enabled() { return iEnabled; }
       
    71     void    SetEnabled(TBool aEnabled);
       
    72     TInt    GetSamplerType();
       
    73 
       
    74     TInt    CreateFirstSample();
       
    75 
       
    76     void    GetAttributesL(CArrayFixFlat<TSamplerAttributes>* aAttributes);
       
    77     TInt    SetAttributesL(TSamplerAttributes& aAttributes);
       
    78     void    InitiateSamplerAttributesL();
       
    79 
       
    80     TInt    ConvertRawSettingsToAttributes(CDesC8ArrayFlat* aSingleSettingArray);
       
    81 
       
    82     TInt    DoSetSamplerSettings(CDesC8ArrayFlat* aAllSettings, TDesC8& aSamplerName, TInt aIndex);
       
    83     void    SaveSettingToAttributes(const TDesC8& aSetting, TInt aIndex);
       
    84 
       
    85     TUid    Id(TInt aSubId) const;
       
    86 
       
    87     // subsampler settings, i.e. samplers implemented within a plugin
       
    88     // no sub samplers, from CSamplerPluginInterface
       
    89     TInt    SubId(TUid aId) const {return KErrNotFound;}
       
    90     TInt    GetSubSamplers(TDes* aDes){return KErrNotFound;}
       
    91 
       
    92 private:
       
    93             CPwrPlugin();
       
    94     void    ConstructL();
       
    95 
       
    96 private:
       
    97     TUint8                  iVersion[20];
       
    98     TPtr8                   iVersionDescriptor;
       
    99 
       
   100     TInt                    iSamplerType;
       
   101 
       
   102     CProfilerPowerListener* iPowerListener;
       
   103 
       
   104     TInt                    iPeriod;
       
   105     CArrayFixFlat<TSamplerAttributes>* iSamplerAttributes;
       
   106 public:
       
   107     TUint32*                iSampleTime;
       
   108 };
       
   109 
       
   110 #ifdef PWR_SAMPLER_BACKLIGHT
       
   111 class CProfilerPowerListener : public CBase, public MHWRMBatteryPowerObserver, public MHWRMLightObserver
       
   112 #else
       
   113 class CProfilerPowerListener : public CBase, public MHWRMBatteryPowerObserver
       
   114 #endif
       
   115 {
       
   116 public:
       
   117     static  CProfilerPowerListener* NewL(CPwrPlugin* aSampler);
       
   118             ~CProfilerPowerListener();
       
   119 
       
   120 private:
       
   121             CProfilerPowerListener(CPwrPlugin* aSampler);
       
   122     void    ConstructL();
       
   123 
       
   124 public:
       
   125     TInt    StartL(const TDesC8& aBuf);
       
   126     TInt    Stop();
       
   127     TInt    DisplayNotifierL(const TDesC& aLine1, const TDesC& aLine2, const TDesC& aButton1, const TDesC& aButton2);
       
   128 
       
   129     // From MHWRMBatteryPowerObserver
       
   130     virtual void PowerMeasurement(TInt aErr, CHWRMPower::TBatteryPowerMeasurementData& aMeasurement);
       
   131 #ifdef PWR_SAMPLER_BACKLIGHT
       
   132     // From MHWRMLightObserver
       
   133     virtual void LightStatusChanged(TInt aTarget, CHWRMLight::TLightStatus aStatus);
       
   134 #endif
       
   135 
       
   136 private:
       
   137     void    Sample();
       
   138 
       
   139 public:
       
   140     TInt                    iPwrSamplingPeriod;
       
   141     TInt                    iSampleStartTime;
       
   142     // Value that is read from Central Repository and restored after sampling
       
   143     TInt                    iOriginalReportingPeriod;
       
   144 
       
   145 private:
       
   146 
       
   147 #ifdef PWR_SAMPLER_BACKLIGHT
       
   148     TUint8                  iSample[13];
       
   149 #else
       
   150     TUint8                  iSample[12];
       
   151 #endif
       
   152 
       
   153     TUint16                 iNominalCapa;
       
   154     TUint16                 iVoltage;
       
   155     TUint16                 iCurrent;
       
   156 
       
   157     CPwrPlugin*             iSampler;
       
   158     CHWRMPower*             iPowerAPI;
       
   159 
       
   160 #ifdef PWR_SAMPLER_BACKLIGHT
       
   161     CHWRMLight*             iLightAPI;
       
   162     CHWRMLight::TLightStatus iBackLightStatus;
       
   163 #endif
       
   164 };
       
   165 
       
   166 #endif
       
   167