From 270aed5ffac974e129c447347aeb39e3518538c0 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Sun, 29 Nov 2020 00:37:47 +0000 Subject: [PATCH] SYSMON 1.3: better UI, added Rus translation git-svn-id: svn://kolibrios.org@8277 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/sysmon/compile_en.bat | 4 + programs/cmm/sysmon/compile_ru.bat | 9 + programs/cmm/sysmon/cpu_ram.h | 96 -------- programs/cmm/sysmon/drives.h | 72 ------ programs/cmm/sysmon/process.h | 150 ------------ programs/cmm/sysmon/sysmon.c | 362 ++++++++++++++++++++++++----- 6 files changed, 322 insertions(+), 371 deletions(-) create mode 100644 programs/cmm/sysmon/compile_ru.bat delete mode 100644 programs/cmm/sysmon/cpu_ram.h delete mode 100644 programs/cmm/sysmon/drives.h delete mode 100644 programs/cmm/sysmon/process.h diff --git a/programs/cmm/sysmon/compile_en.bat b/programs/cmm/sysmon/compile_en.bat index 3f02ca741b..03e553dc0e 100644 --- a/programs/cmm/sysmon/compile_en.bat +++ b/programs/cmm/sysmon/compile_en.bat @@ -1,5 +1,9 @@ +@del lang.h-- +@echo #define LANG_ENG 1 >lang.h-- + @del sysmon @c-- sysmon.c @rename sysmon.com sysmon @del warning.txt +@del lang.h-- @pause \ No newline at end of file diff --git a/programs/cmm/sysmon/compile_ru.bat b/programs/cmm/sysmon/compile_ru.bat new file mode 100644 index 0000000000..f47286eaad --- /dev/null +++ b/programs/cmm/sysmon/compile_ru.bat @@ -0,0 +1,9 @@ +@del lang.h-- +@echo #define LANG_RUS 1 >lang.h-- + +@del sysmon +@c-- sysmon.c +@rename sysmon.com sysmon +@del warning.txt +@del lang.h-- +@pause \ No newline at end of file diff --git a/programs/cmm/sysmon/cpu_ram.h b/programs/cmm/sysmon/cpu_ram.h deleted file mode 100644 index 614041eda0..0000000000 --- a/programs/cmm/sysmon/cpu_ram.h +++ /dev/null @@ -1,96 +0,0 @@ -//===================================================// -// // -// 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) { - pos = WIN_CONTENT_W-1; - for (i=0; i2) return false; - //if (Form.width < 300) { MoveSize(OLD,OLD,300,OLD); break; } - //if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); break; } - tabs.draw(); - return true; -} +int current_process_id = 0; +int proc_list[256]; -int Sysmon__ButtonEvent() -{ - int bid = GetButtonID(); - if (1==bid) ExitProcess(); - tabs.click(); - return bid; -} +checkbox show_system = { T_SHOW_SYSTEM, false }; -void Sysmon__KeyEvent() -{ - GetKeys(); - if (key_scancode == SCAN_CODE_ESC) ExitProcess(); -} +sensor cpu; +sensor ram; +sensor rd; +sensor tmp; -#include "cpu_ram.h" -#include "drives.h" -#include "process.h" +proc_info Form; -void main() +int right_w; + +//===================================================// +// // +// CODE // +// // +//===================================================// + +void load_lib() { 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); +} + +void main() +{ + int btn; + //dword cpu_frequency = GetCpuFrequency()/1000; + load_lib(); + SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); + loop() switch(@WaitEventTimeout(120)) + { + case evMouse: + SelectList_ProcessMouse(); + break; + case evKey: + GetKeys(); + if (key_scancode == SCAN_CODE_ESC) ExitProcess(); + if (key_scancode == SCAN_CODE_DEL) EventKillCurrentProcess(); + if (select_list.ProcessKey(key_scancode)) SelectList_LineChanged(); + break; + case evButton: + btn = GetButtonID(); + if (1==btn) ExitProcess(); + + if (show_system.click(btn)) { + SelectList_LineChanged(); + } + if (BTN_ID_PROC_KILL == btn) { + EventKillCurrentProcess(); + } + if (BTN_ID_PROC_INFO == btn) { + io.run("/sys/tinfo", itoa(GetProcessSlot(current_process_id))); + } + break; + case evReDraw: + sc.get(); + DefineAndDrawWindow(screen.width/2 - 350, 100, 700, 490, 0x33, sc.work, T_APP_TITLE,0); + GetProcessInfo(#Form, SelfInfo); + if (Form.status_window>2) break; + if (Form.width < RIGHT_X+370) { MoveSize(OLD,OLD,RIGHT_X+370,OLD); break; } + if (Form.height < 420) { MoveSize(OLD,OLD,OLD,420); break; } + right_w = Form.cwidth - RIGHT_X - GAP; + right_w &= ~1; // make sure the number is even + WriteText(GAP+5, WIN_CONTENT_Y-20, 0x90, sc.work_text, T_PROC_HEADER); + + //bool burger_active = false; + //if (menu_id == OPEN_FILE) burger_active = true; + //DrawTopPanelButton(BTN_ID_MENU, Form.cwidth-GAP-3, GAP, -1, burger_active); + + SelectList_Init(GAP, WIN_CONTENT_Y, PROCESS_LIST_W, + Form.cheight-BOTPANEL_H-WIN_CONTENT_Y, false); + SelectList_DrawBorder(); + + DrawBar(select_list.x-2, select_list.y+select_list.h+2, + select_list.w+scroll1.size_x+4, BOTPANEL_H, sc.work); + DrawCaptButton(PROCESS_LIST_W+GAP-110+18, select_list.y+select_list.h+5, + 110,23,BTN_ID_PROC_KILL,0xF38181, 0xFFFfff, T_PROC_KILL); + DrawCaptButton(PROCESS_LIST_W+GAP-165+18, select_list.y+select_list.h+5, + 46,23,BTN_ID_PROC_INFO,sc.button, sc.button_text, T_PROC_INFO); + show_system.draw(GAP-1, select_list.y+select_list.h+10); + + //WriteText(RIGHT_X, WIN_CONTENT_Y+25, 0x90, sc.work, "Update period: 5 seconds"); + cpu.set_size(RIGHT_X, WIN_CONTENT_Y+25, right_w, 100); + ram.set_size(RIGHT_X, WIN_CONTENT_Y+170, right_w, 23); + rd.set_size(RIGHT_X, WIN_CONTENT_Y+240, right_w, 23); + default: + SelectList_LineChanged(); + MonitorCpu(); + MonitorRam(); + MonitorRd(); + MonitorTmp(); + } +} + +void EventKillCurrentProcess() +{ + KillProcess(current_process_id); + pause(10); + SelectList_LineChanged(); +} + +void Processes__GetProcessList() +{ + int i, j; + proc_info Process; + + select_list.count=0; + for (i=0; i> 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, T_CPU_LOAD, cpu_stack[pos]); + DrawIconWithText(RIGHT_X, cpu.y - 25, 48, #param); + + for (i=0; i=right_w) { + pos = right_w-1; + for (i=0; i