diff --git a/Graphs/gLineChart.cpp b/Graphs/gLineChart.cpp index 7bc906b3..41bdd08c 100644 --- a/Graphs/gLineChart.cpp +++ b/Graphs/gLineChart.cpp @@ -270,6 +270,7 @@ void gLineChart::Plot(gGraphWindow & w,float scrx,float scry) bool firstpx=true; if (el.type()==EVL_Waveform) { // Waveform Plot + if (idx>sam) idx-=sam; time=el.time(idx); qint64 rate=sr*sam; @@ -280,8 +281,8 @@ void gLineChart::Plot(gGraphWindow & w,float scrx,float scry) for (int i=idx;i5 && (time < minx)) continue; // Skip stuff before the start of our data window first=false; if (i>=sam) i-=sam; // Start with the previous sample (which will be in clipping area) - time=start+tim[i];//el.time(i); //el.time(i); + time=start+tim[i]; } data=dat[i]*gain; // //data=el.data(i); // raw access is faster diff --git a/Graphs/gLineOverlay.cpp b/Graphs/gLineOverlay.cpp index fd071c51..4a783635 100644 --- a/Graphs/gLineOverlay.cpp +++ b/Graphs/gLineOverlay.cpp @@ -57,6 +57,7 @@ void gLineOverlayBar::Plot(gGraphWindow & w,float scrx,float scry) qint64 Y; for (vector::iterator s=m_day->begin();s!=m_day->end(); s++) { if ((*s)->eventlist.find(m_code)==(*s)->eventlist.end()) continue; + if ((*s)->eventlist[m_code].size()==0) continue; EventList & el=*((*s)->eventlist[m_code][0]); diff --git a/SleepLib/loader_plugins/prs1_loader.cpp b/SleepLib/loader_plugins/prs1_loader.cpp index dc282d62..5dc94c9c 100644 --- a/SleepLib/loader_plugins/prs1_loader.cpp +++ b/SleepLib/loader_plugins/prs1_loader.cpp @@ -554,17 +554,18 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64 //if (code==0xe) { // pos+=2; //} else + delta=0; if (code!=0x12) { //delta=buffer[pos]; //duration=buffer[pos+1]; delta=buffer[pos+1] << 8 | buffer[pos]; pos+=2; + t+=delta*1000; + tt=t;//+(delta*1000); //QDateTime d=QDateTime::fromMSecsSinceEpoch(t); //qDebug()<< d.toString("yyyy-MM-dd HH:mm:ss") << ": " << hex << pos+15 << " " << hex << int(code) << int(delta); - t+=delta*1000; } - //MachineCode cpapcode=Codes[(int)code]; - tt=t; + cnt++; //int fc=0; switch (code) { @@ -612,7 +613,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64 break; case 0x05: // RERA data[0]=buffer[pos++]; - tt-=data[0]*1000; // Subtract Time Offset + tt=t-(data[0]*1000); if (!Code[7]) { Code[7]=new EventList(CPAP_RERA,EVL_Event); session->eventlist[CPAP_RERA].push_back(Code[7]); @@ -622,7 +623,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64 case 0x06: // Obstructive Apoanea data[0]=buffer[pos++]; - tt-=data[0]*1000; // Subtract Time Offset + tt=t-(data[0]*1000); if (!Code[8]) { Code[8]=new EventList(CPAP_Obstructive,EVL_Event); session->eventlist[CPAP_Obstructive].push_back(Code[8]); @@ -631,7 +632,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64 break; case 0x07: // Clear Airway data[0]=buffer[pos++]; - tt-=data[0]*1000; // Subtract Time Offset + tt=t-(data[0]*1000); if (!Code[9]) { Code[9]=new EventList(CPAP_ClearAirway,EVL_Event); session->eventlist[CPAP_ClearAirway].push_back(Code[9]); @@ -640,7 +641,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64 break; case 0x0a: // Hypopnea data[0]=buffer[pos++]; - tt-=data[0]*1000; // Subtract Time Offset + tt=t-(data[0]*1000); if (!Code[10]) { Code[10]=new EventList(CPAP_Hypopnea,EVL_Event); session->eventlist[CPAP_Hypopnea].push_back(Code[10]); @@ -649,7 +650,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64 break; case 0x0c: // Flow Limitation data[0]=buffer[pos++]; - tt-=data[0]*1000; // Subtract Time Offset + tt=t-(data[0]*1000); if (!Code[11]) { Code[11]=new EventList(CPAP_FlowLimit,EVL_Event); session->eventlist[CPAP_FlowLimit].push_back(Code[11]); @@ -724,7 +725,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64 data[0]=buffer[pos+1]<<8 | buffer[pos]; pos+=2; data[1]=buffer[pos++]; - tt-=data[1]*1000; + tt=t-data[1]*1000; if (!Code[23]) { Code[23]=new EventList(CPAP_CSR,EVL_Event); session->eventlist[CPAP_CSR].push_back(Code[23]); diff --git a/SleepLib/loader_plugins/prs1_loader.h b/SleepLib/loader_plugins/prs1_loader.h index 435edf0c..791280ff 100644 --- a/SleepLib/loader_plugins/prs1_loader.h +++ b/SleepLib/loader_plugins/prs1_loader.h @@ -21,7 +21,7 @@ License: GPL //******************************************************************************************** // Please INCREMENT the following value when making changes to this loaders implementation. // -const int prs1_data_version=2; +const int prs1_data_version=3; // //******************************************************************************************** diff --git a/SleepLib/session.cpp b/SleepLib/session.cpp index 4a8e05d9..3a488ef4 100644 --- a/SleepLib/session.cpp +++ b/SleepLib/session.cpp @@ -58,10 +58,12 @@ bool Session::OpenEvents() { if (s_events_loaded) return true; - bool b=LoadEvents(s_eventfile); - if (!b) { - qWarning() << "Error Unkpacking Events" << s_eventfile; - return false; + if (!s_eventfile.isEmpty()) { + bool b=LoadEvents(s_eventfile); + if (!b) { + qWarning() << "Error Unpacking Events" << s_eventfile; + return false; + } } @@ -83,11 +85,14 @@ bool Session::Store(QString path) bool a; a=StoreSummary(base+".000"); // if actually has events //qDebug() << " Summary done"; - if (eventlist.size()>0) - StoreEvents(base+".001"); + if (eventlist.size()>0) { + s_eventfile=base+".001"; + StoreEvents(s_eventfile); + } else { + qDebug() << "Trying to save empty events file"; + } //qDebug() << " Events done"; s_changed=false; - s_eventfile=base+".001"; s_events_loaded=true; //TrashEvents(); diff --git a/daily.cpp b/daily.cpp index b960996d..4c1e27fe 100644 --- a/daily.cpp +++ b/daily.cpp @@ -154,6 +154,10 @@ Daily::Daily(QWidget *parent,QGLWidget * shared) : FRW->AddLayer(g); FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_Hypopnea,QColor("blue"),"H"))); FRW->AddLayer(AddCPAP(new gLineOverlayBar(PRS1_PressurePulse,QColor("red"),"PR",FT_Dot))); + FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_Pressure,QColor("white"),"P",FT_Dot))); + FRW->AddLayer(AddCPAP(new gLineOverlayBar(PRS1_Unknown0B,QColor("blue"),"0B",FT_Dot))); + FRW->AddLayer(AddCPAP(new gLineOverlayBar(PRS1_Unknown10,QColor("orange"),"10",FT_Dot))); + FRW->AddLayer(AddCPAP(new gLineOverlayBar(PRS1_Unknown0E,QColor("yellow"),"0E",FT_Dot))); FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_RERA,QColor("gold"),"RE"))); //FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_Unknown0E,QColor("dark green"),"U0E"))); FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_VSnore,QColor("red"),"VS"))); @@ -387,17 +391,19 @@ void Daily::UpdateEventsTree(QTreeWidget *tree,Day *day) for (unsigned z=0;zsecond.size();z++) { for (int o=0;osecond[z]->count();o++) { qint64 t=m->second[z]->time(o); + if (code==CPAP_CSR) { - t-=(m->second[z]->data(o)/2)*1000; + t-=float(m->second[z]->raw(o)/2.0)*1000.0; } QStringList a; QDateTime d=QDateTime::fromMSecsSinceEpoch(t); - QString s=QString("#%1: %2").arg((int)mccnt[code],(int)3,(int)10,QChar('0')).arg(d.toString("HH:mm:ss")); + QString s=QString("#%1: %2 (%3)").arg((int)mccnt[code],(int)3,(int)10,QChar('0')).arg(d.toString("HH:mm:ss")).arg(m->second[z]->raw(o)); a.append(s); a.append(d.toString("yyyy-MM-dd HH:mm:ss")); mcr->addChild(new QTreeWidgetItem(a)); } - } } + } + } } int cnt=0; for (map::iterator m=mcroot.begin();m!=mcroot.end();m++) {