1 /* |
|
2 * Copyright (c) 2010 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 #include "enginewrapper.h" |
|
19 |
|
20 |
|
21 // --------------------------------------------------------------------------- |
|
22 |
|
23 EngineWrapper::EngineWrapper() |
|
24 { |
|
25 } |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 |
|
29 EngineWrapper::~EngineWrapper() |
|
30 { |
|
31 finalize(); |
|
32 } |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 |
|
36 bool EngineWrapper::initialize() |
|
37 { |
|
38 |
|
39 SampleEntry cpu; |
|
40 cpu.mDescription = "CPU"; |
|
41 cpu.mDriveNumber = -1; |
|
42 cpu.mGraphColor.setNamedColor("yellow"); |
|
43 |
|
44 SampleEntry ram; |
|
45 ram.mDescription = "RAM"; |
|
46 ram.mUnitShort = "b"; |
|
47 ram.mUnitLong = "bytes"; |
|
48 ram.mDriveNumber = -1; |
|
49 ram.mGraphColor.setNamedColor("green"); |
|
50 |
|
51 SampleEntry cdrive; |
|
52 cdrive.mDescription = "C:"; |
|
53 cdrive.mUnitShort = "b"; |
|
54 cdrive.mUnitLong = "bytes"; |
|
55 cdrive.mDriveNumber = 0; |
|
56 cdrive.mGraphColor.setNamedColor("cyan"); |
|
57 |
|
58 SampleEntry ddrive; |
|
59 ddrive.mDescription = "D:"; |
|
60 ddrive.mUnitShort = "b"; |
|
61 ddrive.mUnitLong = "bytes"; |
|
62 ddrive.mDriveNumber = 0; |
|
63 ddrive.mGraphColor.setNamedColor("blue"); |
|
64 |
|
65 mEntries << cpu << ram << cdrive << ddrive; |
|
66 |
|
67 connect(&mTimer, SIGNAL(timeout()), this, SLOT(update())); |
|
68 mStartTime = QTime::currentTime(); |
|
69 mTimer.start(600); |
|
70 |
|
71 return true; |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 |
|
76 void EngineWrapper::finalize() |
|
77 { |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 |
|
82 bool EngineWrapper::updateSettings() |
|
83 { |
|
84 emit settingsUpdated(); |
|
85 return true; |
|
86 } |
|
87 |
|
88 void EngineWrapper::update() |
|
89 { |
|
90 // do some updates :) |
|
91 for (int i=0; i<mEntries.length(); i++) |
|
92 { |
|
93 SampleEntry & entry = mEntries[i]; |
|
94 if (entry.mSampleData.length() > 0) |
|
95 { |
|
96 SampleData data = entry.mSampleData.at(0); |
|
97 data.mFree += 10000 * (qrand() % 1000 - 500); |
|
98 data.mTimeFromStart = mStartTime.msecsTo(QTime::currentTime()) * 1000; |
|
99 entry.mSampleData.prepend(data); |
|
100 } |
|
101 else |
|
102 { |
|
103 SampleData data = {100000000L, 200000000L, mStartTime.msecsTo(QTime::currentTime()) * 1000}; |
|
104 entry.mSampleData.prepend(data); |
|
105 } |
|
106 |
|
107 if (entry.mSampleData.length() > 64) |
|
108 { |
|
109 entry.mSampleData.removeLast(); |
|
110 } |
|
111 } |
|
112 |
|
113 emit samplesUpdated(); |
|
114 } |
|