Code cleanup, BMI notes display fix, Show PRS1 flex mode & Humidifier setting in daily Details panel

This commit is contained in:
Mark Watkins 2011-12-14 14:54:17 +10:00
parent 6cb33f3293
commit 33120c4ec4
17 changed files with 103 additions and 121 deletions

View File

@ -1647,7 +1647,7 @@ QPixmap gGraph::renderPixmap(int w, int h)
gGraphView *sg=mainwin->snapshotGraph();
if (!sg) return QPixmap();
double scale=sg->printScaleY(); //sqrt(sg->printScaleX()*sg->printScaleX()+sg->printScaleY()*sg->printScaleY());
//double scale=sg->printScaleY(); //sqrt(sg->printScaleX()*sg->printScaleX()+sg->printScaleY()*sg->printScaleY());
/*
fa.setPointSize(fa.pointSize()*scale);
fb.setPointSize(fb.pointSize()*scale);
@ -2226,7 +2226,7 @@ void gGraphView::paintGL()
//((QGLContext*)context())->makeCurrent();
float linesize=lines->size();
//float linesize=lines->size();
//if (print_scaleY>1) {
// lines->setSize(3);
// }

View File

@ -135,9 +135,6 @@ void gLineChart::paint(gGraph & w,int left, int top, int width, int height)
qWarning() << "gLineChart::Plot() NULL Session Record.. This should not happen";
continue;
}
if (m_code==CPAP_FlowRate){
int i=5;
}
schema::Channel ch=schema::channel[m_code];
bool fndbetter=false;
for (QList<schema::Channel *>::iterator l=ch.m_links.begin();l!=ch.m_links.end();l++) {

View File

@ -115,6 +115,10 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh
if (xx<(1800000)) {
GetTextExtent(m_label,x,y);
w.renderText(m_label,x1-(x/2),top-y+(3*w.printScaleY()));
QString a=QString::number(int(el.data(i)));
GetTextExtent(a,x,y);
w.renderText(a,x1-(x/2),bottom+y+(3*w.printScaleY()));
}
}

View File

@ -102,13 +102,13 @@ void gSegmentChart::paint(gGraph & w,int left, int top, int width, int height)
GLShortBuffer *lines2=w.lines();
for (unsigned m=0;m<size;m++) {
data=m_values[m];
QColor & col=schema::channel[m_codes[m % m_colors.size()]].defaultColor();
if (data==0) continue;
/////////////////////////////////////////////////////////////////////////////////////
// Pie Chart
/////////////////////////////////////////////////////////////////////////////////////
if (m_graph_type==GST_Pie) {
QColor & col=schema::channel[m_codes[m % m_colors.size()]].defaultColor();
j=float(data)/float(m_total); // ratio of this pie slice
// Draw Filling
@ -152,6 +152,7 @@ void gSegmentChart::paint(gGraph & w,int left, int top, int width, int height)
// CandleStick Chart
/////////////////////////////////////////////////////////////////////////////////////
} else if (m_graph_type==GST_CandleStick) {
QColor & col=m_colors[m % m_colors.size()];
float bw=xmult*float(data);
quads->add(xp,start_py,xp+bw,start_py,m_gradient_color);
@ -169,8 +170,12 @@ void gSegmentChart::paint(gGraph & w,int left, int top, int width, int height)
}
xp+=bw;
/////////////////////////////////////////////////////////////////////////////////////
// Line Chart
/////////////////////////////////////////////////////////////////////////////////////
} else if (m_graph_type==GST_Line) {
float h=float(data)*ymult;
QColor col=Qt::black; //m_colors[m % m_colors.size()];
float h=(top+height)-(float(data)*ymult);
if (line_first) {
line_first=false;
} else {
@ -255,4 +260,5 @@ void gTAPGraph::SetDay(Day *d)
m_total+=i.value()/1000L;
m_names.push_back(QString::number(val,'f',2));
}
m_empty=m_values.size()==0;
}

View File

@ -134,9 +134,6 @@ void SummaryChart::SetDay(Day * nullday)
day->settingExists(code) ||
day->hasData(code,type);
if (code==CPAP_AHI) {
int i=5;
}
if (hascode) {
m_days[dn]=day;
switch(m_type[j]) {
@ -158,9 +155,6 @@ void SummaryChart::SetDay(Day * nullday)
case ST_SETSUM: tmp=day->settings_sum(code); break;
default: break;
}
if (tmp>10000) {
int i=5;
}
if (suboffset>0) {
tmp-=suboffset;
if (tmp<0) tmp=0;
@ -269,12 +263,6 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height)
EventDataType maxy=m_maxy;
EventDataType miny=m_miny;
/*if (m_codes[0]=="HumidSet") {
int i=1;
}*/
if (w.title()=="Session Times") {
int i=5;
}
w.roundY(miny,maxy);
EventDataType yy=maxy-miny;

