From face1259eeccb64a48c3c9d5b116f707170a465a Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Mon, 18 Aug 2014 10:22:16 +1000 Subject: [PATCH] CMS50F37 debug test 3 --- .../SleepLib/loader_plugins/cms50f37_loader.cpp | 16 +++++++++++++--- sleepyhead/SleepLib/machine_loader.cpp | 10 ++++++++++ sleepyhead/SleepLib/machine_loader.h | 2 ++ sleepyhead/oximeterimport.cpp | 11 ++++++++++- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp b/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp index 8900bcce..3b78d66f 100644 --- a/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp @@ -35,9 +35,6 @@ using namespace std; extern QProgressBar *qprogress; -static unsigned char cms50_sequence[] = { 0xa7, 0xa2, 0xa0, 0xb0, 0xac, 0xb3, 0xad, 0xa3, 0xab, 0xa4, 0xa5, 0xaf, 0xa7, 0xa2, 0xa6 }; -int cms50_seqlength = sizeof(cms50_sequence); - CMS50F37Loader::CMS50F37Loader() { m_type = MT_OXIMETER; @@ -116,9 +113,22 @@ int CMS50F37Loader::Open(QString path) return 0; } +static unsigned char cms50_sequence[] = { 0xa7, 0xa2, 0xa0, 0xb0, 0xac, 0xb3, 0xad, 0xa3, 0xab, 0xa4, 0xa5, 0xaf, 0xa7, 0xa2, 0xa6 }; +int cms50_seqlength = sizeof(cms50_sequence); + void CMS50F37Loader::processBytes(QByteArray bytes) { + if (sequence < cms50_seqlength) { + unsigned char cmd = cms50_sequence[sequence]; + + if (cmd == 0xa5) { // DateTime +// > 7d 81 a5 80 80 80 80 80 80 +// < 07 80 80 80 94 8e 88 92 +// < 12 80 80 80 80 a3 bb 80 + + } + } QStringList data; diff --git a/sleepyhead/SleepLib/machine_loader.cpp b/sleepyhead/SleepLib/machine_loader.cpp index 683d9bdd..3953eade 100644 --- a/sleepyhead/SleepLib/machine_loader.cpp +++ b/sleepyhead/SleepLib/machine_loader.cpp @@ -45,6 +45,16 @@ MachineLoader * lookupLoader(Machine * m) return nullptr; } +MachineLoader * lookupLoader(QString loaderName) +{ + for (int i=0; i < m_loaders.size(); ++i) { + MachineLoader * loader = m_loaders.at(i); + if (loader->loaderName() == loaderName) + return loader; + } + return nullptr; +} + QHash > MachineList; diff --git a/sleepyhead/SleepLib/machine_loader.h b/sleepyhead/SleepLib/machine_loader.h index bafed479..7b2ebfae 100644 --- a/sleepyhead/SleepLib/machine_loader.h +++ b/sleepyhead/SleepLib/machine_loader.h @@ -148,6 +148,8 @@ struct ImportPath // Put in machine loader class as static?? void RegisterLoader(MachineLoader *loader); MachineLoader * lookupLoader(Machine * m); +MachineLoader * lookupLoader(QString loaderName); + void DestroyLoaders(); bool compressFile(QString inpath, QString outpath = ""); diff --git a/sleepyhead/oximeterimport.cpp b/sleepyhead/oximeterimport.cpp index 8bf2aba5..b81e0389 100644 --- a/sleepyhead/oximeterimport.cpp +++ b/sleepyhead/oximeterimport.cpp @@ -22,6 +22,7 @@ extern MainWindow * mainwin; #include "SleepLib/loader_plugins/cms50_loader.h" +#include "SleepLib/loader_plugins/cms50f37_loader.h" Qt::DayOfWeek firstDayOfWeekFromLocale(); QList GetOxiLoaders(); @@ -155,7 +156,15 @@ SerialOximeter * OximeterImport::detectOximeter() ui->retryButton->setVisible(false); - QList loaders = GetOxiLoaders(); + QList loaders; //= GetOxiLoaders(); + + if (p_profile->oxi->oximeterType() == "Contec CMS50D+/E/F") { + SerialOximeter * oxi = qobject_cast(lookupLoader(cms50_class_name)); + loaders.push_back(oxi); + } else if (p_profile->oxi->oximeterType() == "Contec CMS50F v3.7+") { + SerialOximeter * oxi = qobject_cast(lookupLoader(cms50f37_class_name)); + loaders.push_back(oxi); + } else return nullptr; updateStatus(tr("Scanning for compatible oximeters"));