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_MODEL_H |
|
20 #define PERFMON_MODEL_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 |
|
50 |
|
51 // FORWARD DECLARATIONS |
|
52 class CPerfMonValuesContainer; |
|
53 class CPerfMonGraphsContainer; |
|
54 class CPerfMonDataPopupContainer; |
|
55 class CEikonEnv; |
|
56 class CCoeControl; |
|
57 class CDictionaryFileStore; |
|
58 |
|
59 |
|
60 // CLASS DECLARATIONS |
|
61 |
|
62 |
|
63 class TPerfMonSources |
|
64 { |
|
65 public: |
|
66 TBool iSrcEnabled[ESourcesLength]; |
|
67 |
|
68 public: |
|
69 inline void SetDefaults1() |
|
70 { |
|
71 iSrcEnabled[ESourceCPU] = ETrue; |
|
72 iSrcEnabled[ESourceRAM] = ETrue; |
|
73 iSrcEnabled[ESourceC] = ETrue; |
|
74 iSrcEnabled[ESourceD] = EFalse; |
|
75 iSrcEnabled[ESourceE] = EFalse; |
|
76 iSrcEnabled[ESourceF] = EFalse; |
|
77 iSrcEnabled[ESourceG] = EFalse; |
|
78 iSrcEnabled[ESourceH] = EFalse; |
|
79 iSrcEnabled[ESourceI] = EFalse; |
|
80 } |
|
81 inline void SetDefaults2() |
|
82 { |
|
83 iSrcEnabled[ESourceCPU] = ETrue; |
|
84 iSrcEnabled[ESourceRAM] = ETrue; |
|
85 iSrcEnabled[ESourceC] = EFalse; |
|
86 iSrcEnabled[ESourceD] = EFalse; |
|
87 iSrcEnabled[ESourceE] = EFalse; |
|
88 iSrcEnabled[ESourceF] = EFalse; |
|
89 iSrcEnabled[ESourceG] = EFalse; |
|
90 iSrcEnabled[ESourceH] = EFalse; |
|
91 iSrcEnabled[ESourceI] = EFalse; |
|
92 } |
|
93 TInt EnabledSourcesCount() |
|
94 { |
|
95 TInt srcCount(0); |
|
96 |
|
97 for (TInt i=0; i<ESourcesLength; i++) |
|
98 { |
|
99 if (iSrcEnabled[i]) |
|
100 srcCount++; |
|
101 } |
|
102 |
|
103 return srcCount; |
|
104 } |
|
105 }; |
|
106 |
|
107 |
|
108 class TPerfMonSettings |
|
109 { |
|
110 public: |
|
111 TInt iHeartBeat; |
|
112 TInt iMaxSamples; |
|
113 TInt iPriority; |
|
114 TInt iCPUMode; |
|
115 TBool iKeepBacklightOn; |
|
116 |
|
117 TInt iDataPopupVisibility; |
|
118 TInt iDataPopupLocation; |
|
119 TPerfMonSources iDataPopupSources; |
|
120 |
|
121 TInt iGraphsVerticalBarPeriod; |
|
122 TPerfMonSources iGraphsSources; |
|
123 |
|
124 TInt iLoggingMode; |
|
125 TFileName iLoggingFilePath; |
|
126 TPerfMonSources iLoggingSources; |
|
127 |
|
128 TBool iLoggingEnabled; |
|
129 }; |
|
130 |
|
131 |
|
132 class TSampleData |
|
133 { |
|
134 public: |
|
135 TInt64 iFree; |
|
136 TInt64 iSize; |
|
137 TTimeIntervalMicroSeconds iTimeFromStart; |
|
138 }; |
|
139 |
|
140 typedef CArrayFixSeg<TSampleData> CSampleDataArray; |
|
141 |
|
142 |
|
143 class TSampleEntry |
|
144 { |
|
145 public: |
|
146 TBuf<16> iDescription; |
|
147 TBuf<16> iUnitTypeShort; //eg. b |
|
148 TBuf<16> iUnitTypeLong; //eg. bytes |
|
149 TInt iDriveNumber; //used only for disk drives |
|
150 TRgb iGraphColor; |
|
151 CSampleDataArray* iSampleDataArray; |
|
152 }; |
|
153 |
|
154 typedef CArrayFixSeg<TSampleEntry> CSampleEntryArray; |
|
155 |
|
156 |
|
157 |
|
158 class CPerfMonModel : public CActive |
|
159 { |
|
160 private: |
|
161 enum TContainerDrawState |
|
162 { |
|
163 EDrawStateInvalid = -1, |
|
164 EDrawStateValues, |
|
165 EDrawStateGraphs |
|
166 }; |
|
167 |
|
168 public: |
|
169 static CPerfMonModel* NewL(); |
|
170 ~CPerfMonModel(); |
|
171 void ActivateModelL(); |
|
172 void DeActivateModelL(); |
|
173 void EnableLogging(TBool aEnable); |
|
174 |
|
175 private: |
|
176 void RunL(); |
|
177 void DoCancel(); |
|
178 |
|
179 private: |
|
180 CPerfMonModel(); |
|
181 void ConstructL(); |
|
182 void LoadSettingsL(); |
|
183 void SaveSettingsL(); |
|
184 void HandleSettingsChangeL(); |
|
185 void OpenLogFile(TBool aOpen); |
|
186 void SendDrawEventToContainersL(); |
|
187 void CreateSamplesDataArrayL(); |
|
188 void UpdateSamplesDataL(); |
|
189 void AppendLatestSamplesToLogsL(); |
|
190 void ActivateCPUMonitoringL(); |
|
191 TBool OpenHandleToNullThread(); |
|
192 void DeActivateCPUMonitoring(); |
|
193 TBool CPUTimeSupported(); |
|
194 TThreadPriority SettingItemToThreadPriority(TInt aIndex); |
|
195 void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TInt& aValue); |
|
196 void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TDes& aValue); |
|
197 void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TPerfMonSources& aValue); |
|
198 void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TInt& aValue); |
|
199 void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TDes& aValue); |
|
200 void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TPerfMonSources& aValue); |
|
201 |
|
202 public: |
|
203 void SetValuesContainer(CPerfMonValuesContainer* aValuesContainer); |
|
204 void SetGraphsContainer(CPerfMonGraphsContainer* aGraphsContainer); |
|
205 TInt LaunchSettingsDialogL(); |
|
206 |
|
207 inline TPerfMonSettings& Settings() { return iSettings; } |
|
208 inline CEikonEnv* EikonEnv() { return iEnv; } |
|
209 inline RApaLsSession& LsSession() { return iLs; } |
|
210 |
|
211 inline CPerfMonValuesContainer* ValuesContainer() { return iValuesContainer; } |
|
212 inline CPerfMonGraphsContainer* GraphsContainer() { return iGraphsContainer; } |
|
213 inline CPerfMonDataPopupContainer* DataPopupContainer() { return iDataPopupContainer; } |
|
214 |
|
215 |
|
216 inline CSampleEntryArray* SampleEntryArray() { return iSampleEntryArray; } |
|
217 |
|
218 private: |
|
219 RTimer iTimer; |
|
220 CPerfMonValuesContainer* iValuesContainer; |
|
221 CPerfMonGraphsContainer* iGraphsContainer; |
|
222 CPerfMonDataPopupContainer* iDataPopupContainer; |
|
223 CEikonEnv* iEnv; |
|
224 TPerfMonSettings iSettings; |
|
225 RApaLsSession iLs; |
|
226 TInt iDrawState; |
|
227 CSampleEntryArray* iSampleEntryArray; |
|
228 TTime iStartTime; |
|
229 |
|
230 TInt iCurrentCPUMode; |
|
231 |
|
232 RThread iNullThread; |
|
233 RThread iCPULoadThread; |
|
234 TBool iCPULoadCalibrating; |
|
235 TInt iCPULoadCalibrationCounter; |
|
236 TInt64 iCPULoadMaxValue; |
|
237 TInt64 iCPULoadPreviousValue; |
|
238 TInt64 iCPULoadCounter; |
|
239 TTime iPreviousTime; |
|
240 |
|
241 TBool iLogFileInitialized; |
|
242 RFile iLogFile; |
|
243 }; |
|
244 |
|
245 |
|
246 #endif |
|