diff --git a/include/reHDD.h b/include/reHDD.h index df32002..7ac6bfd 100644 --- a/include/reHDD.h +++ b/include/reHDD.h @@ -10,6 +10,9 @@ #define DRYRUN +#define WORSE_HOURS 19200 //mark drive if at this limit or beyond +#define WORSE_POWERUP 4000 //mark drive if at this limit or beyond + #include #include #include diff --git a/include/tui.h b/include/tui.h index 0bbd795..7748ef5 100644 --- a/include/tui.h +++ b/include/tui.h @@ -14,8 +14,7 @@ #define COLOR_AREA_OVERVIEW 2 #define COLOR_AREA_ENTRY 3 #define COLOR_AREA_ENTRY_SELECTED 4 - -#define COLOR_GRAY 8 +#define COLOR_AREA_DETAIL 5 class TUI { diff --git a/src/TUI/tui.cpp b/src/TUI/tui.cpp index c92872e..504d520 100644 --- a/src/TUI/tui.cpp +++ b/src/TUI/tui.cpp @@ -40,16 +40,13 @@ void TUI::initTUI() curs_set(0); noecho(); cbreak(); - init_color(COLOR_GRAY, 173, 170, 173); - init_pair(COLOR_AREA_STDSCR,COLOR_WHITE, COLOR_BLUE); wbkgd(stdscr, COLOR_PAIR(COLOR_AREA_STDSCR)); - init_pair(COLOR_AREA_ENTRY, COLOR_BLACK, COLOR_GRAY); - init_pair(COLOR_AREA_ENTRY_SELECTED, COLOR_BLACK, COLOR_WHITE); - init_pair(COLOR_AREA_OVERVIEW, COLOR_BLACK, COLOR_GRAY); - init_pair(COLOR_AREA_OVERVIEW, COLOR_BLACK, COLOR_GRAY); - + init_pair(COLOR_AREA_ENTRY, COLOR_BLACK, COLOR_WHITE); + init_pair(COLOR_AREA_ENTRY_SELECTED, COLOR_BLACK, COLOR_RED); + init_pair(COLOR_AREA_OVERVIEW, COLOR_BLACK, COLOR_WHITE); + init_pair(COLOR_AREA_DETAIL, COLOR_BLACK, COLOR_WHITE); mvprintw(0, 2, "reHDD - HDD refurbishing tool - GPL 3.0 "); @@ -81,8 +78,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); + 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); @@ -166,33 +163,63 @@ WINDOW* TUI::createDetailViewWindow( int iXSize, int iYSize, int iXStart, Drive { WINDOW *newWindow; newWindow = newwin(iYSize, iXSize, 2, iXStart); - - wbkgd(newWindow, COLOR_PAIR(COLOR_AREA_OVERVIEW)); + wbkgd(newWindow, COLOR_PAIR(COLOR_AREA_DETAIL)); box(newWindow, ACS_VLINE, ACS_HLINE); 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(); - + uint16_t u16Line = 2; - 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,u16Line++, 3, sPath.c_str()); + mvwaddstr(newWindow,u16Line++, 3, sModelFamlily.c_str()); + mvwaddstr(newWindow,u16Line++, 3, sModelName.c_str()); + mvwaddstr(newWindow,u16Line++, 3, sCapacity.c_str()); + mvwaddstr(newWindow,u16Line++, 3, sSerial.c_str()); - 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()); + attroff(COLOR_PAIR(COLOR_AREA_DETAIL)); + if(drive.getPowerOnHours() >= WORSE_HOURS) + { + mvwaddstr(newWindow,u16Line++, 3, "------------> WARNING: OPERATING HOURS <-----------"); + mvwaddstr(newWindow,u16Line++, 3, sPowerOnHours.c_str()); + mvwaddstr(newWindow,u16Line++, 3, "---------------------------------------------------"); + } + else + { + mvwaddstr(newWindow,u16Line++, 3, sPowerOnHours.c_str()); + } + + if(drive.getPowerCycles() >= WORSE_POWERUP) + { + mvwaddstr(newWindow,u16Line++, 3, "------------> WARNING: POWER-ON <------------------"); + mvwaddstr(newWindow,u16Line++, 3, sPowerCycle.c_str()); + mvwaddstr(newWindow,u16Line++, 3, "---------------------------------------------------"); + } + else + { + mvwaddstr(newWindow,u16Line++, 3, sPowerCycle.c_str()); + } + + if(drive.getErrorCount() > 0) + { + mvwaddstr(newWindow,u16Line++, 3, "------------> WARNING: S.M.A.R.T ERROR <-----------"); + mvwaddstr(newWindow,u16Line++, 3, sErrorCount.c_str()); + mvwaddstr(newWindow,u16Line++, 3, "---------------------------------------------------"); + } + else + { + mvwaddstr(newWindow,u16Line++, 3, sErrorCount.c_str()); + } + keypad(newWindow, TRUE); return newWindow; } diff --git a/src/drive.cpp b/src/drive.cpp index cb30cca..1b7b5c3 100644 --- a/src/drive.cpp +++ b/src/drive.cpp @@ -61,27 +61,30 @@ string Drive::sCapacityToText() return "ERROR"; } - string Drive::sErrorCountToText(){ - return to_string(getErrorCount()); - } +string Drive::sErrorCountToText() +{ + return to_string(getErrorCount()); +} - string Drive::sPowerOnHoursToText(){ - double dYears = 0U; - uint32_t u32Hours = getPowerOnHours(); - stringstream stream; +string Drive::sPowerOnHoursToText() +{ + double dYears = 0U; + uint32_t u32Hours = getPowerOnHours(); + stringstream stream; - dYears = (double) ((double)u32Hours/(double)8760U); - - stream << fixed << setprecision(2) << dYears; - string sRet = to_string(getPowerOnHours()) + " hours or " + stream.str() + " years"; + dYears = (double) ((double)u32Hours/(double)8760U); - return sRet; - } + stream << fixed << setprecision(2) << dYears; + string sRet = to_string(getPowerOnHours()) + " hours or " + stream.str() + " years"; - string Drive::sPowerCyclesToText(){ - return to_string(getPowerCycles()); - } + return sRet; +} + +string Drive::sPowerCyclesToText() +{ + return to_string(getPowerCycles()); +} /** * \brief set S.M.A.R.T. values in model