diff --git a/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp b/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp index fb7723e6..505bc83f 100644 --- a/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp @@ -452,7 +452,7 @@ void CMS50F37Loader::processBytes(QByteArray bytes) if (res == 0x09) { msb = buffer.at(idx+1); // 9,80,e1,c4,ce,82 // cms50i data - for (int i = 2, msb = buffer.at(idx+1); i < 9; i++, msb>>= 1) { + for (int i = 2, msb = buffer.at(idx+1); i < len; i++, msb>>= 1) { buffer[idx+i] = (buffer[idx+i] & 0x7f) | (msb & 0x01 ? 0x80 : 0); } @@ -466,7 +466,7 @@ void CMS50F37Loader::processBytes(QByteArray bytes) } else if (res == 0x0f) { // f,80,de,c2,de,c2,de,c2 cms50F data... - for (int i = 2, msb = buffer.at(idx+1); i < 9; i++, msb>>= 1) { + for (int i = 2, msb = buffer.at(idx+1); i < len; i++, msb>>= 1) { buffer[idx+i] = (buffer[idx+i] & 0x7f) | (msb & 0x01 ? 0x80 : 0); } diff --git a/sleepyhead/oximeterimport.cpp b/sleepyhead/oximeterimport.cpp index d8f672a2..b12133fe 100644 --- a/sleepyhead/oximeterimport.cpp +++ b/sleepyhead/oximeterimport.cpp @@ -857,27 +857,29 @@ void OximeterImport::on_saveButton_clicked() } lastspo2 = rec->spo2; - // Perfusion Index - if (rec->perf > 0) { - if (lastperf == 0) { - ELperf = session->AddEventList(OXI_Perf, EVL_Event); - } - if (lastperf != rec->perf) { - if (lastperf > 0) { - ELperf->AddEvent(ti, lastperf); + if (haveperf) { + // Perfusion Index + if (rec->perf > 0) { + if (lastperf == 0) { + ELperf = session->AddEventList(OXI_Perf, EVL_Event); + } + if (lastperf != rec->perf) { + if (lastperf > 0) { + ELperf->AddEvent(ti, lastperf); + } + ELperf->AddEvent(ti, rec->perf); + } + lastgoodperf = rec->perf; + } else { + // end section properly + if (lastgoodperf > 0) { + ELperf->AddEvent(ti, lastperf); + session->setLast(OXI_Perf, ti); + lastgoodperf = 0; } - ELperf->AddEvent(ti, rec->perf); - } - lastgoodperf = rec->perf; - } else { - // end section properly - if (lastgoodperf > 0) { - ELperf->AddEvent(ti, lastperf); - session->setLast(OXI_Perf, ti); - lastgoodperf = 0; } + lastperf = rec->perf; } - lastperf = rec->perf; ti += step; } @@ -892,21 +894,27 @@ void OximeterImport::on_saveButton_clicked() session->setLast(OXI_SPO2, ti); } - if (lastperf > 0) { + + if (haveperf && lastperf > 0) { ELperf->AddEvent(ti, lastperf); session->setLast(OXI_Perf, ti); } + if (haveperf) { + session->first(OXI_Perf); + session->last(OXI_Perf); + session->count(OXI_Perf); + session->Min(OXI_Perf); + session->Max(OXI_Perf); + } calcSPO2Drop(session); calcPulseChange(session); session->first(OXI_Pulse); session->first(OXI_SPO2); - session->first(OXI_Perf); session->last(OXI_Pulse); session->last(OXI_SPO2); - session->last(OXI_Perf); session->first(OXI_PulseChange); session->first(OXI_SPO2Drop); @@ -921,15 +929,12 @@ void OximeterImport::on_saveButton_clicked() session->count(OXI_Pulse); session->count(OXI_SPO2); - session->count(OXI_Perf); session->count(OXI_PulseChange); session->count(OXI_SPO2Drop); session->Min(OXI_Pulse); session->Min(OXI_SPO2); - session->Min(OXI_Perf); session->Max(OXI_Pulse); session->Max(OXI_SPO2); - session->Max(OXI_Perf); session->really_set_last(ti); session->SetChanged(true);