increase visibility of smart values
This commit is contained in:
parent
65c19f6fb9
commit
ade79add2a
@ -45,12 +45,12 @@ private:
|
|||||||
static string sRamUsage;
|
static string sRamUsage;
|
||||||
static string sLocalTime;
|
static string sLocalTime;
|
||||||
|
|
||||||
|
|
||||||
WINDOW* overview;
|
WINDOW* overview;
|
||||||
WINDOW* systemview;
|
WINDOW* systemview;
|
||||||
WINDOW* detailview;
|
WINDOW* detailview;
|
||||||
WINDOW* menuview;
|
WINDOW* menuview;
|
||||||
WINDOW* dialog;
|
WINDOW* dialog;
|
||||||
|
WINDOW* smartWarning;
|
||||||
|
|
||||||
static void centerTitle(WINDOW *pwin, const char * title);
|
static void centerTitle(WINDOW *pwin, const char * title);
|
||||||
static WINDOW *createOverViewWindow( int iXSize, int iYSize);
|
static WINDOW *createOverViewWindow( int iXSize, int iYSize);
|
||||||
@ -61,6 +61,7 @@ private:
|
|||||||
static WINDOW *createMenuView(int iXSize, int iYSize, int iXStart, int iYStart, struct MenuState menustate);
|
static WINDOW *createMenuView(int iXSize, int iYSize, int iXStart, int iYStart, struct MenuState menustate);
|
||||||
static WINDOW *createDialog(int iXSize, int iYSize, int iXStart, int iYStart, string selectedTask, string optionA, string optionB);
|
static WINDOW *createDialog(int iXSize, int iYSize, int iXStart, int iYStart, string selectedTask, string optionA, string optionB);
|
||||||
static WINDOW* createFrozenWarning(int iXSize, int iYSize, int iXStart, int iYStart, string sPath, string sModelFamily, string sModelName, string sSerial, string sProgress);
|
static WINDOW* createFrozenWarning(int iXSize, int iYSize, int iXStart, int iYStart, string sPath, string sModelFamily, string sModelName, string sSerial, string sProgress);
|
||||||
|
static WINDOW* createSmartWarning(int iXSize, int iYSize, int iXStart, int iYStart, string sPath, uint32_t u32PowerOnHours, uint32_t u32PowerCycles, uint32_t u32ErrorCount);
|
||||||
|
|
||||||
void displaySelectedDrive(Drive drive, int stdscrX, int stdscrY);
|
void displaySelectedDrive(Drive drive, int stdscrX, int stdscrY);
|
||||||
|
|
||||||
|
@ -69,14 +69,19 @@ string Drive::sErrorCountToText()
|
|||||||
|
|
||||||
string Drive::sPowerOnHoursToText()
|
string Drive::sPowerOnHoursToText()
|
||||||
{
|
{
|
||||||
|
double dDays = 0U;
|
||||||
double dYears = 0U;
|
double dYears = 0U;
|
||||||
uint32_t u32Hours = getPowerOnHours();
|
uint32_t u32Hours = getPowerOnHours();
|
||||||
stringstream stream;
|
stringstream streamDays;
|
||||||
|
stringstream streamYears;
|
||||||
|
|
||||||
|
dDays = (double) ((double)u32Hours/(double)24U);
|
||||||
dYears = (double) ((double)u32Hours/(double)8760U);
|
dYears = (double) ((double)u32Hours/(double)8760U);
|
||||||
|
|
||||||
stream << fixed << setprecision(2) << dYears;
|
streamDays << fixed << setprecision(0) << dDays;
|
||||||
string sRet = to_string(getPowerOnHours()) + " hours or " + stream.str() + " years";
|
streamYears << fixed << setprecision(1) << dYears;
|
||||||
|
|
||||||
|
string sRet = to_string(getPowerOnHours()) + " hours or " + streamDays.str() + " days or " + streamYears.str() + " years";
|
||||||
|
|
||||||
return sRet;
|
return sRet;
|
||||||
}
|
}
|
||||||
|
118
src/tui.cpp
118
src/tui.cpp
@ -53,18 +53,18 @@ void TUI::initTUI()
|
|||||||
void TUI::updateTUI(vector <Drive>* pvecDrives, uint8_t u8SelectedEntry)
|
void TUI::updateTUI(vector <Drive>* pvecDrives, uint8_t u8SelectedEntry)
|
||||||
{
|
{
|
||||||
mxUIrefresh.lock();
|
mxUIrefresh.lock();
|
||||||
int stdscrX, stdscrY;
|
uint16_t u16StdscrX, u16StdscrY;
|
||||||
getmaxyx(stdscr, stdscrY, stdscrX);
|
getmaxyx(stdscr, u16StdscrY, u16StdscrX);
|
||||||
|
|
||||||
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));
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
overview=createOverViewWindow((int)(stdscrX/3), (stdscrY-15));
|
overview=createOverViewWindow((int)(u16StdscrX/3), (u16StdscrY-15));
|
||||||
wrefresh(overview);
|
wrefresh(overview);
|
||||||
|
|
||||||
systemview=createSystemStats((int)(stdscrX/3), 10, (stdscrY-11));
|
systemview=createSystemStats((int)(u16StdscrX/3), 10, (u16StdscrY-11));
|
||||||
wrefresh(systemview);
|
wrefresh(systemview);
|
||||||
|
|
||||||
delwin(detailview);
|
delwin(detailview);
|
||||||
@ -82,7 +82,14 @@ void TUI::updateTUI(vector <Drive>* pvecDrives, uint8_t u8SelectedEntry)
|
|||||||
if(u8SelectedEntry == (it - pvecDrives->begin()))
|
if(u8SelectedEntry == (it - pvecDrives->begin()))
|
||||||
{
|
{
|
||||||
bSelectedEntry = true; //mark this drive in entries list
|
bSelectedEntry = true; //mark this drive in entries list
|
||||||
displaySelectedDrive(pvecDrives->at(u8SelectedEntry), stdscrX, stdscrY);
|
displaySelectedDrive(pvecDrives->at(u8SelectedEntry), u16StdscrX, u16StdscrY);
|
||||||
|
|
||||||
|
if((it->getPowerOnHours() >= WORSE_HOURS) || (it->getPowerCycles() >= WORSE_POWERUP) || (it->getErrorCount() > 0))
|
||||||
|
{
|
||||||
|
// smart values are bad --> show warning
|
||||||
|
smartWarning=createSmartWarning(50, 10, ((u16StdscrX)-(int)(u16StdscrX/2)+35),(int)(u16StdscrY/2)-5, it->getPath(), it->getPowerOnHours(), it->getPowerCycles(), it->getErrorCount());
|
||||||
|
wrefresh(smartWarning);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stringstream stream;
|
stringstream stream;
|
||||||
@ -116,7 +123,7 @@ void TUI::updateTUI(vector <Drive>* pvecDrives, uint8_t u8SelectedEntry)
|
|||||||
#ifdef FROZEN_ALERT
|
#ifdef FROZEN_ALERT
|
||||||
if(bSelectedEntry)
|
if(bSelectedEntry)
|
||||||
{
|
{
|
||||||
dialog=createFrozenWarning(70, 16, ((stdscrX)-(int)(stdscrX/2)-20),(int)(stdscrY/2)-8, it->getPath(), it->getModelFamily(), it->getModelName(), it->getSerial(), stream.str() + "%");
|
dialog=createFrozenWarning(70, 16, ((u16StdscrX)-(int)(u16StdscrX/2)-20),(int)(u16StdscrY/2)-8, it->getPath(), it->getModelFamily(), it->getModelName(), it->getSerial(), stream.str() + "%");
|
||||||
wrefresh(dialog);
|
wrefresh(dialog);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -126,7 +133,7 @@ void TUI::updateTUI(vector <Drive>* pvecDrives, uint8_t u8SelectedEntry)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
WINDOW * tmp = createEntryWindow( ((int)(stdscrX/3) - 2), 5, 3, (5* (it - pvecDrives->begin()) )+3, sModelFamily, sModelName, sCapacity, sState, bSelectedEntry);
|
WINDOW * tmp = createEntryWindow( ((int)(u16StdscrX/3) - 2), 5, 3, (5* (it - pvecDrives->begin()) )+3, sModelFamily, sModelName, sCapacity, sState, bSelectedEntry);
|
||||||
wrefresh(tmp);
|
wrefresh(tmp);
|
||||||
}//end loop though drives
|
}//end loop though drives
|
||||||
|
|
||||||
@ -141,10 +148,10 @@ void TUI::updateTUI(vector <Drive>* pvecDrives, uint8_t u8SelectedEntry)
|
|||||||
menustate.bDelete = false;
|
menustate.bDelete = false;
|
||||||
menustate.bShred = false;
|
menustate.bShred = false;
|
||||||
|
|
||||||
menuview=createMenuView(((stdscrX)-(int)(stdscrX/3)-7), 10, (int)(stdscrX/3)+5,(stdscrY-11), menustate);
|
menuview=createMenuView(((u16StdscrX)-(int)(u16StdscrX/3)-7), 10, (int)(u16StdscrX/3)+5,(u16StdscrY-11), menustate);
|
||||||
wrefresh(menuview);
|
wrefresh(menuview);
|
||||||
|
|
||||||
detailview=overwriteDetailViewWindow(((stdscrX)-(int)(stdscrX/3)-7), (stdscrY-15), (int)(stdscrX/3)+5);
|
detailview=overwriteDetailViewWindow(((u16StdscrX)-(int)(u16StdscrX/3)-7), (u16StdscrY-15), (int)(u16StdscrX/3)+5);
|
||||||
wrefresh(detailview);
|
wrefresh(detailview);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,38 +246,9 @@ WINDOW* TUI::createDetailViewWindow( int iXSize, int iYSize, int iXStart, Drive
|
|||||||
|
|
||||||
attroff(COLOR_PAIR(COLOR_AREA_DETAIL));
|
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, 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, 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, sErrorCount.c_str());
|
||||||
mvwaddstr(newWindow,u16Line++, 3, "---------------------------------------------------");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mvwaddstr(newWindow,u16Line++, 3, sErrorCount.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
return newWindow;
|
return newWindow;
|
||||||
}
|
}
|
||||||
@ -355,7 +333,19 @@ WINDOW* TUI::createSystemStats(int iXSize, int iYSize, int iYStart)
|
|||||||
strftime(buffer,sizeof(buffer),"Date: %d-%m-%Y Time: %H:%M",timeinfo);
|
strftime(buffer,sizeof(buffer),"Date: %d-%m-%Y Time: %H:%M",timeinfo);
|
||||||
string time(buffer);
|
string time(buffer);
|
||||||
|
|
||||||
mvwaddstr(newWindow,2, 2, time.c_str());
|
string sLine01 = "reHDD - hard drive refurbishing tool";
|
||||||
|
string sLine02 = "Version: " + string(REHDD_VERSION);
|
||||||
|
string sLine03 = "Available under GPL 3.0";
|
||||||
|
string sLine04 = "https://git.mosad.xyz/localhorst/reHDD";
|
||||||
|
|
||||||
|
uint16_t u16Line = 2;
|
||||||
|
|
||||||
|
mvwaddstr(newWindow,u16Line++, (iXSize/2)-(sLine01.size()/2), sLine01.c_str());
|
||||||
|
mvwaddstr(newWindow,u16Line++, (iXSize/2)-(sLine01.size()/2), sLine02.c_str());
|
||||||
|
mvwaddstr(newWindow,u16Line++, (iXSize/2)-(sLine01.size()/2), sLine03.c_str());
|
||||||
|
mvwaddstr(newWindow,u16Line++, (iXSize/2)-(sLine01.size()/2), sLine04.c_str());
|
||||||
|
u16Line++;
|
||||||
|
mvwaddstr(newWindow,u16Line++, (iXSize/2)-(sLine01.size()/2), time.c_str());
|
||||||
|
|
||||||
return newWindow;
|
return newWindow;
|
||||||
}
|
}
|
||||||
@ -399,9 +389,10 @@ WINDOW* TUI::createDialog(int iXSize, int iYSize, int iXStart, int iYStart, stri
|
|||||||
|
|
||||||
centerTitle(newWindow, task.c_str());
|
centerTitle(newWindow, task.c_str());
|
||||||
|
|
||||||
uint16_t u16Line = 2;
|
uint16_t u16Line = 3;
|
||||||
mvwaddstr(newWindow,u16Line++, 3, optionA.c_str());
|
mvwaddstr(newWindow,u16Line++, (iXSize/2)-(optionA.size()/2), optionA.c_str());
|
||||||
mvwaddstr(newWindow,u16Line++, 3, optionB.c_str());
|
u16Line++;
|
||||||
|
mvwaddstr(newWindow,u16Line++, (iXSize/2)-(optionB.size()/2), optionB.c_str());
|
||||||
|
|
||||||
return newWindow;
|
return newWindow;
|
||||||
}
|
}
|
||||||
@ -485,12 +476,12 @@ void TUI::displaySelectedDrive(Drive drive, int stdscrX, int stdscrY)
|
|||||||
|
|
||||||
if(menustate.bConfirmShred == true)
|
if(menustate.bConfirmShred == true)
|
||||||
{
|
{
|
||||||
dialog=createDialog(70, 10, ((stdscrX)-(int)(stdscrX/3)-7)-(int)((stdscrX/3)+5)/2,(int)(stdscrY/2)-5, "Confirm SHRED", "Press ENTER for SHRED", "Press ESC for cancel");
|
dialog=createDialog(40, 10, ((stdscrX)-(int)(stdscrX/3)-7)-(int)((stdscrX/3)+5)/2,(int)(stdscrY/2)-5, "Confirm SHRED", "Press ENTER for SHRED", "Press ESC for cancel");
|
||||||
wrefresh(dialog);
|
wrefresh(dialog);
|
||||||
}
|
}
|
||||||
else if(menustate.bConfirmDelete == true)
|
else if(menustate.bConfirmDelete == true)
|
||||||
{
|
{
|
||||||
dialog=createDialog(70, 10, ((stdscrX)-(int)(stdscrX/3)-7)-(int)((stdscrX/3)+5)/2,(int)(stdscrY/2)-5, "Confirm DELETE", "Press ENTER for DELETE", "Press ESC for cancel");
|
dialog=createDialog(40, 10, ((stdscrX)-(int)(stdscrX/3)-7)-(int)((stdscrX/3)+5)/2,(int)(stdscrY/2)-5, "Confirm DELETE", "Press ENTER for DELETE", "Press ESC for cancel");
|
||||||
wrefresh(dialog);
|
wrefresh(dialog);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -498,3 +489,42 @@ void TUI::displaySelectedDrive(Drive drive, int stdscrX, int stdscrY)
|
|||||||
delwin(dialog);
|
delwin(dialog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WINDOW* TUI::createSmartWarning(int iXSize, int iYSize, int iXStart, int iYStart, string sPath, uint32_t u32PowerOnHours, uint32_t u32PowerCycles, uint32_t u32ErrorCount)
|
||||||
|
{
|
||||||
|
WINDOW *newWindow;
|
||||||
|
newWindow = newwin(iYSize, iXSize, iYStart, iXStart);
|
||||||
|
|
||||||
|
wbkgd(newWindow, COLOR_PAIR(COLOR_AREA_ENTRY_SELECTED));
|
||||||
|
box(newWindow, ACS_VLINE, ACS_HLINE);
|
||||||
|
|
||||||
|
string sHeader = "Drive " + sPath + " is suspicious";
|
||||||
|
string sLine01 = "Please evaluate this drive carefully.";
|
||||||
|
|
||||||
|
centerTitle(newWindow, sHeader.c_str());
|
||||||
|
|
||||||
|
uint16_t u16Line = 2;
|
||||||
|
mvwaddstr(newWindow,u16Line++, (iXSize/2)-(sLine01.size()/2), sLine01.c_str());
|
||||||
|
u16Line++;
|
||||||
|
|
||||||
|
if(u32PowerOnHours > WORSE_HOURS)
|
||||||
|
{
|
||||||
|
string sLineTmp = "Operating hours exceeded " + to_string(WORSE_HOURS) + " hours: " + to_string(u32PowerOnHours);
|
||||||
|
mvwaddstr(newWindow,u16Line++, (iXSize/2)-(sLine01.size()/2), sLineTmp.c_str());
|
||||||
|
u16Line++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(u32PowerCycles > WORSE_POWERUP)
|
||||||
|
{
|
||||||
|
string sLineTmp = "Power-on exceeded " + to_string(WORSE_POWERUP) + " cycles: " + to_string(u32PowerCycles);
|
||||||
|
mvwaddstr(newWindow,u16Line++, (iXSize/2)-(sLine01.size()/2), sLineTmp.c_str());
|
||||||
|
u16Line++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(u32ErrorCount > 0)
|
||||||
|
{
|
||||||
|
string sLineTmp = "S.M.A.R.T. erros detected: " + to_string(u32ErrorCount);
|
||||||
|
mvwaddstr(newWindow,u16Line++, (iXSize/2)-(sLine01.size()/2), sLineTmp.c_str());
|
||||||
|
}
|
||||||
|
return newWindow;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user