View File

@ -9,52 +9,10 @@
#include "profiles.h"
bool SearchApnea(Session *session, qint64 time, qint64 dist=15000)
{
qint64 t;
QHash<ChannelID,QVector<EventList *> >::iterator it;
it=session->eventlist.find(CPAP_Obstructive);
if (it!=session->eventlist.end()) {
for (int i=0;i<it.value().size();i++) {
EventList *el=it.value()[i];
for (unsigned j=0;j<el->count();j++) {
t=el->time(j);
if (qAbs(time-t)<dist)
return true;
}
}
}
it=session->eventlist.find(CPAP_Apnea);
if (it!=session->eventlist.end()) {
for (int i=0;i<it.value().size();i++) {
EventList *el=it.value()[i];
for (unsigned j=0;j<el->count();j++) {
t=el->time(j);
if (qAbs(time-t)<dist)
return true;
}
}
}
it=session->eventlist.find(CPAP_ClearAirway);
if (it!=session->eventlist.end()) {
for (int i=0;i<it.value().size();i++) {
EventList *el=it.value()[i];
for (unsigned j=0;j<el->count();j++) {
t=el->time(j);
if (qAbs(time-t)<dist)
return true;
}
}
}
it=session->eventlist.find(CPAP_Hypopnea);
if (it!=session->eventlist.end()) {
for (int i=0;i<it.value().size();i++) {
EventList *el=it.value()[i];
for (unsigned j=0;j<el->count();j++) {
t=el->time(j);
if (qAbs(time-t)<dist)
return true;
}
}
}
if (session->SearchEvent(CPAP_Obstructive,time,dist)) return true;
if (session->SearchEvent(CPAP_Apnea,time,dist)) return true;
if (session->SearchEvent(CPAP_ClearAirway,time,dist)) return true;
if (session->SearchEvent(CPAP_Hypopnea,time,dist)) return true;
return false;
}
@ -263,7 +221,7 @@ int filterFlow(Session *session, EventList *in, EventList *out, EventList *tv, E
uf=new EventList(EVL_Event,1,0,0,0,0,true);
session->eventlist["UserFlag1"].push_back(uf);
}
uf->AddEvent(time,0,1);
uf->AddEvent(time,len/1000L,1);
}
}
}

View File

@ -193,7 +193,7 @@ EventDataType Day::p90(ChannelID code) // The "average" p90.. this needs fixing.
// Don't assume sessions are in order.
unsigned cnt=0,c;
EventDataType p,tmp;
EventDataType p;
QMap<EventDataType, unsigned> pmap;
QMap<EventDataType, float> tmap;

View File

@ -319,7 +319,7 @@ int IntellipapLoader::Open(QString & path,Profile *profile)
//}
quint64 first=qint64(sid)*1000L;
quint64 last=qint64(SessionEnd[i])*1000L;
quint64 len=last-first;
//quint64 len=last-first;
//if (len>0) {
//if (!sess->first()) {
sess->set_first(first);

View File

