perfmon/engine/src/perfmon_engine.cpp
author hgs
Thu, 17 Jun 2010 15:34:52 +0300
changeset 30 d8e625c87f33
parent 17 4f2773374eff
permissions -rw-r--r--
201023_1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
 * All rights reserved.
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
 *
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
 * Initial Contributors:
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
 *
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
 * Contributors:
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
 *
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
 * Description:  
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
 *
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
 */
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
// INCLUDE FILES
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
#include "perfmon_engine.h"
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
#include <coeutils.h>
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <bautils.h>
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <eikenv.h>
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include <e32hal.h>
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <u32std.h>
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
#include <s32file.h>
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#include <akntitle.h> 
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include <eikspane.h>
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include <aknnotewrappers.h>  
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
_LIT(KDefaultLogFilePath, "c:\\data\\PerfMon.log");
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
const TInt KCalibrationLength = 2;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
const TInt KMinimumSamplesLength = 16;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
const TInt KCPUTimeMultiplier = 1000000; // used to avoid TReal conversions
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
const TInt KSettingsDrive = EDriveC;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
_LIT(KSettingsFileName, "perfmon_settings.ini");
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
// --------------------------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
TInt CPULoadCount(TAny* aInt)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
    // increase the counter
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
    (*(TUint*) aInt)++;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
    return 1;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
TInt CPULoadNOPThread(TAny* aParam)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
    CTrapCleanup* pC = CTrapCleanup::New();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
    CActiveScheduler* pS = new CActiveScheduler;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
    CActiveScheduler::Install(pS);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    52
    CIdle* idle = CIdle::NewL(CActive::EPriorityLow);
15
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
    TCallBack cb(CPULoadCount, aParam);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
    idle->Start(cb);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
    pS->Start();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
    delete idle;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
    delete pS;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
    delete pC;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
    return 0;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
// ===================================== MEMBER FUNCTIONS =====================================
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
CPerfMonEngine::CPerfMonEngine() :
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
    CActive(EPriorityUserInput)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
// --------------------------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
void CPerfMonEngine::ConstructL()
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
    iCurrentCPUMode = ECPUModeNotSet;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
    iLogFileInitialized = EFalse;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
    iEnv = CEikonEnv::Static();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
    User::LeaveIfError(iLs.Connect());
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
    User::LeaveIfError(iTimer.CreateLocal());
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
    CActiveScheduler::Add(this);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
// --------------------------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
void CPerfMonEngine::ActivateEngineL()
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
    // load settings
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
    TRAP_IGNORE(LoadSettingsL());
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
    // create data storages for the samples
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
    CreateSamplesDataArrayL();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
    // set default modes
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
    HandleSettingsChangeL();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
    // start sampling data immediately (jump to RunL)    
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
    iTimer.After(iStatus, 100);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
    SetActive();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
// --------------------------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
void CPerfMonEngine::DeActivateEngineL()
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
    Cancel();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
    DeActivateCPUMonitoring();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
    // close log file
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
    OpenLogFile(EFalse);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
// --------------------------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
CPerfMonEngine::~CPerfMonEngine()
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
    iTimer.Close();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
    // clear data storages
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
    if (iSampleEntryArray)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
        {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
        for (TInt i = 0; i < iSampleEntryArray->Count(); i++)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
            delete iSampleEntryArray->At(i).iSampleDataArray;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
        delete iSampleEntryArray;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
        }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
    iLs.Close();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
// --------------------------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
void CPerfMonEngine::DoCancel()
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
    iTimer.Cancel();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
// --------------------------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
void CPerfMonEngine::RunL()
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
    // calculate new values 
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
    UpdateSamplesDataL();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
    // log changes
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
    AppendLatestSamplesToLogsL();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
    // redraw views
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
    SendDrawEventToContainersL();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
    // continue
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
    iTimer.After(iStatus, iSettings.iHeartBeat * 1000); // convert from milliseconds to microseconds
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
    SetActive();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
