From a3fb5b1c34290b68cb7712e2592a9a3c1b4628d4 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Tue, 7 Jun 2011 12:23:26 +1000 Subject: [PATCH] CMS50 Progress Bar stuff --- Projects/CodeBlocks/SleepyHead.depend | 4 +- .../sleeplib/loader_plugins/cms50_loader.cpp | 48 ++++++++++++------- src/version.h | 12 ++--- 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/Projects/CodeBlocks/SleepyHead.depend b/Projects/CodeBlocks/SleepyHead.depend index ee421c22..a87e5ec6 100644 --- a/Projects/CodeBlocks/SleepyHead.depend +++ b/Projects/CodeBlocks/SleepyHead.depend @@ -8295,7 +8295,7 @@ -1307412369 /home/mark/projects/git/sleepyhead/src/version.h +1307413369 /home/mark/projects/git/sleepyhead/src/version.h 1307358939 /home/mark/projects/git/sleepyhead/src/libs/sleeplib/prs1_loader.h "machine.h" @@ -8413,7 +8413,7 @@ 1307358939 /home/mark/projects/git/sleepyhead/src/libs/sleeplib/loader_plugins/cms50_loader.h "sleeplib/machine_loader.h" -1307412363 source:/home/mark/projects/git/sleepyhead/src/libs/sleeplib/loader_plugins/cms50_loader.cpp +1307413299 source:/home/mark/projects/git/sleepyhead/src/libs/sleeplib/loader_plugins/cms50_loader.cpp "cms50_loader.h" diff --git a/src/libs/sleeplib/loader_plugins/cms50_loader.cpp b/src/libs/sleeplib/loader_plugins/cms50_loader.cpp index 8b95be4e..047faebe 100644 --- a/src/libs/sleeplib/loader_plugins/cms50_loader.cpp +++ b/src/libs/sleeplib/loader_plugins/cms50_loader.cpp @@ -32,6 +32,7 @@ bool CMS50Loader::Open(wxString & path,Profile *profile) // Data Folder // SpO2 Review.ini // SpO2.ini + assert(profile!=NULL); wxString tmp=path+wxFileName::GetPathSeparator()+wxT("Data"); if ((wxFileExists(path+wxFileName::GetPathSeparator()+wxT("SpO2 Review.ini"))) @@ -48,11 +49,17 @@ bool CMS50Loader::Open(wxString & path,Profile *profile) } bool CMS50Loader::OpenCMS50(wxString & path, Profile *profile) { - wxDir dir; - if (!dir.Open(path)) return false; - list files; - wxString filename,pathname; + list files; + wxDir dir; + + if (!dir.Open(path)) return false; + + if(loader_progress) { + loader_progress->Update(0); + } + + bool cont=dir.GetFirst(&filename); @@ -62,6 +69,8 @@ bool CMS50Loader::OpenCMS50(wxString & path, Profile *profile) files.push_back(pathname); } cont=dir.GetNext(&filename); + if (loader_progress) loader_progress->Pulse(); + } int size=files.size(); if (size==0) return false; @@ -69,17 +78,31 @@ bool CMS50Loader::OpenCMS50(wxString & path, Profile *profile) Machine *mach=CreateMachine(profile); int cnt=0; for (list::iterator n=files.begin();n!=files.end();n++,++cnt) { - if (loader_progress) loader_progress->Update((float(cnt)/float(size)*100.0)); + if (loader_progress) loader_progress->Update((float(cnt)/float(size)*50.0)); OpenSPORFile((*n),mach,profile); } mach->Save(); + if (loader_progress) loader_progress->Update(100); return true; } bool CMS50Loader::OpenSPORFile(wxString path,Machine *mach,Profile *profile) { + assert(mach!=NULL); + assert(profile!=NULL); + wxFFile f; unsigned char tmp[256]; - if (!f.Open(path,wxT("rb"))) return false; + + __int16_t data_starts; + __int16_t some_code; + __int16_t some_more_code; + int num_records; + int br; + + if (!f.Open(path,wxT("rb"))) + return false; + + // Find everything after the last _ wxString str=path.AfterLast(wxChar('_')); wxString id=str.BeforeFirst(wxChar('.')); @@ -91,14 +114,6 @@ bool CMS50Loader::OpenSPORFile(wxString path,Machine *mach,Profile *profile) if (mach->SessionExists(sessid)) return false; // Already imported - // Find everything after the last _ - short data_starts; - short some_code; - int num_records; - short some_more_code; - int br; - - br=f.Read(tmp,2); if (br!=2) return false; @@ -223,10 +238,7 @@ bool CMS50Loader::OpenSPORFile(wxString path,Machine *mach,Profile *profile) } Machine *CMS50Loader::CreateMachine(Profile *profile) { - if (!profile) { // shouldn't happen.. - wxLogError(wxT("No Profile!")); - return NULL; - } + assert(profile!=NULL); // NOTE: This only allows for one CMS50 machine per profile.. // Upgrading their oximeter will use this same record.. diff --git a/src/version.h b/src/version.h index ca0c5f8c..1a649ffa 100644 --- a/src/version.h +++ b/src/version.h @@ -16,14 +16,14 @@ namespace AutoVersion{ //Standard Version Type static const long MAJOR = 0; static const long MINOR = 7; - static const long BUILD = 3342; - static const long REVISION = 1381; + static const long BUILD = 3347; + static const long REVISION = 1415; //Miscellaneous Version Types - static const long BUILDS_COUNT = 520; - #define RC_FILEVERSION 0,7,3342,1381 - #define RC_FILEVERSION_STRING "0, 7, 3342, 1381\0" - static const char FULLVERSION_STRING[] = "0.7.3342.1381"; + static const long BUILDS_COUNT = 529; + #define RC_FILEVERSION 0,7,3347,1415 + #define RC_FILEVERSION_STRING "0, 7, 3347, 1415\0" + static const char FULLVERSION_STRING[] = "0.7.3347.1415"; //These values are to keep track of your versioning state, don't modify them. static const long BUILD_HISTORY = 0;