Subversion Repositories Kolibri OS

Rev

Rev 8381 | Rev 8392 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8381 Rev 8383
1
/*
1
/*
2
 * System Monitor
2
 * System Monitor
3
 * version 1.36
3
 * version 1.36
4
 * Author: Leency
4
 * Author: Leency
5
*/
5
*/
6
 
6
 
7
#define MEMSIZE 4096*30
7
#define MEMSIZE 4096*30
8
 
8
 
9
#ifndef AUTOBUILD
9
#ifndef AUTOBUILD
10
#include "lang.h--"
10
#include "lang.h--"
11
#endif
11
#endif
12
 
12
 
13
//===================================================//
13
//===================================================//
14
//                                                   //
14
//                                                   //
15
//                       LIB                         //
15
//                       LIB                         //
16
//                                                   //
16
//                                                   //
17
//===================================================//
17
//===================================================//
18
 
-
 
19
#include "../lib/io.h"
18
 
20
#include "../lib/gui.h"
19
#include "../lib/gui.h"
21
#include "../lib/fs.h"
20
#include "../lib/fs.h"
22
#include "../lib/list_box.h"
21
#include "../lib/list_box.h"
23
 
22
 
24
#include "../lib/obj/libio.h"
23
#include "../lib/obj/libio.h"
25
#include "../lib/obj/libimg.h"
24
#include "../lib/obj/libimg.h"
26
#include "../lib/obj/box_lib.h"
25
#include "../lib/obj/box_lib.h"
27
 
26
 
28
#include "../lib/patterns/select_list.h"
27
#include "../lib/patterns/select_list.h"
29
#include "../lib/patterns/restart_process.h"
28
#include "../lib/patterns/restart_process.h"
30
 
29
 
31
//===================================================//
30
//===================================================//
32
//                                                   //
31
//                                                   //
33
//                      CONST                        //
32
//                      CONST                        //
34
//                                                   //
33
//                                                   //
35
//===================================================//
34
//===================================================//
36
 
35
 
37
#define GAP 16   //Window padding
36
#define GAP 16   //Window padding
38
#define WIN_CONTENT_X GAP
37
#define WIN_CONTENT_X GAP
39
#define WIN_CONTENT_Y GAP+15
38
#define WIN_CONTENT_Y GAP+15
40
#define PROCESS_LIST_W 260
39
#define PROCESS_LIST_W 260
41
#define RIGHT_X PROCESS_LIST_W + GAP + GAP + 22
40
#define RIGHT_X PROCESS_LIST_W + GAP + GAP + 22
42
#define ICONGAP 26
41
#define ICONGAP 26
43
#define BOTPANEL_H 36
42
#define BOTPANEL_H 36
44
 
43
 
45
#ifdef LANG_RUS
44
#ifdef LANG_RUS
46
	#define T_APP_TITLE      "‘¨á⥬­ë© ¬®­¨â®à"
45
	#define T_APP_TITLE      "‘¨á⥬­ë© ¬®­¨â®à"
47
	#define T_SHOW_SYSTEM    "‘¨á⥬­ë¥"
46
	#define T_SHOW_SYSTEM    "‘¨á⥬­ë¥"
48
	#define T_DETAILS        "®¤à®¡­¥¥"
47
	#define T_DETAILS        "®¤à®¡­¥¥"
49
	#define T_PROC_KILL      "‘­ïâì § ¤ çã"
48
	#define T_PROC_KILL      "‘­ïâì § ¤ çã"
50
	#define T_PROC_INFO      "ˆ­ä®"
49
	#define T_PROC_INFO      "ˆ­ä®"
51
	#define T_PROC_HEADER    "à®æ¥áá        Ž‡“ Š¡      – %"
50
	#define T_PROC_HEADER    "à®æ¥áá        Ž‡“ Š¡      – %"
52
	#define T_CPU_LOAD       "‡ £à㧪  ¯à®æ¥áá®à  %i%%   "
51
	#define T_CPU_LOAD       "‡ £à㧪  ¯à®æ¥áá®à  %i%%   "
53
	#define T_RAM_USAGE      " ¬ïâì Ž‡“: %i Œ¡ ᢮¡®¤­® ¨§ %i Œ¡"
52
	#define T_RAM_USAGE      " ¬ïâì Ž‡“: %i Œ¡ ᢮¡®¤­® ¨§ %i Œ¡"
54
	#define T_RD_USAGE       "‘¨á⥬­ë© ¤¨áª: %i Š¡ ᢮¡®¤­® ¨§ 1.4 Œ¡"
53
	#define T_RD_USAGE       "‘¨á⥬­ë© ¤¨áª: %i Š¡ ᢮¡®¤­® ¨§ 1.4 Œ¡"
55
	#define T_TMP_USAGE      "TMP%i ¤¨áª: %i Œ¡ ᢮¡®¤­® ¨§ %i Œ¡"
54
	#define T_TMP_USAGE      "TMP%i ¤¨áª: %i Œ¡ ᢮¡®¤­® ¨§ %i Œ¡"
56
#else
55
#else
57
	#define T_APP_TITLE      "System Monitor"
56
	#define T_APP_TITLE      "System Monitor"
58
	#define T_SHOW_SYSTEM    "System"
57
	#define T_SHOW_SYSTEM    "System"
59
	#define T_DETAILS        "Details"
58
	#define T_DETAILS        "Details"
60
	#define T_PROC_KILL      "Terminate"
59
	#define T_PROC_KILL      "Terminate"
61
	#define T_PROC_INFO      "Info"
60
	#define T_PROC_INFO      "Info"
62
	#define T_PROC_HEADER    "Process        RAM Kb     CPU %"
61
	#define T_PROC_HEADER    "Process        RAM Kb     CPU %"
63
	#define T_CPU_LOAD       "CPU load %i%%   "
62
	#define T_CPU_LOAD       "CPU load %i%%   "
64
	#define T_RAM_USAGE      "RAM usage: %i Mb free of %i Mb"
63
	#define T_RAM_USAGE      "RAM usage: %i Mb free of %i Mb"
65
	#define T_RD_USAGE       "System disk usage: %i Kb free of 1.4 Mb"
64
	#define T_RD_USAGE       "System disk usage: %i Kb free of 1.4 Mb"
66
	#define T_TMP_USAGE      "TMP%i usage: %i Mb free of %i Mb"
65
	#define T_TMP_USAGE      "TMP%i usage: %i Mb free of %i Mb"
67
#endif
66
#endif
68
 
67
 
69
enum {
68
enum {
70
	BTN_ID_SHOW_SYSTEM_PROCESSES=200,
69
	BTN_ID_SHOW_SYSTEM_PROCESSES=200,
71
	BTN_ID_PROC_KILL,
70
	BTN_ID_PROC_KILL,
72
	BTN_ID_PROC_INFO,
71
	BTN_ID_PROC_INFO,
73
	BTN_ID_MENU
72
	BTN_ID_MENU
74
};
73
};
75
 
74
 
76
//===================================================//
75
//===================================================//
77
//                                                   //
76
//                                                   //
78
//                       VARS                        //
77
//                       VARS                        //
79
//                                                   //
78
//                                                   //
80
//===================================================//
79
//===================================================//
81
 
80
 
82
int current_process_id = 0;
81
int current_process_id = 0;
83
int proc_list[256];
82
int proc_list[256];
84
 
83
 
85
checkbox show_system = { T_SHOW_SYSTEM, false };
84
checkbox show_system = { T_SHOW_SYSTEM, false };
86
 
85
 
87
sensor cpu;
86
sensor cpu;
88
sensor ram;
87
sensor ram;
89
sensor rd;
88
sensor rd;
90
sensor tmp;
89
sensor tmp;
91
 
90
 
92
proc_info Form;
91
proc_info Form;
93
 
92
 
94
int right_w;
93
int right_w;
95
 
94
 
96
//===================================================//
95
//===================================================//
97
//                                                   //
96
//                                                   //
98
//                       CODE                        //
97
//                       CODE                        //
99
//                                                   //
98
//                                                   //
100
//===================================================//
99
//===================================================//
101
 
100
 
102
void load_lib()
101
void load_lib()
103
{
102
{
104
	load_dll(libio, #libio_init,1);
103
	load_dll(libio, #libio_init,1);
105
	load_dll(libimg, #libimg_init,1);
104
	load_dll(libimg, #libimg_init,1);
106
	load_dll(boxlib, #box_lib_init,0);
105
	load_dll(boxlib, #box_lib_init,0);
107
}
106
}
108
 
107
 
109
void main()
108
void main()
110
{
109
{
111
	int btn;
110
	int btn;
112
	//dword cpu_frequency = GetCpuFrequency()/1000;
111
	//dword cpu_frequency = GetCpuFrequency()/1000;
113
	load_lib();
112
	load_lib();
114
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
113
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
115
	loop() switch(@WaitEventTimeout(50))
114
	loop() switch(@WaitEventTimeout(50))
116
	{
115
	{
117
	   	case evMouse:
116
	   	case evMouse:
118
			SelectList_ProcessMouse();
117
			SelectList_ProcessMouse();
119
			break;
118
			break;
120
		case evKey:
119
		case evKey:
121
			GetKeys();
120
			GetKeys();
122
			if (key_scancode == SCAN_CODE_ESC) ExitProcess();
121
			if (key_scancode == SCAN_CODE_ESC) ExitProcess();
123
			if (key_scancode == SCAN_CODE_DEL) EventKillCurrentProcess();
122
			if (key_scancode == SCAN_CODE_DEL) EventKillCurrentProcess();
124
			if (select_list.ProcessKey(key_scancode)) SelectList_LineChanged();
123
			if (select_list.ProcessKey(key_scancode)) SelectList_LineChanged();
125
			break;
124
			break;
126
		case evButton:
125
		case evButton:
127
			btn = GetButtonID();
126
			btn = GetButtonID();
128
			if (1==btn) ExitProcess();
127
			if (1==btn) ExitProcess();
129
 
128
 
130
			if (show_system.click(btn)) {
129
			if (show_system.click(btn)) {
131
				SelectList_LineChanged();
130
				SelectList_LineChanged();
132
			}
131
			}
133
			if (BTN_ID_PROC_KILL == btn) {
132
			if (BTN_ID_PROC_KILL == btn) {
134
				EventKillCurrentProcess();
133
				EventKillCurrentProcess();
135
			}
134
			}
136
			if (BTN_ID_PROC_INFO == btn) {
135
			if (BTN_ID_PROC_INFO == btn) {
137
				io.run("/sys/tinfo", itoa(GetProcessSlot(current_process_id))); 
136
				RunProgram("/sys/tinfo", itoa(GetProcessSlot(current_process_id))); 
138
			}
137
			}
139
			break;
138
			break;
140
		case evReDraw:
139
		case evReDraw:
141
			sc.get();
140
			sc.get();
142
			DefineAndDrawWindow(screen.width/2 - 350, 100, 700, 490, 0x33, sc.work, T_APP_TITLE,0);
141
			DefineAndDrawWindow(screen.width/2 - 350, 100, 700, 490, 0x33, sc.work, T_APP_TITLE,0);
143
			GetProcessInfo(#Form, SelfInfo);
142
			GetProcessInfo(#Form, SelfInfo);
144
			if (Form.status_window>2) break;
143
			if (Form.status_window>2) break;
145
			if (Form.width  < RIGHT_X+370) { MoveSize(OLD,OLD,RIGHT_X+370,OLD); break; }
144
			if (Form.width  < RIGHT_X+370) { MoveSize(OLD,OLD,RIGHT_X+370,OLD); break; }
146
			if (Form.height < 420) { MoveSize(OLD,OLD,OLD,420); break; }
145
			if (Form.height < 420) { MoveSize(OLD,OLD,OLD,420); break; }
147
			right_w = Form.cwidth - RIGHT_X - GAP;
146
			right_w = Form.cwidth - RIGHT_X - GAP;
148
			right_w &= ~1; // make sure the number is even
147
			right_w &= ~1; // make sure the number is even
149
			WriteText(GAP+5, WIN_CONTENT_Y-20, 0x90, sc.work_text, T_PROC_HEADER);
148
			WriteText(GAP+5, WIN_CONTENT_Y-20, 0x90, sc.work_text, T_PROC_HEADER);
150
 
149
 
151
			//bool burger_active = false;
150
			//bool burger_active = false;
152
			//if (menu_id == OPEN_FILE) burger_active = true;
151
			//if (menu_id == OPEN_FILE) burger_active = true;
153
			//DrawTopPanelButton(BTN_ID_MENU, Form.cwidth-GAP-3, GAP, -1, burger_active);
152
			//DrawTopPanelButton(BTN_ID_MENU, Form.cwidth-GAP-3, GAP, -1, burger_active);
154
 
153
 
155
			SelectList_Init(GAP, WIN_CONTENT_Y, PROCESS_LIST_W, 
154
			SelectList_Init(GAP, WIN_CONTENT_Y, PROCESS_LIST_W, 
156
				Form.cheight-BOTPANEL_H-WIN_CONTENT_Y, false);
155
				Form.cheight-BOTPANEL_H-WIN_CONTENT_Y, false);
157
			SelectList_DrawBorder();
156
			SelectList_DrawBorder();
158
 
157
 
159
			DrawBar(select_list.x-2, select_list.y+select_list.h+2, 
158
			DrawBar(select_list.x-2, select_list.y+select_list.h+2, 
160
				select_list.w+scroll1.size_x+4, BOTPANEL_H, sc.work);
159
				select_list.w+scroll1.size_x+4, BOTPANEL_H, sc.work);
161
			DrawCaptButton(PROCESS_LIST_W+GAP-110+18, select_list.y+select_list.h+5,
160
			DrawCaptButton(PROCESS_LIST_W+GAP-110+18, select_list.y+select_list.h+5,
162
				110,23,BTN_ID_PROC_KILL,0xF38181, 0xFFFfff, T_PROC_KILL);
161
				110,23,BTN_ID_PROC_KILL,0xF38181, 0xFFFfff, T_PROC_KILL);
163
			DrawCaptButton(PROCESS_LIST_W+GAP-165+18, select_list.y+select_list.h+5,
162
			DrawCaptButton(PROCESS_LIST_W+GAP-165+18, select_list.y+select_list.h+5,
164
				46,23,BTN_ID_PROC_INFO,sc.button, sc.button_text, T_PROC_INFO);
163
				46,23,BTN_ID_PROC_INFO,sc.button, sc.button_text, T_PROC_INFO);
165
			show_system.draw(GAP-1, select_list.y+select_list.h+10);
164
			show_system.draw(GAP-1, select_list.y+select_list.h+10);
166
 
165
 
167
			//WriteText(RIGHT_X, WIN_CONTENT_Y+25, 0x90, sc.work, "Update period: 5 seconds");
166
			//WriteText(RIGHT_X, WIN_CONTENT_Y+25, 0x90, sc.work, "Update period: 5 seconds");
168
			cpu.set_size(RIGHT_X, WIN_CONTENT_Y+25, right_w, 100);
167
			cpu.set_size(RIGHT_X, WIN_CONTENT_Y+25, right_w, 100);
169
			ram.set_size(RIGHT_X, WIN_CONTENT_Y+170, right_w, 23);
168
			ram.set_size(RIGHT_X, WIN_CONTENT_Y+170, right_w, 23);
170
			rd.set_size(RIGHT_X, WIN_CONTENT_Y+240, right_w, 23);
169
			rd.set_size(RIGHT_X, WIN_CONTENT_Y+240, right_w, 23);
171
		default:
170
		default:
172
			MonitorCpu();
171
			MonitorCpu();
173
			MonitorRam();
172
			MonitorRam();
174
			SelectList_LineChanged();
173
			SelectList_LineChanged();
175
			MonitorRd();
174
			MonitorRd();
176
			MonitorTmp();
175
			MonitorTmp();
177
	}
176
	}
178
}
177
}
179
 
178
 
180
void EventKillCurrentProcess()
179
void EventKillCurrentProcess()
181
{
180
{
182
	KillProcess(current_process_id);
181
	KillProcess(current_process_id);
183
	pause(10);
182
	pause(10);
184
	SelectList_LineChanged(); 
183
	SelectList_LineChanged(); 
185
}
184
}
186
 
185
 
187
void Processes__GetProcessList()
186
void Processes__GetProcessList()
188
{
187
{
189
	int i, j;
188
	int i, j;
190
	proc_info Process;
189
	proc_info Process;
191
 
190
 
192
	select_list.count=0;
191
	select_list.count=0;
193
	for (i=0; i
192
	for (i=0; i
194
	{
193
	{
195
		GetProcessInfo(#Process, i);
194
		GetProcessInfo(#Process, i);
196
		if (Process.name) 
195
		if (Process.name) 
197
		{
196
		{
198
			for (j=0; j<11; j++) if (Process.name[j]!=' ') { 
197
			for (j=0; j<11; j++) if (Process.name[j]!=' ') { 
199
				if (show_system.checked==false) {
198
				if (show_system.checked==false) {
200
					//do not show system process
199
					//do not show system process
201
					if (Process.name[0]=='@') break;
200
					if (Process.name[0]=='@') break;
202
					if (!strcmp(#Process.name, "IDLE")) break;
201
					if (!strcmp(#Process.name, "IDLE")) break;
203
					if (!strcmp(#Process.name, "OS")) break;
202
					if (!strcmp(#Process.name, "OS")) break;
204
				}
203
				}
205
				proc_list[select_list.count] = i;
204
				proc_list[select_list.count] = i;
206
				select_list.count++;
205
				select_list.count++;
207
				break; 
206
				break; 
208
			}
207
			}
209
		}
208
		}
210
	}
209
	}
211
}
210
}
212
 
211
 
213
void SelectList_DrawLine(dword i)
212
void SelectList_DrawLine(dword i)
214
{
213
{
215
	int posy, j, len;
214
	int posy, j, len;
216
	char cpu_use[16], mem_use[16], mem_use_pretty[16];
215
	char cpu_use[16], mem_use[16], mem_use_pretty[16];
217
	dword bg_color;
216
	dword bg_color;
218
	proc_info Process;
217
	proc_info Process;
219
	static unsigned maxcpu;
218
	static unsigned maxcpu;
220
	if (!maxcpu) maxcpu = GetCpuFrequency();
219
	if (!maxcpu) maxcpu = GetCpuFrequency();
221
 
220
 
222
	GetProcessInfo(#Process, proc_list[i+select_list.first]);
221
	GetProcessInfo(#Process, proc_list[i+select_list.first]);
223
	
222
	
224
	posy = i *select_list.item_h + select_list.y;
223
	posy = i *select_list.item_h + select_list.y;
225
	if (i % 2) bg_color = 0xFFFfff; else bg_color = 0xF0F0F0;
224
	if (i % 2) bg_color = 0xFFFfff; else bg_color = 0xF0F0F0;
226
	if (i+select_list.first == select_list.cur_y) {
225
	if (i+select_list.first == select_list.cur_y) {
227
		current_process_id = Process.ID; 
226
		current_process_id = Process.ID; 
228
		bg_color = 0x67CCEB;
227
		bg_color = 0x67CCEB;
229
	}
228
	}
230
	DrawBar(select_list.x, posy, select_list.w, select_list.item_h, bg_color);
229
	DrawBar(select_list.x, posy, select_list.w, select_list.item_h, bg_color);
231
 
230
 
232
	WriteText(GAP+5, posy+select_list.text_y, 0x90, 0, #Process.name);
231
	WriteText(GAP+5, posy+select_list.text_y, 0x90, 0, #Process.name);
233
 
232
 
234
	if (Process.use_memory < 3670016000) 
233
	if (Process.use_memory < 3670016000) 
235
	{
234
	{
236
		sprintf(#mem_use, "%i", Process.use_memory/1024);
235
		sprintf(#mem_use, "%i", Process.use_memory/1024);
237
		len = strlen(#mem_use);
236
		len = strlen(#mem_use);
238
		strcpy(#mem_use_pretty, "               ");
237
		strcpy(#mem_use_pretty, "               ");
239
 
238
 
240
		for (j=1; j<=len; j++) {
239
		for (j=1; j<=len; j++) {
241
			EDI = sizeof(mem_use_pretty)-1-j - calc(j/4);
240
			EDI = sizeof(mem_use_pretty)-1-j - calc(j/4);
242
			mem_use_pretty[EDI] = mem_use[len-j];
241
			mem_use_pretty[EDI] = mem_use[len-j];
243
		}
242
		}
244
 
243
 
245
		WriteText(GAP+109, posy+select_list.text_y, 0x90, 0x444444, #mem_use_pretty+16-9);
244
		WriteText(GAP+109, posy+select_list.text_y, 0x90, 0x444444, #mem_use_pretty+16-9);
246
	}
245
	}
247
 
246
 
248
	sprintf(#cpu_use, "%i", Process.use_cpu*100/maxcpu);
247
	sprintf(#cpu_use, "%i", Process.use_cpu*100/maxcpu);
249
	if (maxcpu) WriteText(GAP+203 - calc(strlen(#cpu_use)-4*8), 
248
	if (maxcpu) WriteText(GAP+203 - calc(strlen(#cpu_use)-4*8), 
250
		posy+select_list.text_y, 0x90, 0x444444, #cpu_use);
249
		posy+select_list.text_y, 0x90, 0x444444, #cpu_use);
251
}
250
}
252
 
251
 
253
void SelectList_LineChanged() 
252
void SelectList_LineChanged() 
254
{
253
{
255
	Processes__GetProcessList();
254
	Processes__GetProcessList();
256
	SelectList_Draw();
255
	SelectList_Draw();
257
}
256
}
258
 
257
 
259
void MonitorRd()
258
void MonitorRd()
260
{
259
{
261
	dword rdempty = malloc(1440*1024);
260
	dword rdempty = malloc(1440*1024);
262
	CreateFile(0, 1440*1024, rdempty, "/rd/1/rdempty");
261
	CreateFile(0, 1440*1024, rdempty, "/rd/1/rdempty");
263
	free(rdempty);
262
	free(rdempty);
264
	file_size stdcall ("/rd/1/rdempty");
263
	file_size stdcall ("/rd/1/rdempty");
265
	rdempty = EBX / 1024;
264
	rdempty = EBX / 1024;
266
	DeleteFile("/rd/1/rdempty");
265
	DeleteFile("/rd/1/rdempty");
267
 
266
 
268
	sprintf(#param, T_RD_USAGE, rdempty);
267
	sprintf(#param, T_RD_USAGE, rdempty);
269
	DrawIconWithText(RIGHT_X, rd.y - 25, 5, #param);
268
	DrawIconWithText(RIGHT_X, rd.y - 25, 5, #param);
270
 
269
 
271
	rd.draw_progress(rdempty * rd.w / 1440);	
270
	rd.draw_progress(rdempty * rd.w / 1440);	
272
}
271
}
273
 
272
 
274
dword GetTmpDiskFreeSpace(int _id)
273
dword GetTmpDiskFreeSpace(int _id)
275
{
274
{
276
	DIR_SIZE dir_size;
275
	DIR_SIZE dir_size;
277
	sprintf(#param, "/tmp%i/1", _id);
276
	sprintf(#param, "/tmp%i/1", _id);
278
	dir_size.get(#param);
277
	dir_size.get(#param);
279
	dir_size.bytes += dir_size.files/2 + 32 * 512; //file attr size + FAT table size
278
	dir_size.bytes += dir_size.files/2 + 32 * 512; //file attr size + FAT table size
280
	dir_size.bytes /= 1024*1024; //convert to MiB
279
	dir_size.bytes /= 1024*1024; //convert to MiB
281
	return dir_size.bytes;	
280
	return dir_size.bytes;	
282
}
281
}
283
 
282
 
284
void MonitorTmp()
283
void MonitorTmp()
285
{
284
{
286
	char text_status[64];
285
	char text_status[64];
287
	int i, yy=WIN_CONTENT_Y+300;
286
	int i, yy=WIN_CONTENT_Y+300;
288
	dword tmp_size[10];
287
	dword tmp_size[10];
289
	dword free_space;
288
	dword free_space;
290
	for (i=0; i<=9; i++) 
289
	for (i=0; i<=9; i++) 
291
	{
290
	{
292
		file_size stdcall ( sprintf(#param, "/tmp%i/1", i) );
291
		file_size stdcall ( sprintf(#param, "/tmp%i/1", i) );
293
		tmp_size[i] =  EBX / 1024 / 1024;
292
		tmp_size[i] =  EBX / 1024 / 1024;
294
 
293
 
295
		if (EBX) {
294
		if (EBX) {
296
			free_space = tmp_size[i] - GetTmpDiskFreeSpace(i);
295
			free_space = tmp_size[i] - GetTmpDiskFreeSpace(i);
297
			sprintf(#text_status, T_TMP_USAGE, i, free_space, tmp_size[i]);
296
			sprintf(#text_status, T_TMP_USAGE, i, free_space, tmp_size[i]);
298
			tmp.set_size(RIGHT_X, yy, right_w, 23);
297
			tmp.set_size(RIGHT_X, yy, right_w, 23);
299
			tmp.draw_progress(free_space * right_w / tmp_size[i]);
298
			tmp.draw_progress(free_space * right_w / tmp_size[i]);
300
			DrawIconWithText(RIGHT_X, tmp.y - 25, 50, #text_status);
299
			DrawIconWithText(RIGHT_X, tmp.y - 25, 50, #text_status);
301
			yy += 65;
300
			yy += 65;
302
		}
301
		}
303
	}
302
	}
304
}
303
}
305
 
304
 
306
void DrawIconWithText(dword _x, _y, _icon, _title)
305
void DrawIconWithText(dword _x, _y, _icon, _title)
307
{
306
{
308
	DrawIcon16(_x, _y, sc.work, _icon);
307
	DrawIcon16(_x, _y, sc.work, _icon);
309
	WriteTextWithBg(_x+ICONGAP, _y, 0xD0, sc.work_text, _title, sc.work);
308
	WriteTextWithBg(_x+ICONGAP, _y, 0xD0, sc.work_text, _title, sc.work);
310
}
309
}
311
 
310
 
312
dword GetCpuLoad(dword max_h)
311
dword GetCpuLoad(dword max_h)
313
{
312
{
314
	dword idle;
313
	dword idle;
315
	dword CPU_SEC = GetCpuFrequency() >> 20 + 1;
314
	dword CPU_SEC = GetCpuFrequency() >> 20 + 1;
316
	dword IDLE_SEC = GetCpuIdleCount() >> 20 * max_h;
315
	dword IDLE_SEC = GetCpuIdleCount() >> 20 * max_h;
317
 
316
 
318
	EAX = IDLE_SEC;
317
	EAX = IDLE_SEC;
319
	EBX = CPU_SEC;
318
	EBX = CPU_SEC;
320
	$cdq
319
	$cdq
321
	$div ebx
320
	$div ebx
322
	idle = EAX;
321
	idle = EAX;
323
 
322
 
324
	return max_h - idle;
323
	return max_h - idle;
325
}
324
}
326
 
325
 
327
int pos=0;
326
int pos=0;
328
void MonitorCpu()
327
void MonitorCpu()
329
{
328
{
330
	static dword cpu_stack[1980*3];
329
	static dword cpu_stack[1980*3];
331
	int i;
330
	int i;
332
	if (!cpu.w) return;
331
	if (!cpu.w) return;
333
 
332
 
334
	cpu_stack[pos] = GetCpuLoad(cpu.h);
333
	cpu_stack[pos] = GetCpuLoad(cpu.h);
335
	if (cpu_stack[pos]<=2) || (cpu_stack[pos]>cpu.h) cpu_stack[pos]=2;
334
	if (cpu_stack[pos]<=2) || (cpu_stack[pos]>cpu.h) cpu_stack[pos]=2;
336
	
335
	
337
	sprintf(#param, T_CPU_LOAD, cpu_stack[pos]);
336
	sprintf(#param, T_CPU_LOAD, cpu_stack[pos]);
338
	DrawIconWithText(RIGHT_X, cpu.y - 25, 48, #param);
337
	DrawIconWithText(RIGHT_X, cpu.y - 25, 48, #param);
339
	
338
	
340
	#define LINEW 8
339
	#define LINEW 8
341
	for (i=0; i
340
	for (i=0; i
342
		DrawBar(i+cpu.x, cpu.y, LINEW, cpu.h-cpu_stack[i], PROGRESS_BG);
341
		DrawBar(i+cpu.x, cpu.y, LINEW, cpu.h-cpu_stack[i], PROGRESS_BG);
343
		DrawBar(i+cpu.x, cpu.h-cpu_stack[i]+cpu.y, LINEW, cpu_stack[i], 0xDFA13B);
342
		DrawBar(i+cpu.x, cpu.h-cpu_stack[i]+cpu.y, LINEW, cpu_stack[i], 0xDFA13B);
344
		//DrawBar(i+LINEW+cpu.x, cpu.y, 1, cpu.h, PROGRESS_BG);
343
		//DrawBar(i+LINEW+cpu.x, cpu.y, 1, cpu.h, PROGRESS_BG);
345
	}
344
	}
346
 
345
 
347
	pos++;
346
	pos++;
348
	if (pos>=right_w) {
347
	if (pos>=right_w) {
349
		pos = right_w-1;
348
		pos = right_w-1;
350
		for (i=0; i
349
		for (i=0; i
351
			cpu_stack[i] = cpu_stack[i+1];
350
			cpu_stack[i] = cpu_stack[i+1];
352
		}
351
		}
353
	}
352
	}
354
}
353
}
355
 
354
 
356
void MonitorRam()
355
void MonitorRam()
357
{
356
{
358
	ram.draw_progress(GetFreeRAM()*ram.w/GetTotalRAM());
357
	ram.draw_progress(GetFreeRAM()*ram.w/GetTotalRAM());
359
	sprintf(#param, T_RAM_USAGE, GetFreeRAM()/1024, GetTotalRAM()/1024);
358
	sprintf(#param, T_RAM_USAGE, GetFreeRAM()/1024, GetTotalRAM()/1024);
360
	DrawIconWithText(RIGHT_X, ram.y - 25, 51, #param);
359
	DrawIconWithText(RIGHT_X, ram.y - 25, 51, #param);
361
}
360
}