From 99273756dafeb2e92d33b2990c62d6b18c2d1abe Mon Sep 17 00:00:00 2001 From: localhorst Date: Fri, 7 Aug 2020 12:07:29 +0200 Subject: [PATCH] show drive overview --- include/drive.h | 3 +++ include/reHDD.h | 13 +++---------- include/tui.h | 2 +- src/TUI/tui.cpp | 31 ++++++++++++++++++++++++++----- src/drive.cpp | 16 ++++++++++++++++ 5 files changed, 49 insertions(+), 16 deletions(-) diff --git a/include/drive.h b/include/drive.h index 53bad36..f1377c9 100644 --- a/include/drive.h +++ b/include/drive.h @@ -38,6 +38,9 @@ public: uint32_t powerCycles); string sCapacityToText(); + string sErrorCountToText(); + string sPowerOnHoursToText(); + string sPowerCyclesToText(); private: string sPath; diff --git a/include/reHDD.h b/include/reHDD.h index 19a3aa8..0fdf6fc 100644 --- a/include/reHDD.h +++ b/include/reHDD.h @@ -50,21 +50,14 @@ public: private: - - static void searchDrives(vector * pvecDrives); static void printDrives(vector * pvecDrives); static void filterIgnoredDrives(vector * pvecDrives); static void addSMARTData(vector * pvecDrives); static void ThreadScannDevices(); - static void ThreadUserInput(); - - static void handleArrowKey(TUI::UserInput userInput); - - static void filterNewDrives(vector * pvecOldDrives, vector * pvecNewDrives); - - - + static void ThreadUserInput(); + static void handleArrowKey(TUI::UserInput userInput); + static void filterNewDrives(vector * pvecOldDrives, vector * pvecNewDrives); }; diff --git a/include/tui.h b/include/tui.h index 9b340e2..0bbd795 100644 --- a/include/tui.h +++ b/include/tui.h @@ -43,7 +43,7 @@ private: static void centerTitle(WINDOW *pwin, const char * title); static WINDOW *createOverViewWindow( int iXSize, int iYSize); - static WINDOW *createDetailViewWindow( int iXSize, int iYSize, int iXStart); + static WINDOW *createDetailViewWindow( int iXSize, int iYSize, int iXStart, Drive drive); static WINDOW *createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart,string sModelFamily, string sModelName, string sCapacity, bool bSelected); }; diff --git a/src/TUI/tui.cpp b/src/TUI/tui.cpp index 9140991..c92872e 100644 --- a/src/TUI/tui.cpp +++ b/src/TUI/tui.cpp @@ -69,9 +69,6 @@ void TUI::updateTUI(vector * pvecDrives, int32_t i32SelectedEntry) overview=createOverViewWindow((int)(stdscrX/3), (stdscrY-15)); wrefresh(overview); - detailview=createDetailViewWindow(((stdscrX)-(int)(stdscrX/3)-7), (stdscrY-3), (int)(stdscrX/3)+5); - wrefresh(detailview); - vector ::iterator it; for (it = pvecDrives->begin(); it != pvecDrives->end(); ++it) { @@ -84,6 +81,8 @@ void TUI::updateTUI(vector * pvecDrives, int32_t i32SelectedEntry) if(i32SelectedEntry == (it - pvecDrives->begin())) { bSelectedEntry = true; + detailview=createDetailViewWindow(((stdscrX)-(int)(stdscrX/3)-7), (stdscrY-3), (int)(stdscrX/3)+5, pvecDrives->at((it - pvecDrives->begin()))); + wrefresh(detailview); } WINDOW * tmp = createEntryWindow( ((int)(stdscrX/3) - 2), 5, 3, (5* (it - pvecDrives->begin()) )+3, sModelFamily, sModelName, sCapacity, bSelectedEntry); @@ -163,14 +162,36 @@ WINDOW* TUI::createOverViewWindow( int iXSize, int iYSize) return newWindow; } -WINDOW* TUI::createDetailViewWindow( int iXSize, int iYSize, int iXStart) +WINDOW* TUI::createDetailViewWindow( int iXSize, int iYSize, int iXStart, Drive drive) { WINDOW *newWindow; newWindow = newwin(iYSize, iXSize, 2, iXStart); wbkgd(newWindow, COLOR_PAIR(COLOR_AREA_OVERVIEW)); box(newWindow, ACS_VLINE, ACS_HLINE); - centerTitle(newWindow, "Selected Drive: xyz"); + string title = "Selected Drive: " + drive.getModelName() + " " + drive.sCapacityToText(); + centerTitle(newWindow, title.c_str()); + + + + + string sPath = "Path: " +drive.getPath(); + string sModelFamlily = "ModelFamily: " + drive.getModelFamily(); + string sModelName = "ModelName: " + drive.getModelName(); + string sCapacity = "Capacity: " + drive.sCapacityToText(); + string sSerial = "Serial: " + drive.getSerial(); + string sPowerOnHours = "PowerOnHours: " + drive.sPowerOnHoursToText(); + string sPowerCycle = "PowerCycle: " + drive.sPowerCyclesToText(); + string sErrorCount = "ErrorCount: " + drive.sErrorCountToText(); + + mvwaddstr(newWindow,2, 3, sPath.c_str()); + mvwaddstr(newWindow,3, 3, sModelFamlily.c_str()); + mvwaddstr(newWindow,4, 3, sModelName.c_str()); + mvwaddstr(newWindow,5, 3, sCapacity.c_str()); + mvwaddstr(newWindow,6, 3, sSerial.c_str()); + mvwaddstr(newWindow,7, 3, sPowerOnHours.c_str()); + mvwaddstr(newWindow,8, 3, sPowerCycle.c_str()); + mvwaddstr(newWindow,9, 3, sErrorCount.c_str()); keypad(newWindow, TRUE); return newWindow; diff --git a/src/drive.cpp b/src/drive.cpp index 367ba09..67b28f8 100644 --- a/src/drive.cpp +++ b/src/drive.cpp @@ -61,6 +61,22 @@ string Drive::sCapacityToText() return "ERROR"; } + string Drive::sErrorCountToText(){ + return to_string(getErrorCount()); + } + + + string Drive::sPowerOnHoursToText(){ + + //TODO show in human readable format + + return to_string(getPowerOnHours()); + + } + string Drive::sPowerCyclesToText(){ + return to_string(getPowerCycles()); + } + /** * \brief set S.M.A.R.T. values in model * \param string modelFamily