reHDD/src/drive.cpp

87 lines
1.8 KiB
C++

/**
* @file drive.cpp
* @brief represent physical drive
* @author hendrik schutter
* @date 01.05.2020
*/
#include "../include/reHDD.h"
string Drive::getPath(void)
{
return sPath;
}
string Drive::getModelFamily(void)
{
return sModelFamily;
}
string Drive::getModelName(void)
{
return sModelName;
}
string Drive::getSerial(void)
{
return sSerial;
}
uint64_t Drive::getCapacity(void)
{
return u64Capacity;
}
uint32_t Drive::getErrorCount(void)
{
return u32ErrorCount;
}
uint32_t Drive::getPowerOnHours(void)
{
return u32PowerOnHours;
}
uint32_t Drive::getPowerCycles(void)
{
return u32PowerCycles;
}
string Drive::sCapacityToText() {
if(getCapacity() <= (999*1000000000UL)) {
// Less or even 999 GB --> GB
return to_string(getCapacity() / 1000000000UL) + " GB";
}
else {
// More 999 GB --> TB
return to_string(getCapacity() / 1000000000000UL) + " TB";
}
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
*/
void Drive::setDriveSMARTData( string modelFamily,
string modelName,
string serial,
uint64_t capacity,
uint32_t errorCount,
uint32_t powerOnHours,
uint32_t powerCycle)
{
this->sModelFamily = modelFamily;
sModelName = modelName;
sSerial = serial;
u64Capacity = capacity;
u32ErrorCount = errorCount;
u32PowerOnHours = powerOnHours;
u32PowerCycles = powerCycle;
}