Added Channel Register to machine object. Needs Reimporting

This commit is contained in:
Mark Watkins 2011-09-13 18:12:07 +10:00
parent 2a9ff00e33
commit 9f459c97f0
15 changed files with 163 additions and 143 deletions

View File

@ -404,11 +404,11 @@ bool SummaryChart::mouseMoveEvent(QMouseEvent *event)
val=QString::number(d.value()[1],'f',2);
}
QString z=dt.toString(Qt::SystemLocaleShortDate)+"\n"+m_label+"="+val;//+"\nAHI="+QString::number(day->cph(CPAP_AHI));
QString z=dt.toString(Qt::SystemLocaleShortDate)+"\r\n"+m_label+"="+val;//+"\nAHI="+QString::number(day->cph(CPAP_AHI));
graph->ToolTip(z,x,y,2200);
return true;
} else {
QString z=dt.toString(Qt::SystemLocaleShortDate)+"\nNo Data";
QString z=dt.toString(Qt::SystemLocaleShortDate)+"\r\nNo Data";
graph->ToolTip(z,x,y,2200);
}
}

View File

@ -334,10 +334,11 @@ int Day::count(ChannelID code)
}
bool Day::channelExists(ChannelID id)
{
for (int i=0;i<sessions.size();i++) {
if (machine->hasChannel(id)) return true;
/*for (int i=0;i<sessions.size();i++) {
if (sessions[i]->channelExists(id))
return true;
}
} */
return false;
}

View File

@ -11,7 +11,7 @@ License: GPL
#include "SleepLib/machine_loader.h"
const QString cms50_class_name="CMS50";
const int cms50_data_version=3;
const int cms50_data_version=4;
class CMS50Loader : public MachineLoader
{

View File

@ -87,7 +87,6 @@ Machine *PRS1Loader::CreateMachine(QString serial,Profile *profile)
profile->AddMachine(m);
m->properties["Serial"]=serial;
return m;
}
bool isdigit(QChar c)
@ -314,37 +313,6 @@ int PRS1Loader::OpenMachine(Machine *m,QString path,Profile *profile)
continue;
}
ChannelID e[]={
CPAP_Obstructive, CPAP_Hypopnea, CPAP_ClearAirway, CPAP_RERA, CPAP_FlowLimit, CPAP_VSnore,
CPAP_CSR, PRS1_VSnore2
};
/*for (unsigned i=0;i<sizeof(e)/sizeof(ChannelID);i++) {
sess->count(e[i]);
sess->max(e[i]);
sess->min(e[i]);
sess->avg(e[i]);
sess->p90(e[i]);
sess->cph(e[i]);
sess->sph(e[i]);
}*/
ChannelID a[]={
CPAP_FlowRate, CPAP_MaskPressure, CPAP_Leak, CPAP_Snore, CPAP_EPAP,
CPAP_IPAP, CPAP_TidalVolume, CPAP_RespiratoryRate,
CPAP_PatientTriggeredBreaths,CPAP_MinuteVentilation, CPAP_IPAP_Low,
CPAP_IPAP_High, CPAP_FlowLimitGraph, CPAP_PressureSupport, CPAP_PressurePulse
};
for (unsigned i=0;i<sizeof(a)/sizeof(ChannelID);i++) {
if (sess->eventlist.contains(a[i])) {
/*sess->min(a[i]);
sess->max(a[i]);
sess->avg(a[i]);
sess->wavg(a[i]);
sess->p90(a[i]); */
//sess->cph(a[i]);
}
}
if (sess->count(CPAP_IPAP)>0) {
//sess->summaryCPAP_Mode]!=MODE_ASV)
sess->settings[CPAP_Mode]=MODE_BIPAP;
@ -561,7 +529,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
delta=buffer[pos+1] << 8 | buffer[pos];
pos+=2;
t+=qint64(delta)*1000L;
tt=t;;
tt=t;
}
cnt++;
@ -570,6 +538,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
if (!Code[0]) {
Code[0]=new EventList(PRS1_Unknown00,EVL_Event);
session->eventlist[PRS1_Unknown00].push_back(Code[0]);
session->machine()->registerChannel(PRS1_Unknown00);
}
Code[0]->AddEvent(t,buffer[pos++]);
break;
@ -577,6 +546,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
if (!Code[1]) {
Code[1]=new EventList(PRS1_Unknown01,EVL_Event);
session->eventlist[PRS1_Unknown01].push_back(Code[1]);
session->machine()->registerChannel(PRS1_Unknown01);
}
Code[1]->AddEvent(t,0);
break;
@ -584,6 +554,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
if (!Code[2]) {
Code[2]=new EventList(CPAP_Pressure,EVL_Event,0.1);
session->eventlist[CPAP_Pressure].push_back(Code[2]);
session->machine()->registerChannel(CPAP_Pressure);
}
Code[2]->AddEvent(t,buffer[pos++]);
break;
@ -595,6 +566,10 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
session->eventlist[CPAP_IPAP].push_back(Code[4]);
Code[5]=new EventList(CPAP_PressureSupport,EVL_Event,0.1);
session->eventlist[CPAP_PressureSupport].push_back(Code[5]);
session->machine()->registerChannel(CPAP_EPAP);
session->machine()->registerChannel(CPAP_IPAP);
session->machine()->registerChannel(CPAP_PressureSupport);
}
Code[3]->AddEvent(t,data[0]=buffer[pos++]);
Code[4]->AddEvent(t,data[1]=buffer[pos++]);
@ -604,6 +579,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
if (!Code[6]) {
Code[6]=new EventList(CPAP_PressurePulse,EVL_Event);
session->eventlist[CPAP_PressurePulse].push_back(Code[6]);
session->machine()->registerChannel(CPAP_PressurePulse);
}
Code[6]->AddEvent(t,buffer[pos++]);
//qDebug() << hex << data[0];
@ -614,6 +590,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
if (!Code[7]) {
Code[7]=new EventList(CPAP_RERA,EVL_Event);
session->eventlist[CPAP_RERA].push_back(Code[7]);
session->machine()->registerChannel(CPAP_RERA);
}
Code[7]->AddEvent(tt,data[0]);
break;
@ -624,6 +601,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
if (!Code[8]) {
Code[8]=new EventList(CPAP_Obstructive,EVL_Event);
session->eventlist[CPAP_Obstructive].push_back(Code[8]);
session->machine()->registerChannel(CPAP_Obstructive);
}
Code[8]->AddEvent(tt,data[0]);
break;
@ -633,6 +611,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
if (!Code[9]) {
Code[9]=new EventList(CPAP_ClearAirway,EVL_Event);
session->eventlist[CPAP_ClearAirway].push_back(Code[9]);
session->machine()->registerChannel(CPAP_ClearAirway);
}
Code[9]->AddEvent(tt,data[0]);
break;
@ -642,6 +621,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
if (!Code[10]) {
Code[10]=new EventList(CPAP_Hypopnea,EVL_Event);
session->eventlist[CPAP_Hypopnea].push_back(Code[10]);
session->machine()->registerChannel(CPAP_Hypopnea);
}
Code[10]->AddEvent(tt,data[0]);
break;
@ -651,6 +631,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
if (!Code[11]) {
Code[11]=new EventList(CPAP_FlowLimit,EVL_Event);
session->eventlist[CPAP_FlowLimit].push_back(Code[11]);
session->machine()->registerChannel(CPAP_FlowLimit);
}
Code[11]->AddEvent(tt,data[0]);
break;
@ -661,6 +642,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
if (!Code[12]) {
Code[12]=new EventList(PRS1_Unknown0B,EVL_Event);
session->eventlist[PRS1_Unknown0B].push_back(Code[12]);
session->machine()->registerChannel(PRS1_Unknown0B);
}
// FIXME
Code[12]->AddEvent(t,data[0]);
@ -669,6 +651,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
if (!Code[13]) {
Code[13]=new EventList(CPAP_VSnore,EVL_Event);
session->eventlist[CPAP_VSnore].push_back(Code[13]);
session->machine()->registerChannel(CPAP_VSnore);
}
Code[13]->AddEvent(t,0);
break;
@ -680,6 +663,8 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
session->eventlist[CPAP_Leak].push_back(Code[14]);
Code[15]=new EventList(CPAP_Snore,EVL_Event);
session->eventlist[CPAP_Snore].push_back(Code[15]);
session->machine()->registerChannel(CPAP_Leak);
session->machine()->registerChannel(CPAP_Snore);
}
Code[14]->AddEvent(t,data[0]);
Code[15]->AddEvent(t,data[1]);
@ -687,6 +672,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
if (!Code[16]) {
Code[16]=new EventList(PRS1_VSnore2,EVL_Event);
session->eventlist[PRS1_VSnore2].push_back(Code[16]);
session->machine()->registerChannel(PRS1_VSnore2);
}
Code[16]->AddEvent(t,data[1]);
}
@ -701,6 +687,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
if (!Code[17]) {
Code[17]=new EventList(PRS1_Unknown0E,EVL_Event);
session->eventlist[PRS1_Unknown0E].push_back(Code[17]);
session->machine()->registerChannel(PRS1_Unknown0E);
}
Code[17]->AddEvent(t,data[0]);
//qDebug() << hex << data[0] << data[1] << data[2];
@ -715,6 +702,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
if (!Code[20]) {
Code[20]=new EventList(PRS1_Unknown10,EVL_Event);
session->eventlist[PRS1_Unknown10].push_back(Code[20]);
session->machine()->registerChannel(PRS1_Unknown10);
}
Code[20]->AddEvent(t,data[0]);
break;
@ -726,6 +714,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
if (!Code[23]) {
Code[23]=new EventList(CPAP_CSR,EVL_Event);
session->eventlist[CPAP_CSR].push_back(Code[23]);
session->machine()->registerChannel(CPAP_CSR);
}
Code[23]->AddEvent(tt,data[0]);
break;
@ -737,6 +726,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
if (!Code[24]) {
Code[24]=new EventList(PRS1_Unknown12,EVL_Event);
session->eventlist[PRS1_Unknown12].push_back(Code[24]);
session->machine()->registerChannel(PRS1_Unknown12);
}
Code[24]->AddEvent(t,data[0]);
break;
@ -814,6 +804,7 @@ bool PRS1Loader::Parse002ASV(Session *session,unsigned char *buffer,int size,qin
if (!Code[1]) {
Code[1]=new EventList(cpapcode,EVL_Event,0.1);
session->eventlist[cpapcode].push_back(Code[1]);
session->machine()->registerChannel(cpapcode);
}
Code[1]->AddEvent(t,0);
break;
@ -823,6 +814,7 @@ bool PRS1Loader::Parse002ASV(Session *session,unsigned char *buffer,int size,qin
if (!Code[2]) {
Code[2]=new EventList(cpapcode,EVL_Event,0.1);
session->eventlist[cpapcode].push_back(Code[2]);
session->machine()->registerChannel(cpapcode);
}
Code[2]->AddEvent(t,data[0]);
break;
@ -831,6 +823,7 @@ bool PRS1Loader::Parse002ASV(Session *session,unsigned char *buffer,int size,qin
if (!Code[3]) {
Code[3]=new EventList(cpapcode,EVL_Event);
session->eventlist[cpapcode].push_back(Code[3]);
session->machine()->registerChannel(cpapcode);
}
Code[3]->AddEvent(t,data[0]);
break;
@ -841,6 +834,7 @@ bool PRS1Loader::Parse002ASV(Session *session,unsigned char *buffer,int size,qin
if (!Code[4]) {
Code[4]=new EventList(cpapcode,EVL_Event);
session->eventlist[cpapcode].push_back(Code[4]);
session->machine()->registerChannel(cpapcode);
}
Code[4]->AddEvent(tt,data[0]);
break;
@ -851,6 +845,7 @@ bool PRS1Loader::Parse002ASV(Session *session,unsigned char *buffer,int size,qin
if (!Code[5]) {
Code[5]=new EventList(cpapcode,EVL_Event);
session->eventlist[cpapcode].push_back(Code[5]);
session->machine()->registerChannel(cpapcode);
}
Code[5]->AddEvent(tt,data[0]);
break;
@ -860,6 +855,7 @@ bool PRS1Loader::Parse002ASV(Session *session,unsigned char *buffer,int size,qin
if (!Code[6]) {
Code[6]=new EventList(cpapcode,EVL_Event);
session->eventlist[cpapcode].push_back(Code[6]);
session->machine()->registerChannel(cpapcode);
}
Code[6]->AddEvent(tt,data[0]);
break;
@ -869,6 +865,7 @@ bool PRS1Loader::Parse002ASV(Session *session,unsigned char *buffer,int size,qin
if (!Code[10]) {
Code[10]=new EventList(cpapcode,EVL_Event);
session->eventlist[cpapcode].push_back(Code[10]);
session->machine()->registerChannel(cpapcode);
}
Code[10]->AddEvent(tt,data[0]);
break;
@ -878,6 +875,7 @@ bool PRS1Loader::Parse002ASV(Session *session,unsigned char *buffer,int size,qin
if (!Code[11]) {
Code[11]=new EventList(cpapcode,EVL_Event);
session->eventlist[cpapcode].push_back(Code[11]);
session->machine()->registerChannel(cpapcode);
}
Code[11]->AddEvent(tt,data[0]);
@ -889,6 +887,7 @@ bool PRS1Loader::Parse002ASV(Session *session,unsigned char *buffer,int size,qin
if (!Code[7]) {
Code[7]=new EventList(cpapcode,EVL_Event);
session->eventlist[cpapcode].push_back(Code[7]);
session->machine()->registerChannel(cpapcode);
}
Code[7]->AddEvent(tt,data[0]);
break;
@ -899,6 +898,7 @@ bool PRS1Loader::Parse002ASV(Session *session,unsigned char *buffer,int size,qin
if (!Code[8]) {
Code[8]=new EventList(cpapcode,EVL_Event);
session->eventlist[cpapcode].push_back(Code[8]);
session->machine()->registerChannel(cpapcode);
}
Code[8]->AddEvent(tt,data[0]);
break;
@ -915,6 +915,7 @@ bool PRS1Loader::Parse002ASV(Session *session,unsigned char *buffer,int size,qin
if (!Code[9]) {
Code[9]=new EventList(cpapcode,EVL_Event,2.0);
session->eventlist[cpapcode].push_back(Code[9]);
session->machine()->registerChannel(cpapcode);
}
Code[9]->AddEvent(tt,data[0]);
//session->AddEvent(new Event(tt,cpapcode, data[0], data, 2));
@ -923,36 +924,47 @@ bool PRS1Loader::Parse002ASV(Session *session,unsigned char *buffer,int size,qin
if (!Code[12]) {
Code[12]=new EventList(CPAP_IPAP,EVL_Event,0.1);
session->eventlist[CPAP_IPAP].push_back(Code[12]);
session->machine()->registerChannel(CPAP_IPAP);
Code[13]=new EventList(CPAP_IPAP_Low,EVL_Event,0.1);
session->eventlist[CPAP_IPAP_Low].push_back(Code[13]);
session->machine()->registerChannel(CPAP_IPAP_Low);
Code[14]=new EventList(CPAP_IPAP_High,EVL_Event,0.1);
session->eventlist[CPAP_IPAP_High].push_back(Code[14]);
session->machine()->registerChannel(CPAP_IPAP_High);
Code[15]=new EventList(CPAP_Leak,EVL_Event);
session->eventlist[CPAP_Leak].push_back(Code[15]);
session->machine()->registerChannel(CPAP_Leak);
Code[16]=new EventList(CPAP_RespiratoryRate,EVL_Event);
session->eventlist[CPAP_RespiratoryRate].push_back(Code[16]);
session->machine()->registerChannel(CPAP_RespiratoryRate);
Code[17]=new EventList(CPAP_PatientTriggeredBreaths,EVL_Event);
session->eventlist[CPAP_PatientTriggeredBreaths].push_back(Code[17]);
session->machine()->registerChannel(CPAP_PatientTriggeredBreaths);
Code[18]=new EventList(CPAP_MinuteVentilation,EVL_Event);
session->eventlist[CPAP_MinuteVentilation].push_back(Code[18]);
session->machine()->registerChannel(CPAP_MinuteVentilation);
Code[19]=new EventList(CPAP_TidalVolume,EVL_Event,10.0);
session->eventlist[CPAP_TidalVolume].push_back(Code[19]);
session->machine()->registerChannel(CPAP_TidalVolume);
Code[20]=new EventList(CPAP_Snore,EVL_Event);
session->eventlist[CPAP_Snore].push_back(Code[20]);
session->machine()->registerChannel(CPAP_Snore);
Code[22]=new EventList(CPAP_EPAP,EVL_Event,0.1);
session->eventlist[CPAP_EPAP].push_back(Code[22]);
session->machine()->registerChannel(CPAP_EPAP);
Code[23]=new EventList(CPAP_PressureSupport,EVL_Event,0.1);
session->eventlist[CPAP_PressureSupport].push_back(Code[23]);
session->machine()->registerChannel(CPAP_PressureSupport);
}
Code[12]->AddEvent(t,data[0]=buffer[pos++]); // IAP
@ -968,6 +980,7 @@ bool PRS1Loader::Parse002ASV(Session *session,unsigned char *buffer,int size,qin
if (!Code[21]) {
Code[21]=new EventList(CPAP_VSnore,EVL_Event);
session->eventlist[CPAP_VSnore].push_back(Code[21]);
session->machine()->registerChannel(CPAP_VSnore);
}
Code[21]->AddEvent(t,0); //data[2]); // VSnore
}
@ -1214,6 +1227,7 @@ bool PRS1Loader::OpenWaveforms(Session *session,QString filename)
double gain;
if (i==1) gain=0.1; else gain=1;
EventList *a=new EventList(wc[i],EVL_Waveform,gain,0,0,0,rate);
session->machine()->registerChannel(wc[i]);
if (whl[i].sample_format)
a->AddWaveform(qint64(start)*1000L,(unsigned char *)waveform[i],wlength[i],qint64(wdur[i])*1000L);
else {
@ -1268,6 +1282,7 @@ bool PRS1Loader::OpenWaveforms(Session *session,QString filename)
double gain;
if (i==1) gain=0.1; else gain=1;
EventList *a=new EventList(wc[i],EVL_Waveform,gain,0,0,0,rate);
session->machine()->registerChannel(wc[i]);
if (whl[i].sample_format)
a->AddWaveform(qint64(start)*1000L,(unsigned char *)waveform[i],wlength[i],qint64(wdur[i])*1000L);

View File

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

View File

@ -366,55 +366,6 @@ int ResmedLoader::Open(QString & path,Profile *profile)
m->AddSession(sess,profile); // Adding earlier than I really like here..
}
if (!done && sess) {
ChannelID e[]={
CPAP_Obstructive, CPAP_Hypopnea, CPAP_ClearAirway, CPAP_Apnea
};
/*for (unsigned i=0;i<sizeof(e)/sizeof(ChannelID);i++) {
// Merge this crap together where possible
sess->count(e[i]);
sess->max(e[i]);
sess->min(e[i]);
sess->avg(e[i]);
//sess->p90(e[i]);
sess->cph(e[i]);
sess->sph(e[i]);
}*/
sess->setCph(CPAP_AHI,sess->cph(CPAP_Obstructive)+sess->cph(CPAP_Hypopnea)+sess->cph(CPAP_ClearAirway)+sess->cph(CPAP_Apnea));
sess->setSph(CPAP_AHI,sess->sph(CPAP_Obstructive)+sess->sph(CPAP_Hypopnea)+sess->sph(CPAP_ClearAirway)+sess->sph(CPAP_Apnea));
/*ChannelID a[]={
CPAP_Leak, CPAP_Snore, CPAP_EPAP,
CPAP_IPAP, CPAP_TidalVolume, CPAP_RespiratoryRate,
CPAP_PatientTriggeredBreaths,CPAP_MinuteVentilation,
CPAP_FlowLimitGraph, CPAP_PressureSupport,CPAP_Pressure,CPAP_RespiratoryEvent,
CPAP_Te,CPAP_Ti,CPAP_IE
};
for (unsigned i=0;i<sizeof(a)/sizeof(ChannelID);i++) {
if (sess->eventlist.contains(a[i])) {
sess->count(a[i]);
sess->min(a[i]);
sess->max(a[i]);
sess->avg(a[i]);
sess->wavg(a[i]);
sess->p90(a[i]);
sess->cph(a[i]);
}
}
ChannelID b[]={
CPAP_FlowRate, CPAP_MaskPressure
};
for (unsigned i=0;i<sizeof(b)/sizeof(ChannelID);i++) {
if (sess->eventlist.contains(b[i])) {
sess->count(a[i]);
sess->min(b[i]);
sess->max(b[i]);
sess->avg(b[i]);
//sess->wavg(b[i]);
//sess->p90(b[i]);
sess->cph(b[i]);
}
} */
sess->settings[CPAP_Mode]=MODE_APAP;
}
@ -510,6 +461,8 @@ bool ResmedLoader::LoadEVE(Session *sess,EDFParser &edf)
if (!EL[0]) {
EL[0]=new EventList(code,EVL_Event);
sess->eventlist[code].push_back(EL[0]);
sess->machine()->registerChannel(code);
}
EL[0]->AddEvent(tt,duration);
} else if (t=="hypopnea") {
@ -517,6 +470,7 @@ bool ResmedLoader::LoadEVE(Session *sess,EDFParser &edf)
if (!EL[1]) {
EL[1]=new EventList(code,EVL_Event);
sess->eventlist[code].push_back(EL[1]);
sess->machine()->registerChannel(code);
}
EL[1]->AddEvent(tt,duration+10); // Only Hyponea's Need the extra duration???
} else if (t=="apnea") {
@ -524,6 +478,7 @@ bool ResmedLoader::LoadEVE(Session *sess,EDFParser &edf)
if (!EL[2]) {
EL[2]=new EventList(code,EVL_Event);
sess->eventlist[code].push_back(EL[2]);
sess->machine()->registerChannel(code);
}
EL[2]->AddEvent(tt,duration);
} else if (t=="central apnea") {
@ -531,6 +486,7 @@ bool ResmedLoader::LoadEVE(Session *sess,EDFParser &edf)
if (!EL[3]) {
EL[3]=new EventList(code,EVL_Event);
sess->eventlist[code].push_back(EL[3]);
sess->machine()->registerChannel(code);
}
EL[3]->AddEvent(tt,duration);
} else {
@ -569,10 +525,14 @@ bool ResmedLoader::LoadBRP(Session *sess,EDFParser &edf)
es.gain*=60;
es.physical_dimension="L/M";
code=CPAP_FlowRate;
sess->machine()->registerChannel(code);
} else if (edf.edfsignals[s]->label.startsWith("Mask Pres")) {
code=CPAP_MaskPressure;
sess->machine()->registerChannel(code);
} else if (es.label.startsWith("Resp Event")) {
code=CPAP_RespiratoryEvent;
sess->machine()->registerChannel(code);
} else {
qDebug() << "Unobserved ResMed BRP Signal " << edf.edfsignals[s]->label;
continue;
@ -604,7 +564,14 @@ EventList * ResmedLoader::ToTimeDelta(Session *sess,EDFParser &edf, EDFSignal &
//if (gain==0) gain=1;
EventList *el=new EventList(code,EVL_Event,es.gain,es.offset,min,max);
sess->eventlist[code].push_back(el);
for (int i=0;i<recs;i++) {
int startpos=0;
/*if ((code==CPAP_Pressure) || (code==CPAP_IPAP) || (code==CPAP_EPAP)
|| (code==CPAP_TherapyPressure)) {
startpos=0;
tt+=rate*startpos;
}*/
for (int i=startpos;i<recs;i++) {
c=es.data[i];
if (first) {
@ -637,8 +604,10 @@ bool ResmedLoader::LoadSAD(Session *sess,EDFParser &edf)
ChannelID code;
if (edf.edfsignals[s]->label=="Pulse") {
code=CPAP_Pulse;
sess->machine()->registerChannel(code);
} else if (edf.edfsignals[s]->label=="SpO2") {
code=CPAP_SPO2;
sess->machine()->registerChannel(code);
} else {
qDebug() << "Unobserved ResMed SAD Signal " << edf.edfsignals[s]->label;
continue;
@ -781,6 +750,7 @@ bool ResmedLoader::LoadPLD(Session *sess,EDFParser &edf)
a=NULL;
}
if (a) {
sess->machine()->registerChannel(code);
sess->setMin(code,a->min());
sess->setMax(code,a->max());
a->setDimension(es.physical_dimension);

View File

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

View File

@ -1,5 +0,0 @@
#include "sleep_database.h"
/*database::database()
{
}*/

View File

@ -1,33 +0,0 @@
#ifndef DATABASE_H
#define DATABASE_H
//********************************************************************************************
/// IMPORTANT!!!
//********************************************************************************************
// Please INCREMENT the following value when making changes to this loaders implementation.
//
const int sleeplib_data_version=1;
//
//********************************************************************************************
/*#include <QString>
#include "SleepLib/profiles.h"
const QString sleeplib_class_name="SleepDB";
class SleepDatabase : public MachineLoader
{
public:
SleepDatabase();
virtual ~SleepDatabase();
virtual bool Open(QString & path,Profile *profile);
virtual int Version() { return sleeplib_data_version; };
virtual const QString & ClassName() { return sleeplib_class_name; };
Machine *CreateMachine(QString serial,Profile *profile);
static void Register();
protected:
map<QString,Machine *> MachList;
};*/
#endif // DATABASE_H

View File

@ -492,22 +492,52 @@ bool Machine::Purge(int secret)
} else could_not_kill++;
}
dir.remove(path+"/channels.dat");
if (could_not_kill>0) {
qWarning() << "Could not purge path\n" << path << "\n\n" << could_not_kill << " file(s) remain.. Suggest manually deleting this path\n";
return false;
// qWarning() << "Could not purge path\n" << path << "\n\n" << could_not_kill << " file(s) remain.. Suggest manually deleting this path\n";
// return false;
}
return true;
}
const quint32 channel_version=1;
bool Machine::Load()
{
QString path=profile->Get("DataFolder")+"/"+hexid();
QDir dir(path);
qDebug() << "Loading " << path;
if (!dir.exists() || !dir.isReadable())
return false;
QString fn=path+"/channels.dat";
QFile cf(fn);
cf.open(QIODevice::ReadOnly);
QDataStream in(&cf);
in.setVersion(QDataStream::Qt_4_6);
in.setByteOrder(QDataStream::LittleEndian);
quint32 tmp;
in >> tmp;
if (magic!=tmp) {
qDebug() << "Machine Channel file format is wrong" << fn;
}
in >> tmp;
if (tmp!=channel_version) {
qDebug() << "Machine Channel file format is wrong" << fn;
}
qint32 tmp2;
in >> tmp2;
if (tmp2!=m_id) {
qDebug() << "Machine Channel file format is wrong" << fn;
}
in >> m_channels;
cf.close();
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
dir.setSorting(QDir::Name);
@ -561,12 +591,34 @@ bool Machine::SaveSession(Session *sess)
if (sess->IsChanged()) sess->Store(path);
return true;
}
bool Machine::Save()
{
int size=0;
int cnt=0;
QString path=profile->Get("DataFolder")+"/"+hexid();
QDir dir(path);
if (!dir.exists()) {
dir.mkdir(path);
}
QString fn=path+"/channels.dat";
QFile cf(fn);
if (cf.open(QIODevice::WriteOnly)) {
int i=4;
}
QDataStream out(&cf);
out.setVersion(QDataStream::Qt_4_6);
out.setByteOrder(QDataStream::LittleEndian);
out << (quint32)magic; // Magic Number
out << (quint32)channel_version;// File Version
out << (quint32)m_id;// Machine ID
out << m_channels;
cf.close();
// Calculate size for progress bar
size=sessionlist.size();
@ -666,7 +718,11 @@ CPAP::CPAP(Profile *p,MachineID id):Machine(p,id)
{
m_type=MT_CPAP;
// FlagColours=DefaultFlagColours;
registerChannel(CPAP_Obstructive);
registerChannel(CPAP_Hypopnea);
registerChannel(CPAP_ClearAirway);
registerChannel(CPAP_Snore);
registerChannel(CPAP_Leak);
}
CPAP::~CPAP()
@ -679,6 +735,9 @@ CPAP::~CPAP()
Oximeter::Oximeter(Profile *p,MachineID id):Machine(p,id)
{
m_type=MT_OXIMETER;
registerChannel(OXI_Pulse);
registerChannel(OXI_SPO2);
registerChannel(OXI_Plethysomogram);
}
Oximeter::~Oximeter()

View File

@ -91,6 +91,8 @@ public:
const MachineID & id() { return m_id; }
const QDate & FirstDay() { return firstday; }
const QDate & LastDay() { return lastday; }
bool hasChannel(ChannelID id) { return m_channels.contains(id) && m_channels[id]; }
void registerChannel(ChannelID id,bool b=true) { m_channels[id]=b; }
protected:
QDate firstday,lastday;
@ -102,6 +104,7 @@ protected:
Profile *profile;
bool changed;
bool firstsession;
QHash<ChannelID,bool> m_channels;
};
class CPAP:public Machine

View File

@ -104,7 +104,6 @@ bool Session::Store(QString path)
const quint16 filetype_summary=0;
const quint16 filetype_data=1;
const quint32 magic=0xC73216AB;
bool Session::StoreSummary(QString filename)
{
@ -441,8 +440,10 @@ EventDataType Session::min(ChannelID id)
return i.value();
QHash<ChannelID,QVector<EventList *> >::iterator j=eventlist.find(id);
if (j==eventlist.end())
if (j==eventlist.end()) {
m_min[id]=0;
return 0;
}
QVector<EventList *> & evec=j.value();
bool first=true;
@ -467,8 +468,10 @@ EventDataType Session::max(ChannelID id)
return i.value();
QHash<ChannelID,QVector<EventList *> >::iterator j=eventlist.find(id);
if (j==eventlist.end())
if (j==eventlist.end()) {
m_max[id]=0;
return 0;
}
QVector<EventList *> & evec=j.value();
bool first=true;
@ -558,8 +561,10 @@ int Session::count(ChannelID id)
return i.value();
QHash<ChannelID,QVector<EventList *> >::iterator j=eventlist.find(id);
if (j==eventlist.end())
if (j==eventlist.end()) {
m_cnt[id]=0;
return 0;
}
QVector<EventList *> & evec=j.value();
int sum=0;
@ -577,8 +582,10 @@ double Session::sum(ChannelID id)
return i.value();
QHash<ChannelID,QVector<EventList *> >::iterator j=eventlist.find(id);
if (j==eventlist.end())
if (j==eventlist.end()) {
m_sum[id]=0;
return 0;
}
QVector<EventList *> & evec=j.value();
double sum=0;
@ -598,8 +605,10 @@ EventDataType Session::avg(ChannelID id)
return i.value();
QHash<ChannelID,QVector<EventList *> >::iterator j=eventlist.find(id);
if (j==eventlist.end())
if (j==eventlist.end()) {
m_avg[id]=0;
return 0;
}
QVector<EventList *> & evec=j.value();
double val=0;
@ -647,8 +656,10 @@ EventDataType Session::p90(ChannelID id) // 90th Percentile
if (i!=m_90p.end())
return i.value();
if (!eventlist.contains(id))
if (!eventlist.contains(id)) {
m_90p[id]=0;
return 0;
}
EventDataType val=percentile(id,0.9);
m_90p[id]=val;

View File

@ -16,6 +16,7 @@
#include "SleepLib/event.h"
class EventList;
class Machine;
const quint32 magic=0xC73216AB;
enum SummaryType { ST_CNT, ST_SUM, ST_AVG, ST_WAVG, ST_90P, ST_MIN, ST_MAX, ST_CPH, ST_SPH, ST_FIRST, ST_LAST, ST_HOURS };
@ -129,7 +130,7 @@ public:
qint64 last(ChannelID code);
void UpdateSummaries();
Machine * machine() { return s_machine; }
protected:
SessionID s_session;

View File

@ -32,7 +32,6 @@ SOURCES += main.cpp\
SleepLib/loader_plugins/prs1_loader.cpp \
SleepLib/loader_plugins/zeo_loader.cpp \
SleepLib/loader_plugins/resmed_loader.cpp \
SleepLib/loader_plugins/sleep_database.cpp \
daily.cpp \
oximetry.cpp \
overview.cpp \
@ -98,7 +97,6 @@ HEADERS += \
Graphs/gSegmentChart.h\
Graphs/gSessionTime.h \
SleepLib/loader_plugins/resmed_loader.h \
SleepLib/loader_plugins/sleep_database.h \
qextserialport/qextserialport_global.h \
qextserialport/qextserialport.h \
qextserialport/qextserialenumerator.h \

View File

@ -130,8 +130,8 @@ Overview::Overview(QWidget *parent,Profile * _profile,gGraphView * shared) :
ui->dateStart->calendarWidget()->setWeekdayTextFormat(Qt::Sunday, format);
ui->dateEnd->calendarWidget()->setWeekdayTextFormat(Qt::Saturday, format);
ui->dateEnd->calendarWidget()->setWeekdayTextFormat(Qt::Sunday, format);
connect(ui->dateStart->calendarWidget(),SIGNAL(currentPageChanged(int,int)),this,SLOT(on_dateStart_currentPageChanged(int,int)));
connect(ui->dateEnd->calendarWidget(),SIGNAL(currentPageChanged(int,int)),this,SLOT(on_dateEnd_currentPageChanged(int,int)));
connect(ui->dateStart->calendarWidget(),SIGNAL(currentPageChanged(int,int)),SLOT(on_dateStart_currentPageChanged(int,int)));
connect(ui->dateEnd->calendarWidget(),SIGNAL(currentPageChanged(int,int)),SLOT(on_dateEnd_currentPageChanged(int,int)));
report=NULL;
}
Overview::~Overview()