diff --git a/include/drive.h b/include/drive.h index 3d7f3b1..bfd33da 100644 --- a/include/drive.h +++ b/include/drive.h @@ -46,6 +46,11 @@ private: uint32_t u32ErrorCount = 0U; uint32_t u32PowerOnHours = 0U; //in hours uint32_t u32PowerCycles = 0U; + uint32_t u32ShredPercentage = 0U; //in percent + + + + }; #endif // DRIVE_H_ \ No newline at end of file diff --git a/include/reHDD.h b/include/reHDD.h index a05e1ad..46a7d05 100644 --- a/include/reHDD.h +++ b/include/reHDD.h @@ -15,12 +15,17 @@ #include #include #include +#include +#include +#include using namespace std; #include "drive.h" #include "smart.h" #include "wipe.h" +//#include "tui.h" +//#include "tui_data.h" template T* iterator_to_pointer(I i) { @@ -40,9 +45,16 @@ private: vector vecDrives; //stores all drive data void searchDrives(vector * pvecDrives); + void printDrives(vector * pvecDrives); void filterIgnoredDrives(vector * pvecDrives); void addSMARTData(vector * pvecDrives); + + static void ThreadDevices(); + + + + }; diff --git a/include/tui.h b/include/tui.h new file mode 100644 index 0000000..bcdb7e6 --- /dev/null +++ b/include/tui.h @@ -0,0 +1,41 @@ +/** + * @file tui.h + * @brief display user interface + * @author hendrik schutter + * @date 03.08.2020 + */ + +#ifndef TUI_H_ +#define TUI_H_ + +#include "reHDD.h" + +#define COLOR_AREA_STDSCR 1 +#define COLOR_AREA_OVERVIEW 2 +#define COLOR_AREA_ENTRY 3 + +#define COLOR_GRAY 8 + +class TUI +{ +protected: + +public: + + TUI(void); + + void initTUI(); + + void updateTUI(TUI_DATA data); + + + +private: + + void centerTitle(WINDOW *pwin, const char * title); + + + +}; + +#endif // TUI_H_ \ No newline at end of file diff --git a/include/tui_data.h b/include/tui_data.h new file mode 100644 index 0000000..3d5a383 --- /dev/null +++ b/include/tui_data.h @@ -0,0 +1,45 @@ +/** + * @file tui_data.h + * @brief ui model data + * @author hendrik schutter + * @date 03.08.2020 + */ + +#ifndef TUI_DATA_H_ +#define TUI_DATA_H_ + +#include "reHDD.h" + +#define COLOR_AREA_STDSCR 1 +#define COLOR_AREA_OVERVIEW 2 +#define COLOR_AREA_ENTRY 3 + +#define COLOR_GRAY 8 + + +class TUI_DATA +{ +protected: + +public: + + TUI_DATA(vector * pvecDrives); + + + + + + + +private: + + + + + string sCpuUsage; + string sRamUsage; + string sLocalTime; + +}; + +#endif // TUI_DATA_H_ \ No newline at end of file diff --git a/makefile b/makefile index c76a225..5c4fced 100644 --- a/makefile +++ b/makefile @@ -18,7 +18,7 @@ DCOMPILE_FLAGS = -D DEBUG # Add additional include paths INCLUDES = include # General linker settings -LINK_FLAGS = +LINK_FLAGS = -lpthread # Doc DOCDIR = doc #### END PROJECT SETTINGS #### diff --git a/src/TUI/tui.cpp b/src/TUI/tui.cpp new file mode 100644 index 0000000..b65f90a --- /dev/null +++ b/src/TUI/tui.cpp @@ -0,0 +1,39 @@ +/** + * @file tui.cpp + * @brief display user interface + * @author hendrik schutter + * @date 03.08.2020 + */ +/* +#include "../include/reHDD.h" +*/ + +/** + * \brief wipe drive with shred + * \param pointer of Drive instance + * \return void + */ +/* +void TUI::initTUI() +{ + initscr(); + raw(); + keypad(stdscr,TRUE); + if(has_colors() == TRUE) { + start_color(); + } else { + printf("Your terminal does not support color\n"); + exit(1); + } + clear(); + curs_set(0); + init_color(COLOR_GRAY, 173, 170, 173); +} + +void TUI::updateTUI(TUI_DATA data){ + + + + + +}*/ \ No newline at end of file diff --git a/src/TUI/tui_data.cpp b/src/TUI/tui_data.cpp new file mode 100644 index 0000000..b0255fa --- /dev/null +++ b/src/TUI/tui_data.cpp @@ -0,0 +1,29 @@ +/** + * @file tui.cpp + * @brief display user interface + * @author hendrik schutter + * @date 03.08.2020 + */ + +//#include "../include/reHDD.h" + +/* + + TUI_DATA::TUI_DATA(vector * pvecDrives) +{ + + + + + + + + +} + + + + + + +*/ diff --git a/src/main.cpp b/src/main.cpp index 4978cb8..6f287a6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,7 +14,7 @@ */ int main(void) { - cout << "refurbishingHddTool" << endl; + // cout << "refurbishingHddTool" << endl; reHDD* app = new reHDD(); app->app_logic(); diff --git a/src/reHDD.cpp b/src/reHDD.cpp index ec03080..72780b7 100644 --- a/src/reHDD.cpp +++ b/src/reHDD.cpp @@ -7,6 +7,9 @@ #include "../include/reHDD.h" + +static int fd[2];//File descriptor for creating a pipe + /** * \brief app constructor * \param void @@ -26,10 +29,44 @@ void reHDD::app_logic(void) { cout << "app logic" << endl; - searchDrives(&vecDrives); //search for new drives and store them in list - filterIgnoredDrives(&vecDrives); //filter out ignored drives - addSMARTData(&vecDrives); //add S.M.A.R.T. Data to the drives - printDrives(&vecDrives); //print currently attached drives + thread thDevices(ThreadDevices); + + + //searchDrives(&vecDrives); //search for new drives and store them in list + //filterIgnoredDrives(&vecDrives); //filter out ignored drives + //addSMARTData(&vecDrives); //add S.M.A.R.T. Data to the drives + // printDrives(&vecDrives); //print currently attached drives + + + + int result = pipe (fd); + +while(1){ + char ch; + + + result = read (fd[0],&ch,1); + + if (result != 1) { + perror("read"); + exit(3); + } + + printf ("From Main Thread: %c\n", ch); + + + } + + + + + thDevices.join(); + + std::cout << std::endl; + +/* + + size_t u64SelectedDriveIndex = 0U; size_t u64DriveVecSize = (vecDrives.size()); @@ -39,18 +76,60 @@ void reHDD::app_logic(void) cout << "Selected drive index: " << u64SelectedDriveIndex << endl; if(u64SelectedDriveIndex < (u64DriveVecSize)) { - Wipe::wipeDrive(&vecDrives[u64SelectedDriveIndex]); + // Wipe::wipeDrive(&vecDrives[u64SelectedDriveIndex]); } +*/ +} + +void reHDD::ThreadDevices(){ + + + +while(true){ + +cout << "Thread" << endl; + + + + + + + + + + + + + + + int result = write (fd[1], "A",1); + //cout << result << endl; + if (result != 1){ + perror ("write error"); + // exit (2); + } + + sleep(5); //sleep 5 sec +} + + } + + /** * \brief search attached drives on /dev/sd* * \param pointer of vector * pvecDrives * \return void */ -void reHDD::searchDrives(vector * pvecDrives) + void reHDD::searchDrives(vector * pvecDrives) { + + + + + cout << "search drives ..." << endl; char * cLine = NULL; size_t len = 0; @@ -71,6 +150,8 @@ void reHDD::searchDrives(vector * pvecDrives) } } fclose(outputfileHwinfo); + + } /** diff --git a/vcCodium.code-workspace b/vcCodium.code-workspace index 6b6425d..9860bd5 100644 --- a/vcCodium.code-workspace +++ b/vcCodium.code-workspace @@ -12,7 +12,9 @@ "unordered_map": "cpp", "string_view": "cpp", "ostream": "cpp", - "chrono": "cpp" - } + "chrono": "cpp", + "thread": "cpp" + }, + "git.ignoreLimitWarning": true } } \ No newline at end of file