@ -471,9 +471,9 @@ bool PRS1Loader::ParseSummary(Machine *mach, qint32 sequence, quint32 timestamp,
} else session->settings[PRS1_FlexMode]=(int)PR_CFLEX;
} else session->settings[PRS1_FlexMode]=(int)PR_NONE;
session->settings["FlexSet"]=(int)data[offset+0x08] & 3;
session->settings["HumidSet"]=(int)data[offset+0x09]&0x0f;
session->settings["HumidStat"]=(data[offset+0x09]&0x80)==0x80;
session->settings[PRS1_FlexSet]=(int)data[offset+0x08] & 3;
session->settings[PRS1_HumidSetting]=(int)data[offset+0x09]&0x0f;
session->settings[PRS1_HumidStatus]=(data[offset+0x09]&0x80)==0x80;
session->settings["SysLock"]=(data[offset+0x0a]&0x80)==0x80;
session->settings["SysOneResistStat"]=(data[offset+0x0a]&0x40)==0x40;
session->settings["SysOneResistSet"]=(int)data[offset+0x0a]&7;
@ -538,7 +538,7 @@ bool PRS1Loader::ParseSummary(Machine *mach, qint32 sequence, quint32 timestamp,
new_sessions[sequence]=session;
return true;
}
bool PRS1Loader::Parse002v5(Machine *mach, qint32 sequence, quint32 timestamp, unsigned char *buffer, quint16 size)
bool PRS1Loader::Parse002v5(qint32 sequence, quint32 timestamp, unsigned char *buffer, quint16 size)
{
if (!new_sessions.contains(sequence))
return false;
@ -568,9 +568,6 @@ bool PRS1Loader::Parse002v5(Machine *mach, qint32 sequence, quint32 timestamp, u
bool badcode=false;
while (pos<size) {
if (pos>=70) {
int i=5;
}
unsigned char code=buffer[pos++];
if (code>=ncodes) {
qDebug() << "Illegal PRS1 code " << hex << int(code) << " appeared at " << hex << pos;
@ -793,7 +790,6 @@ bool PRS1Loader::Parse002v5(Machine *mach, qint32 sequence, quint32 timestamp, u
break;
}
if (badcode) {
int i=5;
break;
}
}
@ -804,14 +800,14 @@ bool PRS1Loader::Parse002v5(Machine *mach, qint32 sequence, quint32 timestamp, u
}
bool PRS1Loader::Parse002(Machine *mach, qint32 sequence, quint32 timestamp, unsigned char *buffer, quint16 size)
bool PRS1Loader::Parse002(qint32 sequence, quint32 timestamp, unsigned char *buffer, quint16 size)
{
if (!new_sessions.contains(sequence))
return false;
unsigned char code;
EventList * Code[0x20]={0};
EventDataType data[10],tmp;
EventDataType data[10];
int cnt=0;
short delta;
int tdata;
@ -1006,7 +1002,7 @@ bool PRS1Loader::Parse002(Machine *mach, qint32 sequence, quint32 timestamp, uns
}
bool PRS1Loader::ParseWaveform(Machine *mach, qint32 sequence, quint32 timestamp, unsigned char *data, quint16 size, quint16 duration, quint16 num_signals, quint16 interleave, quint8 sample_format)
bool PRS1Loader::ParseWaveform(qint32 sequence, quint32 timestamp, unsigned char *data, quint16 size, quint16 duration, quint16 num_signals, quint16 interleave, quint8 sample_format)
{
if (!new_sessions.contains(sequence))
return false;
@ -1025,6 +1021,7 @@ bool PRS1Loader::ParseWaveform(Machine *mach, qint32 sequence, quint32 timestamp
}
return true;
}
bool PRS1Loader::OpenFile(Machine *mach, QString filename)
@ -1034,7 +1031,7 @@ bool PRS1Loader::OpenFile(Machine *mach, QString filename)
qint64 pos;
unsigned char ext,htype,sum;
unsigned char *header,*data;
int chunk,hl,lasthl;
int chunk,hl;
quint16 size,datasize,c16,crc;
// waveform stuff
@ -1131,9 +1128,9 @@ bool PRS1Loader::OpenFile(Machine *mach, QString filename)
ParseSummary(mach,sequence,timestamp,data,datasize,version);
} else if (ext==2) {
if (version==5) {
Parse002v5(mach,sequence,timestamp,data,datasize);
Parse002v5(sequence,timestamp,data,datasize);
} else {
Parse002(mach,sequence,timestamp,data,datasize);
Parse002(sequence,timestamp,data,datasize);
}
} else if (ext==5) {
//ParseWaveform(mach,sequence,timestamp,data,datasize,duration,num_signals,interleave,sample_format);

View File

@ -57,10 +57,10 @@ protected:
//bool OpenSummary(Session *session,QString filename);
//bool OpenEvents(Session *session,QString filename);
bool OpenWaveforms(SessionID sid, QString filename);
bool ParseWaveform(Machine *mach, qint32 sequence, quint32 timestamp, unsigned char *data, quint16 size, quint16 duration, quint16 num_signals, quint16 interleave, quint8 sample_format);
bool ParseWaveform(qint32 sequence, quint32 timestamp, unsigned char *data, quint16 size, quint16 duration, quint16 num_signals, quint16 interleave, quint8 sample_format);
bool ParseSummary(Machine *mach, qint32 sequence, quint32 timestamp, unsigned char *data, quint16 size, char version);
bool Parse002(Machine *mach, qint32 sequence, quint32 timestamp, unsigned char *data, quint16 size);
bool Parse002v5(Machine *mach, qint32 sequence, quint32 timestamp, unsigned char *data, quint16 size);
bool Parse002(qint32 sequence, quint32 timestamp, unsigned char *data, quint16 size);
bool Parse002v5(qint32 sequence, quint32 timestamp, unsigned char *data, quint16 size);
bool OpenFile(Machine *mach, QString filename);
//bool Parse002(Session *session,unsigned char *buffer,int size,qint64 timestamp,long fpos);

View File

@ -59,8 +59,6 @@ const QString CPAP_IPAPHi="IPAPHi";
const QString CPAP_EPAP="EPAP";
const QString CPAP_Pressure="Pressure";
const QString CPAP_PS="PS";
const QString PRS1_FlexMode="FlexMode";
const QString PRS1_FlexSet="FlexSet";
const QString CPAP_Mode="PAPMode";
const QString CPAP_BrokenSummary="BrokenSummary";
const QString CPAP_PressureMin="PressureMin";
@ -110,6 +108,10 @@ const QString PRS1_0E="PRS1_0E";
const QString PRS1_0F="PRS1_0F";
const QString PRS1_10="PRS1_10";
const QString PRS1_12="PRS1_12";
const QString PRS1_FlexMode="FlexMode";
const QString PRS1_FlexSet="FlexSet";
const QString PRS1_HumidStatus="FlexSet";
const QString PRS1_HumidSetting="HumidSet";
const QString OXI_Pulse="Pulse";
const QString OXI_SPO2="SPO2";

View File

@ -56,6 +56,11 @@ public:
const QString & description() { return m_description; }
const QString & label() { return m_label; }
const QString & units() { return m_unit; }
QString option(int i) {
if (m_options.contains(i))
return m_options[i];
return QString();
}
QColor & defaultColor() { return m_defaultcolor; }
void setDefaultColor(QColor color) { m_defaultcolor=color; }
QHash<int,QString> m_options;

View File

@ -463,9 +463,6 @@ void Session::UpdateSummaries()
QHash<ChannelID,QVector<EventList *> >::iterator c;
for (c=eventlist.begin();c!=eventlist.end();c++) {
id=c.key();
if (id==CPAP_AHI) {
int i=5;
}
if (schema::channel[id].type()==schema::DATA) {
//sum(id); // avg calculates this and cnt.
min(id);
@ -489,6 +486,25 @@ void Session::UpdateSummaries()
}
bool Session::SearchEvent(ChannelID code, qint64 time, qint64 dist)
{
qint64 t;
QHash<ChannelID,QVector<EventList *> >::iterator it;
it=eventlist.find(code);
if (it!=eventlist.end()) {
for (int i=0;i<it.value().size();i++) {
EventList *el=it.value()[i];
for (unsigned j=0;j<el->count();j++) {
t=el->time(j);
if (qAbs(time-t)<dist)
return true;
}
}
}
return false;
}
EventDataType Session::min(ChannelID id)
{
QHash<ChannelID,EventDataType>::iterator i=m_min.find(id);
@ -516,9 +532,6 @@ EventDataType Session::min(ChannelID id)
if (min>t1) min=t1;
}
}
if (min>10000) {
int i=5;
}
m_min[id]=min;
return min;
}
@ -899,9 +912,6 @@ EventDataType Session::wavg(ChannelID id)
lasttime=time;
lastval=val;
}*/
if (id==CPAP_AHI) {
int i=5;
}
time=evec[i]->time(0)/1000L;
minval=val=evec[i]->raw(0);
for (quint32 j=1;j<evec[i]->count();j++) {
@ -924,9 +934,6 @@ EventDataType Session::wavg(ChannelID id)
}
}
if (id==CPAP_Snore) {
int i=5;
}
if (minval<0) minval=-minval;
minval++;
// if (minval<0) minval+=(0-minval)+1; else minval=1;

View File

@ -35,6 +35,9 @@ public:
bool OpenEvents();
void TrashEvents();
bool SearchEvent(ChannelID code, qint64 time, qint64 dist=15000);
const SessionID & session() {
return s_session;
}

View File

@ -117,6 +117,13 @@ Daily::Daily(QWidget *parent,gGraphView * shared, MainWindow *mw)
// Event Pie Chart (for snapshot purposes)
// TODO: Convert snapGV to generic for snapshotting multiple graphs (like reports does)
// TAP=new gGraph(GraphView,"Time@Pressure","cmH2O",100);
// TAP->showTitle(false);
// gTAPGraph * tap=new gTAPGraph(CPAP_Pressure,GST_Line);
// TAP->AddLayer(AddCPAP(tap));
//TAP->setMargins(0,0,0,0);
GAHI=new gGraph(snapGV,"Breakdown","events",172);
gSegmentChart * evseg=new gSegmentChart(GST_Pie);
evseg->AddSlice(CPAP_Hypopnea,QColor(0x40,0x40,0xff,0xff),"H");
@ -838,21 +845,22 @@ void Daily::Load(QDate date)
html+="<tr><td colspan=5>&nbsp;</td></tr>\n";
}
html+="</table>";
//html+="<table cellspacing=0 cellpadding=0 border=0 width='100%'>\n";
html+="</table><hr height=2/>";
if (cpap) {
// if ((*profile)["EnableGraphSnapshots"].toBool()) {
/*if (cpap->channelExists(CPAP_Pressure)) {
html+=("<tr><td colspan=4 align=center><i>")+tr("Time@Pressure")+("</i></td></tr>\n");
TAP->setFixedSize(gwwidth,30);
QPixmap pixmap=TAP->renderPixmap(gwwidth,30,false);
//TAP->setFixedSize(gwwidth,30);
QPixmap pixmap=TAP->renderPixmap(200,30);
QByteArray byteArray;
QBuffer buffer(&byteArray); // use buffer to store pixmap into byteArray
buffer.open(QIODevice::WriteOnly);
pixmap.save(&buffer, "PNG");
html+="<tr><td colspan=4 align=center><img src=\"data:image/png;base64," + byteArray.toBase64() + "\"></td></tr>\n";
}
if (cpap->channelExists(CPAP_EPAP)) {
//html+="<tr height='2'><td colspan=4 height='2'><hr></td></tr>\n";
html+=("<tr><td colspan=4 align=center><i>")+tr("Time@EPAP")+("</i></td></tr>\n");
@ -874,6 +882,17 @@ void Daily::Load(QDate date)
pixmap.save(&buffer, "PNG");
html+="<tr><td colspan=4 align=center><img src=\"data:image/png;base64," + byteArray.toBase64() + "\"></td></tr>\n";
} */
html+="<table cellpadding=0 cellspacing=0 border=0 width=100%>";
if (cpap->machine->GetClass()=="PRS1") {
int i=cpap->settings_max(PRS1_FlexMode);
int j=cpap->settings_max(PRS1_FlexSet);
html+="<tr><td colspan=4>Pressure Relief: "+schema::channel[PRS1_FlexMode].option(i)+" "+schema::channel[PRS1_FlexSet].option(j)+"</td></tr>";
i=cpap->settings_max(PRS1_HumidSetting);
QString humid=(i==0) ? "Off" : "x"+QString::number(i);
html+="<tr><td colspan=4>Humidifier Setting: "+humid+"</td></tr>";
}
html+="</table><hr height=2>";
//}
@ -983,10 +1002,10 @@ void Daily::Load(QDate date)
}
double height=PROFILE["Height"].toDouble(&ok)/100.0;
if (height>0 && kg>0) {
//double bmi=kg/(height*height);
double bmi=kg/(height*height);
ui->BMI->setVisible(true);
ui->BMIlabel->setVisible(true);
//ui->BMI->display(bmi);
ui->BMI->display(bmi);
}
}
@ -1435,10 +1454,6 @@ void Daily::on_ZombieMeter_valueChanged(int action)
}
}
void Daily::on_ZombieMeter_actionTriggered(int action)
{
}
void Daily::on_bookmarkTable_itemChanged(QTableWidgetItem *item)
{
Q_UNUSED(item);

View File

@ -77,7 +77,6 @@ private slots:
void on_treeWidget_itemClicked(QTreeWidgetItem *item, int column);
void graphtogglebutton_toggled(bool);
void on_ZombieMeter_actionTriggered(int action);
void on_addBookmarkButton_clicked();

View File

@ -122,16 +122,17 @@ One id code per item
<Option id="5" value="x5"/>
</channel>
<channel id="0xe105" class="setting" scope="!session" name="FlexMode" details="Pressure Relief Mode" label="Flex Mode" type="integer">
<Option id="0" value="None"/>
<Option id="1" value="C-Flex"/>
<Option id="2" value="C-Flex+"/>
<Option id="3" value="A-Flex"/>
<Option id="1" value="None"/>
<Option id="2" value="C-Flex"/>
<Option id="3" value="C-Flex+"/>
<Option id="4" value="A-Flex"/>
<Option id="5" value="Bi-Flex"/>
</channel>
<channel id="0xe106" class="setting" scope="!session" name="FlexSet" details="Pressure Relief Setting" label="Flex Set." type="integer">
<Option id="0" value="0"/>
<Option id="1" value="1"/>
<Option id="2" value="2"/>
<Option id="3" value="3"/>
<Option id="0" value=""/>
<Option id="1" value="x1"/>
<Option id="2" value="x2"/>
<Option id="3" value="x3"/>
</channel>
<channel id="0xe107" class="setting" scope="!session" name="HoseDiam" details="Hose Diameter" label="Hose Diameter" type="bool">
<Option id="0" value="22mm"/>