display shred duration after completion
This commit is contained in:
parent
48bbad914f
commit
ecc8a71c64
|
@ -38,6 +38,7 @@ private:
|
|||
time_t u32Timestamp = 0U; //unix timestamp for detecting a frozen drive
|
||||
double d32TaskPercentage = 0U; //in percent for Shred (1 to 100)
|
||||
time_t u32TimestampTaskStart = 0U; //unix timestamp for duration of an action
|
||||
time_t u32TaskDuration = 0U; //time needed to complete the task
|
||||
|
||||
private:
|
||||
void setTimestamp();
|
||||
|
@ -79,6 +80,9 @@ public:
|
|||
void setActionStartTimestamp();
|
||||
time_t getActionStartTimestamp();
|
||||
|
||||
void calculateTaskDuration();
|
||||
time_t getTaskDuration();
|
||||
|
||||
};
|
||||
|
||||
#endif // DRIVE_H_
|
|
@ -29,7 +29,7 @@
|
|||
#endif
|
||||
|
||||
// Logic
|
||||
#define DRYRUN //don´t touch the drives
|
||||
//#define DRYRUN //don´t touch the drives
|
||||
#define FROZEN_ALERT //show alert if drive is frozen
|
||||
|
||||
//IPC pipes
|
||||
|
|
|
@ -64,8 +64,7 @@ private:
|
|||
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);
|
||||
|
||||
string calculateTimeDelta(time_t start, time_t end);
|
||||
string formatTimeDuration(time_t u32Duration);
|
||||
|
||||
};
|
||||
#endif // TUI_H_
|
|
@ -134,7 +134,6 @@ void Drive::setDriveSMARTData( string modelFamily,
|
|||
u32PowerCycles = powerCycle;
|
||||
}
|
||||
|
||||
|
||||
void Drive::setTimestamp()
|
||||
{
|
||||
time(&this->u32Timestamp);
|
||||
|
@ -150,6 +149,19 @@ time_t Drive::getActionStartTimestamp()
|
|||
return this->u32TimestampTaskStart;
|
||||
}
|
||||
|
||||
void Drive::calculateTaskDuration()
|
||||
{
|
||||
time_t u32localtime;
|
||||
time(&u32localtime);
|
||||
|
||||
this->u32TaskDuration = u32localtime - this->u32TimestampTaskStart;
|
||||
}
|
||||
|
||||
time_t Drive::getTaskDuration()
|
||||
{
|
||||
return this->u32TaskDuration;
|
||||
}
|
||||
|
||||
void Drive::checkFrozenDrive(void)
|
||||
{
|
||||
time_t u32localtime;
|
||||
|
|
22
src/tui.cpp
22
src/tui.cpp
|
@ -96,7 +96,7 @@ void TUI::updateTUI(list <Drive>* plistDrives, uint8_t u8SelectedEntry)
|
|||
}
|
||||
|
||||
stringstream stream;
|
||||
time_t u32localtime;
|
||||
|
||||
|
||||
switch (it->state)
|
||||
{
|
||||
|
@ -105,13 +105,13 @@ void TUI::updateTUI(list <Drive>* plistDrives, uint8_t u8SelectedEntry)
|
|||
stream << fixed << setprecision(2) << (it->getTaskPercentage());
|
||||
sState = "Shredding: " + stream.str() + "%";
|
||||
|
||||
time(&u32localtime);
|
||||
sTime = this->calculateTimeDelta(it->getActionStartTimestamp(), u32localtime);
|
||||
it->calculateTaskDuration();
|
||||
sTime = this->formatTimeDuration(it->getTaskDuration());
|
||||
break;
|
||||
case Drive::DELETE_ACTIVE:
|
||||
sState = "Deleting ...";
|
||||
time(&u32localtime);
|
||||
sTime = this->calculateTimeDelta(it->getActionStartTimestamp(), u32localtime);
|
||||
it->calculateTaskDuration();
|
||||
sTime = this->formatTimeDuration(it->getTaskDuration());
|
||||
break;
|
||||
|
||||
case Drive::NONE:
|
||||
|
@ -124,6 +124,7 @@ void TUI::updateTUI(list <Drive>* plistDrives, uint8_t u8SelectedEntry)
|
|||
if (it->bWasShredded)
|
||||
{
|
||||
sState = "SHREDDED"; //mark drive as shreded previously, overwrite if deleted
|
||||
sTime = this->formatTimeDuration(it->getTaskDuration());
|
||||
}
|
||||
break;
|
||||
case Drive::FROZEN:
|
||||
|
@ -447,18 +448,15 @@ WINDOW* TUI::createFrozenWarning(int iXSize, int iYSize, int iXStart, int iYStar
|
|||
return newWindow;
|
||||
}
|
||||
|
||||
string TUI::calculateTimeDelta(time_t start, time_t end)
|
||||
string TUI::formatTimeDuration(time_t u32Duration)
|
||||
{
|
||||
std::ostringstream out;
|
||||
|
||||
int hr=(int)((end - start)/3600);
|
||||
int min=((int)((end - start)/60))%60;
|
||||
int sec=(int)((end - start)%60);
|
||||
|
||||
int hr=(int)((u32Duration)/3600);
|
||||
int min=((int)((u32Duration)/60))%60;
|
||||
int sec=(int)((u32Duration)%60);
|
||||
char s[25];
|
||||
sprintf(s, "%02d:%02d:%02d", hr, min, sec);
|
||||
out << s;
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue