Revision: 201033 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 15 Sep 2010 00:19:18 +0300
branchRCL_3
changeset 22 e26895079d7c
parent 21 52e343bb8f80
Revision: 201033 Kit: 201035
piprofiler/group/ReleaseNotes_PIProfiler.txt
piprofiler/group/bld.inf
piprofiler/plugins/GeneralsPlugin/src/GppSamplerImpl.cpp
piprofiler/plugins/PWRplugin/data/2001E5B9.rss
piprofiler/plugins/PWRplugin/group/PWRPlugin.mmp
piprofiler/plugins/PWRplugin/group/bld.inf
piprofiler/plugins/PWRplugin/inc/PwrPlugin.h
piprofiler/plugins/PWRplugin/sis/PWRPlugin.pkg
piprofiler/plugins/PWRplugin/src/PwrPlugin.cpp
piprofiler/plugins/PWRplugin/src/PwrPluginImplementationTable.cpp
piprofiler/rom/piprofiler.iby
piprofiler/rom/piprofiler_s2.iby
piprofiler/symbian_version.hrh
Binary file piprofiler/group/ReleaseNotes_PIProfiler.txt has changed
--- a/piprofiler/group/bld.inf	Wed Sep 01 12:37:10 2010 +0100
+++ b/piprofiler/group/bld.inf	Wed Sep 15 00:19:18 2010 +0300
@@ -26,8 +26,15 @@
 #include "../plugins/DebugOutputWriterPlugin/group/bld.inf"
 #include "../plugins/DiskWriterPlugin/group/bld.inf"
 
+#if ( SYMBIAN_VERSION_SUPPORT >= SYMBIAN_3 )
+    #include "../plugins/PWRPlugin/group/bld.inf"
+#endif
 
 PRJ_EXPORTS
-../rom/piprofiler.iby CORE_IBY_EXPORT_PATH(tools,piprofiler.iby)
+#if ( SYMBIAN_VERSION_SUPPORT >= SYMBIAN_3 )
+    ../rom/piprofiler.iby CORE_IBY_EXPORT_PATH(tools,piprofiler.iby)
+#else
+    ../rom/piprofiler_s2.iby CORE_IBY_EXPORT_PATH(tools,piprofiler.iby)
+#endif
 ../rom/piprofiler_ldd.iby CORE_IBY_EXPORT_PATH(tools/rom,piprofiler_ldd.iby)
 
