sysmon: add process tab

git-svn-id: svn://kolibrios.org@7614 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2019-03-18 22:31:13 +00:00
parent c89576f170
commit 6af7c83564
13 changed files with 323 additions and 295 deletions

View File

@ -142,7 +142,7 @@ lif=14
3ds=15 3ds=15
asc=15 asc=15
vox=15 vox=15
tls=15 stl=15
kex=16 kex=16
skn=17 skn=17
obj=18 obj=18
@ -225,4 +225,4 @@ djvu=85
csv=28 csv=28
rft=85 rft=85
lif=13 lif=13
tls=78 stl=78

View File

@ -153,7 +153,9 @@ void EventManualSearch()
void EventOpenApp() void EventOpenApp()
{ {
RunProgram("syspanel", APP_PLUS_INI_PATH); if (RunProgram("/sys/syspanel", APP_PLUS_INI_PATH) < 0) {
notify("'App+ can not be started because\n/sys/syspanel does not exists' -E");
}
} }
void EventButton(dword id) void EventButton(dword id)

View File

@ -19,6 +19,8 @@
#include "..\lib\patterns\select_list.h" #include "..\lib\patterns\select_list.h"
#include "..\lib\patterns\simple_open_dialog.h" #include "..\lib\patterns\simple_open_dialog.h"
#include "ui_elements_preview.h"
//===================================================// //===================================================//
// // // //
// DATA // // DATA //
@ -69,17 +71,9 @@ int cur;
proc_info Form; proc_info Form;
block skp; block skp;
_tabs tabs = { LP, LP, NULL, NULL, SKINS }; _tabs tabs = { SKINS, LP, LP, NULL, NULL };
checkbox update_docky = { T_UPDATE_DOCK, false }; checkbox update_docky = { T_UPDATE_DOCK, false };
checkbox checkbox1 = { "Checkbox", true };
more_less_box spinbox1 = { 23, 0, 999, "SpinBox" };
edit_box edit_cmm = {180,NULL,NULL,0xffffff,0x94AECE,0xFFFfff,0xffffff,
0x10000000,sizeof(param)-2,#param,0, 0b};
char st_str[16];
edit_box edit_st = {180,NULL,NULL,0xffffff,0x94AECE,0xFFFfff,0xffffff,
0x10000000,sizeof(st_str)-2,#st_str,0, 0b};
char default_dir[] = "/rd/1"; char default_dir[] = "/rd/1";
od_filter filter2 = { 8, "TXT\0\0" }; od_filter filter2 = { 8, "TXT\0\0" };
@ -191,7 +185,8 @@ void main()
void draw_window() void draw_window()
{ {
DefineAndDrawWindow(screen.width-600/2,80,630,504+skin_height,0x74,NULL,WINDOW_HEADER,0); system.color.get();
DefineAndDrawWindow(screen.width-600/2,80,630,504+skin_height,0x34,system.color.work,WINDOW_HEADER,0);
GetProcessInfo(#Form, SelfInfo); GetProcessInfo(#Form, SelfInfo);
IF (Form.status_window>=2) return; IF (Form.status_window>=2) return;
DrawWindowContent(); DrawWindowContent();
@ -200,19 +195,15 @@ void draw_window()
void DrawWindowContent() void DrawWindowContent()
{ {
int id; int id;
incn y;
int list_w; int list_w;
system.color.get(); system.color.get();
if (tabs.active_tab == SKINS) list_w=250; else list_w=350; if (tabs.active_tab == SKINS) list_w=250; else list_w=350;
DrawWideRectangle(0, 0, Form.cwidth, Form.cheight, LP, system.color.work);
tabs.w = Form.cwidth-LP-LP; tabs.w = Form.cwidth-LP-LP;
tabs.h = Form.cheight-LP-LP; tabs.h = Form.cheight-LP-LP;
tabs.draw_wrapper(); tabs.draw_wrapper();
tabs.draw_button(tabs.x+TAB_PADDING, SKINS, T_SKINS); tabs.draw_button(tabs.x+TAB_PADDING, SKINS, T_SKINS);
tabs.draw_button(strlen(T_SKINS)*8+tabs.x+TAB_PADDING+TAB_PADDING, WALLPAPERS, T_WALLPAPERS); tabs.draw_button(strlen(T_SKINS)*8+tabs.x+TAB_PADDING+TAB_PADDING, WALLPAPERS, T_WALLPAPERS);
@ -235,46 +226,24 @@ void DrawWindowContent()
SelectList_Draw(); SelectList_Draw();
SelectList_DrawBorder(); SelectList_DrawBorder();
//DrawWideRectangle(0, 0, Form.cwidth, Form.cheight, LP, system.color.work);
if (tabs.active_tab == SKINS) if (tabs.active_tab == SKINS)
{ {
DrawBar(skp.x-20, select_list.y, skp.w+40, select_list.h, system.color.work);
DrawRectangle(skp.x-20, select_list.y, skp.w+40, select_list.h, system.color.work_graph);
update_docky.draw(skp.x, select_list.y+15); update_docky.draw(skp.x, select_list.y+15);
y.n = skp.y;
DrawFrame(skp.x, skp.y, skp.w, skp.h, " Components Preview "); DrawFrame(skp.x, skp.y, skp.w, skp.h, " Components Preview ");
spinbox1.draw(skp.x+20, y.inc(30)); DrawUiElementsPreview(skp.x+20, skp.y, skp.h);
WriteText(skp.x+20, y.inc(30), 0x90, system.color.work_text, "C-- Edit");
DrawEditBoxPos(skp.x+20, y.inc(20), #edit_cmm);
WriteText(skp.x+20, y.inc(35), 0x90, system.color.work_text, "Strandard Edit");
DrawStEditBoxPos(skp.x+20, y.inc(20), #edit_st);
DrawStandartCaptButton(skp.x+20, skp.y+skp.h-40, GetFreeButtonId(), "Button1");
DrawStandartCaptButton(skp.x+120, skp.y+skp.h-40, GetFreeButtonId(), "Button2");
} }
if (tabs.active_tab == WALLPAPERS) if (tabs.active_tab == WALLPAPERS)
{ {
skp.x -= TAB_PADDING + 3; skp.x -= TAB_PADDING + 3;
DrawStandartCaptButton(skp.x, select_list.y, BTN_SELECT_WALLP_FOLDER, T_SELECT_FOLDER); DrawStandartCaptButton(skp.x, select_list.y, BTN_SELECT_WALLP_FOLDER, T_SELECT_FOLDER);
DrawBar(skp.x, select_list.y+50, 180, 80, system.color.work);
DrawFrame(skp.x, select_list.y+50, 180, 80, T_PICTURE_MODE); DrawFrame(skp.x, select_list.y+50, 180, 80, T_PICTURE_MODE);
optionbox_stretch.draw(skp.x+14, select_list.y+70); optionbox_stretch.draw(skp.x+14, select_list.y+70);
optionbox_tiled.draw(skp.x+14, select_list.y+97); optionbox_tiled.draw(skp.x+14, select_list.y+97);
} }
} }
:void DrawStEditBoxPos(dword x,y, edit_box_pointer)
{
dword c_inactive = MixColors(system.color.work_graph, system.color.work, 128);
dword c_active = MixColors(system.color.work_graph, 0, 128);
ESI = edit_box_pointer;
ESI.edit_box.left = x;
ESI.edit_box.top = y;
ESI.edit_box.blur_border_color = c_inactive;
ESI.edit_box.focus_border_color = c_active;
edit_box_draw stdcall (edit_box_pointer);
}
void Open_Dir() void Open_Dir()
{ {
@ -356,7 +325,7 @@ void EventTabClick(int N)
select_list.cur_y = active_wallpaper; select_list.cur_y = active_wallpaper;
} }
if (select_list.cur_y>select_list.visible) select_list.first=select_list.cur_y; select_list.CheckDoesValuesOkey(); if (select_list.cur_y>select_list.visible) select_list.first=select_list.cur_y; select_list.CheckDoesValuesOkey();
if (select_list.w) DrawWindowContent(); if (select_list.w) draw_window();
} }
void EventDeleteFile() void EventDeleteFile()

View File

@ -0,0 +1,34 @@
checkbox checkbox1 = { "Checkbox", true };
more_less_box spinbox1 = { 23, 0, 999, "SpinBox" };
edit_box edit_cmm = {180,NULL,NULL,0xffffff,0x94AECE,0xFFFfff,0xffffff,
0x10000000,sizeof(param)-2,#param,0, 0b};
char st_str[16];
edit_box edit_st = {180,NULL,NULL,0xffffff,0x94AECE,0xFFFfff,0xffffff,
0x10000000,sizeof(st_str)-2,#st_str,0, 0b};
void DrawUiElementsPreview(dword x,y,h)
{
incn y2;
y2.n = y;
spinbox1.draw(x, y2.inc(30));
WriteText(x, y2.inc(30), 0x90, system.color.work_text, "C-- Edit");
DrawEditBoxPos(x, y2.inc(20), #edit_cmm);
WriteText(x, y2.inc(35), 0x90, system.color.work_text, "Strandard Edit");
DrawStEditBoxPos(x, y2.inc(20), #edit_st);
DrawStandartCaptButton(x, y+h-40, GetFreeButtonId(), "Button1");
DrawStandartCaptButton(x+100, y+h-40, GetFreeButtonId(), "Button2");
}
:void DrawStEditBoxPos(dword x,y, edit_box_pointer)
{
dword c_inactive = MixColors(system.color.work_graph, system.color.work, 128);
dword c_active = MixColors(system.color.work_graph, 0, 128);
ESI = edit_box_pointer;
ESI.edit_box.left = x;
ESI.edit_box.top = y;
ESI.edit_box.blur_border_color = c_inactive;
ESI.edit_box.focus_border_color = c_active;
edit_box_draw stdcall (edit_box_pointer);
}

View File

@ -1,5 +1,5 @@
@del "kf_view"
@C-- "font_viewer.c" @C-- "font_viewer.c"
@del "font_viewer" @rename "font_viewer.com" "kf_view"
@rename "font_viewer.com" "font_viewer"
@del warning.txt @del warning.txt
@pause @pause

View File

@ -12,7 +12,7 @@ enum {
PHRASE_TAB=20, CHARS_TAB PHRASE_TAB=20, CHARS_TAB
}; };
_tabs tabs = { 0,0, WIN_W, WIN_H, PHRASE_TAB}; _tabs tabs = { PHRASE_TAB };
block preview = { 0, PANELH, WIN_W, WIN_H - PANELH }; block preview = { 0, PANELH, WIN_W, WIN_H - PANELH };
checkbox bold = { "Bold", false }; checkbox bold = { "Bold", false };

View File

@ -4,9 +4,8 @@
:struct _tabs :struct _tabs
{ {
int x,y,w,h;
int active_tab; int active_tab;
int c; int x,y,w,h;
void draw_button(); void draw_button();
int click(); int click();
void draw_wrapper(); void draw_wrapper();
@ -14,20 +13,8 @@
:void _tabs::draw_wrapper() :void _tabs::draw_wrapper()
{ {
dword color_light = MixColors(system.color.work, 0xFFFfff, 40); DrawRectangle(x,y+TAB_HEIGHT,w-1,h-TAB_HEIGHT, system.color.work_graph);
dword color_content = MixColors(system.color.work, 0xFFFfff, 120); DrawRectangle(x+1,y+1+TAB_HEIGHT,w-3,h-2-TAB_HEIGHT, system.color.work_light);
dword color_light_border = MixColors(system.color.work, system.color.work_graph, 120);
DrawRectangle(x-1, y-1, w+1, h+1, system.color.work_graph);
DrawBar(x, y, w, h, color_content); //0xF3F3F3
DrawRectangle3D(x, y, w-1, h-1, color_light, color_content); //0xF3F3F3
DrawBar(x+1, y+h+1, w-2, 2, system.color.work_dark); //"shadow"
DrawBar(x, y+TAB_HEIGHT-1, w, 1, color_light_border);
DrawBar(x, y+TAB_HEIGHT, w, 1, color_light);
c = y + TAB_HEIGHT;
} }
:void _tabs::draw_button(dword xx, but_id, text) :void _tabs::draw_button(dword xx, but_id, text)
@ -38,16 +25,17 @@
if (but_id==active_tab) if (but_id==active_tab)
{ {
col_bg=0xE44C9C; col_bg=0xE44C9C;
col_text=0x000000; col_text=system.color.work_text;
} }
else else
{ {
col_bg=0xC3A1B7; col_bg=0xC3A1B7;
col_text=0x333333; col_text= MixColors(system.color.work, system.color.work_text, 120);
} }
DefineHiddenButton(xx,y, ww-1,hh-1, but_id); DefineHiddenButton(xx-2,y, ww-1+4,hh-1, but_id);
WriteText(xx, y+6, 0x90, col_text, text); WriteText(xx, y+6, 0x90, col_text, text);
DrawBar(xx, y+hh-3, ww, 3, col_bg); DrawBar(xx, y+hh-3, ww, 3, col_bg);
//DrawStandartCaptButton(xx, y, but_id, text); //GetFreeButtonId()
} }
:int _tabs::click(int N) :int _tabs::click(int N)

View File

@ -217,7 +217,7 @@ void MailBoxLoop() {
if (!mailstart) break; if (!mailstart) break;
CreateFile(strlen(mailstart), mailstart, "mail.txt"); CreateFile(strlen(mailstart), mailstart, "mail.txt");
pause(10); pause(10);
RunProgram("tinypad", "mail.txt"); RunProgram("/sys/tinypad", "mail.txt");
} }
if (id==STOP_LOADING) if (id==STOP_LOADING)
{ {

View File

@ -1,6 +0,0 @@
if tup.getconfig("NO_CMM") ~= "" then return end
if tup.getconfig("LANG") == "ru"
then C_LANG = "LANG_RUS"
else C_LANG = "LANG_ENG" -- this includes default case without config
end
tup.rule("process.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "process.com")

View File

@ -1,9 +0,0 @@
@del lang.h--
@echo #define LANG_RUS 1 >lang.h--
C-- process.c
@del process
@rename process.com process
@pause
@del lang.h--
@del warning.txt

View File

@ -0,0 +1,185 @@
//===================================================//
// //
// DATA //
// //
//===================================================//
dword cpu_stack[1980*3];
sensor cpu;
sensor ram;
sensor rd;
sensor tmp[10];
dword tmp_size[10];
//===================================================//
// //
// CODE //
// //
//===================================================//
void General__Main()
{
dword cpu_frequency;
incn y;
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON);
cpu_frequency = GetCpuFrequency()/1000;
GetTmpDiskSizes();
goto _GENERAL_REDRAW;
loop()
{
WaitEventTimeout(25);
switch(EAX & 0xFF)
{
case evButton:
Sysmon__ButtonEvent(GetButtonID());
break;
case evKey:
GetKeys();
if (key_scancode == SCAN_CODE_ESC) ExitProcess();
break;
case evReDraw:
_GENERAL_REDRAW:
if (!Sysmon__DefineAndDrawWindow()) break;
y.n = WIN_CONTENT_Y;
if (cpu_frequency < 1000) sprintf(#param, "CPU frequency: %i Hz", cpu_frequency);
else sprintf(#param, "CPU frequency: %i MHz", cpu_frequency/1000);
DrawBlockHeader(WIN_PAD, y.inc(0), 37, "CPU load", #param);
cpu.set_size(WIN_PAD, y.inc(45), WIN_CONTENT_W, 100);
sprintf(#param, "Total RAM: %i MiB", GetTotalRAM()/1024);
DrawBlockHeader(WIN_PAD, y.inc(cpu.h + 25), 36, "RAM usage", #param);
ram.set_size(WIN_PAD, y.inc(45), WIN_CONTENT_W, 23);
DrawBlockHeader(WIN_PAD, y.inc(ram.h + 25), 3, "System RAM Disk usage", "Fixed size: 1.44 MiB");
rd.set_size(WIN_PAD, y.inc(45), WIN_CONTENT_W, 23);
sprintf(#param, "TMP Disk 0 size: %i MiB", tmp_size[0]);
DrawBlockHeader(WIN_PAD, y.inc(rd.h + 25), 50, "Virtual drive usage", #param);
tmp[0].set_size(WIN_PAD, y.inc(45), WIN_CONTENT_W, 23);
default:
MonitorCpu();
//MonitorRam();
ram.draw_progress(
GetFreeRAM()*ram.w/GetTotalRAM(),
GetTotalRAM()-GetFreeRAM()/1024,
GetFreeRAM()/1024,
"M"
);
DrawBar(ram.x+ram.w-96, ram.y-25, 96, 20, system.color.work);
sprintf(#param, "%i KiB", GetTotalRAM()-GetFreeRAM());
WriteText(ram.x+ram.w-calc(strlen(#param)*8), ram.y-25, 0x90, system.color.work_text, #param);
//MonitorRd();
dir_size.get("/rd/1");
dir_size.bytes += dir_size.files/2 + 32 * 512; //file attr size + FAT table size
dir_size.bytes /= 1024; //convert to KiB
dir_size.bytes = 1440 - dir_size.bytes;
rd.draw_progress(
dir_size.bytes*rd.w/1440,
1440 - dir_size.bytes,
dir_size.bytes,
"K"
);
//MonitorTmp();
if (tmp_size[0]) {
dir_size.get("/tmp0/1");
dir_size.bytes += dir_size.files/2 + 32 * 512; //file attr size + FAT table size
dir_size.bytes /= 1024*1024; //convert to MiB
dir_size.bytes= tmp_size[0] - dir_size.bytes;
tmp[0].draw_progress(
dir_size.bytes*tmp[0].w/tmp_size[0],
tmp_size[0] - dir_size.bytes,
dir_size.bytes,
"M"
);
}
}
}
}
void DrawBlockHeader(dword _x, _y, _icon, _title, _subtitle)
{
#define ICONGAP 45
WriteTextB(_x+ICONGAP, _y, 0x90, system.color.work_text, _title);
DrawIcon32(_x, _y, system.color.work, _icon);
WriteText(_x+ICONGAP, _y+20, 0x90, system.color.work_text, _subtitle);
}
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;
}
dword GetDiskSize(dword disk_n)
{
BDVK bdvk;
char tmp_path[8];
strcpy(#tmp_path, "/tmp0/1");
tmp_path[4] = disk_n + '0';
GetFileInfo(#tmp_path, #bdvk);
return bdvk.sizelo;
}
void GetTmpDiskSizes()
{
char i;
for (i=0; i<=9; i++)
{
tmp_size[i] = GetDiskSize(i) / 1024 / 1024;
}
}
//===================================================//
// //
// MONITORS //
// //
//===================================================//
int pos=0;
void MonitorCpu()
{
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;
DrawBar(cpu.x+cpu.w-30, cpu.y-25, 30, 20, system.color.work);
sprintf(#param, "%i%%", cpu_stack[pos]);
WriteText(cpu.x+cpu.w-calc(strlen(#param)*8), cpu.y-25, 0x90, system.color.work_text, #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];
}
}
}

View File

@ -1,18 +1,3 @@
#define MEMSIZE 4096*20
//===================================================//
// //
// LIB //
// //
//===================================================//
#include "../lib/gui.h"
#include "../lib/list_box.h"
#include "../lib/obj/box_lib.h"
#include "../lib/io.h"
#include "../lib/patterns/select_list.h"
#include "../lib/patterns/restart_process.h"
//===================================================// //===================================================//
// // // //
// DATA // // DATA //
@ -24,13 +9,10 @@
#define T_DETAILS "Details" #define T_DETAILS "Details"
#define T_END_PROCESS "End process" #define T_END_PROCESS "End process"
#define BOTPANEL_H 36
#define BOTPANEL_H 34
proc_info Form;
proc_info Process;
enum { enum {
BTN_ID_SHOW_SYSTEM_PROCESSES=20, BTN_ID_SHOW_SYSTEM_PROCESSES=200,
BTN_ID_KILL_PROCESS, BTN_ID_KILL_PROCESS,
BTN_ID_SHOW_PROCESS_INFO BTN_ID_SHOW_PROCESS_INFO
}; };
@ -47,19 +29,18 @@ checkbox show_system = { T_SHOW_SYSTEM_PROCESSES, false };
// // // //
//===================================================// //===================================================//
void main() void Processes__Main()
{ {
int btn; int btn;
load_dll(boxlib, #box_lib_init,0);
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
maxcpu = GetCpuFrequency(); maxcpu = GetCpuFrequency();
goto _PROCESS_REDRAW;
loop() loop()
{ {
WaitEventTimeout(50); WaitEventTimeout(50);
switch(EAX & 0xFF) switch(EAX & 0xFF)
{ {
case evMouse: case evMouse:
if (!CheckActiveProcess(Form.ID)) break;
SelectList_ProcessMouse(); SelectList_ProcessMouse();
break; break;
case evKey: case evKey:
@ -68,10 +49,8 @@ void main()
break; break;
case evButton: case evButton:
btn = GetButtonID(); btn = GetButtonID();
if (1 == btn) Sysmon__ButtonEvent(btn);
{
ExitProcess();
}
if (show_system.click(btn)) if (show_system.click(btn))
{ {
SelectList_LineChanged(); SelectList_LineChanged();
@ -88,21 +67,21 @@ void main()
} }
break; break;
case evReDraw: case evReDraw:
system.color.get(); _PROCESS_REDRAW:
DefineAndDrawWindow(screen.width-400/2,screen.height-450/2,400,454,0x73,0,T_WINDOW_TITLE,0); if (!Sysmon__DefineAndDrawWindow()) break;
GetProcessInfo(#Form, SelfInfo);
if (Form.status_window>2) break; SelectList_Init(WIN_PAD, WIN_CONTENT_Y,
if (Form.width < 300) { MoveSize(OLD,OLD,300,OLD); break; } WIN_CONTENT_W-scroll1.size_x,
if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); break; } WIN_CONTENT_H-BOTPANEL_H-TAB_HEIGHT, false);
SelectList_Init(6, 6, Form.cwidth-12 - scroll1.size_x, Form.cheight-12-BOTPANEL_H, false);
SelectList_DrawBorder(); SelectList_DrawBorder();
DrawWideRectangle(0, 0, Form.cwidth, Form.cheight, 4, system.color.work);
//DrawWideRectangle(0, 0, Form.cwidth, Form.cheight, 4, system.color.work);
DrawBar(select_list.x-2, select_list.y+select_list.h+2, DrawBar(select_list.x-2, select_list.y+select_list.h+2,
select_list.w+scroll1.size_x+4, BOTPANEL_H, system.color.work); select_list.w+scroll1.size_x+4, BOTPANEL_H, system.color.work);
DrawCaptButton(Form.cwidth-116, DrawCaptButton(Form.cwidth-110-WIN_PAD,
select_list.y+select_list.h+5, select_list.y+select_list.h+5,
110,25,BTN_ID_KILL_PROCESS,0xF38181, 0xFFFfff, T_END_PROCESS); 110,25,BTN_ID_KILL_PROCESS,0xF38181, 0xFFFfff, T_END_PROCESS);
DrawCaptButton(Form.cwidth-236, DrawCaptButton(Form.cwidth-230-WIN_PAD,
select_list.y+select_list.h+5, select_list.y+select_list.h+5,
110,25,BTN_ID_SHOW_PROCESS_INFO, 110,25,BTN_ID_SHOW_PROCESS_INFO,
system.color.work_button, system.color.work_button_text, T_DETAILS); system.color.work_button, system.color.work_button_text, T_DETAILS);
@ -113,16 +92,11 @@ void main()
} }
} }
void SelectList_LineChanged() void Processes__GetProcessList()
{
GetProcessList();
SelectList_Draw();
}
void GetProcessList()
{ {
int i, j; int i, j;
proc_info Process;
select_list.count=0; select_list.count=0;
for (i=0; i<MAX_PROCESS_COUNT; i++) for (i=0; i<MAX_PROCESS_COUNT; i++)
{ {
@ -149,6 +123,8 @@ void SelectList_DrawLine(dword i)
int posy; int posy;
char cpu_use[16]; char cpu_use[16];
dword bg_color; dword bg_color;
proc_info Process;
GetProcessInfo(#Process, proc_list[i+select_list.first]); GetProcessInfo(#Process, proc_list[i+select_list.first]);
posy = i *select_list.item_h + select_list.y; posy = i *select_list.item_h + select_list.y;
@ -165,9 +141,8 @@ void SelectList_DrawLine(dword i)
posy+select_list.text_y, select_list.font_type, 0x444444, #cpu_use); posy+select_list.text_y, select_list.font_type, 0x444444, #cpu_use);
} }
void SelectList_LineChanged()
{
Processes__GetProcessList();
SelectList_Draw();
}
stop:

View File

@ -4,15 +4,26 @@
* Author: Leency * Author: Leency
*/ */
#define MEMSIZE 4096*10 #define MEMSIZE 4096*30
//===================================================//
// //
// LIB //
// //
//===================================================//
#include "../lib/io.h" #include "../lib/io.h"
#include "../lib/gui.h" #include "../lib/gui.h"
#include "../lib/fs.h" #include "../lib/fs.h"
#include "../lib/list_box.h"
#include "../lib/obj/libio.h" #include "../lib/obj/libio.h"
#include "../lib/obj/libimg.h" #include "../lib/obj/libimg.h"
#include "../lib/obj/libini.h" #include "../lib/obj/libini.h"
#include "../lib/obj/box_lib.h"
#include "../lib/patterns/select_list.h"
#include "../lib/patterns/restart_process.h"
//===================================================// //===================================================//
// // // //
@ -20,188 +31,67 @@
// // // //
//===================================================// //===================================================//
#define CPU_STACK 440 #define WIN_PAD 20 //Window padding
dword cpu_stack[CPU_STACK]; #define WIN_CONTENT_X WIN_PAD
#define WIN_CONTENT_Y TAB_HEIGHT+WIN_PAD
#define WIN_CONTENT_W 400
#define WIN_CONTENT_H 465
proc_info Form;
sensor cpu; #include "general.h"
sensor ram; #include "process.h"
sensor rd;
sensor tmp[10];
dword tmp_size[10]; #define T_GENERAL "General"
#define T_PROCESSES "Processes"
//===================================================// enum {
// // TAB_GENERAL=20,
// CODE // TAB_PROCESSES
// // };
//===================================================// _tabs tabs = { TAB_GENERAL, 4, 0, WIN_CONTENT_W+WIN_PAD+WIN_PAD-4-4, TAB_HEIGHT };
void main() void main()
{ {
proc_info Form;
dword cpu_frequency = GetCpuFrequency()/1000;
int id;
incn y;
load_dll(libio, #libio_init,1); load_dll(libio, #libio_init,1);
load_dll(libimg, #libimg_init,1); load_dll(libimg, #libimg_init,1);
load_dll(libini, #lib_init,1); load_dll(libini, #lib_init,1);
load_dll(boxlib, #box_lib_init,0);
General__Main();
}
GetTmpDiskSizes(); int Sysmon__DefineAndDrawWindow()
loop()
{ {
WaitEventTimeout(25);
switch(EAX & 0xFF)
{
case evButton:
if (GetButtonID()) ExitProcess();
break;
case evKey:
GetKeys();
if (key_scancode == SCAN_CODE_ESC) ExitProcess();
break;
case evReDraw:
#define LEFT 25
#define ICONGAP 45
system.color.get(); system.color.get();
DefineAndDrawWindow(150, 100, CPU_STACK+LEFT+LEFT+4+9, 480 + skin_height + 4, 0x34, system.color.work, "System Monitor",0); 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, system.color.work, "System Monitor",0);
GetProcessInfo(#Form, SelfInfo); GetProcessInfo(#Form, SelfInfo);
if (Form.status_window>2) return false;
y.n = 0; //if (Form.width < 300) { MoveSize(OLD,OLD,300,OLD); break; }
if (cpu_frequency < 1000) sprintf(#param, "CPU frequency: %i Hz", cpu_frequency); //if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); break; }
else sprintf(#param, "CPU frequency: %i MHz", cpu_frequency/1000); tabs.draw_wrapper();
DrawBlockHeader(LEFT, y.inc(20), 37, "CPU load", #param); tabs.draw_button(tabs.x+TAB_PADDING, TAB_GENERAL, T_GENERAL);
cpu.set_size(LEFT, y.inc(45), CPU_STACK, 100); tabs.draw_button(strlen(T_GENERAL)*8+tabs.x+TAB_PADDING+TAB_PADDING, TAB_PROCESSES, T_PROCESSES);
return true;
sprintf(#param, "Total RAM: %i MiB", GetTotalRAM()/1024);
DrawBlockHeader(LEFT, y.inc(cpu.h + 25), 36, "RAM usage", #param);
ram.set_size(LEFT, y.inc(45), CPU_STACK, 23);
DrawBlockHeader(LEFT, y.inc(ram.h + 25), 3, "System RAM Disk usage", "Fixed size: 1.44 MiB");
rd.set_size(LEFT, y.inc(45), CPU_STACK, 23);
sprintf(#param, "TMP Disk 0 size: %i MiB", tmp_size[0]);
DrawBlockHeader(LEFT, y.inc(rd.h + 25), 50, "Virtual drive usage", #param);
tmp[0].set_size(LEFT, y.inc(45), CPU_STACK, 23);
default:
MonitorCpu();
//MonitorRam();
ram.draw_progress(
GetFreeRAM()*ram.w/GetTotalRAM(),
GetTotalRAM()-GetFreeRAM()/1024,
GetFreeRAM()/1024,
"M"
);
DrawBar(ram.x+ram.w-96, ram.y-25, 96, 20, system.color.work);
sprintf(#param, "%i KiB", GetTotalRAM()-GetFreeRAM());
WriteText(ram.x+ram.w-calc(strlen(#param)*8), ram.y-25, 0x90, system.color.work_text, #param);
//MonitorRd();
dir_size.get("/rd/1");
dir_size.bytes += dir_size.files/2 + 32 * 512; //file attr size + FAT table size
dir_size.bytes /= 1024; //convert to KiB
dir_size.bytes = 1440 - dir_size.bytes;
rd.draw_progress(
dir_size.bytes*rd.w/1440,
1440 - dir_size.bytes,
dir_size.bytes,
"K"
);
//MonitorTmp();
if (tmp_size[0]) {
dir_size.get("/tmp0/1");
dir_size.bytes += dir_size.files/2 + 32 * 512; //file attr size + FAT table size
dir_size.bytes /= 1024*1024; //convert to MiB
dir_size.bytes= tmp_size[0] - dir_size.bytes;
tmp[0].draw_progress(
dir_size.bytes*tmp[0].w/tmp_size[0],
tmp_size[0] - dir_size.bytes,
dir_size.bytes,
"M"
);
}
}
}
}
void DrawBlockHeader(dword _x, _y, _icon, _title, _subtitle)
{
WriteTextB(_x+ICONGAP, _y, 0x90, system.color.work_text, _title);
DrawIcon32(_x, _y, system.color.work, _icon);
WriteText(_x+ICONGAP, _y+20, 0x90, system.color.work_text, _subtitle);
}
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;
}
dword GetDiskSize(dword disk_n)
{
BDVK bdvk;
char tmp_path[8];
strcpy(#tmp_path, "/tmp0/1");
tmp_path[4] = disk_n + '0';
GetFileInfo(#tmp_path, #bdvk);
return bdvk.sizelo;
}
void GetTmpDiskSizes()
{
char i;
for (i=0; i<=9; i++)
{
tmp_size[i] = GetDiskSize(i) / 1024 / 1024;
}
} }
//===================================================// //===================================================//
// // // //
// MONITORS // // EVENTS //
// // // //
//===================================================// //===================================================//
int pos=0; void Sysmon__ButtonEvent(dword id)
void MonitorCpu()
{ {
int i; if (1==id) ExitProcess();
if (!cpu.w) return; if (TAB_GENERAL==id) {
tabs.active_tab = TAB_GENERAL;
cpu_stack[pos] = GetCpuLoad(cpu.h); General__Main();
if (cpu_stack[pos]<=2) || (cpu_stack[pos]>cpu.h) cpu_stack[pos]=2;
DrawBar(cpu.x+cpu.w-30, cpu.y-25, 30, 20, system.color.work);
sprintf(#param, "%i%%", cpu_stack[pos]);
WriteText(cpu.x+cpu.w-calc(strlen(#param)*8), cpu.y-25, 0x90, system.color.work_text, #param);
for (i=0; i<CPU_STACK; 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>=CPU_STACK) {
pos = CPU_STACK-1;
for (i=0; i<pos; i++) {
cpu_stack[i] = cpu_stack[i+1];
} }
if (TAB_PROCESSES==id) {
tabs.active_tab = TAB_PROCESSES;
Processes__Main();
} }
} }
stop: