added warning levels

This commit is contained in:
Hendrik Schutter 2020-08-07 16:17:45 +02:00
parent 29eda094a7
commit 1e4d9975c6
4 changed files with 78 additions and 46 deletions

View File

@ -10,6 +10,9 @@
#define DRYRUN #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 <iostream> #include <iostream>
#include <string> #include <string>
#include <fstream> #include <fstream>

View File

@ -14,8 +14,7 @@
#define COLOR_AREA_OVERVIEW 2 #define COLOR_AREA_OVERVIEW 2
#define COLOR_AREA_ENTRY 3 #define COLOR_AREA_ENTRY 3
#define COLOR_AREA_ENTRY_SELECTED 4 #define COLOR_AREA_ENTRY_SELECTED 4
#define COLOR_AREA_DETAIL 5
#define COLOR_GRAY 8
class TUI class TUI
{ {

View File

@ -40,16 +40,13 @@ void TUI::initTUI()
curs_set(0); curs_set(0);
noecho(); noecho();
cbreak(); cbreak();
init_color(COLOR_GRAY, 173, 170, 173);
init_pair(COLOR_AREA_STDSCR,COLOR_WHITE, COLOR_BLUE); init_pair(COLOR_AREA_STDSCR,COLOR_WHITE, COLOR_BLUE);
wbkgd(stdscr, COLOR_PAIR(COLOR_AREA_STDSCR)); wbkgd(stdscr, COLOR_PAIR(COLOR_AREA_STDSCR));
init_pair(COLOR_AREA_ENTRY, COLOR_BLACK, COLOR_GRAY); init_pair(COLOR_AREA_ENTRY, COLOR_BLACK, COLOR_WHITE);
init_pair(COLOR_AREA_ENTRY_SELECTED, COLOR_BLACK, COLOR_WHITE); init_pair(COLOR_AREA_ENTRY_SELECTED, COLOR_BLACK, COLOR_RED);
init_pair(COLOR_AREA_OVERVIEW, COLOR_BLACK, COLOR_GRAY); init_pair(COLOR_AREA_OVERVIEW, COLOR_BLACK, COLOR_WHITE);
init_pair(COLOR_AREA_OVERVIEW, COLOR_BLACK, COLOR_GRAY); init_pair(COLOR_AREA_DETAIL, COLOR_BLACK, COLOR_WHITE);
mvprintw(0, 2, "reHDD - HDD refurbishing tool - GPL 3.0 "); mvprintw(0, 2, "reHDD - HDD refurbishing tool - GPL 3.0 ");
@ -81,8 +78,8 @@ void TUI::updateTUI(vector <Drive>* pvecDrives, int32_t i32SelectedEntry)
if(i32SelectedEntry == (it - pvecDrives->begin())) if(i32SelectedEntry == (it - pvecDrives->begin()))
{ {
bSelectedEntry = true; bSelectedEntry = true;
detailview=createDetailViewWindow(((stdscrX)-(int)(stdscrX/3)-7), (stdscrY-3), (int)(stdscrX/3)+5, pvecDrives->at((it - pvecDrives->begin()))); detailview=createDetailViewWindow(((stdscrX)-(int)(stdscrX/3)-7), (stdscrY-3), (int)(stdscrX/3)+5, pvecDrives->at((it - pvecDrives->begin())));
wrefresh(detailview); wrefresh(detailview);
} }
WINDOW * tmp = createEntryWindow( ((int)(stdscrX/3) - 2), 5, 3, (5* (it - pvecDrives->begin()) )+3, sModelFamily, sModelName, sCapacity, bSelectedEntry); 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; WINDOW *newWindow;
newWindow = newwin(iYSize, iXSize, 2, iXStart); newWindow = newwin(iYSize, iXSize, 2, iXStart);
wbkgd(newWindow, COLOR_PAIR(COLOR_AREA_DETAIL));
wbkgd(newWindow, COLOR_PAIR(COLOR_AREA_OVERVIEW));
box(newWindow, ACS_VLINE, ACS_HLINE); box(newWindow, ACS_VLINE, ACS_HLINE);
string title = "Selected Drive: " + drive.getModelName() + " " + drive.sCapacityToText(); string title = "Selected Drive: " + drive.getModelName() + " " + drive.sCapacityToText();
centerTitle(newWindow, title.c_str()); 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(); mvwaddstr(newWindow,u16Line++, 3, sPath.c_str());
string sModelFamlily = "ModelFamily: " + drive.getModelFamily(); mvwaddstr(newWindow,u16Line++, 3, sModelFamlily.c_str());
string sModelName = "ModelName: " + drive.getModelName(); mvwaddstr(newWindow,u16Line++, 3, sModelName.c_str());
string sCapacity = "Capacity: " + drive.sCapacityToText(); mvwaddstr(newWindow,u16Line++, 3, sCapacity.c_str());
string sSerial = "Serial: " + drive.getSerial(); mvwaddstr(newWindow,u16Line++, 3, sSerial.c_str());
string sPowerOnHours = "PowerOnHours: " + drive.sPowerOnHoursToText();
string sPowerCycle = "PowerCycle: " + drive.sPowerCyclesToText();
string sErrorCount = "ErrorCount: " + drive.sErrorCountToText();
mvwaddstr(newWindow,2, 3, sPath.c_str()); attroff(COLOR_PAIR(COLOR_AREA_DETAIL));
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());
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); keypad(newWindow, TRUE);
return newWindow; return newWindow;
} }

View File

@ -61,27 +61,30 @@ string Drive::sCapacityToText()
return "ERROR"; return "ERROR";
} }
string Drive::sErrorCountToText(){ string Drive::sErrorCountToText()
return to_string(getErrorCount()); {
} return to_string(getErrorCount());
}
string Drive::sPowerOnHoursToText(){ string Drive::sPowerOnHoursToText()
double dYears = 0U; {
uint32_t u32Hours = getPowerOnHours(); double dYears = 0U;
stringstream stream; uint32_t u32Hours = getPowerOnHours();
stringstream stream;
dYears = (double) ((double)u32Hours/(double)8760U); dYears = (double) ((double)u32Hours/(double)8760U);
stream << fixed << setprecision(2) << dYears;
string sRet = to_string(getPowerOnHours()) + " hours or " + stream.str() + " years";
return sRet; stream << fixed << setprecision(2) << dYears;
} string sRet = to_string(getPowerOnHours()) + " hours or " + stream.str() + " years";
string Drive::sPowerCyclesToText(){ return sRet;
return to_string(getPowerCycles()); }
}
string Drive::sPowerCyclesToText()
{
return to_string(getPowerCycles());
}
/** /**
* \brief set S.M.A.R.T. values in model * \brief set S.M.A.R.T. values in model