added states for tasks

This commit is contained in:
2020-08-09 21:41:28 +02:00
parent f4726bf08c
commit c2ab7c1c7f
6 changed files with 203 additions and 32 deletions

View File

@ -12,6 +12,29 @@
class Drive
{
public:
enum TaskState {NONE,
SHRED_SELECTED,
SHRED_ACTIVE,
SHRED_FINISHED,
DELETE_SELECTED,
DELETE_ACTIVE,
DELETE_FINISHED
} state;
private:
string sPath;
string sModelFamily;
string sModelName;
string sSerial;
uint64_t u64Capacity = 0U; //in byte
uint32_t u32ErrorCount = 0U;
uint32_t u32PowerOnHours = 0U; //in hours
uint32_t u32PowerCycles = 0U;
uint8_t u8TaskPercentage = 0U; //in percent for Shred (1 to 100) and Delete (1 OR 100)
protected:
public:
@ -42,18 +65,11 @@ public:
string sPowerOnHoursToText();
string sPowerCyclesToText();
void setTaskPercentage(uint8_t u8TaskPercentage);
uint8_t getTaskPercentage(void);
private:
string sPath;
string sModelFamily;
string sModelName;
string sSerial;
uint64_t u64Capacity = 0U; //in byte
uint32_t u32ErrorCount = 0U;
uint32_t u32PowerOnHours = 0U; //in hours
uint32_t u32PowerCycles = 0U;
uint32_t u32ShredPercentage = 0U; //in percent
};

View File

@ -13,6 +13,8 @@
#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 SELECTED_DRIVE vecDrives.at(i32SelectedEntry)
#include <iostream>
#include <string>
#include <fstream>
@ -58,11 +60,15 @@ private:
static void searchDrives(vector <Drive>* pvecDrives);
static void printDrives(vector <Drive>* pvecDrives);
static void filterIgnoredDrives(vector <Drive>* pvecDrives);
static void filterNewDrives(vector <Drive>* pvecOldDrives, vector <Drive>* pvecNewDrives);
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 handleEnter();
static void handleESC();
static void handleAbort();
};

View File

@ -23,12 +23,21 @@ protected:
public:
enum UserInput { UpKey, DownKey, Abort, Shred, Delete, Enter, ESC, Undefined};
struct MenuState
{
bool bAbort;
bool bShred;
bool bDelete;
bool bConfirmAbort;
bool bConfirmShred;
bool bConfirmDelete;
};
TUI(void);
static void initTUI();
void updateTUI(vector <Drive>* pvecDrives, int32_t i32SelectedEntry);
void updateTUI(vector <Drive>* pvecDrives, int32_t i32SelectedEntry, struct MenuState menustate);
static enum UserInput readUserInput();
@ -37,17 +46,17 @@ private:
static string sRamUsage;
static string sLocalTime;
WINDOW *detailview;
WINDOW *overview;
WINDOW *systemview;
WINDOW* detailview;
WINDOW* overview;
WINDOW* systemview;
WINDOW* menuview;
static void centerTitle(WINDOW *pwin, const char * title);
static WINDOW *createOverViewWindow( int iXSize, int iYSize);
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);
static WINDOW *createSystemStats(int iXSize, int iYSize, int iYStart);
static WINDOW *createMenuView(int iXSize, int iYSize, int iXStart, int iYStart, struct MenuState menustate);
};
#endif // TUI_H_