// --------------------------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
void CPerfMonEngine::HandleSettingsChangeL()
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
    // set priority of the thread
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
    RThread().SetPriority(SettingItemToThreadPriority(iSettings.iPriority));
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
    // init cpu monitor if setting has been changed
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
    if (iCurrentCPUMode != iSettings.iCPUMode)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
        {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
        DeActivateCPUMonitoring();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
        ActivateCPUMonitoringL();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
        }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
    // close log file
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
    OpenLogFile(EFalse);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
    // enable log file
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
    if (iSettings.iLoggingEnabled && (iSettings.iLoggingMode
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
            == ELoggingModeLogFile || iSettings.iLoggingMode
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
            == ELoggingModeRDebugLogFile))
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
        OpenLogFile(ETrue);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
// --------------------------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
void CPerfMonEngine::EnableLogging(TBool aEnable)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
    if (aEnable)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
        {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
        if (iSettings.iLoggingMode == ELoggingModeLogFile
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
                || iSettings.iLoggingMode == ELoggingModeRDebugLogFile)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
            OpenLogFile(ETrue);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
        iSettings.iLoggingEnabled = ETrue;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
        }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
    else // disable
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   198
        {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
        iSettings.iLoggingEnabled = EFalse;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
        OpenLogFile(EFalse);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
        }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
// --------------------------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
void CPerfMonEngine::OpenLogFile(TBool aOpen)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
    // open log file for writing
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
    if (aOpen)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
        {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
        if (!iLogFileInitialized)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
            TInt err(KErrNone);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
            // open the log file for writing
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
            if (iLogFile.Open(iEnv->FsSession(), iSettings.iLoggingFilePath,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
                    EFileWrite) != KErrNone)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
                {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
                iEnv->FsSession().MkDirAll(iSettings.iLoggingFilePath);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
                err = iLogFile.Replace(iEnv->FsSession(),
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
                        iSettings.iLoggingFilePath, EFileWrite);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   222
                }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   223
            else
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
                {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
                // file opens correctly, seek to the end
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
                TInt fileSize = 0;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
                iLogFile.Size(fileSize);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
                err = iLogFile.Seek(ESeekCurrent, fileSize);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
                }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
            if (err == KErrNone)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
                {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
                iLogFileInitialized = ETrue;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
                }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
            else
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
                {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
                // show error
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
                CAknErrorNote* note = new (ELeave) CAknErrorNote();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
                note->ExecuteLD(_L("Unable to create log file, check settings"));
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
                }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
        }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   244
    // close handle to log file
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   245
    else
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
        {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
        if (iLogFileInitialized)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   248
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
            iLogFile.Flush();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   250
            iLogFile.Close();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
            iLogFileInitialized = EFalse;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
        }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
// --------------------------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   259
void CPerfMonEngine::ActivateCPUMonitoringL()
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   261
    // reset counter variables
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
    iCPULoadCalibrating = ETrue;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
    iCPULoadCalibrationCounter = 0;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
    iCPULoadMaxValue = 999999999;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
    iCPULoadPreviousValue = 1;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
    iCPULoadCounter = 0;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   267
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   268
    // use null thread is cpu time is supported and the setting is on
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
    if (CPUTimeSupported() && iSettings.iCPUMode == ECPUModeCPUTime)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   270
        {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   271
        // try to open handle to null thread
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
        if (OpenHandleToNullThread())
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
            // handle is open, get initial value
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
            TTimeIntervalMicroSeconds time;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
            iNullThread.GetCpuTime(time);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
            iCPULoadPreviousValue = time.Int64();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
            iPreviousTime.HomeTime();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   279
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   280
            iCurrentCPUMode = ECPUModeCPUTime;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   281
            return; // cpu time is succesfully in use           
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   282
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   283
        }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   284
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
    // otherwise use normal sampling with nops    
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
    iCurrentCPUMode = ECPUModeNotSet;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   287
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
    // show a warning if cpu time cannot be taken in use
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
    if (iSettings.iCPUMode == ECPUModeCPUTime)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
        {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
        CAknInformationNote* note = new (ELeave) CAknInformationNote();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
        note->ExecuteLD(
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
                _L("CPU Time not supported in this system, using NOPs sampling"));
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   294
        }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
    // create a thread for CPU load monitoring
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   297
    User::LeaveIfError(iCPULoadThread.Create(_L("PerfMonCPULoad"),
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
            CPULoadNOPThread, 0x1000, 0x1000, 0x100000, &iCPULoadCounter));
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   299
    iCPULoadThread.SetPriority(EPriorityAbsoluteVeryLow);
15
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
    iCPULoadThread.Resume();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
    iCurrentCPUMode = ECPUModeNOPs; // NOPs taken succesfully in use
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
// --------------------------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
TBool CPerfMonEngine::OpenHandleToNullThread()
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
    // find the kernel process and then the null thread
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
    TFindProcess fp(_L("ekern.exe*"));
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
    TFullName kernelName;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
    if (fp.Next(kernelName) == KErrNone)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
        {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
        // process found, append null thread identifier
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
        kernelName.Append(_L("::Null"));
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   317
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318
        // find the thread
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   319
        TFindThread ft(kernelName);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   321
        TFullName threadName;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
        if (ft.Next(threadName) == KErrNone)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
            // open instance to the thread
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
            if (iNullThread.Open(threadName) != KErrNone)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
                return EFalse;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
        }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   330
    // process not found
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
    else
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
        return EFalse;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   334
    // success!
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
    return ETrue;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
// --------------------------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
void CPerfMonEngine::DeActivateCPUMonitoring()
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   341
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
    if (iCurrentCPUMode == ECPUModeCPUTime)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
        {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
        iNullThread.Close();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   345
        }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   346
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   347
    else if (iCurrentCPUMode == ECPUModeNOPs)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   348
        {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
        // kill the cpu load thread
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   350
        iCPULoadThread.Kill(0);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   351
        iCPULoadThread.Close();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   352
        }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   353
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   354
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
// --------------------------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   356
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   357
TBool CPerfMonEngine::CPUTimeSupported()
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   358
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
    TTimeIntervalMicroSeconds time;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   360
    TInt err = RThread().GetCpuTime(time);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   361
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   362
    if (err == KErrNone && time.Int64() > 0)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
        return ETrue;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   364
    else
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
        return EFalse;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   366
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   367
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
// --------------------------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   369
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
TThreadPriority CPerfMonEngine::SettingItemToThreadPriority(TInt aIndex)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   371
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   372
    TThreadPriority threadPriority = EPriorityNull;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   373
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
    switch (aIndex)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   375
        {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   376
        case EThreadPriorityTypeMuchLess:
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   378
            threadPriority = EPriorityMuchLess;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   379
            break;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
        case EThreadPriorityTypeLess:
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   382
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
            threadPriority = EPriorityLess;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
            break;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
        case EThreadPriorityTypeNormal:
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   388
            threadPriority = EPriorityNormal;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   389
            break;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   390
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
        case EThreadPriorityTypeMore:
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   392
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   393
            threadPriority = EPriorityMore;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   394
            break;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   396
        case EThreadPriorityTypeMuchMore:
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   398
            threadPriority = EPriorityMuchMore;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
            break;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
        case EThreadPriorityTypeRealTime:
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
            threadPriority = EPriorityRealTime;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
            break;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   406
        case EThreadPriorityTypeAbsoluteVeryLow:
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
            threadPriority = EPriorityAbsoluteVeryLow;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
            break;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
        case EThreadPriorityTypeAbsoluteLow:
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
            threadPriority = EPriorityAbsoluteLow;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
            break;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   415
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
        case EThreadPriorityTypeAbsoluteBackground:
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
            threadPriority = EPriorityAbsoluteBackground;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
            break;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
        case EThreadPriorityTypeAbsoluteForeground:
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
            threadPriority = EPriorityAbsoluteForeground;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
            break;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   425
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   426
        case EThreadPriorityTypeAbsoluteHigh:
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
            threadPriority = EPriorityAbsoluteHigh;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
            break;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
        default:
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434
            User::Panic(_L("Wrong tp index"), 276);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
            break;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   436
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   437
        }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   439
    return threadPriority;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
// --------------------------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
void CPerfMonEngine::CreateSamplesDataArrayL()
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
    TInt
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
            maxSamples =
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
                    iSettings.iMaxSamples >= KMinimumSamplesLength ? iSettings.iMaxSamples
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
                            : KMinimumSamplesLength;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   451
    // create the data structure to store all samples
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   452
    iSampleEntryArray = new (ELeave) CSampleEntryArray(16);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   453
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
    // add all source entries
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
    for (TInt i = 0; i < ESourcesLength; i++)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
        {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
        TSampleEntry newSampleEntry;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   458
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
        if (i == ESourceCPU)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   460
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   461
            newSampleEntry.iDescription.Copy(_L("CPU"));
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   462
            newSampleEntry.iUnitTypeShort.Copy(KNullDesC);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   463
            newSampleEntry.iUnitTypeLong.Copy(KNullDesC);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   464
            newSampleEntry.iDriveNumber = -1;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   465
            newSampleEntry.iGraphColor = KRgbYellow;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   466
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   467
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   468
        else if (i == ESourceRAM)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   469
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   470
            newSampleEntry.iDescription.Copy(_L("RAM"));
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   471
            newSampleEntry.iUnitTypeShort.Copy(_L("b"));
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   472
            newSampleEntry.iUnitTypeLong.Copy(_L("bytes"));
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   473
            newSampleEntry.iDriveNumber = -1;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   474
            newSampleEntry.iGraphColor = KRgbGreen;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   475
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   476
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   477
        else //drives
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   478
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   479
            TChar driveLetter = 'C' + i - ESourceC; // C is the first drive
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   480
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   481
            newSampleEntry.iDescription.Append(driveLetter);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   482
            newSampleEntry.iDescription.Append(_L(":"));
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   483
            newSampleEntry.iUnitTypeShort.Copy(_L("b"));
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   484
            newSampleEntry.iUnitTypeLong.Copy(_L("bytes"));
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   485
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   486
            iEnv->FsSession().CharToDrive(driveLetter,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   487
                    newSampleEntry.iDriveNumber);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   488
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   489
            newSampleEntry.iGraphColor = KRgbCyan;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   490
            newSampleEntry.iGraphColor.SetGreen(255 - (i - ESourceC) * 30);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   491
            newSampleEntry.iGraphColor.SetRed(i * 30);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   492
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   493
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   494
        newSampleEntry.iSampleDataArray = new (ELeave) CSampleDataArray(
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   495
                maxSamples);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   496
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   497
        iSampleEntryArray->AppendL(newSampleEntry);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   498
        }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   499
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   500
    // save current time as start time
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   501
    iStartTime.HomeTime();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   502
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   503
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   504
// --------------------------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   505
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   506
void CPerfMonEngine::UpdateSamplesDataL()
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   507
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   508
    // reset inactivity timers
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   509
    if (iSettings.iKeepBacklightOn)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   510
        User::ResetInactivityTime();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   511
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   512
    // get current time
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   513
    TTime currentTime;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   514
    currentTime.HomeTime();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   515
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
    // calculate time difference
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
    TTimeIntervalMicroSeconds timeDeltaFromPreviousSample =
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
            currentTime.MicroSecondsFrom(iPreviousTime);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   519
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   520
    // remember current time as previous
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   521
    iPreviousTime = currentTime;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   522
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   523
    // get CPU
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
    TInt64 cpuLoadDelta(0);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
    TInt64 cpuLoadFree(0);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   526
    TInt64 cpuLoadSize(0);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   527
    TInt64 currentCPUValue(0);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   529
    if (iCurrentCPUMode == ECPUModeCPUTime || iCurrentCPUMode == ECPUModeNOPs)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   530
        {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   531
        if (iCurrentCPUMode == ECPUModeCPUTime)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   532
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   533
            TTimeIntervalMicroSeconds time;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   534
            iNullThread.GetCpuTime(time);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   535
            currentCPUValue = time.Int64();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   536
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   537
        else if (iCurrentCPUMode == ECPUModeNOPs)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   538
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   539
            currentCPUValue = iCPULoadCounter;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   540
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   541
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   542
        // get delta and store the previous value
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   543
        cpuLoadDelta = currentCPUValue - iCPULoadPreviousValue;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   544
        iCPULoadPreviousValue = currentCPUValue;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   545
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   546
        // velocity = distance / time
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   547
        cpuLoadFree = cpuLoadDelta * KCPUTimeMultiplier
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   548
                / timeDeltaFromPreviousSample.Int64();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   549
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   550
        // detect maximum value
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   551
        if (cpuLoadFree > iCPULoadMaxValue)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   552
            iCPULoadMaxValue = cpuLoadFree;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   553
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   554
        // check calibration status      
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   555
        if (iCPULoadCalibrating)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   556
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   557
            iCPULoadCalibrationCounter++;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   558
            cpuLoadSize = cpuLoadFree;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   559
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   560
            // check if need to calibrate anymore
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   561
            if (iCPULoadCalibrationCounter > KCalibrationLength)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   562
                {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   563
                iCPULoadCalibrating = EFalse;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   564
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   565
                // from the samples, get the minimum value, and let it be the max value 
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   566
                for (TInt i = 0; i
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   567
                        < iSampleEntryArray->At(0).iSampleDataArray->Count(); i++)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   568
                    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   569
                    TInt64 newCPULoadMaxValue = iCPULoadMaxValue;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   570
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   571
                    if (iSampleEntryArray->At(0).iSampleDataArray->At(i).iFree
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   572
                            < newCPULoadMaxValue)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   573
                        {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   574
                        newCPULoadMaxValue
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   575
                                = iSampleEntryArray->At(0).iSampleDataArray->At(
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   576
                                        i).iFree;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   577
                        }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   578
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   579
                    iCPULoadMaxValue = newCPULoadMaxValue;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   580
                    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   581
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   582
                // adjust priority of the poller thread
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   583
                if (iCurrentCPUMode == ECPUModeNOPs)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   584
                    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   585
                    iCPULoadThread.SetPriority(EPriorityAbsoluteVeryLow);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   586
                    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   587
                }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   588
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   589
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   590
        else
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   591
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   592
            cpuLoadSize = iCPULoadMaxValue;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   593
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   594
        }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   595
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   596
    // save cpu sample data    
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   597
    TSampleData cpuSample;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   598
    cpuSample.iFree = cpuLoadFree;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   599
    cpuSample.iSize = cpuLoadSize;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   600
    cpuSample.iTimeFromStart = currentTime.MicroSecondsFrom(iStartTime);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   601
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   602
    iSampleEntryArray->At(0).iSampleDataArray->InsertL(0, cpuSample);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   603
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   604
    // get ram memory
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   605
    TMemoryInfoV1Buf ramMemory;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   606
    UserHal::MemoryInfo(ramMemory);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   607
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   608
    TSampleData memorySample;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   609
    memorySample.iFree = ramMemory().iFreeRamInBytes;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   610
    memorySample.iSize = ramMemory().iMaxFreeRamInBytes;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   611
    memorySample.iTimeFromStart = currentTime.MicroSecondsFrom(iStartTime);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   612
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   613
    iSampleEntryArray->At(1).iSampleDataArray->InsertL(0, memorySample);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   614
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   615
    // all drives
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   616
    for (TInt i = 2; i < iSampleEntryArray->Count(); i++)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   617
        {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   618
        TSampleData driveSample;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   619
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   620
        // get volume info from RFs
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   621
        TVolumeInfo volumeInfo;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   622
        if (iEnv->FsSession().Volume(volumeInfo,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   623
                iSampleEntryArray->At(i).iDriveNumber) == KErrNone)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   624
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   625
            driveSample.iFree = volumeInfo.iFree;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   626
            driveSample.iSize = volumeInfo.iSize;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   627
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   628
        else
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   629
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   630
            driveSample.iFree = 0;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   631
            driveSample.iSize = 0;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   632
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   633
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   634
        driveSample.iTimeFromStart = currentTime.MicroSecondsFrom(iStartTime);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   635
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   636
        iSampleEntryArray->At(i).iSampleDataArray->InsertL(0, driveSample);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   637
        }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   638
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   639
    // compress sample data arrays to save memory
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   640
    TInt curLength(iSampleEntryArray->At(0).iSampleDataArray->Count());
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   641
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   642
    TInt
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   643
            maxSamples =
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   644
                    iSettings.iMaxSamples >= KMinimumSamplesLength ? iSettings.iMaxSamples
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   645
                            : KMinimumSamplesLength;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   646
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   647
    if (curLength > maxSamples && curLength % 5 == 0)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   648
        {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   649
        for (TInt i = 0; i < iSampleEntryArray->Count(); i++)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   650
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   651
            iSampleEntryArray->At(i).iSampleDataArray->ResizeL(maxSamples); // looses old samples
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   652
            iSampleEntryArray->At(i).iSampleDataArray->Compress();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   653
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   654
        }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   655
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   656
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   657
// --------------------------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   658
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   659
void CPerfMonEngine::AppendLatestSamplesToLogsL()
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   660
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   661
    if (iSettings.iLoggingEnabled && SampleEntryArray())
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   662
        {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   663
        // loop all sources
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   664
        for (TInt i = 0; i < SampleEntryArray()->Count(); i++)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   665
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   666
            // check if this setting has been enabled and it has some data
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   667
            if (iSettings.iLoggingSources.iSrcEnabled[i]
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   668
                    && SampleEntryArray()->At(i).iSampleDataArray->Count() > 0)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   669
                {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   670
                // get current sample
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   671
                TSampleData& currentSample =
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   672
                        SampleEntryArray()->At(i).iSampleDataArray->At(0);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   673
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   674
                TBuf<128> buf;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   675
                buf.Append(_L("PERFMON;"));
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   676
                buf.Append(SampleEntryArray()->At(i).iDescription);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   677
                buf.Append(_L(";"));
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   678
                buf.AppendNum(currentSample.iTimeFromStart.Int64());
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   679
                buf.Append(_L(";"));
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   680
                buf.AppendNum(currentSample.iFree);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   681
                buf.Append(_L(";"));
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   682
                buf.AppendNum(currentSample.iSize);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   683
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   684
                // print to RDebug
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   685
                if (iSettings.iLoggingMode == ELoggingModeRDebug
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   686
                        || iSettings.iLoggingMode == ELoggingModeRDebugLogFile)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   687
                    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   688
                    RDebug::Print(buf);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   689
                    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   690
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   691
                // print to log file
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   692
                if (iSettings.iLoggingMode == ELoggingModeLogFile
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   693
                        || iSettings.iLoggingMode == ELoggingModeRDebugLogFile)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   694
                    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   695
                    buf.Append(_L("\r\n"));
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   696
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   697
                    TBuf8<128> buf8;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   698
                    buf8.Copy(buf);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   699
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   700
                    iLogFile.Write(buf8);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   701
                    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   702
                }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   703
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   704
        }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   705
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   706
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   707
void CPerfMonEngine::LoadSettingsL()
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   708
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   709
    // set defaults
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   710
    iSettings.iHeartBeat = 600;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   711
    iSettings.iMaxSamples = 64;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   712
    iSettings.iPriority = EThreadPriorityTypeNormal;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   713
    iSettings.iCPUMode = ECPUModeCPUTime;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   714
    iSettings.iKeepBacklightOn = ETrue;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   715
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   716
    iSettings.iDataPopupVisibility = EDataPopupVisbilityAlwaysOn;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   717
    // TODO: remove the next line once data popup is working
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   718
    iSettings.iDataPopupVisibility = EDataPopupVisbilityAlwaysAlwaysOff;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   719
    iSettings.iDataPopupLocation = EDataPopupLocationTopRight;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   720
    iSettings.iDataPopupSources.SetDefaults1();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   721
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   722
    iSettings.iGraphsVerticalBarPeriod = 5;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   723
    iSettings.iGraphsSources.SetDefaults2();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   724
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   725
    iSettings.iLoggingMode = ELoggingModeRDebug;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   726
    iSettings.iLoggingFilePath.Copy(KDefaultLogFilePath);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   727
    iSettings.iLoggingSources.SetDefaults2();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   728
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   729
    iSettings.iLoggingEnabled = EFalse;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   730
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   731
    // make sure that the private path of this app in c-drive exists
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   732
    iEnv->FsSession().CreatePrivatePath(KSettingsDrive); // c:\\private\\20011385\\
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   733
    
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   734
    // handle settings always in the private directory 
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   735
    if (iEnv->FsSession().SetSessionToPrivate(KSettingsDrive) == KErrNone)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   736
        {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   737
        const TUid KUidPerfMon =
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   738
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   739
            0x20011385
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   740
            };
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   741
        // open or create a dictionary file store
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   742
        CDictionaryFileStore* settingsStore = CDictionaryFileStore::OpenLC(
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   743
                iEnv->FsSession(), KSettingsFileName, KUidPerfMon);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   744
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   745
        LoadDFSValueL(settingsStore, KPMSettingHeartBeat, iSettings.iHeartBeat);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   746
        LoadDFSValueL(settingsStore, KPMSettingMaxSamples,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   747
                iSettings.iMaxSamples);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   748
        LoadDFSValueL(settingsStore, KPMSettingPriority, iSettings.iPriority);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   749
        
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   750
        LoadDFSValueL(settingsStore, KPMSettingCPUMode, iSettings.iCPUMode);
15
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   751
        
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   752
        LoadDFSValueL(settingsStore, KPMSettingKeepBackLightOn,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   753
                iSettings.iKeepBacklightOn);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   754
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   755
        LoadDFSValueL(settingsStore, KPMSettingDataPopupVisbility,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   756
                iSettings.iDataPopupVisibility);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   757
        LoadDFSValueL(settingsStore, KPMSettingDataPopupLocation,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   758
                iSettings.iDataPopupLocation);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   759
        LoadDFSValueL(settingsStore, KPMSettingDataPopupSources,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   760
                iSettings.iDataPopupSources);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   761
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   762
        LoadDFSValueL(settingsStore, KPMSettingGraphsVerticalBarPeriod,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   763
                iSettings.iGraphsVerticalBarPeriod);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   764
        LoadDFSValueL(settingsStore, KPMSettingGraphsSources,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   765
                iSettings.iGraphsSources);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   766
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   767
        LoadDFSValueL(settingsStore, KPMSettingLoggingMode,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   768
                iSettings.iLoggingMode);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   769
        LoadDFSValueL(settingsStore, KPMSettingLoggingFilePath,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   770
                iSettings.iLoggingFilePath);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   771
        LoadDFSValueL(settingsStore, KPMSettingLoggingSources,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   772
                iSettings.iLoggingSources);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   773
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   774
        CleanupStack::PopAndDestroy(); // settingsStore         
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   775
        }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   776
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   777
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   778
// --------------------------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   779
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   780
void CPerfMonEngine::SaveSettingsL()
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   781
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   782
    // handle settings always in c:\\private\\20011385\\
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   783
    if (iEnv->FsSession().SetSessionToPrivate( KSettingsDrive ) == KErrNone)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   784
        {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   785
        // delete existing store to make sure that it is clean and not eg corrupted
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   786
        if (BaflUtils::FileExists(iEnv->FsSession(), KSettingsFileName))
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   787
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   788
            iEnv->FsSession().Delete(KSettingsFileName);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   789
            }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   790
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   791
        const TUid KUidPerfMon =
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   792
            {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   793
            0x20011385
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   794
            };
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   795
        // create a dictionary file store
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   796
        CDictionaryFileStore* settingsStore = CDictionaryFileStore::OpenLC(
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   797
                iEnv->FsSession(), KSettingsFileName, KUidPerfMon);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   798
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   799
        SaveDFSValueL(settingsStore, KPMSettingHeartBeat, iSettings.iHeartBeat);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   800
        SaveDFSValueL(settingsStore, KPMSettingMaxSamples,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   801
                iSettings.iMaxSamples);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   802
        SaveDFSValueL(settingsStore, KPMSettingPriority, iSettings.iPriority);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   803
        SaveDFSValueL(settingsStore, KPMSettingCPUMode, iSettings.iCPUMode);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   804
        SaveDFSValueL(settingsStore, KPMSettingKeepBackLightOn,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   805
                iSettings.iKeepBacklightOn);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   806
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   807
        SaveDFSValueL(settingsStore, KPMSettingDataPopupVisbility,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   808
                iSettings.iDataPopupVisibility);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   809
        SaveDFSValueL(settingsStore, KPMSettingDataPopupLocation,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   810
                iSettings.iDataPopupLocation);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   811
        SaveDFSValueL(settingsStore, KPMSettingDataPopupSources,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   812
                iSettings.iDataPopupSources);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   813
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   814
        SaveDFSValueL(settingsStore, KPMSettingGraphsVerticalBarPeriod,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   815
                iSettings.iGraphsVerticalBarPeriod);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   816
        SaveDFSValueL(settingsStore, KPMSettingGraphsSources,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   817
                iSettings.iGraphsSources);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   818
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   819
        SaveDFSValueL(settingsStore, KPMSettingLoggingMode,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   820
                iSettings.iLoggingMode);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   821
        SaveDFSValueL(settingsStore, KPMSettingLoggingFilePath,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   822
                iSettings.iLoggingFilePath);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   823
        SaveDFSValueL(settingsStore, KPMSettingLoggingSources,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   824
                iSettings.iLoggingSources);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   825
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   826
        settingsStore->CommitL();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   827
        CleanupStack::PopAndDestroy(); // settingsStore             
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   828
        }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   829
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   830
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   831
// ---------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   832
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   833
void CPerfMonEngine::LoadDFSValueL(CDictionaryFileStore* aDicFS,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   834
        const TUid& aUid, TInt& aValue)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   835
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   836
    if (aDicFS->IsPresentL(aUid))
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   837
        {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   838
        RDictionaryReadStream in;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   839
        in.OpenLC(*aDicFS, aUid);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   840
        aValue = in.ReadInt16L();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   841
        CleanupStack::PopAndDestroy(); // in        
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   842
        }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   843
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   844
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   845
// ---------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   846
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   847
void CPerfMonEngine::LoadDFSValueL(CDictionaryFileStore* aDicFS,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   848
        const TUid& aUid, TDes& aValue)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   849
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   850
    if (aDicFS->IsPresentL(aUid))
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   851
        {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   852
        RDictionaryReadStream in;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   853
        in.OpenLC(*aDicFS, aUid);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   854
        TInt bufLength = in.ReadInt16L(); // get length of descriptor
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   855
        in.ReadL(aValue, bufLength); // get the descriptor itself
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   856
        CleanupStack::PopAndDestroy(); // in
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   857
        }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   858
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   859
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   860
// ---------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   861
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   862
void CPerfMonEngine::LoadDFSValueL(CDictionaryFileStore* aDicFS,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   863
        const TUid& aUid, TPerfMonSources& aValue)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   864
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   865
    if (aDicFS->IsPresentL(aUid))
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   866
        {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   867
        RDictionaryReadStream in;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   868
        in.OpenLC(*aDicFS, aUid);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   869
        TInt bufLength = in.ReadInt16L(); // get length of the array
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   870
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   871
        if (bufLength < 0 || bufLength > ESourcesLength) // check for validaty
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   872
            User::Leave(KErrNotSupported);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   873
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   874
        for (TInt i = 0; i < bufLength; i++) // get all items
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   875
            aValue.iSrcEnabled[i] = in.ReadInt16L();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   876
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   877
        CleanupStack::PopAndDestroy(); // in
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   878
        }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   879
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   880
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   881
// ---------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   882
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   883
void CPerfMonEngine::SaveDFSValueL(CDictionaryFileStore* aDicFS,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   884
        const TUid& aUid, const TInt& aValue)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   885
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   886
    RDictionaryWriteStream out;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   887
    out.AssignLC(*aDicFS, aUid);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   888
    out.WriteInt16L(aValue);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   889
    out.CommitL();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   890
    CleanupStack::PopAndDestroy(); // out
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   891
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   892
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   893
// ---------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   894
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   895
void CPerfMonEngine::SaveDFSValueL(CDictionaryFileStore* aDicFS,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   896
        const TUid& aUid, const TDes& aValue)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   897
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   898
    RDictionaryWriteStream out;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   899
    out.AssignLC(*aDicFS, aUid);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   900
    out.WriteInt16L(aValue.Length()); // write length of the descriptor
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   901
    out.WriteL(aValue, aValue.Length()); // write the descriptor itself
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   902
    out.CommitL();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   903
    CleanupStack::PopAndDestroy(); // out
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   904
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   905
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   906
// ---------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   907
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   908
void CPerfMonEngine::SaveDFSValueL(CDictionaryFileStore* aDicFS,
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   909
        const TUid& aUid, const TPerfMonSources& aValue)
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   910
    {
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   911
    RDictionaryWriteStream out;
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   912
    out.AssignLC(*aDicFS, aUid);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   913
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   914
    out.WriteInt16L(ESourcesLength); // write length of the array
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   915
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   916
    for (TInt i = 0; i < ESourcesLength; i++) // write all items
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   917
        out.WriteInt16L(aValue.iSrcEnabled[i]);
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   918
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   919
    out.CommitL();
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   920
    CleanupStack::PopAndDestroy(); // out
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   921
    }
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   922
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   923
// ---------------------------------------------------------------------------
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   924
e11368ed4880 Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   925
// End of File