Add nvme check before for loop

This commit is contained in:
Spiros
2024-05-31 17:59:45 +03:00
parent eccf01ad7e
commit 97b8619984

View File

@@ -195,9 +195,10 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal
powerOnHoursLineEdit->setText(powerOnTime);
powerOnHoursLineEdit->setAlignment(Qt::AlignRight);
if (!isNvme) {
for (const QJsonValue &attr : attributes) { //Need different logic for NVMe
QJsonObject attrObj = attr.toObject();
if (attrObj["id"] == 241 && !isNvme) {
if (attrObj["id"] == 241) {
if (attrObj["name"] == "Total_Writes_GB") {
totalWrites = QString::number(attrObj["raw"].toObject()["value"].toInt()) + " GB";
} else if (attrObj["name"] == "Host_Writes_32MiB") {
@@ -210,7 +211,7 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal
unsigned long long totalGbWriten = (lbaWritten * logicalBlockSize) / oneGB;
totalWrites = QString::number(static_cast<int>(totalGbWriten)) + " GB";
}
} else if (attrObj["id"] == 242 && !isNvme) {
} else if (attrObj["id"] == 242) {
if (attrObj["name"] == "Total_Reads_GB") {
totalReads = QString::number(attrObj["raw"].toObject()["value"].toInt()) + " GB";
} else if (attrObj["name"] == "Host_Reads_32MiB") {
@@ -223,7 +224,7 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal
unsigned long long totalGbWriten = (lbaRead * logicalBlockSize) / oneGB;
totalReads = QString::number(static_cast<int>(totalGbWriten)) + " GB";
}
} else if (attrObj["id"] == 246 && !isNvme) { // MX500
} else if (attrObj["id"] == 246) { // MX500
if (attrObj["name"] == "Total_LBAs_Written") {
unsigned int logicalBlockSize = localObj["logical_block_size"].toInt();
unsigned long long lbaWritten = attrObj["raw"].toObject()["value"].toVariant().toLongLong();
@@ -233,6 +234,7 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal
}
}
}
}
totalReadsLineEdit->setText(totalReads);
totalReadsLineEdit->setAlignment(Qt::AlignRight);