reHDD/src/drive.cpp

87 lines
1.8 KiB
C++
Raw Normal View History

/**
2020-05-02 22:06:47 +02:00
* @file drive.cpp
* @brief represent physical drive
* @author hendrik schutter
* @date 01.05.2020
*/
2020-05-02 22:06:47 +02:00
#include "../include/reHDD.h"
string Drive::getPath(void)
{
return sPath;
}
2020-05-02 00:49:11 +02:00
string Drive::getModelFamily(void)
{
2020-05-02 00:49:11 +02:00
return sModelFamily;
}
2020-05-02 00:49:11 +02:00
string Drive::getModelName(void)
{
2020-05-02 00:49:11 +02:00
return sModelName;
}
string Drive::getSerial(void)
{
return sSerial;
}
2020-05-02 13:25:27 +02:00
uint64_t Drive::getCapacity(void)
{
2020-05-02 13:25:27 +02:00
return u64Capacity;
}
uint32_t Drive::getErrorCount(void)
{
return u32ErrorCount;
}
uint32_t Drive::getPowerOnHours(void)
{
return u32PowerOnHours;
}
2020-05-02 13:25:27 +02:00
uint32_t Drive::getPowerCycles(void)
{
2020-05-02 13:25:27 +02:00
return u32PowerCycles;
}
2020-08-06 11:41:38 +02:00
string Drive::sCapacityToText() {
2020-08-06 11:51:13 +02:00
if(getCapacity() <= (999*1000000000UL)) {
2020-08-04 22:35:29 +02:00
// Less or even 999 GB --> GB
2020-08-06 11:51:13 +02:00
return to_string(getCapacity() / 1000000000UL) + " GB";
2020-08-04 22:35:29 +02:00
}
2020-08-06 11:41:38 +02:00
else {
// More 999 GB --> TB
2020-08-06 11:51:13 +02:00
return to_string(getCapacity() / 1000000000000UL) + " TB";
2020-08-04 22:35:29 +02:00
}
return "ERROR";
}
/**
* \brief set S.M.A.R.T. values in model
* \param string modelFamily
* \param string modelName
* \param string serial
* \param uint64_t capacity
* \param uint32_t errorCount
* \param uint32_t powerOnHours
* \param uint32_t powerCycle
* \return void
*/
2020-05-02 00:49:11 +02:00
void Drive::setDriveSMARTData( string modelFamily,
string modelName,
string serial,
2020-05-02 13:25:27 +02:00
uint64_t capacity,
2020-05-02 00:49:11 +02:00
uint32_t errorCount,
uint32_t powerOnHours,
2020-05-02 13:25:27 +02:00
uint32_t powerCycle)
2020-05-02 00:49:11 +02:00
{
this->sModelFamily = modelFamily;
2020-05-02 00:49:11 +02:00
sModelName = modelName;
sSerial = serial;
2020-05-02 13:25:27 +02:00
u64Capacity = capacity;
2020-05-02 00:49:11 +02:00
u32ErrorCount = errorCount;
u32PowerOnHours = powerOnHours;
2020-05-02 13:25:27 +02:00
u32PowerCycles = powerCycle;
2020-05-02 00:49:11 +02:00
}