Reuse SmartStatus::SelfTestStatus enum.

This commit is contained in:
Andrius Štikonas 2018-04-09 15:37:46 +01:00
parent b5d0b500cf
commit 492e3beb18
5 changed files with 7 additions and 78 deletions

View File

@ -33,7 +33,7 @@ SmartDiskInformation::SmartDiskInformation() :
m_SmartStatus(false),
m_BadAttributeNow(false),
m_BadAttributeInThePast(false),
m_SelfTestExecutionStatus(SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_SUCCESS_OR_NEVER),
m_SelfTestExecutionStatus(SmartStatus::SelfTestStatus::Success),
m_Overall(SmartStatus::Overall::Bad)
{
}

View File

@ -34,22 +34,6 @@ class SmartAttributeParsedData;
*/
class SmartDiskInformation
{
public:
/** SMART self test execution state */
enum SmartSelfTestExecutionStatus {
SMART_SELF_TEST_EXECUTION_STATUS_SUCCESS_OR_NEVER = 0,
SMART_SELF_TEST_EXECUTION_STATUS_ABORTED = 1,
SMART_SELF_TEST_EXECUTION_STATUS_INTERRUPTED = 2,
SMART_SELF_TEST_EXECUTION_STATUS_FATAL = 3,
SMART_SELF_TEST_EXECUTION_STATUS_ERROR_UNKNOWN = 4,
SMART_SELF_TEST_EXECUTION_STATUS_ERROR_ELECTRICAL = 5,
SMART_SELF_TEST_EXECUTION_STATUS_ERROR_SERVO = 6,
SMART_SELF_TEST_EXECUTION_STATUS_ERROR_READ = 7,
SMART_SELF_TEST_EXECUTION_STATUS_ERROR_HANDLING = 8,
SMART_SELF_TEST_EXECUTION_STATUS_INPROGRESS = 15,
_SMART_SELF_TEST_EXECUTION_STATUS_MAX
};
public:
SmartDiskInformation();
@ -92,7 +76,7 @@ public:
return m_SmartStatus; /**< @return a boolean representing SMART status */
}
SmartSelfTestExecutionStatus selfTestExecutionStatus() const
SmartStatus::SelfTestStatus selfTestExecutionStatus() const
{
return m_SelfTestExecutionStatus; /**< @return SMART self execution status */
}
@ -158,7 +142,7 @@ public:
m_SmartStatus = smartStatus;
}
void setSelfTestExecutionStatus(SmartSelfTestExecutionStatus status)
void setSelfTestExecutionStatus(SmartStatus::SelfTestStatus status)
{
m_SelfTestExecutionStatus = status;
}
@ -183,10 +167,9 @@ private:
bool m_SmartStatus;
bool m_BadAttributeNow;
bool m_BadAttributeInThePast;
SmartSelfTestExecutionStatus m_SelfTestExecutionStatus;
SmartStatus::SelfTestStatus m_SelfTestExecutionStatus;
SmartStatus::Overall m_Overall;
QList<SmartAttributeParsedData> m_Attributes;
};
#endif // SMARTDISKINFORMATION_H

View File

@ -91,8 +91,7 @@ bool SmartParser::init()
QJsonObject selfTest = smartJson[self_test].toObject();
QJsonObject selfTestStatus = selfTest[status].toObject();
m_DiskInformation->setSelfTestExecutionStatus((SmartDiskInformation::SmartSelfTestExecutionStatus)
selfTestStatus[value].toInt());
m_DiskInformation->setSelfTestExecutionStatus(static_cast<SmartStatus::SelfTestStatus>(selfTestStatus[value].toInt()));
loadAttributes();

View File

@ -64,69 +64,16 @@ void SmartStatus::update()
return;
setStatus(disk->smartStatus());
setModelName(disk->model());
setFirmware(disk->firmware());
setSerial(disk->serial());
switch (disk->selfTestExecutionStatus()) {
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ABORTED:
setSelfTestStatus(SelfTestStatus::Aborted);
break;
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_INTERRUPTED:
setSelfTestStatus(SelfTestStatus::Interrupted);
break;
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_FATAL:
setSelfTestStatus(SelfTestStatus::Fatal);
break;
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_UNKNOWN:
setSelfTestStatus(SelfTestStatus::ErrorUnknown);
break;
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_ELECTRICAL:
setSelfTestStatus(SelfTestStatus::ErrorEletrical);
break;
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_SERVO:
setSelfTestStatus(SelfTestStatus::ErrorServo);
break;
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_READ:
setSelfTestStatus(SelfTestStatus::ErrorRead);
break;
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_HANDLING:
setSelfTestStatus(SelfTestStatus::ErrorHandling);
break;
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_INPROGRESS:
setSelfTestStatus(SelfTestStatus::InProgress);
break;
default:
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_SUCCESS_OR_NEVER:
setSelfTestStatus(SelfTestStatus::Success);
break;
}
setSelfTestStatus(disk->selfTestExecutionStatus());
setOverall(disk->overall());
setTemp(disk->temperature());
setBadSectors(disk->badSectors());
setPoweredOn(disk->poweredOn());
setPowerCycles(disk->powerCycles());
addAttributes(disk->attributes());
setInitSuccess(true);
}

View File

@ -50,7 +50,7 @@ public:
ErrorServo,
ErrorRead,
ErrorHandling,
InProgress
InProgress = 15,
};
public: