Daily view Events Tab cleanup

This commit is contained in:
Mark Watkins 2011-06-30 20:56:22 +10:00
parent 7b53ae0f23
commit 95d006f699
5 changed files with 103 additions and 90 deletions

View File

@ -45,7 +45,7 @@ void WaveData::Reload(Day *day)
Waveform *w=(*l); Waveform *w=(*l);
double st=w->start().toMSecsSinceEpoch()/86400000.0; double st=w->start().toMSecsSinceEpoch()/86400000.0;
double rate=(w->duration()/w->samples())/86400.0; double rate=(w->duration()/w->samples())/86400.0;
qDebug("Waveform Chunk contains %i samples",w->samples()); //qDebug("Waveform Chunk contains %i samples",w->samples());
for (int i=0;i<w->samples();i++) { for (int i=0;i<w->samples();i++) {
QPointD r(st,(*w)[i]); QPointD r(st,(*w)[i]);
st+=rate; st+=rate;

View File

@ -259,7 +259,7 @@ int PRS1Loader::OpenMachine(Machine *m,QString path,Profile *profile)
cnt++; cnt++;
//if (qprogress) qprogress->Pulse(); //Update((float(cnt)/float(size)*25)); //if (qprogress) qprogress->Pulse(); //Update((float(cnt)/float(size)*25));
if (qprogress) qprogress->setValue((float(cnt)/float(size)*25.0)); if (qprogress) qprogress->setValue((float(cnt)/float(size)*33.0));
} }
} }
size=sessfiles.size(); size=sessfiles.size();
@ -270,7 +270,7 @@ int PRS1Loader::OpenMachine(Machine *m,QString path,Profile *profile)
for (map<SessionID,StringList>::iterator s=sessfiles.begin(); s!=sessfiles.end(); s++) { for (map<SessionID,StringList>::iterator s=sessfiles.begin(); s!=sessfiles.end(); s++) {
session=s->first; session=s->first;
cnt++; cnt++;
if (qprogress) qprogress->setValue(25.0+(float(cnt)/float(size)*25.0)); if (qprogress) qprogress->setValue(33.0+(float(cnt)/float(size)*33.0));
if (m->SessionExists(session)) continue; if (m->SessionExists(session)) continue;
if (s->second[0].isEmpty()) continue; if (s->second[0].isEmpty()) continue;

View File

@ -12,6 +12,7 @@ License: GPL
#include <QFile> #include <QFile>
#include <QMessageBox> #include <QMessageBox>
#include <QProgressBar> #include <QProgressBar>
#include <math.h>
#include "resmed_loader.h" #include "resmed_loader.h"
#include "SleepLib/session.h" #include "SleepLib/session.h"
@ -80,7 +81,7 @@ bool EDFParser::Parse()
return false; return false;
} }
qDebug(startdate.toString("yyyy-MM-dd HH:mm:ss").toLatin1()); //qDebug(startdate.toString("yyyy-MM-dd HH:mm:ss").toLatin1());
num_header_bytes=Read(8).toLong(&ok); num_header_bytes=Read(8).toLong(&ok);
if (!ok) if (!ok)
@ -130,10 +131,13 @@ bool EDFParser::Parse()
for (int x=0;x<num_data_records;x++) { for (int x=0;x<num_data_records;x++) {
for (int i=0;i<num_signals;i++) { for (int i=0;i<num_signals;i++) {
EDFSignal & sig=*edfsignals[i]; EDFSignal & sig=*edfsignals[i];
for (int j=0;j<sig.nr;j++) { memcpy((char *)&sig.data[sig.pos],(char *)&buffer[pos],sig.nr*2);
sig.pos+=sig.nr;
pos+=sig.nr*2;
/*for (int j=0;j<sig.nr;j++) {
qint16 t=Read16(); qint16 t=Read16();
sig.data[sig.pos++]=t; sig.data[sig.pos++]=t;
} } */
} }
} }
@ -146,7 +150,7 @@ bool EDFParser::Open(QString name)
if (!f.isReadable()) return false; if (!f.isReadable()) return false;
filename=name; filename=name;
filesize=f.size(); filesize=f.size();
qDebug(("Opening "+name).toLatin1()); //qDebug(("Opening "+name).toLatin1());
buffer=new char [filesize]; buffer=new char [filesize];
f.read(buffer,filesize); f.read(buffer,filesize);
f.close(); f.close();
@ -207,6 +211,7 @@ bool ResmedLoader::Open(QString & path,Profile *profile)
if (f.open(QIODevice::ReadOnly)) { if (f.open(QIODevice::ReadOnly)) {
if (!f.isReadable()) if (!f.isReadable())
return false; return false;
while (!f.atEnd()) { while (!f.atEnd()) {
QString line=f.readLine().trimmed(); QString line=f.readLine().trimmed();
QString key,value; QString key,value;
@ -232,10 +237,11 @@ bool ResmedLoader::Open(QString & path,Profile *profile)
QString ext,rest,datestr,s,codestr; QString ext,rest,datestr,s,codestr;
SessionID sessionid; SessionID sessionid;
QDateTime date; QDateTime date;
QString filename;
int size=flist.size(); int size=flist.size();
for (int i=0;i<size;i++) { for (int i=0;i<size;i++) {
QFileInfo fi=flist.at(i); QFileInfo fi=flist.at(i);
QString filename=fi.fileName(); filename=fi.fileName();
ext=filename.section(".",1).toLower(); ext=filename.section(".",1).toLower();
if (ext!="edf") continue; if (ext!="edf") continue;
@ -255,18 +261,19 @@ bool ResmedLoader::Open(QString & path,Profile *profile)
Machine *m=NULL; Machine *m=NULL;
QString fn;
Session *sess=NULL; Session *sess=NULL;
int cnt=0; int cnt=0;
size=sessfiles.size(); size=sessfiles.size();
for (map<SessionID,vector<QString> >::iterator si=sessfiles.begin();si!=sessfiles.end();si++) { for (map<SessionID,vector<QString> >::iterator si=sessfiles.begin();si!=sessfiles.end();si++) {
sessionid=si->first; sessionid=si->first;
qDebug("Parsing Session %li",sessionid); //qDebug("Parsing Session %li",sessionid);
bool done=false; bool done=false;
bool first=true; bool first=true;
for (int i=0;i<si->second.size();i++) { for (int i=0;i<si->second.size();i++) {
QString fn=si->second[i].section("_",-1).toLower(); fn=si->second[i].section("_",-1).toLower();
EDFParser edf(si->second[i]); EDFParser edf(si->second[i]);
qDebug("Parsing File %i %i",i,edf.filesize); //qDebug("Parsing File %i %i",i,edf.filesize);
if (!edf.Parse()) if (!edf.Parse())
continue; continue;
@ -328,29 +335,35 @@ bool ResmedLoader::Open(QString & path,Profile *profile)
if (qprogress) qprogress->setValue(33.0+(float(++cnt)/float(size)*33.0)); if (qprogress) qprogress->setValue(33.0+(float(++cnt)/float(size)*33.0));
} }
// m->save(); //m->Save();
if (qprogress) qprogress->setValue(100); if (qprogress) qprogress->setValue(100);
return 0; return 0;
} }
//bool ResmedLoader::ParseTAL(Machine *mach,Session *sess,EDFParser &edf,int pos)
bool ResmedLoader::LoadEVE(Machine *mach,Session *sess,EDFParser &edf) bool ResmedLoader::LoadEVE(Machine *mach,Session *sess,EDFParser &edf)
{ {
QString t; QString t;
long recs;
double totaldur,duration;
char * data;
char c;
long pos;
bool sign,ok;
double d;
QDateTime tt;
EventDataType fields[3];
MachineCode code;
Event *e;
for (int s=0;s<edf.GetNumSignals();s++) { for (int s=0;s<edf.GetNumSignals();s++) {
long recs=edf.edfsignals[s]->nr*edf.GetNumDataRecords()*2; recs=edf.edfsignals[s]->nr*edf.GetNumDataRecords()*2;
double totaldur=edf.GetNumDataRecords()*edf.GetDuration(); totaldur=edf.GetNumDataRecords()*edf.GetDuration();
totaldur/=3600.0; totaldur/=3600.0;
t.sprintf("EVE: %li %.2f",recs,totaldur); //t.sprintf("EVE: %li %.2f",recs,totaldur);
qDebug((edf.edfsignals[s]->label+" "+t).toLatin1()); //qDebug((edf.edfsignals[s]->label+" "+t).toLatin1());
char * data=(char *)edf.edfsignals[s]->data; data=(char *)edf.edfsignals[s]->data;
long pos=0; pos=0;
QDateTime tt=edf.startdate; tt=edf.startdate;
bool sign; duration=0;
double d;
bool ok;
double duration=0;
char c;
while (pos<recs) { while (pos<recs) {
c=data[pos]; c=data[pos];
if ((c!='+') && (c!='-')) if ((c!='+') && (c!='-'))
@ -402,21 +415,19 @@ bool ResmedLoader::LoadEVE(Machine *mach,Session *sess,EDFParser &edf)
t+=tolower(data[pos++]); t+=tolower(data[pos++]);
} while ((data[pos]!=20) && (pos<recs)); // start code } while ((data[pos]!=20) && (pos<recs)); // start code
if (!t.isEmpty()) { if (!t.isEmpty()) {
EventDataType fields[3]; code=MC_UNKNOWN;
MachineCode code=MC_UNKNOWN;
if (t=="obstructive apnea") code=CPAP_Obstructive; if (t=="obstructive apnea") code=CPAP_Obstructive;
else if (t=="hypopnea") code=CPAP_Hypopnea; else if (t=="hypopnea") code=CPAP_Hypopnea;
else if (t=="central apnea") code=CPAP_ClearAirway; else if (t=="central apnea") code=CPAP_ClearAirway;
if (code!=MC_UNKNOWN) { if (code!=MC_UNKNOWN) {
fields[0]=duration; fields[0]=duration;
Event *e=new Event(tt,code,fields,1); sess->AddEvent(new Event(tt,code,fields,1));
sess->AddEvent(e);
} else { } else {
if (t!="recording starts") { if (t!="recording starts") {
qDebug(("Unknown ResMed annotation field: "+t).toLatin1()); qDebug(("Unknown ResMed annotation field: "+t).toLatin1());
} }
} }
qDebug((tt.toString("yyyy-MM-dd HH:mm:ss")+t).toLatin1()); // qDebug((tt.toString("yyyy-MM-dd HH:mm:ss")+t).toLatin1());
} }
if (pos>=recs) { if (pos>=recs) {
qDebug(("Short EDF EVE file"+edf.filename).toLatin1()); qDebug(("Short EDF EVE file"+edf.filename).toLatin1());
@ -451,8 +462,8 @@ bool ResmedLoader::LoadBRP(Machine *mach,Session *sess,EDFParser &edf)
Waveform *w=new Waveform(edf.startdate,code,edf.edfsignals[s]->data,recs,duration,edf.edfsignals[s]->digital_minimum,edf.edfsignals[s]->digital_maximum); Waveform *w=new Waveform(edf.startdate,code,edf.edfsignals[s]->data,recs,duration,edf.edfsignals[s]->digital_minimum,edf.edfsignals[s]->digital_maximum);
edf.edfsignals[s]->data=NULL; // so it doesn't get deleted when edf gets trashed. edf.edfsignals[s]->data=NULL; // so it doesn't get deleted when edf gets trashed.
sess->AddWaveform(w); sess->AddWaveform(w);
t.sprintf("BRP: %li %.2f",recs,duration); //t.sprintf("BRP: %li %.2f",recs,duration);
qDebug((edf.edfsignals[s]->label+" "+t).toLatin1()); //qDebug((edf.edfsignals[s]->label+" "+t).toLatin1());
} }
} }
void ResmedLoader::ToTimeDelta(Machine *mach,Session *sess,EDFParser &edf, qint16 *data, MachineCode code, long recs, double duration,EventDataType divisor) void ResmedLoader::ToTimeDelta(Machine *mach,Session *sess,EDFParser &edf, qint16 *data, MachineCode code, long recs, double duration,EventDataType divisor)
@ -463,6 +474,7 @@ void ResmedLoader::ToTimeDelta(Machine *mach,Session *sess,EDFParser &edf, qint1
EventDataType c,last; EventDataType c,last;
for (int i=0;i<recs;i++) { for (int i=0;i<recs;i++) {
c=data[i]/divisor; c=data[i]/divisor;
//c=EventDataType(q)/2.0; //data[i]/divisor;
if (first) { if (first) {
sess->AddEvent(new Event(tt,code,&c,1)); sess->AddEvent(new Event(tt,code,&c,1));

View File

@ -414,7 +414,7 @@ bool Machine::Save()
for (s=d->second->begin(); s!=d->second->end(); s++) { for (s=d->second->begin(); s!=d->second->end(); s++) {
cnt++; cnt++;
if (qprogress) qprogress->setValue(50+(float(cnt)/float(size)*50.0)); if (qprogress) qprogress->setValue(66+(float(cnt)/float(size)*33));
if ((*s)->IsChanged()) (*s)->Store(path); if ((*s)->IsChanged()) (*s)->Store(path);
} }
} }

115
daily.cpp
View File

@ -387,7 +387,12 @@ void Daily::UpdateEventsTree(QTreeWidget *tree,Day *day)
for (m=(*s)->events.begin();m!=(*s)->events.end();m++) { for (m=(*s)->events.begin();m!=(*s)->events.end();m++) {
MachineCode code=m->first; MachineCode code=m->first;
if (code==CPAP_Leak) continue; if (code==CPAP_Leak) continue;
if (code==CPAP_SnoreGraph) continue; if (code==CPAP_RespiratoryRate) continue;
if (code==CPAP_TidalVolume) continue;
if (code==CPAP_MinuteVentilation) continue;
if (code==CPAP_Pressure) continue;
if (code==CPAP_Snore) continue;
if (code==PRS1_Unknown12) continue; if (code==PRS1_Unknown12) continue;
QTreeWidgetItem *mcr; QTreeWidgetItem *mcr;
if (mcroot.find(code)==mcroot.end()) { if (mcroot.find(code)==mcroot.end()) {
@ -509,18 +514,18 @@ void Daily::Load(QDate date)
QString submodel=tr("Unknown Model"); QString submodel=tr("Unknown Model");
//html=html+"<tr><td colspan=4 align=center><i>"+tr("Machine Information")+"</i></td></tr>\n"; //html+="<tr><td colspan=4 align=center><i>"+tr("Machine Information")+"</i></td></tr>\n";
if (cpap->machine->properties.find("SubModel")!=cpap->machine->properties.end()) if (cpap->machine->properties.find("SubModel")!=cpap->machine->properties.end())
submodel=" <br>"+cpap->machine->properties["SubModel"]; submodel=" <br>"+cpap->machine->properties["SubModel"];
html=html+"<tr><td colspan=4 align=center><b>"+cpap->machine->properties["Brand"]+"</b> <br>"+cpap->machine->properties["Model"]+" "+cpap->machine->properties["ModelNumber"]+submodel+"</td></tr>\n"; html+="<tr><td colspan=4 align=center><b>"+cpap->machine->properties["Brand"]+"</b> <br>"+cpap->machine->properties["Model"]+" "+cpap->machine->properties["ModelNumber"]+submodel+"</td></tr>\n";
if (pref.Exists("ShowSerialNumbers") && pref["ShowSerialNumbers"].toBool()) { if (pref.Exists("ShowSerialNumbers") && pref["ShowSerialNumbers"].toBool()) {
html=html+"<tr><td colspan=4 align=center>"+cpap->machine->properties["Serial"]+"</td></tr>\n"; html+="<tr><td colspan=4 align=center>"+cpap->machine->properties["Serial"]+"</td></tr>\n";
} }
html=html+"<tr><td align='center'><b>Date</b></td><td align='center'><b>"+tr("Sleep")+"</b></td><td align='center'><b>"+tr("Wake")+"</b></td><td align='center'><b>"+tr("Hours")+"</b></td></tr>"; html+="<tr><td align='center'><b>Date</b></td><td align='center'><b>"+tr("Sleep")+"</b></td><td align='center'><b>"+tr("Wake")+"</b></td><td align='center'><b>"+tr("Hours")+"</b></td></tr>";
int tt=cpap->total_time(); int tt=cpap->total_time();
html=html+"<tr><td align='center'>"+cpap->first().date().toString(Qt::SystemLocaleShortDate)+"</td><td align='center'>"+cpap->first().toString("HH:mm")+"</td><td align='center'>"+cpap->last().toString("HH:mm")+"</td><td align='center'>"+a.sprintf("%02i:%02i",tt/3600,tt%60)+"</td></tr>\n"; html+="<tr><td align='center'>"+cpap->first().date().toString(Qt::SystemLocaleShortDate)+"</td><td align='center'>"+cpap->first().toString("HH:mm")+"</td><td align='center'>"+cpap->last().toString("HH:mm")+"</td><td align='center'>"+a.sprintf("%02i:%02i",tt/3600,tt%60)+"</td></tr>\n";
html=html+"<tr><td colspan=4 align=center><hr></td></tr>\n"; html+="<tr><td colspan=4 align=center><hr></td></tr>\n";
QString cs; QString cs;
if (cpap->machine->GetClass()!="PRS1") { if (cpap->machine->GetClass()!="PRS1") {
@ -542,7 +547,7 @@ void Daily::Load(QDate date)
} }
html+="</tr>"; html+="</tr>";
html=html+("<tr><td colspan=4 align=center><i>")+tr("Event Breakdown")+("</i></td></tr>\n"); html+=("<tr><td colspan=4 align=center><i>")+tr("Event Breakdown")+("</i></td></tr>\n");
{ {
G_AHI->setFixedSize(gwwidth,gwheight); G_AHI->setFixedSize(gwwidth,gwheight);
QPixmap pixmap=G_AHI->renderPixmap(120,120,false); //gwwidth,gwheight,false); QPixmap pixmap=G_AHI->renderPixmap(120,120,false); //gwwidth,gwheight,false);
@ -552,49 +557,49 @@ void Daily::Load(QDate date)
pixmap.save(&buffer, "PNG"); pixmap.save(&buffer, "PNG");
html += "<tr><td colspan=4 align=center><img src=\"data:image/png;base64," + byteArray.toBase64() + "\"></td></tr>\n"; html += "<tr><td colspan=4 align=center><img src=\"data:image/png;base64," + byteArray.toBase64() + "\"></td></tr>\n";
} }
html=html+("</table>"); html+=("</table>");
html=html+("<table cellspacing=0 cellpadding=0 border=0 width='100%'>\n"); html+=("<table cellspacing=0 cellpadding=0 border=0 width='100%'>\n");
//html=html+("<tr><td colspan=4>&nbsp;</td></tr>\n"); //html+=("<tr><td colspan=4>&nbsp;</td></tr>\n");
html=html+("<tr height='2'><td colspan=4 height='2'><hr></td></tr>\n"); html+=("<tr height='2'><td colspan=4 height='2'><hr></td></tr>\n");
//html=html+wxT("<tr><td colspan=4 align=center><hr></td></tr>\n"); //html+=wxT("<tr><td colspan=4 align=center><hr></td></tr>\n");
if (mode==MODE_BIPAP) { if (mode==MODE_BIPAP) {
html=html+("<tr><td colspan=4 align='center'><i>")+tr("90%&nbsp;EPAP ")+a.sprintf("%.2f",eap90)+tr("cmH2O")+"</td></tr>\n"; html+=("<tr><td colspan=4 align='center'><i>")+tr("90%&nbsp;EPAP ")+a.sprintf("%.2f",eap90)+tr("cmH2O")+"</td></tr>\n";
html=html+("<tr><td colspan=4 align='center'><i>")+tr("90%&nbsp;IPAP ")+a.sprintf("%.2f",iap90)+"</td></tr>\n"; html+=("<tr><td colspan=4 align='center'><i>")+tr("90%&nbsp;IPAP ")+a.sprintf("%.2f",iap90)+"</td></tr>\n";
} else if (mode==MODE_APAP) { } else if (mode==MODE_APAP) {
html=html+("<tr><td colspan=4 align='center'><i>")+tr("90%&nbsp;Pressure ")+a.sprintf("%.2f",cpap->summary_weighted_avg(CPAP_PressurePercentValue))+("</i></td></tr>\n"); html+=("<tr><td colspan=4 align='center'><i>")+tr("90%&nbsp;Pressure ")+a.sprintf("%.2f",cpap->summary_weighted_avg(CPAP_PressurePercentValue))+("</i></td></tr>\n");
} else if (mode==MODE_CPAP) { } else if (mode==MODE_CPAP) {
html=html+("<tr><td colspan=4 align='center'><i>")+tr("Pressure ")+a.sprintf("%.2f",cpap->summary_min(CPAP_PressureMin))+("</i></td></tr>\n"); html+=("<tr><td colspan=4 align='center'><i>")+tr("Pressure ")+a.sprintf("%.2f",cpap->summary_min(CPAP_PressureMin))+("</i></td></tr>\n");
} }
//html=html+("<tr><td colspan=4 align=center>&nbsp;</td></tr>\n"); //html+=("<tr><td colspan=4 align=center>&nbsp;</td></tr>\n");
html=html+("<tr><td> </td><td><b>Min</b></td><td><b>Avg</b></td><td><b>Max</b></td></tr>"); html+=("<tr><td> </td><td><b>Min</b></td><td><b>Avg</b></td><td><b>Max</b></td></tr>");
if (mode==MODE_APAP) { if (mode==MODE_APAP) {
html=html+"<tr><td>"+tr("Pressure")+"</td><td>"+a.sprintf("%.2f",cpap->summary_min(CPAP_PressureMinAchieved)); html+="<tr><td align=left>"+tr("Pressure:")+"</td><td>"+a.sprintf("%.2f",cpap->summary_min(CPAP_PressureMinAchieved));
html=html+("</td><td>")+a.sprintf("%.2f",cpap->summary_weighted_avg(CPAP_PressureAverage)); html+=(" </td><td>")+a.sprintf("%.2f",cpap->summary_weighted_avg(CPAP_PressureAverage));
html=html+("</td><td>")+a.sprintf("%.2f",cpap->summary_max(CPAP_PressureMaxAchieved))+("</td></tr>"); html+=("</td><td>")+a.sprintf("%.2f",cpap->summary_max(CPAP_PressureMaxAchieved))+("</td></tr>");
// html=html+wxT("<tr><td><b>")+_("90%&nbsp;Pressure")+wxT("</b></td><td>")+wxString::Format(wxT("%.1fcmH2O"),p90)+wxT("</td></tr>\n"); // html+=wxT("<tr><td><b>")+_("90%&nbsp;Pressure")+wxT("</b></td><td>")+wxString::Format(wxT("%.1fcmH2O"),p90)+wxT("</td></tr>\n");
} else if (mode==MODE_BIPAP) { } else if (mode==MODE_BIPAP) {
html=html+("<tr><td>"+tr("EPAP")+"</td><td>")+a.sprintf("%.2f",cpap->summary_min(BIPAP_EAPMin)); html+=("<tr><td align=left>"+tr("EPAP:")+"</td><td>")+a.sprintf("%.2f",cpap->summary_min(BIPAP_EAPMin));
html=html+("</td><td>")+a.sprintf("%.2f",cpap->summary_weighted_avg(BIPAP_EAPAverage)); html+=(" </td><td>")+a.sprintf("%.2f",cpap->summary_weighted_avg(BIPAP_EAPAverage));
html=html+("</td><td>")+a.sprintf("%.2f",cpap->summary_max(BIPAP_EAPMax))+("</td></tr>"); html+=("</td><td>")+a.sprintf("%.2f",cpap->summary_max(BIPAP_EAPMax))+("</td></tr>");
html=html+("<tr><td>"+tr("IPAP")+"</td><td>")+a.sprintf("%.2f",cpap->summary_min(BIPAP_IAPMin)); html+=("<tr><td> align=left"+tr("IPAP:")+"</td><td>")+a.sprintf("%.2f",cpap->summary_min(BIPAP_IAPMin));
html=html+("</td><td>")+a.sprintf("%.2f",cpap->summary_weighted_avg(BIPAP_IAPAverage)); html+=("</td><td>")+a.sprintf("%.2f",cpap->summary_weighted_avg(BIPAP_IAPAverage));
html=html+("</td><td>")+a.sprintf("%.2f",cpap->summary_max(BIPAP_IAPMax))+("</td></tr>"); html+=("</td><td>")+a.sprintf("%.2f",cpap->summary_max(BIPAP_IAPMax))+("</td></tr>");
} }
html=html+"<tr><td>"+tr("Leak"); html+="<tr><td align=left>"+tr("Leak:");
html=html+"</td><td>"+a.sprintf("%.2f",cpap->summary_min(CPAP_LeakMinimum)); html+="</td><td>"+a.sprintf("%.2f",cpap->summary_min(CPAP_LeakMinimum));
html=html+"</td><td>"+a.sprintf("%.2f",cpap->summary_weighted_avg(CPAP_LeakAverage)); html+="</td><td>"+a.sprintf("%.2f",cpap->summary_weighted_avg(CPAP_LeakAverage));
html=html+"</td><td>"+a.sprintf("%.2f",cpap->summary_max(CPAP_LeakMaximum))+("</td><tr>"); html+="</td><td>"+a.sprintf("%.2f",cpap->summary_max(CPAP_LeakMaximum))+("</td><tr>");
html=html+"<tr><td>"+tr("Snore"); html+="<tr><td align=left>"+tr("Snore:");
html=html+"</td><td>"+a.sprintf("%.2f",cpap->summary_min(CPAP_SnoreMinimum)); html+="</td><td>"+a.sprintf("%.2f",cpap->summary_min(CPAP_SnoreMinimum));
html=html+"</td><td>"+a.sprintf("%.2f",cpap->summary_avg(CPAP_SnoreAverage)); html+="</td><td>"+a.sprintf("%.2f",cpap->summary_avg(CPAP_SnoreAverage));
html=html+"</td><td>"+a.sprintf("%.2f",cpap->summary_max(CPAP_SnoreMaximum))+("</td><tr>"); html+="</td><td>"+a.sprintf("%.2f",cpap->summary_max(CPAP_SnoreMaximum))+("</td><tr>");
FRW->show(); FRW->show();
PRD->show(); PRD->show();
LEAK->show(); LEAK->show();
@ -624,17 +629,17 @@ void Daily::Load(QDate date)
} }
if (oxi) { if (oxi) {
html=html+"<tr><td>"+tr("Pulse"); html+="<tr><td>"+tr("Pulse:");
html=html+"</td><td>"+a.sprintf("%.2fbpm",oxi->summary_min(OXI_PulseMin)); html+="</td><td>"+a.sprintf("%.2fbpm",oxi->summary_min(OXI_PulseMin));
html=html+"</td><td>"+a.sprintf("%.2fbpm",oxi->summary_avg(OXI_PulseAverage)); html+="</td><td>"+a.sprintf("%.2fbpm",oxi->summary_avg(OXI_PulseAverage));
html=html+"</td><td>"+a.sprintf("%.2fbpm",oxi->summary_max(OXI_PulseMax))+"</td><tr>"; html+="</td><td>"+a.sprintf("%.2fbpm",oxi->summary_max(OXI_PulseMax))+"</td><tr>";
html=html+"<tr><td>"+tr("SpO2"); html+="<tr><td>"+tr("SpO2:");
html=html+"</td><td>"+a.sprintf("%.2f%%",oxi->summary_min(OXI_SPO2Min)); html+="</td><td>"+a.sprintf("%.2f%%",oxi->summary_min(OXI_SPO2Min));
html=html+"</td><td>"+a.sprintf("%.2f%%",oxi->summary_avg(OXI_SPO2Average)); html+="</td><td>"+a.sprintf("%.2f%%",oxi->summary_avg(OXI_SPO2Average));
html=html+"</td><td>"+a.sprintf("%.2f%%",oxi->summary_max(OXI_SPO2Max))+"</td><tr>"; html+="</td><td>"+a.sprintf("%.2f%%",oxi->summary_max(OXI_SPO2Max))+"</td><tr>";
//html=html+wxT("<tr><td colspan=4>&nbsp;</td></tr>\n"); //html+=wxT("<tr><td colspan=4>&nbsp;</td></tr>\n");
PULSE->show(); PULSE->show();
//SPO2->show(); //SPO2->show();
@ -648,14 +653,11 @@ void Daily::Load(QDate date)
} else } else
NoData->hide(); NoData->hide();
//ui->graphSizer->invalidate();
//ui->graphSizer->layout();
//GraphWindow->FitInside();
if (cpap) { if (cpap) {
if (mode==MODE_BIPAP) { if (mode==MODE_BIPAP) {
} else if (mode==MODE_APAP) { } else if (mode==MODE_APAP) {
html=html+("<tr><td colspan=4 align=center><i>")+tr("Time@Pressure")+("</i></td></tr>\n"); html+=("<tr><td colspan=4 align=center><i>")+tr("Time@Pressure")+("</i></td></tr>\n");
TAP->setFixedSize(gwwidth,gwheight); TAP->setFixedSize(gwwidth,gwheight);
QPixmap pixmap=TAP->renderPixmap(gwwidth,gwheight,false); QPixmap pixmap=TAP->renderPixmap(gwwidth,gwheight,false);
@ -663,21 +665,20 @@ void Daily::Load(QDate date)
QBuffer buffer(&byteArray); // use buffer to store pixmap into byteArray QBuffer buffer(&byteArray); // use buffer to store pixmap into byteArray
buffer.open(QIODevice::WriteOnly); buffer.open(QIODevice::WriteOnly);
pixmap.save(&buffer, "PNG"); pixmap.save(&buffer, "PNG");
html += "<tr><td colspan=4 align=center><img src=\"data:image/png;base64," + byteArray.toBase64() + "\"></td></tr>\n"; html+="<tr><td colspan=4 align=center><img src=\"data:image/png;base64," + byteArray.toBase64() + "\"></td></tr>\n";
} }
html=html+("</table><hr height=2>"); html+="</table><hr height=2><table cellpadding=0 cellspacing=0 border=0 width=100%>";
html+="<tr><td align=center>SessionID</td><td align=center>Date</td><td align=center>Start</td><td align=center>End</td></tr>";
for (vector<Session *>::iterator s=cpap->begin();s!=cpap->end();s++) { for (vector<Session *>::iterator s=cpap->begin();s!=cpap->end();s++) {
tmp.sprintf(("%06i "+(*s)->first().toString("yyyy-MM-dd HH:mm ")+(*s)->last().toString("HH:mm")+"<br/>").toLatin1(),(*s)->session());
tmp.sprintf(("<tr><td align=center>%08x</td><td align=center>"+(*s)->first().toString("yyyy-MM-dd")+"</td><td align=center>"+(*s)->first().toString("HH:mm ")+"</td><td align=center>"+(*s)->last().toString("HH:mm")+"</td></tr>").toLatin1(),(*s)->session());
html+=tmp; html+=tmp;
} }
html+="</table>";
} }
html+="</html>"; html+="</html>";
//PRD->updateGL();
ui->webView->setHtml(html); ui->webView->setHtml(html);
//frw->Update(cpap);
//FRW->updateGL();
ui->JournalNotes->clear(); ui->JournalNotes->clear();
Session *journal=GetJournalSession(date); Session *journal=GetJournalSession(date);