mirror of
https://github.com/edisionnano/QDiskInfo.git
synced 2026-04-16 16:21:28 +03:00
Support read/writes for WD drives
This commit is contained in:
@@ -216,33 +216,47 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal
|
|||||||
powerOnHoursLineEdit->setAlignment(Qt::AlignRight);
|
powerOnHoursLineEdit->setAlignment(Qt::AlignRight);
|
||||||
|
|
||||||
if (!isNvme) {
|
if (!isNvme) {
|
||||||
for (const QJsonValue &attr : attributes) { //Need different logic for NVMe
|
for (const QJsonValue &attr : attributes) {
|
||||||
QJsonObject attrObj = attr.toObject();
|
QJsonObject attrObj = attr.toObject();
|
||||||
if (attrObj["id"] == 241) {
|
if (attrObj["id"] == 241) {
|
||||||
if (attrObj["name"] == "Total_Writes_GB") {
|
if (attrObj["name"] == "Total_Writes_GB") {
|
||||||
totalWrites = QString::number(attrObj["raw"].toObject()["value"].toInt()) + " GB";
|
totalWrites = QString::number(attrObj["raw"].toObject()["value"].toInt()) + " GB";
|
||||||
} else if (attrObj["name"] == "Host_Writes_32MiB") {
|
} else if (attrObj["name"] == "Host_Writes_32MiB") {
|
||||||
double gibibytes = (attrObj["raw"].toObject()["value"].toInt() * 32 * 1024.0 * 1024.0) / 1e9;
|
double gigabytes = (attrObj["raw"].toObject()["value"].toInt() * 32 * 1024.0 * 1024.0) / 1e9;
|
||||||
totalWrites = QString::number(static_cast<int>(gibibytes)) + " GB";
|
totalWrites = QString::number(static_cast<int>(gigabytes)) + " GB";
|
||||||
} else if (attrObj["name"] == "Total_LBAs_Written") {
|
} else if (attrObj["name"] == "Total_LBAs_Written") {
|
||||||
unsigned int logicalBlockSize = localObj["logical_block_size"].toInt();
|
unsigned int logicalBlockSize = localObj["logical_block_size"].toInt();
|
||||||
unsigned long long lbaWritten = attrObj["raw"].toObject()["value"].toVariant().toLongLong();
|
unsigned long long lbaWritten = attrObj["raw"].toObject()["value"].toVariant().toLongLong();
|
||||||
unsigned long long oneGB = static_cast<unsigned long long>(std::pow(2, 30));
|
unsigned long long oneGB = static_cast<unsigned long long>(std::pow(2, 30));
|
||||||
unsigned long long totalGbWritten = (lbaWritten * logicalBlockSize) / oneGB;
|
unsigned long long totalGbWritten = (lbaWritten * logicalBlockSize) / oneGB;
|
||||||
totalWrites = QString::number(static_cast<int>(totalGbWritten)) + " GB";
|
totalWrites = QString::number(static_cast<int>(totalGbWritten)) + " GB";
|
||||||
|
} else if (attrObj["name"] == "Host_Writes_GiB") { // WD uses GiB
|
||||||
|
double gibibytes = (attrObj["raw"].toObject()["value"].toDouble()
|
||||||
|
double bytesPerGiB = static_cast<double>(1ULL << 30);
|
||||||
|
double bytesPerGB = 1e9;
|
||||||
|
double conversionFactor = bytesPerGiB / bytesPerGB;
|
||||||
|
double gigabytes = gibibytes * conversionFactor;
|
||||||
|
totalWrites = QString::number(static_cast<int>(gigabytes)) + " GB";
|
||||||
}
|
}
|
||||||
} else if (attrObj["id"] == 242) {
|
} else if (attrObj["id"] == 242) {
|
||||||
if (attrObj["name"] == "Total_Reads_GB") {
|
if (attrObj["name"] == "Total_Reads_GB") {
|
||||||
totalReads = QString::number(attrObj["raw"].toObject()["value"].toInt()) + " GB";
|
totalReads = QString::number(attrObj["raw"].toObject()["value"].toInt()) + " GB";
|
||||||
} else if (attrObj["name"] == "Host_Reads_32MiB") {
|
} else if (attrObj["name"] == "Host_Reads_32MiB") {
|
||||||
double gibibytes = (attrObj["raw"].toObject()["value"].toInt() * 32 * 1024.0 * 1024.0) / 1e9;
|
double gigabytes = (attrObj["raw"].toObject()["value"].toInt() * 32 * 1024.0 * 1024.0) / 1e9;
|
||||||
totalReads = QString::number(static_cast<int>(gibibytes)) + " GB";
|
totalReads = QString::number(static_cast<int>(gigabytes)) + " GB";
|
||||||
} else if (attrObj["name"] == "Total_LBAs_Read") {
|
} else if (attrObj["name"] == "Total_LBAs_Read") {
|
||||||
unsigned int logicalBlockSize = localObj["logical_block_size"].toInt();
|
unsigned int logicalBlockSize = localObj["logical_block_size"].toInt();
|
||||||
unsigned long long lbaRead = attrObj["raw"].toObject()["value"].toVariant().toLongLong();
|
unsigned long long lbaRead = attrObj["raw"].toObject()["value"].toVariant().toLongLong();
|
||||||
unsigned long long oneGB = static_cast<unsigned long long>(std::pow(2, 30));
|
unsigned long long oneGB = static_cast<unsigned long long>(std::pow(2, 30));
|
||||||
unsigned long long totalGbRead = (lbaRead * logicalBlockSize) / oneGB;
|
unsigned long long totalGbRead = (lbaRead * logicalBlockSize) / oneGB;
|
||||||
totalReads = QString::number(static_cast<int>(totalGbRead)) + " GB";
|
totalReads = QString::number(static_cast<int>(totalGbRead)) + " GB";
|
||||||
|
} else if (attrObj["name"] == "Host_Reads_GiB") {
|
||||||
|
double gibibytes = (attrObj["raw"].toObject()["value"].toDouble()
|
||||||
|
double bytesPerGiB = static_cast<double>(1ULL << 30);
|
||||||
|
double bytesPerGB = 1e9;
|
||||||
|
double conversionFactor = bytesPerGiB / bytesPerGB;
|
||||||
|
double gigabytes = gibibytes * conversionFactor;
|
||||||
|
totalReads = QString::number(static_cast<int>(gigabytes)) + " GB";
|
||||||
}
|
}
|
||||||
} else if (attrObj["id"] == 246) { // MX500
|
} else if (attrObj["id"] == 246) { // MX500
|
||||||
if (attrObj["name"] == "Total_LBAs_Written") {
|
if (attrObj["name"] == "Total_LBAs_Written") {
|
||||||
|
|||||||
Reference in New Issue
Block a user