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 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 <string>
#include <fstream>

View File

@ -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
{

View File

@ -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 ");
@ -166,15 +163,11 @@ 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();
@ -184,14 +177,48 @@ WINDOW* TUI::createDetailViewWindow( int iXSize, int iYSize, int iXStart, Drive
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());
uint16_t u16Line = 2;
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());
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;

View File

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