|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef PERFMON_ENGINE_H |
|
20 #define PERFMON_ENGINE_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32std.h> |
|
24 #include <e32base.h> |
|
25 #include <apgcli.h> |
|
26 #include <gdi.h> |
|
27 |
|
28 #include "perfmon.hrh" |
|
29 |
|
30 |
|
31 // setting keys (do not change uids of existing keys to maintain compatibility to older versions!) |
|
32 const TUid KPMSettingHeartBeat = { 0x00 }; |
|
33 const TUid KPMSettingMaxSamples = { 0x01 }; |
|
34 const TUid KPMSettingPriority = { 0x02 }; |
|
35 const TUid KPMSettingCPUMode = { 0x03 }; |
|
36 const TUid KPMSettingKeepBackLightOn = { 0x04 }; |
|
37 |
|
38 const TUid KPMSettingDataPopupVisbility = { 0x05 }; |
|
39 const TUid KPMSettingDataPopupLocation = { 0x06 }; |
|
40 const TUid KPMSettingDataPopupSources = { 0x07 }; |
|
41 |
|
42 const TUid KPMSettingGraphsVerticalBarPeriod = { 0x08 }; |
|
43 const TUid KPMSettingGraphsSources = { 0x09 }; |
|
44 |
|
45 const TUid KPMSettingLoggingMode = { 0x0A }; |
|
46 const TUid KPMSettingLoggingFilePath = { 0x0B }; |
|
47 const TUid KPMSettingLoggingSources = { 0x0C }; |
|
48 |
|
49 // FORWARD DECLARATIONS |
|
50 class CPerfMonValuesContainer; |
|
51 class CPerfMonGraphsContainer; |
|
52 class CPerfMonDataPopupContainer; |
|
53 class CEikonEnv; |
|
54 class CCoeControl; |
|
55 class CDictionaryFileStore; |
|
56 |
|
57 |
|
58 // CLASS DECLARATIONS |
|
59 |
|
60 |
|
61 class TPerfMonSources |
|
62 { |
|
63 public: |
|
64 TBool iSrcEnabled[ESourcesLength]; |
|
65 |
|
66 public: |
|
67 inline void SetDefaults1() |
|
68 { |
|
69 iSrcEnabled[ESourceCPU] = ETrue; |
|
70 iSrcEnabled[ESourceRAM] = ETrue; |
|
71 iSrcEnabled[ESourceC] = ETrue; |
|
72 iSrcEnabled[ESourceD] = EFalse; |
|
73 iSrcEnabled[ESourceE] = EFalse; |
|
74 iSrcEnabled[ESourceF] = EFalse; |
|
75 iSrcEnabled[ESourceG] = EFalse; |
|
76 iSrcEnabled[ESourceH] = EFalse; |
|
77 iSrcEnabled[ESourceI] = EFalse; |
|
78 } |
|
79 inline void SetDefaults2() |
|
80 { |
|
81 iSrcEnabled[ESourceCPU] = ETrue; |
|
82 iSrcEnabled[ESourceRAM] = ETrue; |
|
83 iSrcEnabled[ESourceC] = EFalse; |
|
84 iSrcEnabled[ESourceD] = EFalse; |
|
85 iSrcEnabled[ESourceE] = EFalse; |
|
86 iSrcEnabled[ESourceF] = EFalse; |
|
87 iSrcEnabled[ESourceG] = EFalse; |
|
88 iSrcEnabled[ESourceH] = EFalse; |
|
89 iSrcEnabled[ESourceI] = EFalse; |
|
90 } |
|
91 TInt EnabledSourcesCount() |
|
92 { |
|
93 TInt srcCount(0); |
|
94 |
|
95 for (TInt i=0; i<ESourcesLength; i++) |
|
96 { |
|
97 if (iSrcEnabled[i]) |
|
98 srcCount++; |
|
99 } |
|
100 |
|
101 return srcCount; |
|
102 } |
|
103 }; |
|
104 |
|
105 |
|
106 class TPerfMonSettings |
|
107 { |
|
108 public: |
|
109 TInt iHeartBeat; |
|
110 TInt iMaxSamples; |
|
111 TInt iPriority; |
|
112 TInt iCPUMode; |
|
113 TBool iKeepBacklightOn; |
|
114 |
|
115 TInt iDataPopupVisibility; |
|
116 TInt iDataPopupLocation; |
|
117 TPerfMonSources iDataPopupSources; |
|
118 |
|
119 TInt iGraphsVerticalBarPeriod; |
|
120 TPerfMonSources iGraphsSources; |
|
121 |
|
122 TInt iLoggingMode; |
|
123 TFileName iLoggingFilePath; |
|
124 TPerfMonSources iLoggingSources; |
|
125 |
|
126 TBool iLoggingEnabled; |
|
127 }; |
|
128 |
|
129 |
|
130 class TSampleData |
|
131 { |
|
132 public: |
|
133 TInt64 iFree; |
|
134 TInt64 iSize; |
|
135 TTimeIntervalMicroSeconds iTimeFromStart; |
|
136 }; |
|
137 |
|
138 typedef CArrayFixSeg<TSampleData> CSampleDataArray; |
|
139 |
|
140 |
|
141 class TSampleEntry |
|
142 { |
|
143 public: |
|
144 TBuf<16> iDescription; |
|
145 TBuf<16> iUnitTypeShort; //eg. b |
|
146 TBuf<16> iUnitTypeLong; //eg. bytes |
|
147 TInt iDriveNumber; //used only for disk drives |
|
148 TRgb iGraphColor; |
|
149 CSampleDataArray* iSampleDataArray; |
|
150 }; |
|
151 |
|
152 typedef CArrayFixSeg<TSampleEntry> CSampleEntryArray; |
|
153 |
|
154 |
|
155 |
|
156 class CPerfMonEngine : public CActive |
|
157 { |
|
158 public: |
|
159 ~CPerfMonEngine(); |
|
160 void ActivateEngineL(); |
|
161 void DeActivateEngineL(); |
|
162 void EnableLogging(TBool aEnable); |
|
163 |
|
164 private: |
|
165 void RunL(); |
|
166 void DoCancel(); |
|
167 |
|
168 protected: |
|
169 CPerfMonEngine(); |
|
170 void ConstructL(); |
|
171 void LoadSettingsL(); |
|
172 void SaveSettingsL(); |
|
173 void OpenLogFile(TBool aOpen); |
|
174 void CreateSamplesDataArrayL(); |
|
175 void UpdateSamplesDataL(); |
|
176 void AppendLatestSamplesToLogsL(); |
|
177 void ActivateCPUMonitoringL(); |
|
178 TBool OpenHandleToNullThread(); |
|
179 void DeActivateCPUMonitoring(); |
|
180 TBool CPUTimeSupported(); |
|
181 TThreadPriority SettingItemToThreadPriority(TInt aIndex); |
|
182 void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TInt& aValue); |
|
183 void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TDes& aValue); |
|
184 void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TPerfMonSources& aValue); |
|
185 void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TInt& aValue); |
|
186 void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TDes& aValue); |
|
187 void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TPerfMonSources& aValue); |
|
188 |
|
189 protected: |
|
190 virtual void SendDrawEventToContainersL() = 0; |
|
191 virtual void HandleSettingsChangeL(); |
|
192 |
|
193 public: |
|
194 inline TPerfMonSettings& Settings() { return iSettings; } |
|
195 inline CEikonEnv* EikonEnv() { return iEnv; } |
|
196 inline RApaLsSession& LsSession() { return iLs; } |
|
197 |
|
198 inline CSampleEntryArray* SampleEntryArray() { return iSampleEntryArray; } |
|
199 |
|
200 protected: |
|
201 RTimer iTimer; |
|
202 CEikonEnv* iEnv; |
|
203 TPerfMonSettings iSettings; |
|
204 RApaLsSession iLs; |
|
205 CSampleEntryArray* iSampleEntryArray; |
|
206 TTime iStartTime; |
|
207 |
|
208 TInt iCurrentCPUMode; |
|
209 |
|
210 RThread iNullThread; |
|
211 RThread iCPULoadThread; |
|
212 TBool iCPULoadCalibrating; |
|
213 TInt iCPULoadCalibrationCounter; |
|
214 TInt64 iCPULoadMaxValue; |
|
215 TInt64 iCPULoadPreviousValue; |
|
216 TInt64 iCPULoadCounter; |
|
217 TTime iPreviousTime; |
|
218 |
|
219 TBool iLogFileInitialized; |
|
220 RFile iLogFile; |
|
221 }; |
|
222 |
|
223 |
|
224 #endif |