Rev 7362 | Rev 7370 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7362 | Rev 7369 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
2 | * System Monitor |
2 | * System Monitor |
3 | * version 0.7 |
3 | * version 0.85 |
4 | * Author: Leency |
4 | * Author: Leency |
5 | */ |
5 | */ |
Line 6... | Line 6... | ||
6 | 6 | ||
Line 7... | Line 7... | ||
7 | #define MEMSIZE 4096*10 |
7 | #define MEMSIZE 4096*10 |
8 | 8 | ||
- | 9 | #include "../lib/io.h" |
|
Line 9... | Line 10... | ||
9 | #include "../lib/io.h" |
10 | #include "../lib/gui.h" |
10 | #include "../lib/gui.h" |
11 | #include "../lib/fs.h" |
11 | 12 | ||
Line 19... | Line 20... | ||
19 | // // |
20 | // // |
20 | //===================================================// |
21 | //===================================================// |
Line 21... | Line 22... | ||
21 | 22 | ||
22 | #define MIN_PB_BLOCK_W 19 |
23 | #define MIN_PB_BLOCK_W 19 |
23 | #define LOAD_BG 0xFFFfff |
24 | #define LOAD_BG 0xFFFfff |
Line 24... | Line 25... | ||
24 | #define LOAD_ACTIVE 0x4C52FF |
25 | #define LOAD_ACTIVE 0x3887EE |
25 | 26 | ||
26 | struct sensor { |
27 | struct sensor { |
27 | int x,y,w,h; |
28 | int x,y,w,h; |
Line 34... | Line 35... | ||
34 | { |
35 | { |
35 | x=_x+2; |
36 | x=_x+2; |
36 | y=_y; |
37 | y=_y; |
37 | w=_w; |
38 | w=_w; |
38 | h=_h; |
39 | h=_h; |
- | 40 | draw_wrapper(); |
|
39 | } |
41 | } |
Line 40... | Line 42... | ||
40 | 42 | ||
41 | void sensor::draw_wrapper() |
43 | void sensor::draw_wrapper() |
42 | { |
44 | { |
Line 58... | Line 60... | ||
58 | WriteText(-progress_w - calc(strlen(#param)*8)/2 + w+x, h/2-7+y, 0x90, LOAD_ACTIVE, #param); |
60 | WriteText(-progress_w - calc(strlen(#param)*8)/2 + w+x, h/2-7+y, 0x90, LOAD_ACTIVE, #param); |
59 | } |
61 | } |
Line 60... | Line 62... | ||
60 | 62 | ||
61 | //===================================================// |
63 | //===================================================// |
62 | // // |
- | |
63 | // GetSizeDir // |
- | |
64 | // // |
- | |
65 | //===================================================// |
- | |
66 | - | ||
67 | BDVK file_info_dirsize; |
- | |
68 | dword dir_count; |
- | |
69 | dword file_count; |
- | |
70 | dword size_dir; |
- | |
71 | - | ||
72 | void GetDirSizeAndCountFiles(dword way) |
- | |
73 | { |
- | |
74 | dir_count=0; |
- | |
75 | file_count=0; |
- | |
76 | size_dir=0; |
- | |
77 | GetDirSizeAndCountFiles_loop(way); |
- | |
78 | } |
- | |
79 | - | ||
80 | void GetDirSizeAndCountFiles_loop(dword way) |
- | |
81 | { |
- | |
82 | dword dirbuf, fcount, i, filename; |
- | |
83 | dword cur_file; |
- | |
84 | if (dir_exists(way)) |
- | |
85 | { |
- | |
86 | cur_file = malloc(4096); |
- | |
87 | // In the process of recursive descent, memory must be allocated dynamically, |
- | |
88 | // because the static memory -> was a bug !!! But unfortunately pass away to sacrifice speed. |
- | |
89 | GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL); |
- | |
90 | for (i=0; i |
- | |
91 | { |
- | |
92 | filename = i*304+dirbuf+72; |
- | |
93 | sprintf(cur_file,"%s/%s",way,filename); |
- | |
94 | - | ||
95 | if (TestBit(ESDWORD[filename-40], 4) ) |
- | |
96 | { |
- | |
97 | dir_count++; |
- | |
98 | GetDirSizeAndCountFiles_loop(cur_file); |
- | |
99 | } |
- | |
100 | else |
- | |
101 | { |
- | |
102 | GetFileInfo(cur_file, #file_info_dirsize); |
- | |
103 | size_dir += file_info_dirsize.sizelo; |
- | |
104 | file_count++; |
- | |
105 | } |
- | |
106 | } |
- | |
107 | free(cur_file); |
- | |
108 | free(dirbuf); |
- | |
109 | } |
- | |
110 | } |
- | |
111 | - | ||
112 | //===================================================// |
- | |
113 | // // |
64 | // // |
114 | // DATA // |
65 | // DATA // |
115 | // // |
66 | // // |
Line 116... | Line 67... | ||
116 | //===================================================// |
67 | //===================================================// |
Line 121... | Line 72... | ||
121 | sensor cpu; |
72 | sensor cpu; |
122 | sensor ram; |
73 | sensor ram; |
123 | sensor rd; |
74 | sensor rd; |
124 | sensor tmp[10]; |
75 | sensor tmp[10]; |
Line -... | Line 76... | ||
- | 76 | ||
- | 77 | dword tmp_size[10]; |
|
125 | 78 | ||
126 | //===================================================// |
79 | //===================================================// |
127 | // // |
80 | // // |
128 | // CODE // |
81 | // CODE // |
129 | // // |
82 | // // |
Line 139... | Line 92... | ||
139 | 92 | ||
140 | load_dll(libio, #libio_init,1); |
93 | load_dll(libio, #libio_init,1); |
141 | load_dll(libimg, #libimg_init,1); |
94 | load_dll(libimg, #libimg_init,1); |
Line -... | Line 95... | ||
- | 95 | load_dll(libini, #lib_init,1); |
|
- | 96 | ||
142 | load_dll(libini, #lib_init,1); |
97 | GetTmpDiskSizesFromIni(); |
143 | 98 | ||
144 | loop() |
99 | loop() |
145 | { |
100 | { |
146 | WaitEventTimeout(25); |
101 | WaitEventTimeout(25); |
Line 161... | Line 116... | ||
161 | system.color.get(); |
116 | system.color.get(); |
162 | DefineAndDrawWindow(150, 100, CPU_STACK+LEFT+LEFT+4+9, 480 + skin_height + 4, 0x34, system.color.work, "System Monitor",0); |
117 | DefineAndDrawWindow(150, 100, CPU_STACK+LEFT+LEFT+4+9, 480 + skin_height + 4, 0x34, system.color.work, "System Monitor",0); |
163 | GetProcessInfo(#Form, SelfInfo); |
118 | GetProcessInfo(#Form, SelfInfo); |
Line 164... | Line 119... | ||
164 | 119 | ||
165 | y.n = 0; |
- | |
166 | WriteTextB(LEFT+ICONGAP, y.inc(20), 0x90, system.color.work_text, "CPU load"); |
- | |
167 | DrawIcon32(LEFT, y.n, system.color.work, 37); |
- | |
168 | 120 | y.n = 0; |
|
169 | if (cpu_frequency < 1000) sprintf(#param, "CPU frequency: %i Hz", cpu_frequency); |
121 | if (cpu_frequency < 1000) sprintf(#param, "CPU frequency: %i Hz", cpu_frequency); |
170 | else sprintf(#param, "CPU frequency: %i MHz", cpu_frequency/1000); |
122 | else sprintf(#param, "CPU frequency: %i MHz", cpu_frequency/1000); |
171 | WriteText(LEFT+ICONGAP, y.inc(20), 0x90, system.color.work_text, #param); |
123 | DrawBlockHeader(LEFT, y.inc(20), 37, "CPU load", #param); |
172 | cpu.set_size(LEFT, y.inc(25), CPU_STACK, 100); |
- | |
Line 173... | Line -... | ||
173 | cpu.draw_wrapper(); |
- | |
174 | - | ||
175 | WriteTextB(LEFT+ICONGAP, y.inc(cpu.h + 25), 0x90, system.color.work_text, "RAM usage"); |
124 | cpu.set_size(LEFT, y.inc(45), CPU_STACK, 100); |
176 | DrawIcon32(LEFT, y.n, system.color.work, 36); |
125 | |
177 | sprintf(#param, "Total RAM: %i MiB", GetTotalRAM()/1024); |
126 | sprintf(#param, "Total RAM: %i MiB", GetTotalRAM()/1024); |
178 | WriteText(LEFT+ICONGAP, y.inc(20), 0x90, system.color.work_text, #param); |
- | |
179 | ram.set_size(LEFT, y.inc(25), CPU_STACK, 25); |
127 | DrawBlockHeader(LEFT, y.inc(cpu.h + 25), 36, "RAM usage", #param); |
180 | ram.draw_wrapper(); |
- | |
181 | - | ||
182 | WriteTextB(LEFT+ICONGAP, y.inc(ram.h + 25), 0x90, system.color.work_text, "System RAM Disk usage"); |
128 | ram.set_size(LEFT, y.inc(45), CPU_STACK, 23); |
183 | DrawIcon32(LEFT, y.n, system.color.work, 3); |
129 | |
184 | WriteText(LEFT+ICONGAP, y.inc(20), 0x90, system.color.work_text, "Fixed size: 1.44 MiB"); |
- | |
185 | rd.set_size(LEFT, y.inc(25), CPU_STACK, 25); |
130 | DrawBlockHeader(LEFT, y.inc(ram.h + 25), 3, "System RAM Disk usage", "Fixed size: 1.44 MiB"); |
186 | rd.draw_wrapper(); |
- | |
187 | 131 | rd.set_size(LEFT, y.inc(45), CPU_STACK, 23); |
|
188 | WriteTextB(LEFT+ICONGAP, y.inc(ram.h + 25), 0x90, system.color.work_text, "Virtual drive usage"); |
132 | |
189 | DrawIcon32(LEFT, y.n, system.color.work, 50); |
133 | sprintf(#param, "TMP Disk 0 size: %i MiB", tmp_size[0]); |
190 | WriteText(LEFT+ICONGAP, y.inc(20), 0x90, system.color.work_text, "TMP Disk 0 size: 49 MiB"); |
- | |
Line 191... | Line 134... | ||
191 | tmp[0].set_size(LEFT, y.inc(25), CPU_STACK, 25); |
134 | DrawBlockHeader(LEFT, y.inc(rd.h + 25), 50, "Virtual drive usage", #param); |
192 | tmp[0].draw_wrapper(); |
135 | tmp[0].set_size(LEFT, y.inc(45), CPU_STACK, 23); |
Line 193... | Line 136... | ||
193 | 136 | ||
Line 199... | Line 142... | ||
199 | GetTotalRAM()-GetFreeRAM()/1024, |
142 | GetTotalRAM()-GetFreeRAM()/1024, |
200 | GetFreeRAM()/1024, |
143 | GetFreeRAM()/1024, |
201 | "M" |
144 | "M" |
202 | ); |
145 | ); |
Line 203... | Line 146... | ||
203 | 146 | ||
- | 147 | dir_size.get("/rd/1"); |
|
204 | GetDirSizeAndCountFiles("/rd/1"); |
148 | |
205 | size_dir += 32*512; //add FAT table size |
- | |
206 | size_dir += file_count*512/2; //add MAGIC NUMBER |
149 | dir_size.bytes += dir_size.files/2 + 32 * 512; //file attr size + FAT table size |
207 | size_dir /= 1024; //convert to KiB |
150 | dir_size.bytes /= 1024; //convert to KiB |
208 | size_dir= 1440 - size_dir; |
151 | dir_size.bytes = 1440 - dir_size.bytes; |
209 | rd.draw_progress( |
152 | rd.draw_progress( |
210 | size_dir*rd.w/1440, |
153 | dir_size.bytes*rd.w/1440, |
211 | 1440-size_dir, |
154 | 1440 - dir_size.bytes, |
212 | size_dir, |
155 | dir_size.bytes, |
213 | "K" |
156 | "K" |
Line 214... | Line 157... | ||
214 | ); |
157 | ); |
215 | 158 | ||
216 | GetDirSizeAndCountFiles("/tmp0/1"); |
159 | if (tmp_size[0]) { |
217 | size_dir += 32*512; //add FAT table size |
160 | dir_size.get("/tmp0/1"); |
218 | size_dir += file_count*512/2; //add MAGIC NUMBER |
161 | dir_size.bytes += dir_size.files/2 + 32 * 512; //file attr size + FAT table size |
219 | size_dir /= 1024*1024; //convert to MiB |
162 | dir_size.bytes /= 1024*1024; //convert to MiB |
220 | size_dir= 49 - size_dir; |
163 | dir_size.bytes= tmp_size[0] - dir_size.bytes; |
221 | tmp[0].draw_progress( |
164 | tmp[0].draw_progress( |
222 | size_dir*tmp[0].w/49, |
165 | dir_size.bytes*tmp[0].w/tmp_size[0], |
223 | 49-size_dir, |
166 | tmp_size[0] - dir_size.bytes, |
224 | size_dir, |
167 | dir_size.bytes, |
225 | "M" |
168 | "M" |
226 | ); |
169 | ); |
227 | } |
170 | } |
- | 171 | } |
|
- | 172 | } |
|
- | 173 | } |
|
- | 174 | ||
- | 175 | void DrawBlockHeader(dword _x, _y, _icon, _title, _subtitle) |
|
- | 176 | { |
|
- | 177 | WriteTextB(_x+ICONGAP, _y, 0x90, system.color.work_text, _title); |
|
- | 178 | DrawIcon32(_x, _y, system.color.work, _icon); |
|
Line 228... | Line 179... | ||
228 | } |
179 | WriteText(_x+ICONGAP, _y+20, 0x90, system.color.work_text, _subtitle); |
229 | } |
180 | } |
230 | 181 | ||
231 | dword GetCpuLoad(dword max_h) |
182 | dword GetCpuLoad(dword max_h) |
Line 241... | Line 192... | ||
241 | idle = EAX; |
192 | idle = EAX; |
Line 242... | Line 193... | ||
242 | 193 | ||
243 | return max_h - idle; |
194 | return max_h - idle; |
Line -... | Line 195... | ||
- | 195 | } |
|
- | 196 | ||
- | 197 | _ini ini = { "/sys/settings/system.ini", "DiskSizes" }; |
|
- | 198 | void GetTmpDiskSizesFromIni() |
|
- | 199 | { |
|
- | 200 | char i, key[2]; |
|
- | 201 | key[1]=0; |
|
- | 202 | for (i=0; i<=9; i++) |
|
- | 203 | { |
|
- | 204 | key[0]=i+'0'; |
|
- | 205 | tmp_size[i] = ini.GetInt(#key, 0) / 1024 / 1024; |
|
- | 206 | } |
|
244 | } |
207 | } |
245 | 208 | ||
246 | //===================================================// |
209 | //===================================================// |
247 | // // |
210 | // // |
248 | // MONITORS // |
211 | // MONITORS // |