--- a/piprofiler/plugins/GeneralsPlugin/src/GppSamplerImpl.cpp	Wed Sep 01 12:37:10 2010 +0100
+++ b/piprofiler/plugins/GeneralsPlugin/src/GppSamplerImpl.cpp	Wed Sep 15 00:19:18 2010 +0300
@@ -76,7 +76,7 @@
 	{
 	LOGTEXT("GppSamplerImpl::Reset");
 	iLastPc = 0;
-	iLastThread = 0;
+	iLastThread = 0xfffffffe;
 	iRepeat = 0;
 	iIsaStatus = 0;
 	iIsaStart = 0;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/piprofiler/plugins/PWRplugin/data/2001E5B9.rss	Wed Sep 15 00:19:18 2010 +0300
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <ecom/registryinfo.rh>
+
+// Declares info for two implementations
+RESOURCE REGISTRY_INFO theInfo
+    {
+    // UID for the DLL. See mmp files
+    //__SERIES60_3X__ can't be used in resource files
+    dll_uid = 0x2001E5B9;
+
+    // Declare array of interface info. This dll contains implementations for 
+    // only one interface (CSamplerInterfaceDefinition).
+    interfaces = 
+        {
+        INTERFACE_INFO
+            {
+            // UID of interface that is implemented
+            interface_uid = 0x2001E5BC;
+
+            implementations = 
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0x2001E5B9;
+
+                    version_no = 1;
+                    display_name = "PWR Sampler";
+                    default_data = "pwr";
+                    opaque_data = "10";
+                    }
+                };
+            }
+        };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/piprofiler/plugins/PWRplugin/group/PWRPlugin.mmp	Wed Sep 15 00:19:18 2010 +0300
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+
+TARGET          PIProfilerPWR.dll
+TARGETTYPE      PLUGIN
+UID             0x10009D8D 0x2001E5B9
+VENDORID        VID_DEFAULT
+CAPABILITY      ALL -TCB
+SMPSAFE
+
+OS_LAYER_SYSTEMINCLUDE
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../inc
+SOURCEPATH      ../src
+
+START RESOURCE  ../data/2001E5B9.rss
+TARGET PIProfilerPWR.rsc
+END
+
+SOURCE          PwrPluginImplementationTable.cpp
+SOURCE          PwrPlugin.cpp
+
+LIBRARY     euser.lib
+LIBRARY     ecom.lib
+LIBRARY     apparc.lib
+LIBRARY     cone.lib
+LIBRARY     gdi.lib
+LIBRARY     ws32.lib
+LIBRARY     efsrv.lib
+LIBRARY     charconv.lib
+LIBRARY     CommonEngine.lib
+LIBRARY     flogger.lib
+LIBRARY     centralrepository.lib
+LIBRARY     HWRMPowerClient.lib
+LIBRARY     HWRMLightClient.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/piprofiler/plugins/PWRplugin/group/bld.inf	Wed Sep 15 00:19:18 2010 +0300
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+#ifndef SBSV2
+PRJ_PLATFORMS
+DEFAULT
+#endif
+
+PRJ_MMPFILES
+#ifdef MARM
+  #ifndef __SERIES60_30__
+    PWRPlugin.mmp
+  #endif
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/piprofiler/plugins/PWRplugin/inc/PwrPlugin.h	Wed Sep 15 00:19:18 2010 +0300
@@ -0,0 +1,167 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+#ifndef BAPPEA_PWR_SAMPLER_H
+#define BAPPEA_PWR_SAMPLER_H
+
+//#define PWR_SAMPLER_BACKLIGHT
+
+//#include "PIProfilerConfigInternal.h"
+
+// system definitions
+#include <w32std.h>
+#include <e32std.h>
+
+#include <e32property.h>
+#include <HWRMPower.h>
+#include <HWRMLight.h>
+
+// user definitions
+#include <piprofiler/SamplerPluginInterface.h>
+#include <piprofiler/ProfilerGenericClassesUsr.h>
+
+// caption definitions
+_LIT8(KPWRShortName, "pwr");
+_LIT8(KPWRMediumName, "Power sampler");
+_LIT8(KPWRLongName, "Power usage sampler");
+_LIT8(KPWRDescription, "Power sampler: \nSampling power consumption on Nokia S60 devices\nHW dep: N/A\nSW dep: S60 3.0\n");
+
+// Minimum allowed sampling interval (in ms). 0 means undefined.
+const TInt KMinSampleInterval = 250;
+const TInt KReportingPeriodInfinite = 0;
+
+const TUid KGppPropertyCat={0x20201F70};
+enum TGppPropertyKeys
+    {
+    EGppPropertySyncSampleNumber
+    };
+
+const TUid KPwrNotifierUid = { 0x2001E5B9 };
+class CProfilerPowerListener;
+
+/*
+ *
+ * PWR sampler plug-in definition
+ *
+ */
+
+class CPwrPlugin : public CSamplerPluginInterface
+{
+public:
+    static  CPwrPlugin* NewL(const TUid aImplementationUid, TAny* aInitParams);
+            ~CPwrPlugin();
+
+    TInt    ResetAndActivateL(CProfilerSampleStream& aStream);
+    TInt    StopSampling();
+    TBool   Enabled() { return iEnabled; }
+    void    SetEnabled(TBool aEnabled);
+    TInt    GetSamplerType();
+
+    TInt    CreateFirstSample();
+
+    void    GetAttributesL(CArrayFixFlat<TSamplerAttributes>* aAttributes);
+    TInt    SetAttributesL(TSamplerAttributes aAttributes);
+    void    InitiateSamplerAttributesL();
+
+    TInt    ConvertRawSettingsToAttributes(CDesC8ArrayFlat* aSingleSettingArray);
+
+    TInt    DoSetSamplerSettings(CDesC8ArrayFlat* aAllSettings, TDesC8& aSamplerName, TInt aIndex);
+    void    SaveSettingToAttributes(const TDesC8& aSetting, TInt aIndex);
+
+    TUid    Id(TInt aSubId) const;
+
+    // subsampler settings, i.e. samplers implemented within a plugin
+    // no sub samplers, from CSamplerPluginInterface
+    TInt    SubId(TUid aId) const {return KErrNotFound;}
+    TInt    GetSubSamplers(TDes* aDes){return KErrNotFound;}
+
+private:
+            CPwrPlugin();
+    void    ConstructL();
+
+private:
+    TUint8                  iVersion[20];
+    TPtr8                   iVersionDescriptor;
+
+    TInt                    iSamplerType;
+
+    CProfilerPowerListener* iPowerListener;
+
+    TInt                    iPeriod;
+    CArrayFixFlat<TSamplerAttributes>* iSamplerAttributes;
+public:
+    TUint32*                iSampleTime;
+};
+
+#ifdef PWR_SAMPLER_BACKLIGHT
+class CProfilerPowerListener : public MHWRMBatteryPowerObserver, public MHWRMLightObserver
+#else
+class CProfilerPowerListener : public MHWRMBatteryPowerObserver
+#endif
+{
+public:
+    static  CProfilerPowerListener* NewL(CPwrPlugin* aSampler);
+            ~CProfilerPowerListener();
+
+private:
+            CProfilerPowerListener(CPwrPlugin* aSampler);
+    void    ConstructL();
+
+public:
+    TInt    StartL(const TDesC8& aBuf);
+    TInt    Stop();
+    TInt    DisplayNotifierL(const TDesC& aLine1, const TDesC& aLine2, const TDesC& aButton1, const TDesC& aButton2);
+
+    // From MHWRMBatteryPowerObserver
+    virtual void PowerMeasurement(TInt aErr, CHWRMPower::TBatteryPowerMeasurementData& aMeasurement);
+#ifdef PWR_SAMPLER_BACKLIGHT
+    // From MHWRMLightObserver
+    virtual void LightStatusChanged(TInt aTarget, CHWRMLight::TLightStatus aStatus);
+#endif
+
+private:
+    void    Sample();
+
+public:
+    TInt                    iPwrSamplingPeriod;
+    TInt                    iSampleStartTime;
+    // Value that is read from Central Repository and restored after sampling
+    TInt                    iOriginalReportingPeriod;
+
+private:
+
+#ifdef PWR_SAMPLER_BACKLIGHT
+    TUint8                  iSample[13];
+#else
+    TUint8                  iSample[12];
+#endif
+
+    TUint16                 iNominalCapa;
+    TUint16                 iVoltage;
+    TUint16                 iCurrent;
+
+    CPwrPlugin*             iSampler;
+    CHWRMPower*             iPowerAPI;
+
+#ifdef PWR_SAMPLER_BACKLIGHT
+    CHWRMLight*             iLightAPI;
+    CHWRMLight::TLightStatus iBackLightStatus;
+#endif
+};
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/piprofiler/plugins/PWRplugin/sis/PWRPlugin.pkg	Wed Sep 15 00:19:18 2010 +0300
@@ -0,0 +1,44 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+; ShapeImplementation_30_gcce.pkg
+;
+
+;Language - standard language definitions
+&EN
+
+; standard sis file header
+#{"Shape plugin"},(0xE01F614F),2,0,0
+
+
+;
+;Localised Vendor name
+;
+%{"Forum Nokia"}
+
+;
+;Unique Vendor name
+;
+:"Forum Nokia"
+
+;
+;Supports Series 60 v 3.0
+;
+[0x101F7961], 0, 0, 0, {"Series60ProductID"}
+
+
+;Files to include. Check the source paths they match your SDK setup. 
+"\Symbian\9.1\S60_3rd_MR\Epoc32\release\gcce\urel\shapeimplementation.dll"     -   "!:\sys\bin\shapeimplementation.dll"
+"\Symbian\9.1\S60_3rd_MR\epoc32\data\Z\Resource\plugins\shapeimplementation.rsc"   -   "!:\Resource\Plugins\shapeimplementation.RSC"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/piprofiler/plugins/PWRplugin/src/PwrPlugin.cpp	Wed Sep 15 00:19:18 2010 +0300
@@ -0,0 +1,623 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+#include "PwrPlugin.h"
+#include <piprofiler/ProfilerTraces.h>
+
+#include <centralrepository.h>
+#include <HWRMPower.h>
+#include <HWRMLight.h>
+#include <hwrm/hwrmpowerdomaincrkeys.h>
+
+
+// texts for notes
+_LIT(KPowerTextLine1, "Power sampler:");
+_LIT(KPowerTextLine2, "Failed to start power measurement");
+_LIT(KPowerTextErrorSampling, "Error receiving measurement data");
+_LIT(KButtonOk, "Ok");
+
+// LITERALS
+
+_LIT8(KSamplingPeriodMs, "sampling_period_ms");
+
+// CONSTANTS
+// Use this UID if plugin is PwrPlugin:
+const TUid KSamplerPwrPluginUid = { 0x2001E5B9 };
+
+/*
+ *
+ * class CPwrPlugin implementation
+ * 
+ */
+ 
+CPwrPlugin* CPwrPlugin::NewL(const TUid /*aImplementationUid*/, TAny* aInitParams)
+    {
+    LOGTEXT(_L("CPwrPlugin::NewL() - entry"));
+    CPwrPlugin* self = new (ELeave) CPwrPlugin();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    LOGTEXT(_L("CPwrPlugin::NewL() - exit"));
+    return self;
+    }
+
+CPwrPlugin::CPwrPlugin() :
+    iVersionDescriptor(&(this->iVersion[1]),0,19),
+    iSamplerType(PROFILER_USER_MODE_SAMPLER)
+    {
+    iPeriod = 250;
+    iSamplerId = PROFILER_PWR_SAMPLER_ID;
+    iEnabled = EFalse;
+    iPowerListener = NULL;
+    LOGTEXT(_L("CPwrPlugin::CPwrPlugin() - konstruktori"));
+
+    }
+
+void CPwrPlugin::ConstructL() 
+    {
+    LOGTEXT(_L("CPwrPlugin::ConstructL() - entry"));
+    // initiate sampler attributes array
+    iSamplerAttributes = new(ELeave) CArrayFixFlat<TSamplerAttributes>(1); // only one sampler
+
+    // insert default attributes to array
+    InitiateSamplerAttributesL();
+
+    LOGTEXT(_L("CPwrPlugin::ConstructL() - exit"));
+    }
+
+CPwrPlugin::~CPwrPlugin()
+    {
+    LOGTEXT(_L("CPwrPlugin::~CPwrPlugin() - entry"));
+    if(iPowerListener)
+        {
+        if(Enabled())
+            {
+            iPowerListener->Stop();
+            }
+        delete iPowerListener;
+        iPowerListener = NULL;
+        }
+
+    if(iSamplerAttributes)
+        {
+        iSamplerAttributes->Reset();
+        delete iSamplerAttributes;
+        iSamplerAttributes = NULL;
+        }
+
+    LOGTEXT(_L("CPwrPlugin::~CPwrPlugin() - exit"));
+    }
+
+TUid CPwrPlugin::Id(TInt /*aSubId*/) const
+    {
+    LOGSTRING2( "CPwrPlugin::Id():0x%X", KSamplerPwrPluginUid.iUid );
+    return KSamplerPwrPluginUid;
+    }
+
+void CPwrPlugin::InitiateSamplerAttributesL()
+    {
+    // create TSamplerAttributes
+    TSamplerAttributes attr(KSamplerPwrPluginUid.iUid,
+            KPWRShortName(),
+            KPWRLongName(),
+            KPWRDescription(),
+            250,
+            EFalse,
+            EFalse,
+            0); 
+    this->iSamplerAttributes->AppendL(attr);
+    }
+
+void CPwrPlugin::SetEnabled(TBool aEnabled)
+    {
+    iEnabled = aEnabled;
+    }
+
+// returns setting array
+void CPwrPlugin::GetAttributesL(CArrayFixFlat<TSamplerAttributes>* aAttributes)
+    {
+    aAttributes->AppendL(iSamplerAttributes->At(0));
+    }
+
+TInt CPwrPlugin::SetAttributesL(TSamplerAttributes aAttributes)
+    {
+    TSamplerAttributes attr;
+
+    attr = iSamplerAttributes->At(0);
+    // replace the old attribute container
+    iSamplerAttributes->Delete(0);
+    iSamplerAttributes->InsertL(0, aAttributes);
+    return KErrNone;
+    }
+
+/* 
+ * Method for parsing and transforming text array settings into TSamplerAttributes (per each sub sampler),
+ * called by CSamplerController class
+ * 
+ * @param array of raw text setting lines, e.g. [gpp]\nenabled=true\nsampling_period_ms=1\n
+ */
+TInt CPwrPlugin::ConvertRawSettingsToAttributes(CDesC8ArrayFlat* aAllSettingsArray)
+    {
+    // local literals
+    _LIT8(KPWRShort, "pwr");
+
+    TInt err(KErrNone);
+    TBuf8<16> samplerSearchName;
+    samplerSearchName.Copy(KPWRShort);
+
+    // get sampler specific settings  
+    err = DoSetSamplerSettings(aAllSettingsArray, samplerSearchName, 0);
+
+    // returns KErrNone if settings found, otherwise KErrNotFound
+    return err;
+    }
+
+TInt CPwrPlugin::DoSetSamplerSettings(CDesC8ArrayFlat* aAllSettings, TDesC8& aSamplerName, TInt aIndex)
+    {
+    // 
+    TBuf8<16> samplerSearch;
+    samplerSearch.Copy(KBracketOpen);
+    samplerSearch.Append(aSamplerName);
+    samplerSearch.Append(KBracketClose);
+
+    // read a line
+    for (TInt i(0); i<aAllSettings->MdcaCount(); i++)
+        {
+        // check if this line has a setting block start, i.e. contains [xxx] in it
+        if (aAllSettings->MdcaPoint(i).CompareF(samplerSearch) == 0)
+            {
+            // right settings block found, now loop until the next block is found
+            for(TInt j(i+1);j<aAllSettings->MdcaCount();j++)
+                {
+                // check if the next settings block was found
+                if(aAllSettings->MdcaPoint(j).Left(1).CompareF(KBracketOpen) != 0)
+                    {
+                    // save found setting value directly to its owners attributes
+                    SaveSettingToAttributes(aAllSettings->MdcaPoint(j), aIndex);
+                    }
+                else
+                    {
+                    // next block found, return KErrNone
+                    return KErrNone;
+                    }
+                }
+            }
+        }
+
+    return KErrNotFound;
+    }
+
+/**
+ * Method for setting a specific descriptor (from settings file) to attribute structure
+ * 
+ * @param aSetting  
+ * @param aName  
+ */
+void CPwrPlugin::SaveSettingToAttributes(const TDesC8& aSetting, TInt aIndex)
+    {
+    // find the equal mark from the setting line
+    TInt sepPos = aSetting.Find(KSettingItemSeparator);
+    // check that '=' is found
+    if (sepPos > 0)
+        {
+        // check that the element matches
+        if (aSetting.Left(sepPos).CompareF(KEnabled) == 0)
+            {
+            TBool en;
+            CSamplerPluginInterface::Str2Bool(aSetting.Right(aSetting.Length()-sepPos-1), en);
+            if(en != iSamplerAttributes->At(aIndex).iEnabled)
+                {
+                iSamplerAttributes->At(aIndex).iEnabled = en;
+                }
+            }
+        else if (aSetting.Left(sepPos).CompareF(KSamplingPeriodMs) == 0)
+            {
+            TInt sr;
+            CSamplerPluginInterface::Str2Int(aSetting.Right(aSetting.Length()-sepPos-1), sr);
+            if(sr != iSamplerAttributes->At(aIndex).iSampleRate)
+                {
+                iSamplerAttributes->At(aIndex).iSampleRate = sr;
+                }
+            }
+        }
+    }
+
+TInt CPwrPlugin::GetSamplerType()
+    {
+    return iSamplerType;
+    }
+
+TInt CPwrPlugin::ResetAndActivateL(CProfilerSampleStream& aStream) 
+    {
+    LOGTEXT(_L("CPwrPlugin::ResetAndActivate() - entry"));
+    // check if sampler enabled
+    if(iSamplerAttributes->At(0).iEnabled)
+        {
+        // create a new listener instance for every trace, destroy it on stop
+        iPowerListener = CProfilerPowerListener::NewL(this);
+
+        iStream = &aStream;
+        TInt length = this->CreateFirstSample();
+        iVersion[0] = (TUint8)length;
+        LOGSTRING2("CPwrPlugin::ResetAndActivate() - AddSample, length %d", length);
+        TInt ret = this->AddSample(iVersion, length+1, 0);
+
+        LOGSTRING2("CPwrPlugin::ConstructL() - sampling period %d", this->iPeriod);
+
+        HBufC8* iBufRes = HBufC8::NewMaxLC(10);
+        TPtr8 iPtrRes = iBufRes->Des();
+
+        // check if sampling rate set to something reasonable, relevant only in SYNC case
+        if(iSamplerAttributes->At(0).iSampleRate != -1)
+            {
+            iPtrRes.Num(iSamplerAttributes->At(0).iSampleRate);
+            }
+        else
+            {
+            iPtrRes.Append(KNullDesC8);
+            }
+
+        // set disabled
+        SetEnabled(ETrue); 
+
+        // activate power listener
+        ret = iPowerListener->StartL(iPtrRes);
+        LOGTEXT(_L("CPwrPlugin::ResetAndActivate() - exit"));
+
+        CleanupStack::PopAndDestroy();
+        
+        if(ret != KErrNone)
+            return ret;
+        }
+    return KErrNone;
+    }
+
+TInt CPwrPlugin::CreateFirstSample() 
+    {
+    LOGTEXT(_L("CPwrPlugin::CreateFirstSample - entry"));
+    this->iVersionDescriptor.Zero();
+    this->iVersionDescriptor.Append(_L8("Bappea_PWR_V"));
+    this->iVersionDescriptor.Append(PROFILER_PWR_SAMPLER_VERSION);
+    LOGTEXT(_L("CPwrPlugin::CreateFirstSample - exit"));
+    return (TInt)(this->iVersionDescriptor.Length());
+    }
+
+TInt CPwrPlugin::StopSampling() 
+    {
+    if(iPowerListener)
+        {
+        iPowerListener->Stop();
+        delete iPowerListener;
+        iPowerListener = NULL;
+        }
+
+    // set disabled
+    SetEnabled(EFalse);
+
+    return KErrNone;
+    }
+
+
+/*
+ *
+ * class CProfilerPowerListener implementation
+ * 
+ */
+
+CProfilerPowerListener::CProfilerPowerListener(CPwrPlugin* aSampler) :
+    iPwrSamplingPeriod(0),
+    iOriginalReportingPeriod(0),
+    iNominalCapa(0),
+    iVoltage(0), 
+    iCurrent(0),
+    iPowerAPI(0)
+#ifdef PWR_SAMPLER_BACKLIGHT
+    ,iLightAPI(0),
+    iBackLightStatus(CHWRMLight::ELightStatusUnknown)
+#endif
+
+    {
+    LOGTEXT(_L("CProfilerPowerListener::CProfilerPowerListener() - konstuktori"));
+    this->iSampler = aSampler;
+    LOGTEXT(_L("CProfilerPowerListener::CProfilerPowerListener() - konstuktori exit"));
+    }
+
+CProfilerPowerListener* CProfilerPowerListener::NewL(CPwrPlugin* aSampler)
+    {
+    LOGTEXT(_L("CProfilerPowerListener::NewL() - entry"));
+    CProfilerPowerListener* self = new (ELeave) CProfilerPowerListener(aSampler);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    LOGTEXT(_L("CProfilerPowerListener::NewL() - exit"));
+    return self;
+    }
+
+void CProfilerPowerListener::ConstructL()
+    {
+    LOGTEXT(_L("CProfilerPowerListener::ConstructL() - entry"));
+    iSampleStartTime = 0;
+    LOGTEXT(_L("CProfilerPowerListener::ConstructL() - exit"));
+    }
+
+CProfilerPowerListener::~CProfilerPowerListener() 
+    {
+    LOGTEXT(_L("CProfilerPowerListener::~CProfilerPowerListener() - entry"));
+
+    if (iPowerAPI)
+        {
+        delete iPowerAPI;
+        iPowerAPI = 0;
+        }
+#ifdef PWR_SAMPLER_BACKLIGHT
+    if (iLightAPI)
+        {
+        delete iLightAPI;
+        iLightAPI = 0;
+        }
+#endif
+
+    LOGTEXT(_L("CProfilerPowerListener::~CProfilerPowerListener() - exit"));
+    }
+
+TInt CProfilerPowerListener::DisplayNotifierL(const TDesC& aLine1, const TDesC& aLine2, const TDesC& aButton1, const TDesC& aButton2)
+    {
+    RNotifier notifier;
+    TRequestStatus stat;
+
+    TInt buttonValue(0);
+
+    User::LeaveIfError(notifier.Connect());
+
+    notifier.Notify(aLine1, aLine2, aButton1, aButton2, buttonValue, stat);
+    User::WaitForRequest(stat);
+
+    notifier.Close();
+    return buttonValue;
+    }
+
+
+TInt CProfilerPowerListener::StartL(const TDesC8& aBuf)
+    {
+    LOGTEXT(_L("CProfilerPowerListener::StartL() - entry"));
+
+    // get the property value
+    TInt r = RProperty::Get(KGppPropertyCat, EGppPropertySyncSampleNumber, iSampleStartTime);
+    if(r != KErrNone)
+        {
+        LOGSTRING2("CProfilerPowerListener::StartL() - getting iSyncOffset failed, error %d", r);
+        }
+
+   // check if given sampling period is valid
+    if(aBuf.CompareF(KNullDesC8)!= 0)
+        {
+        TLex8* lex = new TLex8(aBuf);
+        lex->Val(iPwrSamplingPeriod);
+        delete lex;
+        }
+    else
+        {
+        // set default period
+        iPwrSamplingPeriod = 250;
+        }
+
+    // Check that sampling period is in allowed range
+    if (KMinSampleInterval > 0 && iPwrSamplingPeriod < KMinSampleInterval)
+        {
+        iPwrSamplingPeriod = KMinSampleInterval;
+        }
+
+    LOGSTRING2("CProfilerPowerListener::StartL() - Sampling period %d", iPwrSamplingPeriod);
+
+    // Start monitoring voltage and current
+    iPowerAPI = CHWRMPower::NewL();
+    iPowerAPI->SetPowerReportObserver(this);
+
+    // Read HWRM reporting settings from central repository
+    CRepository* centRep = CRepository::NewL(KCRUidPowerSettings);
+    TInt baseInterval(0);
+    User::LeaveIfError(centRep->Get(KPowerBaseTimeInterval, baseInterval));
+    User::LeaveIfError(centRep->Get(KPowerMaxReportingPeriod, iOriginalReportingPeriod));
+
+    LOGSTRING2("CProfilerPowerListener::StartL() - HWRM base power report interval: %d", baseInterval);
+    LOGSTRING2("CProfilerPowerListener::StartL() - Original HWRM max power reporting period: %d", iOriginalReportingPeriod);
+
+    User::LeaveIfError(centRep->Set(KPowerMaxReportingPeriod, KReportingPeriodInfinite));
+
+    // Power reporting interval reading may return too low value sometimes. Minimum value expected to be 250ms.
+    if ( baseInterval < KMinSampleInterval )
+        {
+        baseInterval = KMinSampleInterval;
+        LOGSTRING2("CProfilerPowerListener::StartL() - Power report interval too low. Changed to: %d", baseInterval);
+        }
+
+    // Power reporting period is multiplier of HWRM base period
+    TInt intervalMultiplier = iPwrSamplingPeriod / baseInterval;
+
+    if (intervalMultiplier < 1)
+        {
+        intervalMultiplier = 1;
+        }
+
+    LOGSTRING2("CProfilerPowerListener::StartL() - Reporting period multiplier: %d", intervalMultiplier);
+
+    TRequestStatus status(KRequestPending);
+    iPowerAPI->StartAveragePowerReporting(status, intervalMultiplier);
+    User::WaitForRequest(status);
+
+    if (status.Int() != KErrNone)
+        {
+        LOGTEXT(_L("CProfilerPowerListener::StartL() - Failed to initialize power reporting"));
+
+        DisplayNotifierL(KPowerTextLine1, KPowerTextLine2, KButtonOk, KNullDesC);
+
+        return status.Int();
+        }
+
+#ifdef PWR_SAMPLER_BACKLIGHT
+    // Start monitoring backlight status
+    iLightAPI = CHWRMLight::NewL(this);
+#endif
+
+    LOGTEXT(_L("CProfilerPowerListener::StartL() - exit"));
+    return KErrNone;
+    }
+
+void CProfilerPowerListener::Sample()
+    {
+    LOGTEXT(_L("CProfilerPowerListener::Sample() - entry"));
+
+    TRequestStatus status;
+    CHWRMPower::TBatteryConsumptionData consumptionData;
+
+    iPowerAPI->GetBatteryInfo(status, consumptionData);
+    User::WaitForRequest(status);
+
+    // Data is valid only if status == KErrNone 
+    if (status.Int() != KErrNone)
+        {
+        LOGSTRING2("CProfilerPowerListener::Sample() - Getting battery info failed with code: ", status.Int());
+        iNominalCapa = 0;
+        }
+    else
+        {
+        iNominalCapa = consumptionData.iNominalCapacity;
+        }
+
+    // Space for GPP sample time        
+    //TUint32 sampleTime = iSampler->iStream->iSampler->GetSampleTime();
+    TUint32 sampleTime = User::NTickCount() - iSampleStartTime;
+    LOGSTRING2("CProfilerPowerListener::Sample() - Sample time: %d", sampleTime);
+    LOGSTRING2("CProfilerPowerListener::Sample() - Nominal capacitance: %d", iNominalCapa);
+    LOGSTRING2("CProfilerPowerListener::Sample() - Voltage: %d", iVoltage);
+    LOGSTRING2("CProfilerPowerListener::Sample() - Current: %d", iCurrent);
+#ifdef PWR_SAMPLER_BACKLIGHT
+    LOGSTRING2("CProfilerPowerListener::Sample() - Backlight status: %d", (TUint8)iBackLightStatus);
+#endif
+
+    iSample[0] = iNominalCapa;
+    iSample[1] = iNominalCapa >> 8;
+    iSample[2] = iVoltage;
+    iSample[3] = iVoltage >> 8;
+    iSample[4] = iCurrent;
+    iSample[5] = iCurrent >> 8;
+    iSample[6] = iCurrent >> 16;
+    iSample[7] = iCurrent >> 24;
+#ifdef PWR_SAMPLER_BACKLIGHT
+    iSample[8] = (TUint8)iBackLightStatus;
+    iSample[9] = sampleTime;
+    iSample[10] = sampleTime >> 8;
+    iSample[11] = sampleTime >> 16;
+    iSample[12] = sampleTime >> 24;
+
+    iSampler->AddSample(iSample, 13, 0);
+#else
+    iSample[8] = sampleTime;
+    iSample[9] = sampleTime >> 8;
+    iSample[10] = sampleTime >> 16;
+    iSample[11] = sampleTime >> 24;
+
+    iSampler->AddSample(iSample, 12, 0);
+#endif
+
+    LOGTEXT(_L("CProfilerPowerListener::Sample() - exit"));
+    }
+
+TInt CProfilerPowerListener::Stop() 
+    {
+    LOGTEXT(_L("CProfilerPowerListener::Stop() - entry"));
+
+    if (iPowerAPI)
+        {
+        TRAPD(err, iPowerAPI->StopAveragePowerReportingL());
+        if(err != KErrNone)
+            {
+            LOGSTRING2("CProfilerPowerListener::Stop() - Failed to stop power reporting: %d", err);
+            }
+        else
+            {
+            LOGTEXT(_L("CProfilerPowerListener::Stop() - Stopped power monitoring"));
+            }
+        delete iPowerAPI;
+        iPowerAPI = 0;
+
+        // Restore original value to max sampling period
+        CRepository* centRep = 0;
+        TRAP(err, centRep = CRepository::NewL(KCRUidPowerSettings));
+        if (err != KErrNone)
+            {
+            LOGSTRING2("CProfilerPowerListener::Stop() - Failed to open Central Repository: %d", err);
+            }
+        else
+            {
+            err = centRep->Set(KPowerMaxReportingPeriod, iOriginalReportingPeriod);
+            if(err != KErrNone)
+                {
+                LOGSTRING2("CProfilerPowerListener::Stop() - Failed to restore max sampling period: %d", err);
+                }
+            }
+        }
+#ifdef PWR_SAMPLER_BACKLIGHT
+    if (iLightAPI)
+        {
+        delete iLightAPI;
+        iLightAPI = 0;
+        }
+#endif
+
+    LOGTEXT(_L("CProfilerPowerListener::Stop() - exit"));
+    return KErrNone;
+    }
+
+void CProfilerPowerListener::PowerMeasurement(TInt aErr, CHWRMPower::TBatteryPowerMeasurementData& aMeasurement)
+    {
+    LOGTEXT(_L("CProfilerPowerListener::PowerMeasurement - entry"));
+
+    if (aErr == KErrNone)
+        {
+        LOGSTRING3("CProfilerPowerListener::PowerMeasurement - Previous values - Voltage: %d Current: %d", iVoltage, iCurrent);
+        iVoltage = aMeasurement.iAverageVoltage;
+        iCurrent = aMeasurement.iAverageCurrent;
+        LOGSTRING3("CProfilerPowerListener::PowerMeasurement - New values - Voltage: %d Current: %d", iVoltage, iCurrent);
+
+        this->Sample();
+        }
+    else
+        {
+        LOGSTRING2("CProfilerPowerListener::PowerMeasurement - Failed with error code: %d", aErr);
+        DisplayNotifierL(KPowerTextLine1, KPowerTextErrorSampling, KButtonOk, KNullDesC);
+        }
+    LOGTEXT(_L("CProfilerPowerListener::PowerMeasurement - exit"));
+    }
+
+#ifdef PWR_SAMPLER_BACKLIGHT
+void CProfilerPowerListener::LightStatusChanged(TInt aTarget, CHWRMLight::TLightStatus aStatus)
+    {
+    LOGTEXT(_L("CProfilerPowerListener::LightStatusChanged - entry"));
+    LOGSTRING3("CProfilerPowerListener::LightStatusChanged - Target: %d Status: %d", aTarget, aStatus);
+
+    if (aTarget == CHWRMLight::EPrimaryDisplay)
+        {
+        LOGSTRING2("CProfilerPowerListener::LightStatusChanged - Previous light status: %d", iBackLightStatus);
+        iBackLightStatus = aStatus;
+        LOGSTRING2("CProfilerPowerListener::LightStatusChanged - New light status: %d", iBackLightStatus);
+
+        this->Sample();
+        }
+    LOGTEXT(_L("CProfilerPowerListener::LightStatusChanged - exit"));
+    }
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/piprofiler/plugins/PWRplugin/src/PwrPluginImplementationTable.cpp	Wed Sep 15 00:19:18 2010 +0300
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <ecom/implementationproxy.h>
+
+#include "PwrPlugin.h"
+
+
+// Provides a key value pair table, this is used to identify
+// the correct construction function for the requested interface.
+const TImplementationProxy ImplementationTable[] =
+{
+         IMPLEMENTATION_PROXY_ENTRY(0x2001E5B9,  CPwrPlugin::NewL),
+};
+
+// Function used to return an instance of the proxy table.
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+{
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+}
+
--- a/piprofiler/rom/piprofiler.iby	Wed Sep 01 12:37:10 2010 +0100
+++ b/piprofiler/rom/piprofiler.iby	Wed Sep 15 00:19:18 2010 +0300
@@ -22,11 +22,11 @@
 // PI Profiler Engine itself 
 file=ABI_DIR\BUILD_DIR\PIProfilerEngine.exe						sys\bin\PIProfilerEngine.exe
 file=ABI_DIR\BUILD_DIR\PIProfiler.exe							sys\bin\PIProfiler.exe
