From 928e50fcc13706b6a9d0be27f027a804ba674e56 Mon Sep 17 00:00:00 2001
From: sawinglogz <3787776-sawinglogz@users.noreply.gitlab.com>
Date: Sun, 18 Aug 2019 17:03:52 -0400
Subject: [PATCH] Use actual product names for PRS1 instead of mangled
 approximations.

---
 oscar/SleepLib/loader_plugins/prs1_loader.cpp | 81 +------------------
 1 file changed, 3 insertions(+), 78 deletions(-)

diff --git a/oscar/SleepLib/loader_plugins/prs1_loader.cpp b/oscar/SleepLib/loader_plugins/prs1_loader.cpp
index a5fc0369..4fe73689 100644
--- a/oscar/SleepLib/loader_plugins/prs1_loader.cpp
+++ b/oscar/SleepLib/loader_plugins/prs1_loader.cpp
@@ -44,8 +44,6 @@ const int PRS1_HTYPE_INTERVAL=1;
 // that change loader behaviour or modify channels.
 //********************************************************************************************
 
-QHash<int, QString> ModelMap;
-
 
 // CRC-16/KERMIT, polynomial: 0x11021, bit reverse algorithm
 // Table generated by crcmod (crc-kermit)
@@ -445,54 +443,6 @@ void parseModel(MachineInfo & info, const QString & modelnum)
 {
     info.modelnumber = modelnum;
 
-    QString modelstr;
-    bool fnd = false;
-    for (int i=0; i<modelnum.size(); i++) {
-        QChar c = modelnum.at(i);
-        if (c.isDigit()) {
-            modelstr += c;
-            fnd = true;
-        } else if (fnd) break;
-    }
-
-    bool ok;
-    int num = modelstr.toInt(&ok);
-
-    int type = (num / 100);
-
-
-    // TODO: Replace the below with s_PRS1ModelInfo.Name(modelnum), but
-    // first sort out the display of manufacturer/series/model in the
-    // various views, reports, and menus. Those displays should include
-    // the model number as well.
-    switch (type) {
-    case 1: // cpap
-    case 2: // cpap
-    case 3: // cpap
-        info.model = QObject::tr("RemStar Plus Compliance Only");
-        break;
-    case 4: // cpap
-        info.model = QObject::tr("RemStar Pro with C-Flex+");
-        break;
-    case 5: // apap
-        info.model = QObject::tr("RemStar Auto with A-Flex");
-        break;
-    case 6: // bipap
-        info.model = QObject::tr("RemStar BiPAP Pro with Bi-Flex");
-        break;
-    case 7: // bipap auto
-        info.model = QObject::tr("RemStar BiPAP Auto with Bi-Flex");
-        break;
-    case 9: // asv
-        info.model = QObject::tr("BiPAP autoSV Advanced");
-        break;
-    case 10: // Avaps
-        info.model = QObject::tr("BiPAP AVAPS");
-        break;
-    default:
-        info.model = QObject::tr("Unknown Model");
-    }
-
     const char* name = s_PRS1ModelInfo.Name(modelnum);
     const char* series = nullptr;
     for (auto & s : s_PRS1Series.keys()) {
@@ -507,7 +457,9 @@ void parseModel(MachineInfo & info, const QString & modelnum)
         }
         series = "unknown";
     }
-    info.series = QObject::tr(series);
+    
+    info.model = QObject::tr(name);
+    info.series = series;
 }
 
 bool PRS1Loader::PeekProperties(const QString & filename, QHash<QString,QString> & props)
@@ -589,21 +541,12 @@ bool PRS1Loader::PeekProperties(MachineInfo & info, const QString & filename, Ma
         mach->properties[key] = props[key];
     };
 
-    // TODO: replace the below logic with PRS1ModelInfo table-driven logic
-    
     if (!modelnum.isEmpty()) {
         parseModel(info, modelnum);
     } else {
         qWarning() << "missing model number" << filename;
     }
 
-    // TODO: Replace this with PRS1ModelInfo.
-    if (ptype > 0) {
-        if (ModelMap.contains(ptype)) {
-            info.model = ModelMap[ptype];
-        }
-    }
-
     return true;
 }
 
@@ -6403,23 +6346,6 @@ bool PRS1DataChunk::ExtractStoredCrc(int size)
 }
         
 
-void InitModelMap()
-{
-    ModelMap[0x34] = QObject::tr("RemStar Pro with C-Flex+"); // 450/460P
-    ModelMap[0x35] = QObject::tr("RemStar Auto with A-Flex"); // 550/560P
-    ModelMap[0x36] = QObject::tr("RemStar BiPAP Pro with Bi-Flex");
-    ModelMap[0x37] = QObject::tr("RemStar BiPAP Auto with Bi-Flex");
-    ModelMap[0x38] = QObject::tr("RemStar Plus");          // 150/250P/260P
-    ModelMap[0x41] = QObject::tr("BiPAP autoSV Advanced");
-    ModelMap[0x4a] = QObject::tr("BiPAP autoSV Advanced 60 Series");
-    ModelMap[0x4E] = QObject::tr("BiPAP AVAPS");
-    ModelMap[0x58] = QObject::tr("CPAP");  // guessing
-    ModelMap[0x59] = QObject::tr("CPAP Pro"); // guessing
-    ModelMap[0x5A] = QObject::tr("Auto CPAP");
-    ModelMap[0x5B] = QObject::tr("BiPAP Pro"); // guessing
-    ModelMap[0x5C] = QObject::tr("Auto BiPAP");
-}
-
 bool initialized = false;
 
 using namespace schema;
@@ -6667,7 +6593,6 @@ void PRS1Loader::Register()
 
     qDebug() << "Registering PRS1Loader";
     RegisterLoader(new PRS1Loader());
-    InitModelMap();
     initialized = true;
 }