show drive overview

This commit is contained in:
Hendrik Schutter 2020-08-07 12:07:29 +02:00
parent 1b0ea97ed1
commit 99273756da
5 changed files with 49 additions and 16 deletions

View File

@ -38,6 +38,9 @@ public:
uint32_t powerCycles);
string sCapacityToText();
string sErrorCountToText();
string sPowerOnHoursToText();
string sPowerCyclesToText();
private:
string sPath;

View File

@ -50,21 +50,14 @@ public:
private:
static void searchDrives(vector <Drive>* pvecDrives);
static void printDrives(vector <Drive>* pvecDrives);
static void filterIgnoredDrives(vector <Drive>* pvecDrives);
static void addSMARTData(vector <Drive>* pvecDrives);
static void ThreadScannDevices();
static void ThreadUserInput();
static void handleArrowKey(TUI::UserInput userInput);
static void filterNewDrives(vector <Drive>* pvecOldDrives, vector <Drive>* pvecNewDrives);
static void ThreadUserInput();
static void handleArrowKey(TUI::UserInput userInput);
static void filterNewDrives(vector <Drive>* pvecOldDrives, vector <Drive>* pvecNewDrives);
};

View File

@ -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);
};

View File

@ -69,9 +69,6 @@ void TUI::updateTUI(vector <Drive>* 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 <Drive>::iterator it;
for (it = pvecDrives->begin(); it != pvecDrives->end(); ++it)
{
@ -84,6 +81,8 @@ void TUI::updateTUI(vector <Drive>* 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;

View File

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