-data=ZSYSTEM\Install\PIProfiler_stub.sis						system\install\PIProfiler_stub.sis
 
 // sampler plugins
 // NOTE: Mandatory kernel driver included in piprofiler_ldd.iby
 ECOM_PLUGIN(PIProfilerGenerals.dll, PIProfilerGenerals.rsc)
+ECOM_PLUGIN(PIProfilerPWR.dll, PIProfilerPWR.rsc)
 
 ECOM_PLUGIN(PIProfilerBUP.dll, PIProfilerBUP.rsc)
 file=ABI_DIR\BUILD_DIR\PIProfilerTouchEventAnim.dll				sys\bin\PIProfilerTouchEventAnim.dll
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/piprofiler/rom/piprofiler_s2.iby	Wed Sep 15 00:19:18 2010 +0300
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef __PIPROFILER__
+#define __PIPROFILER__
+
+// PI Profiler Engine itself 
+file=ABI_DIR\BUILD_DIR\PIProfilerEngine.exe						sys\bin\PIProfilerEngine.exe
+file=ABI_DIR\BUILD_DIR\PIProfiler.exe							sys\bin\PIProfiler.exe
+
+// sampler plugins
+// NOTE: Mandatory kernel driver included in piprofiler_ldd.iby
+ECOM_PLUGIN(PIProfilerGenerals.dll, PIProfilerGenerals.rsc)
+
+ECOM_PLUGIN(PIProfilerBUP.dll, PIProfilerBUP.rsc)
+file=ABI_DIR\BUILD_DIR\PIProfilerTouchEventAnim.dll				sys\bin\PIProfilerTouchEventAnim.dll
+
+// Writer plugins
+ECOM_PLUGIN(piprofilerdebugwriter.dll, piprofilerdebugwriter.rsc)
+ECOM_PLUGIN(piprofilerdiskwriter.dll, piprofilerdiskwriter.rsc)
+
+#endif //__PIPROFILER__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/piprofiler/symbian_version.hrh	Wed Sep 15 00:19:18 2010 +0300
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Symbian version configuration file 
+*
+*/
+
+#ifndef __SYMBIAN_VERSION_HRH
+#define __SYMBIAN_VERSION_HRH
+
+// S60 and Symbian version number enumeration definitions
+
+#define S60_30                                              30
+#define S60_31                                              31
+#define S60_32                                              32
+#define S60_50                                              50
+#define S60_51                                              91
+#define S60_52                                              92
+#define SYMBIAN_1                                           50
+#define SYMBIAN_2                                           91
+#define SYMBIAN_3                                           92
+#define SYMBIAN_4                                           101
+
+
+/**
+ * Defines the S60 or Symbian version used by this component. This flag can be
+ * used to variate the source code based on the SDK in use. The value of the
+ * flag should be always changed to reflect the current build environment.
+ */
+#define SYMBIAN_VERSION_SUPPORT                              SYMBIAN_3
+
+
+#endif  // __SYMBIAN_VERSION_HRH