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