percent are now two digit precision
This commit is contained in:
parent
320e306d06
commit
b271f7955a
@ -34,7 +34,7 @@ private:
|
||||
uint32_t u32PowerOnHours = 0U; //in hours
|
||||
uint32_t u32PowerCycles = 0U;
|
||||
|
||||
uint8_t u8TaskPercentage = 0U; //in percent for Shred (1 to 100)
|
||||
double d32TaskPercentage = 0U; //in percent for Shred (1 to 100)
|
||||
|
||||
protected:
|
||||
|
||||
@ -66,8 +66,8 @@ public:
|
||||
string sPowerOnHoursToText();
|
||||
string sPowerCyclesToText();
|
||||
|
||||
void setTaskPercentage(uint8_t u8TaskPercentage);
|
||||
uint8_t getTaskPercentage(void);
|
||||
void setTaskPercentage(double d32TaskPercentage);
|
||||
double getTaskPercentage(void);
|
||||
|
||||
};
|
||||
|
||||
|
@ -8,17 +8,13 @@
|
||||
#ifndef REHDD_H_
|
||||
#define REHDD_H_
|
||||
|
||||
#define DRYRUN
|
||||
//#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
|
||||
|
||||
#define SHRED_ITERATIONS 1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define READ 0
|
||||
#define WRITE 1
|
||||
|
||||
|
@ -80,7 +80,7 @@ public:
|
||||
|
||||
private:
|
||||
Shred(void);
|
||||
static inline uint8_t calcProgress();
|
||||
static inline double calcProgress();
|
||||
static inline void tfnge_init_iv(struct tfnge_stream *tfe, const void *key, const void *iv);
|
||||
static inline void tfnge_init(struct tfnge_stream *tfe, const void *key);
|
||||
static inline void tfng_encrypt_rawblk(TFNG_UNIT_TYPE *O, const TFNG_UNIT_TYPE *I, const TFNG_UNIT_TYPE *K);
|
||||
|
@ -86,16 +86,16 @@ string Drive::sPowerCyclesToText()
|
||||
return to_string(getPowerCycles());
|
||||
}
|
||||
|
||||
void Drive::setTaskPercentage(uint8_t u8TaskPercentage)
|
||||
void Drive::setTaskPercentage(double d32TaskPercentage)
|
||||
{
|
||||
if(u8TaskPercentage <= 100)
|
||||
if(d32TaskPercentage <= 100)
|
||||
{
|
||||
this->u8TaskPercentage = u8TaskPercentage;
|
||||
this->d32TaskPercentage = d32TaskPercentage;
|
||||
}
|
||||
}
|
||||
uint8_t Drive::getTaskPercentage(void)
|
||||
double Drive::getTaskPercentage(void)
|
||||
{
|
||||
return this->u8TaskPercentage;
|
||||
return this->d32TaskPercentage;
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,7 +24,7 @@ static struct tfnge_stream tfnge;
|
||||
|
||||
static unsigned long blockcount = 0UL;
|
||||
static long blockcount_max;
|
||||
static uint8_t u8Percent;
|
||||
static double d32Percent;
|
||||
#endif
|
||||
/**
|
||||
* \brief shred drive with shred
|
||||
@ -60,7 +60,7 @@ void Shred::shredDrive(Drive* drive, int* ipSignalFd)
|
||||
|
||||
blockcount_max = SHRED_ITERATIONS*(drive->getCapacity()/4096);
|
||||
|
||||
u8Percent = 0U;
|
||||
d32Percent = 0U;
|
||||
|
||||
rsf = open(randsrc, O_RDONLY | O_LARGEFILE);
|
||||
if (rsf == -1)
|
||||
@ -148,19 +148,19 @@ void Shred::shredDrive(Drive* drive, int* ipSignalFd)
|
||||
// write block loop
|
||||
while (1)
|
||||
{
|
||||
usleep(10);
|
||||
//usleep(10);
|
||||
|
||||
if(drive->state != Drive::SHRED_ACTIVE)
|
||||
{
|
||||
goto _return;
|
||||
}
|
||||
|
||||
uint8_t u8TmpPercent = calcProgress();
|
||||
double d32TmpPercent = calcProgress();
|
||||
|
||||
if(u8Percent != u8TmpPercent)
|
||||
if((d32TmpPercent-d32Percent) >= 0.09)
|
||||
{
|
||||
drive->setTaskPercentage(u8TmpPercent);
|
||||
u8Percent = u8TmpPercent;
|
||||
drive->setTaskPercentage(d32TmpPercent);
|
||||
d32Percent = d32TmpPercent;
|
||||
write(*ipSignalFd, "A",1);
|
||||
}
|
||||
|
||||
@ -267,11 +267,18 @@ void Shred::shredDrive(Drive* drive, int* ipSignalFd)
|
||||
_return:
|
||||
optind++;
|
||||
close(rsf);
|
||||
|
||||
if(drive->state == Drive::SHRED_ACTIVE)
|
||||
{
|
||||
drive->bWasShredded = true;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
#ifndef DRYRUN
|
||||
|
||||
uint8_t Shred::calcProgress()
|
||||
double Shred::calcProgress()
|
||||
{
|
||||
blockcount++;
|
||||
return ((((double)blockcount/(double)blockcount_max))*100);
|
||||
|
19
src/tui.cpp
19
src/tui.cpp
@ -85,11 +85,14 @@ void TUI::updateTUI(vector <Drive>* pvecDrives, uint8_t u8SelectedEntry)
|
||||
displaySelectedDrive(pvecDrives->at(u8SelectedEntry), stdscrX, stdscrY);
|
||||
}
|
||||
|
||||
stringstream stream;
|
||||
|
||||
switch (it->state)
|
||||
{
|
||||
case Drive::SHRED_ACTIVE:
|
||||
sState = "Shredding: " + to_string(it->getTaskPercentage()) + "%";
|
||||
|
||||
stream << fixed << setprecision(2) << (it->getTaskPercentage());
|
||||
sState = "Shredding: " + stream.str() + "%";
|
||||
break;
|
||||
|
||||
case Drive::DELETE_ACTIVE:
|
||||
@ -190,7 +193,7 @@ WINDOW* TUI::createOverViewWindow( int iXSize, int iYSize)
|
||||
|
||||
centerTitle(newWindow, "Detected Drives");
|
||||
|
||||
keypad(newWindow, TRUE);
|
||||
//keypad(newWindow, TRUE);
|
||||
return newWindow;
|
||||
}
|
||||
|
||||
@ -256,7 +259,7 @@ WINDOW* TUI::createDetailViewWindow( int iXSize, int iYSize, int iXStart, Drive
|
||||
mvwaddstr(newWindow,u16Line++, 3, sErrorCount.c_str());
|
||||
}
|
||||
|
||||
keypad(newWindow, TRUE);
|
||||
//keypad(newWindow, TRUE);
|
||||
return newWindow;
|
||||
}
|
||||
|
||||
@ -290,7 +293,7 @@ WINDOW* TUI::overwriteDetailViewWindow( int iXSize, int iYSize, int iXStart)
|
||||
|
||||
attroff(COLOR_PAIR(COLOR_AREA_DETAIL));
|
||||
|
||||
keypad(newWindow, TRUE);
|
||||
//keypad(newWindow, TRUE);
|
||||
return newWindow;
|
||||
}
|
||||
|
||||
@ -320,7 +323,7 @@ WINDOW* TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart,
|
||||
|
||||
mvwaddstr(newWindow,2, iXSize-sState.length()-5, sState.c_str());
|
||||
|
||||
keypad(newWindow, TRUE);
|
||||
//keypad(newWindow, TRUE);
|
||||
|
||||
return newWindow;
|
||||
}
|
||||
@ -346,7 +349,7 @@ WINDOW* TUI::createSystemStats(int iXSize, int iYSize, int iYStart)
|
||||
|
||||
mvwaddstr(newWindow,2, 2, time.c_str());
|
||||
|
||||
keypad(newWindow, TRUE);
|
||||
//keypad(newWindow, TRUE);
|
||||
return newWindow;
|
||||
}
|
||||
|
||||
@ -375,7 +378,7 @@ WINDOW* TUI::createMenuView(int iXSize, int iYSize, int iXStart, int iYStart, st
|
||||
{
|
||||
mvwaddstr(newWindow,u16Line++, 3, "Press D for Delete");
|
||||
}
|
||||
keypad(newWindow, TRUE);
|
||||
//keypad(newWindow, TRUE);
|
||||
return newWindow;
|
||||
}
|
||||
|
||||
@ -393,7 +396,7 @@ WINDOW* TUI::createDialog(int iXSize, int iYSize, int iXStart, int iYStart, stri
|
||||
mvwaddstr(newWindow,u16Line++, 3, optionA.c_str());
|
||||
mvwaddstr(newWindow,u16Line++, 3, optionB.c_str());
|
||||
|
||||
keypad(newWindow, TRUE);
|
||||
//keypad(newWindow, TRUE);
|
||||
return newWindow;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user