Subversion Repositories Kolibri OS

Rev

Rev 7878 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7878 Rev 7906
Line 2... Line 2...
2
//                                                   //
2
//                                                   //
3
//                       DATA                        //
3
//                       DATA                        //
4
//                                                   //
4
//                                                   //
5
//===================================================//
5
//===================================================//
Line 6... Line -...
6
 
-
 
7
dword cpu_stack[1980*3];
-
 
8
 
6
 
9
sensor cpu;
7
sensor cpu;
10
sensor ram;
-
 
11
sensor rd;
-
 
12
sensor tmp[10];
-
 
13
 
-
 
Line 14... Line 8...
14
dword tmp_size[10];
8
sensor ram;
15
 
9
 
16
//===================================================//
10
//===================================================//
17
//                                                   //
11
//                                                   //
18
//                       CODE                        //
12
//                       CODE                        //
Line 19... Line 13...
19
//                                                   //
13
//                                                   //
20
//===================================================//
14
//===================================================//
21
 
15
 
22
void General__Main()
-
 
23
{
-
 
24
	DIR_SIZE dir_size;
16
void DrawIconWithText(dword _x, _y, _icon, _title)
25
	dword cpu_frequency;
-
 
26
	incn y;
17
{
27
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON);
-
 
28
 
18
	DrawIcon16(_x, _y, sc.work, _icon);
29
	cpu_frequency = GetCpuFrequency()/1000;
-
 
Line -... Line 19...
-
 
19
	DrawBar(_x+ICONGAP, _y, WIN_CONTENT_W - ICONGAP - _x, 20, sc.work);
-
 
20
	WriteText(_x+ICONGAP, _y, 0x90, sc.work_text, _title);
-
 
21
}
-
 
22
 
-
 
23
void CPUnRAM__Main()
30
	GetTmpDiskSizes();
24
{
31
 
25
	dword cpu_frequency = GetCpuFrequency()/1000;
32
	goto _GENERAL_REDRAW;
26
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON);
33
	
27
	goto _GENERAL_REDRAW_2;
34
	loop()
28
	loop()
35
	{
-
 
36
		WaitEventTimeout(25);
29
	{
37
		switch(EAX & 0xFF)
-
 
38
		{
-
 
39
			case evButton:
-
 
40
				Sysmon__ButtonEvent(GetButtonID());
-
 
41
				break;
30
		WaitEventTimeout(25);
42
		  
-
 
43
			case evKey:
-
 
44
				GetKeys();
31
		switch(EAX & 0xFF)
45
				if (key_scancode == SCAN_CODE_ESC) ExitProcess();
32
		{
46
				break;
33
			case evButton: Sysmon__ButtonEvent(); break;
47
			 
-
 
48
			case evReDraw:
-
 
49
				_GENERAL_REDRAW:
-
 
50
				if (!Sysmon__DefineAndDrawWindow()) break;
-
 
51
 
-
 
52
				y.n = WIN_CONTENT_Y;
34
			case evKey: Sysmon__KeyEvent(); break;
53
				if (cpu_frequency < 1000) sprintf(#param, "CPU frequency: %i Hz", cpu_frequency);
-
 
54
				else sprintf(#param, "CPU frequency: %i MHz", cpu_frequency/1000);
-
 
55
				DrawBlockHeader(WIN_PAD, y.inc(0), 37, "CPU load", #param);
-
 
56
				cpu.set_size(WIN_PAD, y.inc(45), WIN_CONTENT_W, 100);
35
			case evReDraw: 
57
 
-
 
58
				sprintf(#param, "Total RAM: %i MiB", GetTotalRAM()/1024);
-
 
59
				DrawBlockHeader(WIN_PAD, y.inc(cpu.h + 25), 36, "RAM usage", #param);
-
 
60
				ram.set_size(WIN_PAD, y.inc(45), WIN_CONTENT_W, 23);
-
 
61
 
-
 
62
				DrawBlockHeader(WIN_PAD, y.inc(ram.h + 25), 3, "System RAM Disk usage", "Fixed size: 1.44 MiB");
-
 
63
				rd.set_size(WIN_PAD, y.inc(45), WIN_CONTENT_W, 23);
-
 
64
 
-
 
65
				sprintf(#param, "TMP Disk 0 size: %i MiB", tmp_size[0]);
36
				_GENERAL_REDRAW_2: 
66
				DrawBlockHeader(WIN_PAD, y.inc(rd.h + 25), 50, "Virtual drive usage", #param);
37
				Sysmon__DefineAndDrawWindow(); 
67
				tmp[0].set_size(WIN_PAD, y.inc(45), WIN_CONTENT_W, 23);
-
 
68
 
38
				cpu.set_size(WIN_PAD, WIN_CONTENT_Y+25, WIN_CONTENT_W, 100);
69
			default:
-
 
70
				MonitorCpu();
-
 
71
 
-
 
72
				//MonitorRam();
-
 
73
				ram.draw_progress(
-
 
74
					GetFreeRAM()*ram.w/GetTotalRAM(), 
-
 
75
					GetTotalRAM()-GetFreeRAM()/1024, 
-
 
76
					GetFreeRAM()/1024,
-
 
77
					"M"
-
 
78
					);
-
 
79
				DrawBar(ram.x+ram.w-96, ram.y-25, 96, 20, sc.work);
-
 
80
				sprintf(#param, "%i KiB", GetTotalRAM()-GetFreeRAM());
-
 
81
				WriteText(ram.x+ram.w-calc(strlen(#param)*8), ram.y-25, 0x90, sc.work_text, #param);
-
 
82
 
-
 
83
				//MonitorRd();
-
 
84
				dir_size.get("/rd/1");			
-
 
85
				dir_size.bytes += dir_size.files/2 + 32 * 512; //file attr size + FAT table size
-
 
86
				dir_size.bytes /= 1024; //convert to KiB
-
 
87
				dir_size.bytes = 1440 - dir_size.bytes; 
-
 
88
				rd.draw_progress(
-
 
89
					dir_size.bytes*rd.w/1440,
-
 
90
					1440 - dir_size.bytes,
-
 
91
					dir_size.bytes,
-
 
92
					"K"
-
 
93
					);
-
 
94
 
-
 
95
				//MonitorTmp();
-
 
96
				if (tmp_size[0]) {
-
 
97
					dir_size.get("/tmp0/1");
-
 
98
					dir_size.bytes += dir_size.files/2 + 32 * 512; //file attr size + FAT table size
-
 
99
					dir_size.bytes /= 1024*1024; //convert to MiB
-
 
100
					dir_size.bytes= tmp_size[0] - dir_size.bytes;
-
 
101
					tmp[0].draw_progress(
-
 
102
						dir_size.bytes*tmp[0].w/tmp_size[0],
-
 
103
						tmp_size[0] - dir_size.bytes,
39
				ram.set_size(WIN_PAD, WIN_CONTENT_Y+170, WIN_CONTENT_W, 23);
104
						dir_size.bytes,
40
			default:
105
						"M"
41
				MonitorCpu();
106
						);					
-
 
107
				}
-
 
108
		}
-
 
109
	}
-
 
110
}
-
 
111
 
-
 
112
void DrawBlockHeader(dword _x, _y, _icon, _title, _subtitle)
-
 
113
{
-
 
114
	#define ICONGAP 45
-
 
Line 115... Line 42...
115
	WriteTextB(_x+ICONGAP, _y, 0x90, sc.work_text, _title);
42
				MonitorRam();
116
	DrawIcon32(_x, _y, sc.work, _icon);
43
		}
117
	WriteText(_x+ICONGAP, _y+20, 0x90, sc.work_text, _subtitle);	
44
	}
118
}
45
}
Line 130... Line 57...
130
	idle = EAX;
57
	idle = EAX;
Line 131... Line 58...
131
 
58
 
132
	return max_h - idle;
59
	return max_h - idle;
Line 133... Line -...
133
}
-
 
134
 
-
 
135
dword GetDiskSize(dword disk_n)
-
 
136
{
-
 
137
	BDVK bdvk;
-
 
138
	char tmp_path[8];
-
 
139
	strcpy(#tmp_path, "/tmp0/1");
-
 
140
	tmp_path[4] = disk_n + '0';
-
 
141
	GetFileInfo(#tmp_path, #bdvk);		
-
 
142
	return bdvk.sizelo;
-
 
143
}
-
 
144
void GetTmpDiskSizes()
-
 
145
{
-
 
146
	char i;
-
 
147
	for (i=0; i<=9; i++)
-
 
148
	{
-
 
149
		tmp_size[i] = GetDiskSize(i) / 1024 / 1024;
-
 
150
	}
-
 
151
}
-
 
152
 
-
 
153
//===================================================//
-
 
154
//                                                   //
-
 
155
//                     MONITORS                      //
-
 
156
//                                                   //
-
 
157
//===================================================//
60
}
158
 
61
 
159
int pos=0;
62
int pos=0;
-
 
63
void MonitorCpu()
160
void MonitorCpu()
64
{
161
{
65
	static dword cpu_stack[1980*3];
Line 162... Line 66...
162
	int i;
66
	int i;
163
	if (!cpu.w) return;
67
	if (!cpu.w) return;
Line 164... Line -...
164
 
-
 
165
	cpu_stack[pos] = GetCpuLoad(cpu.h);
68
 
166
	if (cpu_stack[pos]<=2) || (cpu_stack[pos]>cpu.h) cpu_stack[pos]=2;
69
	cpu_stack[pos] = GetCpuLoad(cpu.h);
Line 167... Line 70...
167
	
70
	if (cpu_stack[pos]<=2) || (cpu_stack[pos]>cpu.h) cpu_stack[pos]=2;
168
	DrawBar(cpu.x+cpu.w-30, cpu.y-25, 30, 20, sc.work);
71
	
169
	sprintf(#param, "%i%%", cpu_stack[pos]);
72
	sprintf(#param, "CPU load %i%%", cpu_stack[pos]);
Line 182... Line 85...
182
		for (i=0; i
85
		for (i=0; i
183
			cpu_stack[i] = cpu_stack[i+1];
86
			cpu_stack[i] = cpu_stack[i+1];
184
		}
87
		}
185
	}
88
	}
186
}
89
}
-
 
90
 
-
 
91
void MonitorRam()
-
 
92
{
-
 
93
	ram.draw_progress(GetFreeRAM()*ram.w/GetTotalRAM());
-
 
94
	sprintf(#param, "RAM usage: %i Mb free of %i Mb", GetFreeRAM()/1024, GetTotalRAM()/1024);
-
 
95
	DrawIconWithText(WIN_PAD, ram.y - 25, 51, #param);
-
 
96
}
187
97