From 7e2678078054295f1cc4a85a015ee4ae756efb1d Mon Sep 17 00:00:00 2001 From: Mobarak Hosen Shakil <20867846+imShakil@users.noreply.github.com> Date: Thu, 9 Apr 2020 21:58:32 +0600 Subject: [PATCH] Add files via upload --- PCiNooB.cbp | 47 +++++++++++ PCiNooB.depend | 32 ++++++++ PCiNooB.layout | 10 +++ SystemAnalyzer.h | 202 +++++++++++++++++++++++++++++++++++++++++++++++ main.cpp | 155 ++++++++++++++++++++++++++++++++++++ main.fld | 42 ++++++++++ main.h | 17 ++++ main.o | Bin 0 -> 17672 bytes uptime.h | 123 +++++++++++++++++++++++++++++ 9 files changed, 628 insertions(+) create mode 100644 PCiNooB.cbp create mode 100644 PCiNooB.depend create mode 100644 PCiNooB.layout create mode 100644 SystemAnalyzer.h create mode 100644 main.cpp create mode 100644 main.fld create mode 100644 main.h create mode 100644 main.o create mode 100644 uptime.h diff --git a/PCiNooB.cbp b/PCiNooB.cbp new file mode 100644 index 0000000..8eb1fab --- /dev/null +++ b/PCiNooB.cbp @@ -0,0 +1,47 @@ + + + + + + diff --git a/PCiNooB.depend b/PCiNooB.depend new file mode 100644 index 0000000..870e9a1 --- /dev/null +++ b/PCiNooB.depend @@ -0,0 +1,32 @@ +# depslib dependency file v1.0 +1586447065 source:/home/imshakil/Desktop/GTKApplication/PCiNooB/main.cpp + "main.h" + "SystemAnalyzer.h" + + + + + + + +1586317279 /home/imshakil/Desktop/GTKApplication/PCiNooB/main.h + + + + + + +1586445915 /home/imshakil/Desktop/GTKApplication/PCiNooB/SystemAnalyzer.h + + "uptime.h" + + +1586412187 /home/imshakil/Desktop/GTKApplication/PCiNooB/uptime.h + + + + + + + + diff --git a/PCiNooB.layout b/PCiNooB.layout new file mode 100644 index 0000000..09534b8 --- /dev/null +++ b/PCiNooB.layout @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/SystemAnalyzer.h b/SystemAnalyzer.h new file mode 100644 index 0000000..f81584e --- /dev/null +++ b/SystemAnalyzer.h @@ -0,0 +1,202 @@ +#include +#include "uptime.h" +#include + +using namespace std; + +/** Created a System Class **/ + +class SystemAnalyzer{ + +public: + + /** Get Device Information **/ + + string GetInformationFromCommand(string cmdline) { + string data; + FILE * stream; + const int max_buffer = 256; + char buffer[max_buffer]; + + stream = popen(cmdline.c_str(), "r"); + if (stream) { + while (!feof(stream)) + if (fgets(buffer, max_buffer, stream) != NULL) data.append(buffer); + pclose(stream); + } + return data; + } + + void GetDeviceInfo() + { + freopen("Device.info", "w", stdout); + + string ItemsName[] = { "BIOS Version\t\t: ", "BIOS Vendor\t\t: ", "Release Date\t\t: ", + "Motherboard Name\t: ", "Motherboard Vendor\t: ", "Motherboard Versions\t: ", + "Product\t\t\t: ", "Product Name\t\t: ", "Product Version\t\t: ", "System Vendor\t\t: "}; + + string ItemsPath[] = {"/sys/class/dmi/id/bios_version", "/sys/class/dmi/id/bios_vendor", "/sys/class/dmi/id/bios_date", + "/sys/class/dmi/id/board_name", "/sys/class/dmi/id/board_vendor", "/sys/class/dmi/id/board_version", + "/sys/class/dmi/id/product_sku", "/sys/class/dmi/id/product_name", "/sys/class/dmi/id/product_version", "/sys/class/dmi/id/sys_vendor"}; + + for(int i=0; i<10; i++) + { + ifstream ifs (ItemsPath[i], ifstream::in); + + string line; + while(getline(ifs, line)) cout<3) break; + } + + fclose(stdout); + } + + /** Get Hard Disk Information **/ + + void GetHDDInfo() + { + freopen("HardDisk.info", "w", stdout); + + string ptype[2] = {"GPT", "MBR"}; /// Hard disk partition style + string hddNames[] = {"Disk Model\t: ", "Vendor\t\t: ", "Size\t\t: ", "Version\t\t: ", "Partitioned\t: "}; /// hard disk hardware information + string hddItems[] = {"/sys/block/sda/device/model", "/sys/block/sda/device/vendor", "/sys/block/sda/size", "/sys/block/sda/device/rev", "/sys/block/sda/device/type"}; + string Size[] = {" KB", " MB", " GB", " TB"}; + + for(int i=0; i<5; i++) + { + ifstream ifs (hddItems[i], ifstream::in); + string line; + while(getline(ifs, line)) + { + if(i==2) { + int sz = stoi(line)/2; + cout<> major >> minor >> block >> name; + + int sz = stoi(block); + int cnt = 0; + while(sz>1024) + { + sz /= 1024; + cnt++; + } + if(name.length()==3) name+="0"; + + cout<5) break; + } + + vector entries1; + vector entries2; + + ReadStatsCPU(entries1); + + this_thread::sleep_for(chrono::milliseconds(100)); + + ReadStatsCPU(entries2); + + cout<<"\nControl Processing Unit Uptime\n\n"; + PrintStats(entries1, entries2); + + } + + + /** Get Graphics Processor Unit Information **/ + + void GetGPUInfo() + { + freopen("GPU.info", "w", stdout); + + string ot = GetInformationFromCommand("lspci"); /// get a list of PCI associate with the PC + cout< +#include +#include +#include +#include +#include +using namespace std; + +int minWidth = 650, minHeight = 450; /// Application Window Size + +Fl_Double_Window *window_main=(Fl_Double_Window *)0; + +Fl_Button *btnTest=(Fl_Button *)0; + +Fl_Return_Button *btnClose=(Fl_Return_Button *)0; + + +/** Method to create an object of + SystemAnalyzer Class to call + each method and store information + into text files + **/ + +void GenarateInformation() +{ + SystemAnalyzer sysinfo; + sysinfo.GetCPUInfo(); + sysinfo.GetDeviceInfo(); + sysinfo.GetGPUInfo(); + sysinfo.GetHDDInfo(); + sysinfo.GetMemInfo(); +} + +/** Custom Method to load + information using text buffer + and display in monitor + **/ + +void LoadInformation(char *File) +{ + Fl_Text_Buffer *buff = new Fl_Text_Buffer(); + Fl_Text_Display *disp = new Fl_Text_Display(20, 35, 580, 350); + disp->buffer(buff); + buff->loadfile(File); +} + +void SetWaterMark() +{ + Fl_Box *box = new Fl_Box(0, minHeight-30,100,20,"PC i NooB ~ https://github.com/imshakil/"); + box->labelcolor(FL_DARK_CYAN); +} + +/** Button callback to display new window + with Tabs & specific Device Information. + Created an object of SystemAnalyzer class + to call each method + **/ + +void bt_callback(Fl_Widget*, void* userdata) { + + if(userdata == "test") { + + GenarateInformation(); /// Stored Information in text files. + this_thread::sleep_for(chrono::microseconds(2000)); + + Fl_Window* adw = new Fl_Window (minWidth, minHeight, "PCiNooB - Hardware Information"); /// Added Window + + adw->align(FL_ALIGN_CENTER); + + Fl_Tabs *tabs = new Fl_Tabs(10,0,600,400); + tabs->selection_color(FL_DARK3); + { + Fl_Group *grp0 = new Fl_Group(20, 30, 280, 450, "Device"); + { + LoadInformation("Device.info"); /// loaded information from text file + } + grp0->end(); /// tabs1 ended here + + Fl_Group *grp1 = new Fl_Group(20,30,280,450,"CPU Information"); + { + LoadInformation("CPU.info"); /// loaded information from text file + } + grp1->end(); /// tabs2 ended here + + Fl_Group *grp2 = new Fl_Group(20,30,280,450,"HDD Information"); + { + LoadInformation("HardDisk.info"); /// loaded information from text file + } + grp2->end(); /// tabs3 ended here + + Fl_Group *grp3 = new Fl_Group(20,30,280,450,"Memory Information"); + { + LoadInformation("Memory.info"); /// loaded information from text file + } + grp3->end(); /// tabs4 ended here + + Fl_Group *grp4 = new Fl_Group(20,30,280,450,"GPU Information"); + { + LoadInformation("GPU.info"); ///loaded information from text file + } + grp4->end(); + } + tabs->end(); /// tabs ended here + + SetWaterMark(); /// my github link + adw->show(); /// Display new Window with list of tabs + } +else if (userdata == "close") + exit(0); /// close program with exit button +} + + +/** Main Function of this Application**/ + +int main(int argc, char **argv) { + + Fl_Double_Window* w; + { + Fl_Double_Window* o = window_main = new Fl_Double_Window(minWidth, minHeight, "PCiNooB - PC Configuration"); + w = o; + o->align(FL_ALIGN_CENTER); + { + Fl_Box *box = new Fl_Box(minWidth/2-130,40,260,100,"PC i NooB"); + box->box(FL_UP_BOX); + box->labelsize(36); + box->labelfont(FL_BOLD+FL_ITALIC); + box->labeltype(FL_SHADOW_LABEL); + } + { Fl_Button* o = btnTest = new Fl_Button(minWidth/2 - 80, minHeight/2-40, 160, 40, "Get PC Specification"); /// centralized button in window + o->callback((Fl_Callback*)bt_callback, (void*)("test")); + } + { Fl_Return_Button* o = btnClose = new Fl_Return_Button(minWidth/2-50, minHeight/2+20, 100, 40, "Exit"); /// centralized button in window + o->callback((Fl_Callback*)bt_callback, (void*)("close")); + } + + { + SetWaterMark(); + } + + o->end(); + } + w->show(argc, argv); + return Fl::run(); +} diff --git a/main.fld b/main.fld new file mode 100644 index 0000000..1e46e97 --- /dev/null +++ b/main.fld @@ -0,0 +1,42 @@ +# data file for the Fltk User Interface Designer (fluid) +version 1.0304 +header_name {.h} +code_name {.cpp} +decl {\#include } {private local +} + +Function {bt_callback(Fl_Widget*, void* userdata)} {open return_type {static void} +} { + code {if(userdata == "test") + std::cout << "Testing" << std::endl; +else if (userdata == "close") + exit(0);} {} + Fl_Window {} {open selected + xywh {327 156 650 450} type Double hide + } {} +} + +Function {} {open +} { + Fl_Window window_main { + label {FLTK window} open + xywh {415 203 650 450} type Double box THIN_DOWN_BOX color 26 selection_color 70 labelsize 18 labelcolor 60 align 80 visible + } { + Fl_Input input { + label {Please enter value:} + xywh {145 10 150 25} + } + Fl_Button btnTest { + label Test + user_data {"test"} + callback bt_callback + xywh {10 100 100 25} + } + Fl_Return_Button btnClose { + label Close + user_data {"close"} + callback bt_callback + xywh {195 100 100 25} + } + } +} diff --git a/main.h b/main.h new file mode 100644 index 0000000..d23c852 --- /dev/null +++ b/main.h @@ -0,0 +1,17 @@ +// generated by Fast Light User Interface Designer (fluid) version 1.0107 + +#ifndef main_h +#define main_h +#include +void bt_callback(Fl_Widget*, void* userdata); +#include +extern Fl_Double_Window *window_main; +#include +extern Fl_Input *input; +#include +extern void bt_callback(Fl_Button*, void*); +extern Fl_Button *btnTest; +#include +extern void bt_callback(Fl_Return_Button*, void*); +extern Fl_Return_Button *btnClose; +#endif diff --git a/main.o b/main.o new file mode 100644 index 0000000000000000000000000000000000000000..fc7c81ee13873b148a28deec11dd9274e8964200 GIT binary patch literal 17672 zcmbuG3v^t?dB?A`mU)9Qd6>5#228Pqt{%4RkW{agc8}MR(5`seT(4GF(&E+bp542) zOffMSinp>;^GI+535EhTgfwn2sWGW7FrjWrh&i;uP29$Z133nKdZ2L|H_)Sg|GD4X z9gX+OPMLFNXXZEG_sutRXXZXM`bIF)QCU%8$WUQ?-6)kL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~~HQT~7blS6z{BY6@D>_&?u#{2c%Q literal 0 HcmV?d00001 diff --git a/uptime.h b/uptime.h new file mode 100644 index 0000000..6dc411a --- /dev/null +++ b/uptime.h @@ -0,0 +1,123 @@ + +#include +#include +#include +#include +#include +#include +#include + +const int NUM_CPU_STATES = 10; + +enum CPUStates +{ + S_USER = 0, + S_NICE, + S_SYSTEM, + S_IDLE, + S_IOWAIT, + S_IRQ, + S_SOFTIRQ, + S_STEAL, + S_GUEST, + S_GUEST_NICE +}; + +typedef struct CPUData +{ + std::string cpu; + size_t times[NUM_CPU_STATES]; +} CPUData; + +void ReadStatsCPU(std::vector & entries); + +size_t GetIdleTime(const CPUData & e); +size_t GetActiveTime(const CPUData & e); + +void PrintStats(const std::vector & entries1, const std::vector & entries2); + +void ReadStatsCPU(std::vector & entries) +{ + std::ifstream fileStat("/proc/stat"); + + std::string line; + + const std::string STR_CPU("cpu"); + const std::size_t LEN_STR_CPU = STR_CPU.size(); + const std::string STR_TOT("tot"); + + while(std::getline(fileStat, line)) + { + // cpu stats line found + if(!line.compare(0, LEN_STR_CPU, STR_CPU)) + { + std::istringstream ss(line); + + // store entry + entries.emplace_back(CPUData()); + CPUData & entry = entries.back(); + + // read cpu label + ss >> entry.cpu; + + // remove "cpu" from the label when it's a processor number + if(entry.cpu.size() > LEN_STR_CPU) + entry.cpu.erase(0, LEN_STR_CPU); + // replace "cpu" with "tot" when it's total values + else + entry.cpu = STR_TOT; + + // read times + for(int i = 0; i < NUM_CPU_STATES; ++i) + ss >> entry.times[i]; + } + } +} + +size_t GetIdleTime(const CPUData & e) +{ + return e.times[S_IDLE] + + e.times[S_IOWAIT]; +} + +size_t GetActiveTime(const CPUData & e) +{ + return e.times[S_USER] + + e.times[S_NICE] + + e.times[S_SYSTEM] + + e.times[S_IRQ] + + e.times[S_SOFTIRQ] + + e.times[S_STEAL] + + e.times[S_GUEST] + + e.times[S_GUEST_NICE]; +} + +void PrintStats(const std::vector & entries1, const std::vector & entries2) +{ + const size_t NUM_ENTRIES = entries1.size(); + + for(size_t i = 0; i < NUM_ENTRIES; ++i) + { + const CPUData & e1 = entries1[i]; + const CPUData & e2 = entries2[i]; + + std::cout.width(3); + std::cout << e1.cpu << "] "; + + const float ACTIVE_TIME = static_cast(GetActiveTime(e2) - GetActiveTime(e1)); + const float IDLE_TIME = static_cast(GetIdleTime(e2) - GetIdleTime(e1)); + const float TOTAL_TIME = ACTIVE_TIME + IDLE_TIME; + + std::cout << "active: "; + std::cout.setf(std::ios::fixed, std::ios::floatfield); + std::cout.width(6); + std::cout.precision(2); + std::cout << (100.f * ACTIVE_TIME / TOTAL_TIME) << "%"; + + std::cout << " - idle: "; + std::cout.setf(std::ios::fixed, std::ios::floatfield); + std::cout.width(6); + std::cout.precision(2); + std::cout << (100.f * IDLE_TIME / TOTAL_TIME) << "%" << std::endl; + } +}