/programs/cmm/sysmon/general.h |
---|
File deleted |
/programs/cmm/sysmon/cpu_ram.h |
---|
0,0 → 1,96 |
//===================================================// |
// // |
// DATA // |
// // |
//===================================================// |
sensor cpu; |
sensor ram; |
//===================================================// |
// // |
// CODE // |
// // |
//===================================================// |
void DrawIconWithText(dword _x, _y, _icon, _title) |
{ |
DrawIcon16(_x, _y, sc.work, _icon); |
DrawBar(_x+ICONGAP, _y, WIN_CONTENT_W - ICONGAP - _x, 20, sc.work); |
WriteText(_x+ICONGAP, _y, 0x90, sc.work_text, _title); |
} |
void CPUnRAM__Main() |
{ |
dword cpu_frequency = GetCpuFrequency()/1000; |
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON); |
goto _GENERAL_REDRAW_2; |
loop() |
{ |
WaitEventTimeout(25); |
switch(EAX & 0xFF) |
{ |
case evButton: Sysmon__ButtonEvent(); break; |
case evKey: Sysmon__KeyEvent(); break; |
case evReDraw: |
_GENERAL_REDRAW_2: |
Sysmon__DefineAndDrawWindow(); |
cpu.set_size(WIN_PAD, WIN_CONTENT_Y+25, WIN_CONTENT_W, 100); |
ram.set_size(WIN_PAD, WIN_CONTENT_Y+170, WIN_CONTENT_W, 23); |
default: |
MonitorCpu(); |
MonitorRam(); |
} |
} |
} |
dword GetCpuLoad(dword max_h) |
{ |
dword idle; |
dword CPU_SEC = GetCpuFrequency() >> 20 + 1; |
dword IDLE_SEC = GetCpuIdleCount() >> 20 * max_h; |
EAX = IDLE_SEC; |
EBX = CPU_SEC; |
$cdq |
$div ebx |
idle = EAX; |
return max_h - idle; |
} |
int pos=0; |
void MonitorCpu() |
{ |
static dword cpu_stack[1980*3]; |
int i; |
if (!cpu.w) return; |
cpu_stack[pos] = GetCpuLoad(cpu.h); |
if (cpu_stack[pos]<=2) || (cpu_stack[pos]>cpu.h) cpu_stack[pos]=2; |
sprintf(#param, "CPU load %i%%", cpu_stack[pos]); |
DrawIconWithText(WIN_PAD, cpu.y - 25, 48, #param); |
for (i=0; i<WIN_CONTENT_W; i+=2) { |
DrawBar(i+cpu.x, cpu.y, 1, cpu.h-cpu_stack[i], PROGRESS_BG); |
DrawBar(i+cpu.x, cpu.h-cpu_stack[i]+cpu.y, 1, cpu_stack[i], LOAD_CPU); |
DrawBar(i+1+cpu.x, cpu.y, 1, cpu.h, PROGRESS_BG); |
} |
pos++; |
if (pos>=WIN_CONTENT_W) { |
pos = WIN_CONTENT_W-1; |
for (i=0; i<pos; i++) { |
cpu_stack[i] = cpu_stack[i+1]; |
} |
} |
} |
void MonitorRam() |
{ |
ram.draw_progress(GetFreeRAM()*ram.w/GetTotalRAM()); |
sprintf(#param, "RAM usage: %i Mb free of %i Mb", GetFreeRAM()/1024, GetTotalRAM()/1024); |
DrawIconWithText(WIN_PAD, ram.y - 25, 51, #param); |
} |
/programs/cmm/sysmon/process.h |
---|
32,9 → 32,9 |
void Processes__Main() |
{ |
int btn; |
maxcpu = GetCpuFrequency(); |
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); |
maxcpu = GetCpuFrequency(); |
goto _PROCESS_REDRAW; |
goto _PROCESS_REDRAW_3; |
loop() |
{ |
WaitEventTimeout(50); |
44,35 → 44,31 |
SelectList_ProcessMouse(); |
break; |
case evKey: |
GetKeys(); |
Sysmon__KeyEvent(); |
if (select_list.ProcessKey(key_scancode)) SelectList_LineChanged(); |
break; |
case evButton: |
btn = GetButtonID(); |
Sysmon__ButtonEvent(btn); |
btn = Sysmon__ButtonEvent(); |
if (show_system.click(btn)) |
{ |
if (show_system.click(btn)) { |
SelectList_LineChanged(); |
} |
if (BTN_ID_KILL_PROCESS == btn) |
{ |
if (BTN_ID_KILL_PROCESS == btn) { |
KillProcess(current_process_id); |
pause(10); |
SelectList_LineChanged(); |
} |
if (BTN_ID_SHOW_PROCESS_INFO == btn) |
{ |
if (BTN_ID_SHOW_PROCESS_INFO == btn) { |
io.run("/sys/tinfo", itoa(GetProcessSlot(current_process_id))); |
} |
break; |
case evReDraw: |
_PROCESS_REDRAW: |
_PROCESS_REDRAW_3: |
if (!Sysmon__DefineAndDrawWindow()) break; |
SelectList_Init(WIN_PAD, WIN_CONTENT_Y, |
WIN_CONTENT_W-scroll1.size_x, |
WIN_CONTENT_H-BOTPANEL_H-TAB_HEIGHT, false); |
WIN_CONTENT_H-BOTPANEL_H-WIN_CONTENT_Y, false); |
SelectList_DrawBorder(); |
//DrawWideRectangle(0, 0, Form.cwidth, Form.cheight, 4, sc.work); |
/programs/cmm/sysmon/sysmon.c |
---|
1,6 → 1,6 |
/* |
* System Monitor |
* version 0.87 |
* version 1.0 |
* Author: Leency |
*/ |
33,65 → 33,89 |
#define WIN_PAD 20 //Window padding |
#define WIN_CONTENT_X WIN_PAD |
#define WIN_CONTENT_Y TAB_HEIGHT+WIN_PAD |
#define WIN_CONTENT_Y TAB_HEIGHT+WIN_PAD+20 |
#define WIN_CONTENT_W 400 |
#define WIN_CONTENT_H 465 |
#define ICONGAP 26 |
proc_info Form; |
#include "general.h" |
#include "process.h" |
#define T_GENERAL "General" |
#ifdef LANG_RUS |
#define T_CPU_AND_RAM "à®æ¥áá®à ¨ " |
#define T_DRIVES "¨áª¨" |
#define T_PROCESSES "à®æ¥ááë" |
#define T_APP_TITLE "System Monitor" |
#else |
#define T_CPU_AND_RAM "CPU & RAM" |
#define T_DRIVES "Drives" |
#define T_PROCESSES "Processes" |
#define T_APP_TITLE "System Monitor" |
#endif |
enum { |
TAB_GENERAL=20, |
TAB_DRIVES, |
TAB_PROCESSES |
}; |
_tabs tabs = { TAB_GENERAL, 4, 0, WIN_CONTENT_W+WIN_PAD+WIN_PAD-4-4, TAB_HEIGHT }; |
void main() |
{ |
load_dll(libio, #libio_init,1); |
load_dll(libimg, #libimg_init,1); |
load_dll(libini, #lib_init,1); |
load_dll(boxlib, #box_lib_init,0); |
General__Main(); |
} |
_tabs tabs = { TAB_GENERAL, 4, 10, WIN_CONTENT_W+WIN_PAD+WIN_PAD-4-4, TAB_HEIGHT }; |
//===================================================// |
// // |
// GENERAL EVENTS // |
// // |
//===================================================// |
int Sysmon__DefineAndDrawWindow() |
{ |
dword butx; |
sc.get(); |
DefineAndDrawWindow(screen.width - WIN_CONTENT_H - 200, 100, WIN_CONTENT_W + WIN_PAD + WIN_PAD +9, |
WIN_CONTENT_H + TAB_HEIGHT + skin_height + 4, 0x34, sc.work, "System Monitor",0); |
WIN_CONTENT_H + TAB_HEIGHT + skin_height + 4, 0x34, sc.work, T_APP_TITLE,0); |
GetProcessInfo(#Form, SelfInfo); |
if (Form.status_window>2) return false; |
//if (Form.width < 300) { MoveSize(OLD,OLD,300,OLD); break; } |
//if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); break; } |
tabs.draw_wrapper(); |
tabs.draw_button(tabs.x+TAB_PADDING, TAB_GENERAL, T_GENERAL); |
tabs.draw_button(strlen(T_GENERAL)*8+tabs.x+TAB_PADDING+TAB_PADDING, TAB_PROCESSES, T_PROCESSES); |
butx = tabs.draw_button(tabs.x+TAB_PADDING, TAB_GENERAL, T_CPU_AND_RAM); |
butx = tabs.draw_button(strlen(T_CPU_AND_RAM)*8+TAB_PADDING+butx, TAB_DRIVES, T_DRIVES); |
tabs.draw_button(strlen(T_DRIVES)*8+TAB_PADDING+butx, TAB_PROCESSES, T_PROCESSES); |
return true; |
} |
//===================================================// |
// // |
// EVENTS // |
// // |
//===================================================// |
void Sysmon__ButtonEvent(dword id) |
int Sysmon__ButtonEvent() |
{ |
if (1==id) ExitProcess(); |
if (TAB_GENERAL==id) { |
int bid = GetButtonID(); |
if (1==bid) ExitProcess(); |
if (TAB_GENERAL==bid) { |
tabs.active_tab = TAB_GENERAL; |
General__Main(); |
CPUnRAM__Main(); |
} |
if (TAB_PROCESSES==id) { |
if (TAB_PROCESSES==bid) { |
tabs.active_tab = TAB_PROCESSES; |
Processes__Main(); |
} |
if (TAB_DRIVES==bid) { |
tabs.active_tab = TAB_DRIVES; |
Drives__Main(); |
} |
return bid; |
} |
void Sysmon__KeyEvent() |
{ |
GetKeys(); |
if (key_scancode == SCAN_CODE_ESC) ExitProcess(); |
} |
stop: |
#include "cpu_ram.h" |
#include "drives.h" |
#include "process.h" |
void main() |
{ |
load_dll(libio, #libio_init,1); |
load_dll(libimg, #libimg_init,1); |
load_dll(libini, #lib_init,1); |
load_dll(boxlib, #box_lib_init,0); |
CPUnRAM__Main(); |
} |