reHDD/include/drive.h

105 lines
2.7 KiB
C
Raw Normal View History

/**
2020-05-02 22:06:47 +02:00
* @file drive.h
* @brief represent physical drive
* @author hendrik schutter
* @date 01.05.2020
*/
#ifndef DRIVE_H_
#define DRIVE_H_
2020-05-02 22:06:47 +02:00
#include "reHDD.h"
class Drive
{
2020-08-09 21:41:28 +02:00
public:
enum TaskState {NONE,
SHRED_SELECTED,
SHRED_ACTIVE,
DELETE_SELECTED,
DELETE_ACTIVE,
FROZEN
2020-08-09 21:41:28 +02:00
} state;
2020-08-23 11:04:10 +02:00
struct
{
2022-06-30 00:32:13 +02:00
time_t u32ShredTimeDelta;
std::chrono::time_point<std::chrono::system_clock> chronoShredTimestamp;
unsigned long ulWrittenBytes;
unsigned long ulSpeedMetricBytesWritten;
2022-06-30 00:32:13 +02:00
} sShredSpeed;
2020-08-23 09:26:32 +02:00
bool bWasShredded = false;
bool bWasDeleteted = false;
bool bIsOffline = false;
uint32_t u32DriveChecksumAferShredding = 0U;
2020-08-09 21:41:28 +02:00
private:
string sPath;
time_t u32Timestamp = 0U; //unix timestamp for detecting a frozen drive
2020-08-28 15:28:57 +02:00
double d32TaskPercentage = 0U; //in percent for Shred (1 to 100)
2022-05-11 23:45:05 +02:00
time_t u32TimestampTaskStart = 0U; //unix timestamp for duration of an action
time_t u32TaskDuration = 0U; //time needed to complete the task
2020-08-09 21:41:28 +02:00
struct
{
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 u32Temperature = 0U; //in Fahrenheit, just kidding: degree Celsius
} sSmartData;
private:
void setTimestamp();
protected:
public:
Drive(string path)
{
this->sPath = path;
}
string getPath(void);
2020-05-02 00:49:11 +02:00
string getModelFamily(void);
string getModelName(void);
string getSerial(void);
2020-05-02 13:25:27 +02:00
uint64_t getCapacity(void); //in byte
uint32_t getErrorCount(void);
2020-05-02 13:25:27 +02:00
uint32_t getPowerOnHours(void); //in hours
uint32_t getPowerCycles(void);
uint32_t getTemperature(void); //in Fahrenheit, just kidding: degree Celsius
void checkFrozenDrive(void);
2020-05-02 00:49:11 +02:00
void setDriveSMARTData( string modelFamily,
string modelName,
string serial,
2020-05-02 13:25:27 +02:00
uint64_t capacity,
uint32_t errorCount,
uint32_t powerOnHours,
uint32_t powerCycles,
uint32_t temperature);
2020-08-04 22:35:29 +02:00
string sCapacityToText();
2020-08-07 12:07:29 +02:00
string sErrorCountToText();
string sPowerOnHoursToText();
string sPowerCyclesToText();
string sTemperatureToText();
2020-08-04 22:35:29 +02:00
2020-08-28 15:28:57 +02:00
void setTaskPercentage(double d32TaskPercentage);
double getTaskPercentage(void);
2020-08-03 22:40:07 +02:00
2022-05-11 23:45:05 +02:00
void setActionStartTimestamp();
time_t getActionStartTimestamp();
void calculateTaskDuration();
time_t getTaskDuration();
};
#endif // DRIVE_H_