From 23c02580775dfbb9a7cfe715be1c78008bcd4dbf Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Fri, 14 Sep 2018 18:07:55 +0000 Subject: [PATCH] sysmon: upload a new app System Monitor v0.8 beta git-svn-id: svn://kolibrios.org@7361 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/eolite/Eolite.c | 2 + programs/cmm/sysmon/Tupfile.lua | 6 + programs/cmm/sysmon/compile_en.bat | 6 + programs/cmm/sysmon/sysmon.c | 278 +++++++++++++++++++++++++++++ 4 files changed, 292 insertions(+) create mode 100644 programs/cmm/sysmon/Tupfile.lua create mode 100644 programs/cmm/sysmon/compile_en.bat create mode 100644 programs/cmm/sysmon/sysmon.c diff --git a/programs/cmm/eolite/Eolite.c b/programs/cmm/eolite/Eolite.c index 3e1fdca28d..3fe204706a 100644 --- a/programs/cmm/eolite/Eolite.c +++ b/programs/cmm/eolite/Eolite.c @@ -1,6 +1,8 @@ //Leency, Veliant, Punk_Joker, PavelYakov & KolibriOS Team 2008-2018 //GNU GPL licence. +// 70.5 - get volume info and label + #ifndef AUTOBUILD #include "lang.h--" #endif diff --git a/programs/cmm/sysmon/Tupfile.lua b/programs/cmm/sysmon/Tupfile.lua new file mode 100644 index 0000000000..7919019adb --- /dev/null +++ b/programs/cmm/sysmon/Tupfile.lua @@ -0,0 +1,6 @@ +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("sysmon.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "sysmon.com") diff --git a/programs/cmm/sysmon/compile_en.bat b/programs/cmm/sysmon/compile_en.bat new file mode 100644 index 0000000000..ab01f9cdf1 --- /dev/null +++ b/programs/cmm/sysmon/compile_en.bat @@ -0,0 +1,6 @@ +@del sysmon.kex +@c-- sysmon.c +@rename *.com *.kex +@del warning.txt +@kpack sysmon.kex +@pause \ No newline at end of file diff --git a/programs/cmm/sysmon/sysmon.c b/programs/cmm/sysmon/sysmon.c new file mode 100644 index 0000000000..66044a21e8 --- /dev/null +++ b/programs/cmm/sysmon/sysmon.c @@ -0,0 +1,278 @@ +/* + * System Monitor + * version 0.7 + * Author: Leency +*/ + +#define MEMSIZE 4096*10 + +#include "../lib/io.h" +#include "../lib/gui.h" + +#include "../lib/obj/libio.h" +#include "../lib/obj/libimg.h" +#include "../lib/obj/libini.h" + +//===================================================// +// // +// SENSOR // +// // +//===================================================// + +#define MIN_PB_BLOCK_W 19 +#define LOAD_BG 0xFFFfff +#define LOAD_ACTIVE 0x4C52FF + +struct sensor { + int x,y,w,h; + void set_size(); + void draw_wrapper(); + void draw_progress(); +}; + +void sensor::set_size(dword _x, _y, _w, _h) +{ + x=_x+2; + y=_y; + w=_w; + h=_h; +} + +void sensor::draw_wrapper() +{ + DrawRectangle(x-1, y-1, w+1, h+1, system.color.work_graph); + DrawRectangle3D(x-2, y-2, w+3, h+3, system.color.work_dark, system.color.work_light); +} + +void sensor::draw_progress(dword progress_w, active_value, bg_value, mesure) +{ + if (progress_w < MIN_PB_BLOCK_W) progress_w = MIN_PB_BLOCK_W; + if (progress_w > w-MIN_PB_BLOCK_W) progress_w = w-MIN_PB_BLOCK_W; + + DrawBar(x, y, w-progress_w, h, LOAD_ACTIVE); + sprintf(#param, "%i%s", active_value, mesure); + WriteText(w-progress_w- calc(strlen(#param)*8) /2 + x, h/2-7+y, 0x90, LOAD_BG, #param); + + DrawBar(x+w-progress_w, y, progress_w, h, LOAD_BG); + sprintf(#param, "%i%s", bg_value, mesure); + WriteText(-progress_w - calc(strlen(#param)*8)/2 + w+x, h/2-7+y, 0x90, LOAD_ACTIVE, #param); +} + +//===================================================// +// // +// GetSizeDir // +// // +//===================================================// + +BDVK file_info_dirsize; +dword dir_count; +dword file_count; +dword size_dir; + +void GetDirSizeAndCountFiles(dword way) +{ + dir_count=0; + file_count=0; + size_dir=0; + GetDirSizeAndCountFiles_loop(way); +} + +void GetDirSizeAndCountFiles_loop(dword way) +{ + dword dirbuf, fcount, i, filename; + dword cur_file; + if (dir_exists(way)) + { + cur_file = malloc(4096); + // In the process of recursive descent, memory must be allocated dynamically, + // because the static memory -> was a bug !!! But unfortunately pass away to sacrifice speed. + GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL); + 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; +} + +//===================================================// +// // +// 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=CPU_STACK) { + pos = CPU_STACK-1; + for (i=0; i