Empty data Overlay crash fix, Show extra dots for PRS1, PRS1 alignment cleanup

This commit is contained in:
Mark Watkins 2011-07-30 13:52:29 +10:00
parent 2a5797b141
commit 9840976d8e
6 changed files with 40 additions and 26 deletions

View File

@ -270,6 +270,7 @@ void gLineChart::Plot(gGraphWindow & w,float scrx,float scry)
bool firstpx=true; bool firstpx=true;
if (el.type()==EVL_Waveform) { // Waveform Plot if (el.type()==EVL_Waveform) { // Waveform Plot
if (idx>sam) idx-=sam;
time=el.time(idx); time=el.time(idx);
qint64 rate=sr*sam; qint64 rate=sr*sam;
@ -280,8 +281,8 @@ void gLineChart::Plot(gGraphWindow & w,float scrx,float scry)
for (int i=idx;i<siz;i+=sam) { for (int i=idx;i<siz;i+=sam) {
time+=rate; time+=rate;
//time=el.time(i); //time=el.time(i);
if (time < minx) //if (time < minx)
continue; // Skip stuff before the start of our data window // continue; // Skip stuff before the start of our data window
//data=el.data(i); //data=el.data(i);
data=dat[i];//*gain; data=dat[i];//*gain;
@ -319,8 +320,8 @@ void gLineChart::Plot(gGraphWindow & w,float scrx,float scry)
// Normal Waveform Plot // Normal Waveform Plot
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
for (int i=idx;i<siz;i+=sam,time+=rate) { for (int i=idx;i<siz;i+=sam,time+=rate) {
if (time < minx) //if (time < minx)
continue; // Skip stuff before the start of our data window // continue; // Skip stuff before the start of our data window
data=dat[i];//el.data(i); data=dat[i];//el.data(i);
px=xst+((time - minx) * xmult); // Scale the time scale X to pixel scale X px=xst+((time - minx) * xmult); // Scale the time scale X to pixel scale X
@ -357,13 +358,13 @@ void gLineChart::Plot(gGraphWindow & w,float scrx,float scry)
first=true; first=true;
qint64 start=el.first(); qint64 start=el.first();
for (int i=idx;i<siz;i+=sam) { for (int i=idx;i<siz;i+=sam) {
time=start+tim[i];//el.time(i);
time=start+tim[i];
if (first) { if (first) {
if (num_points>5 && (time < minx)) continue; // Skip stuff before the start of our data window if (num_points>5 && (time < minx)) continue; // Skip stuff before the start of our data window
first=false; first=false;
if (i>=sam) i-=sam; // Start with the previous sample (which will be in clipping area) 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=dat[i]*gain; //
//data=el.data(i); // raw access is faster //data=el.data(i); // raw access is faster

View File

@ -57,6 +57,7 @@ void gLineOverlayBar::Plot(gGraphWindow & w,float scrx,float scry)
qint64 Y; qint64 Y;
for (vector<Session *>::iterator s=m_day->begin();s!=m_day->end(); s++) { for (vector<Session *>::iterator s=m_day->begin();s!=m_day->end(); s++) {
if ((*s)->eventlist.find(m_code)==(*s)->eventlist.end()) continue; 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]); EventList & el=*((*s)->eventlist[m_code][0]);

View File

@ -554,17 +554,18 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
//if (code==0xe) { //if (code==0xe) {
// pos+=2; // pos+=2;
//} else //} else
delta=0;
if (code!=0x12) { if (code!=0x12) {
//delta=buffer[pos]; //delta=buffer[pos];
//duration=buffer[pos+1]; //duration=buffer[pos+1];
delta=buffer[pos+1] << 8 | buffer[pos]; delta=buffer[pos+1] << 8 | buffer[pos];
pos+=2; pos+=2;
t+=delta*1000;
tt=t;//+(delta*1000);
//QDateTime d=QDateTime::fromMSecsSinceEpoch(t); //QDateTime d=QDateTime::fromMSecsSinceEpoch(t);
//qDebug()<< d.toString("yyyy-MM-dd HH:mm:ss") << ": " << hex << pos+15 << " " << hex << int(code) << int(delta); //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++; cnt++;
//int fc=0; //int fc=0;
switch (code) { switch (code) {
@ -612,7 +613,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
break; break;
case 0x05: // RERA case 0x05: // RERA
data[0]=buffer[pos++]; data[0]=buffer[pos++];
tt-=data[0]*1000; // Subtract Time Offset tt=t-(data[0]*1000);
if (!Code[7]) { if (!Code[7]) {
Code[7]=new EventList(CPAP_RERA,EVL_Event); Code[7]=new EventList(CPAP_RERA,EVL_Event);
session->eventlist[CPAP_RERA].push_back(Code[7]); 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 case 0x06: // Obstructive Apoanea
data[0]=buffer[pos++]; data[0]=buffer[pos++];
tt-=data[0]*1000; // Subtract Time Offset tt=t-(data[0]*1000);
if (!Code[8]) { if (!Code[8]) {
Code[8]=new EventList(CPAP_Obstructive,EVL_Event); Code[8]=new EventList(CPAP_Obstructive,EVL_Event);
session->eventlist[CPAP_Obstructive].push_back(Code[8]); session->eventlist[CPAP_Obstructive].push_back(Code[8]);
@ -631,7 +632,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
break; break;
case 0x07: // Clear Airway case 0x07: // Clear Airway
data[0]=buffer[pos++]; data[0]=buffer[pos++];
tt-=data[0]*1000; // Subtract Time Offset tt=t-(data[0]*1000);
if (!Code[9]) { if (!Code[9]) {
Code[9]=new EventList(CPAP_ClearAirway,EVL_Event); Code[9]=new EventList(CPAP_ClearAirway,EVL_Event);
session->eventlist[CPAP_ClearAirway].push_back(Code[9]); session->eventlist[CPAP_ClearAirway].push_back(Code[9]);
@ -640,7 +641,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
break; break;
case 0x0a: // Hypopnea case 0x0a: // Hypopnea
data[0]=buffer[pos++]; data[0]=buffer[pos++];
tt-=data[0]*1000; // Subtract Time Offset tt=t-(data[0]*1000);
if (!Code[10]) { if (!Code[10]) {
Code[10]=new EventList(CPAP_Hypopnea,EVL_Event); Code[10]=new EventList(CPAP_Hypopnea,EVL_Event);
session->eventlist[CPAP_Hypopnea].push_back(Code[10]); session->eventlist[CPAP_Hypopnea].push_back(Code[10]);
@ -649,7 +650,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
break; break;
case 0x0c: // Flow Limitation case 0x0c: // Flow Limitation
data[0]=buffer[pos++]; data[0]=buffer[pos++];
tt-=data[0]*1000; // Subtract Time Offset tt=t-(data[0]*1000);
if (!Code[11]) { if (!Code[11]) {
Code[11]=new EventList(CPAP_FlowLimit,EVL_Event); Code[11]=new EventList(CPAP_FlowLimit,EVL_Event);
session->eventlist[CPAP_FlowLimit].push_back(Code[11]); 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]; data[0]=buffer[pos+1]<<8 | buffer[pos];
pos+=2; pos+=2;
data[1]=buffer[pos++]; data[1]=buffer[pos++];
tt-=data[1]*1000; tt=t-data[1]*1000;
if (!Code[23]) { if (!Code[23]) {
Code[23]=new EventList(CPAP_CSR,EVL_Event); Code[23]=new EventList(CPAP_CSR,EVL_Event);
session->eventlist[CPAP_CSR].push_back(Code[23]); session->eventlist[CPAP_CSR].push_back(Code[23]);

View File

@ -21,7 +21,7 @@ License: GPL
//******************************************************************************************** //********************************************************************************************
// Please INCREMENT the following value when making changes to this loaders implementation. // Please INCREMENT the following value when making changes to this loaders implementation.
// //
const int prs1_data_version=2; const int prs1_data_version=3;
// //
//******************************************************************************************** //********************************************************************************************

View File

@ -58,10 +58,12 @@ bool Session::OpenEvents() {
if (s_events_loaded) if (s_events_loaded)
return true; return true;
bool b=LoadEvents(s_eventfile); if (!s_eventfile.isEmpty()) {
if (!b) { bool b=LoadEvents(s_eventfile);
qWarning() << "Error Unkpacking Events" << s_eventfile; if (!b) {
return false; qWarning() << "Error Unpacking Events" << s_eventfile;
return false;
}
} }
@ -83,11 +85,14 @@ bool Session::Store(QString path)
bool a; bool a;
a=StoreSummary(base+".000"); // if actually has events a=StoreSummary(base+".000"); // if actually has events
//qDebug() << " Summary done"; //qDebug() << " Summary done";
if (eventlist.size()>0) if (eventlist.size()>0) {
StoreEvents(base+".001"); s_eventfile=base+".001";
StoreEvents(s_eventfile);
} else {
qDebug() << "Trying to save empty events file";
}
//qDebug() << " Events done"; //qDebug() << " Events done";
s_changed=false; s_changed=false;
s_eventfile=base+".001";
s_events_loaded=true; s_events_loaded=true;
//TrashEvents(); //TrashEvents();

View File

@ -154,6 +154,10 @@ Daily::Daily(QWidget *parent,QGLWidget * shared) :
FRW->AddLayer(g); FRW->AddLayer(g);
FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_Hypopnea,QColor("blue"),"H"))); 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(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_RERA,QColor("gold"),"RE")));
//FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_Unknown0E,QColor("dark green"),"U0E"))); //FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_Unknown0E,QColor("dark green"),"U0E")));
FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_VSnore,QColor("red"),"VS"))); 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;z<m->second.size();z++) { for (unsigned z=0;z<m->second.size();z++) {
for (int o=0;o<m->second[z]->count();o++) { for (int o=0;o<m->second[z]->count();o++) {
qint64 t=m->second[z]->time(o); qint64 t=m->second[z]->time(o);
if (code==CPAP_CSR) { 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; QStringList a;
QDateTime d=QDateTime::fromMSecsSinceEpoch(t); 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(s);
a.append(d.toString("yyyy-MM-dd HH:mm:ss")); a.append(d.toString("yyyy-MM-dd HH:mm:ss"));
mcr->addChild(new QTreeWidgetItem(a)); mcr->addChild(new QTreeWidgetItem(a));
} }
} } }
}
} }
int cnt=0; int cnt=0;
for (map<MachineCode,QTreeWidgetItem *>::iterator m=mcroot.begin();m!=mcroot.end();m++) { for (map<MachineCode,QTreeWidgetItem *>::iterator m=mcroot.begin();m!=mcroot.end();m++) {