Some other ResMed graphs

This commit is contained in:
Mark Watkins 2011-06-30 06:30:23 +10:00
parent 8aa94b3d94
commit ba2cd0b3ec
8 changed files with 76 additions and 19 deletions

View File

@ -215,12 +215,18 @@ void TAPData::Reload(Day *day)
for (vector<Event *>::iterator e=(*s)->events[code].begin(); e!=(*s)->events[code].end(); e++) {
Event & ev =(*(*e));
val=ev[field]*10.0;
if (field > ev.fields()) throw BoundsError();
assert(field<ev.fields());
//if (field > ev.fields()) throw BoundsError();
if (first) {
first=false; // only bother setting lastval (below) this time.
} else {
double d=last.msecsTo(ev.time())/1000.0;
if (lastval>max_slots) throw BoundsError();
//assert(lastval<max_slots);
if (lastval>max_slots) {
int i=0;
throw BoundsError();
}
pTime[lastval]+=d;
}
cnt++;
@ -278,7 +284,7 @@ void AHIData::Reload(Day *day)
}
FlagData::FlagData(MachineCode _code,double _value,int _field,int _offset)
:gPointData(1024),code(_code),value(_value),field(_field),offset(_offset)
:gPointData(65536),code(_code),value(_value),field(_field),offset(_offset)
{
AddSegment(max_points);
}

View File

@ -33,7 +33,7 @@ public:
virtual ~TAPData();
virtual void Reload(Day *day=NULL);
static const int max_slots=256;
static const int max_slots=4096;
double pTime[max_slots];
MachineCode code;
@ -52,7 +52,7 @@ protected:
class EventData:public gPointData
{
public:
EventData(MachineCode _code,int _field=0,int _size=4096,bool _skipzero=false);
EventData(MachineCode _code,int _field=0,int _size=250000,bool _skipzero=false);
virtual ~EventData();
virtual void Reload(Day *day=NULL);
protected:

View File

@ -312,7 +312,7 @@ int PRS1Loader::OpenMachine(Machine *m,QString path,Profile *profile)
sess->summary[CPAP_CSR]=sess->sum_event_field(CPAP_CSR,0);
sess->summary[CPAP_VSnore]=sess->count_events(CPAP_VSnore);
sess->summary[PRS1_VSnore2]=sess->sum_event_field(PRS1_VSnore2,0);
sess->summary[CPAP_Snore]=sess->sum_event_field(CPAP_Snore,0);
if (sess->count_events(CPAP_IAP)>0) {
@ -363,7 +363,7 @@ int PRS1Loader::OpenMachine(Machine *m,QString path,Profile *profile)
sess->summary[CPAP_SnoreMinimum]=sess->min_event_field(CPAP_SnoreGraph,0);
sess->summary[CPAP_SnoreMaximum]=sess->max_event_field(CPAP_SnoreGraph,0);
sess->summary[CPAP_SnoreMedian]=sess->avg_event_field(CPAP_SnoreGraph,0);
sess->summary[CPAP_SnoreAverage]=sess->weighted_avg_event_field(PRS1_VSnore2,0);
sess->summary[CPAP_SnoreAverage]=sess->weighted_avg_event_field(CPAP_Snore,0);
//Printf(sess->start().Format()+wxT(" avgsummary=%.3f avgmine=%.3f\n"),sess->summary[CPAP_PressureAverage].GetDouble(),sess->weighted_avg_event_field(CPAP_Pressure,0));
sess->SetChanged(true);
@ -563,7 +563,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,time_t
session->AddEvent(new Event(t,cpapcode, data,1));
session->AddEvent(new Event(t,CPAP_SnoreGraph,&data[1],1));
if (data[1]>0) {
session->AddEvent(new Event(t,PRS1_VSnore2, &data[1],1));
session->AddEvent(new Event(t,CPAP_Snore, &data[1],1));
}
} else if (code==0x03) {
data[0]/=10.0;

View File

@ -418,14 +418,62 @@ bool ResmedLoader::LoadBRP(Machine *mach,Session *sess,EDFParser &edf)
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)
{
bool first=true;
double rate=(duration/recs)*1000.0;
QDateTime tt=edf.startdate;
EventDataType c,last;
for (int i=0;i<recs;i++) {
c=data[i]/divisor;
if (first) {
sess->AddEvent(new Event(tt,code,&c,1));
first=false;
} else {
if (last!=c) {
sess->AddEvent(new Event(tt,code,&c,1));
}
}
tt=tt.addMSecs(rate);
last=c;
}
}
bool ResmedLoader::LoadSAD(Machine *mach,Session *sess,EDFParser &edf)
{
// Oximeter bull crap..
}
bool ResmedLoader::LoadPLD(Machine *mach,Session *sess,EDFParser &edf)
{
QString t;
for (int s=0;s<edf.GetNumSignals();s++) {
long recs=edf.edfsignals[s]->nr*edf.GetNumDataRecords();
double duration=edf.GetNumDataRecords()*edf.GetDuration();
if (!sess->first().isValid()) {
sess->set_first(edf.startdate);
sess->set_last(edf.startdate.addMSecs(duration*1000.0));
sess->set_hours(duration/3600.0);
}
MachineCode code;
if (edf.edfsignals[s]->label=="Snore Index") {
code=CPAP_Snore;
ToTimeDelta(mach,sess,edf,edf.edfsignals[s]->data, code,recs,duration);
} else if (edf.edfsignals[s]->label=="Mask Pres") {
code=CPAP_Pressure;
ToTimeDelta(mach,sess,edf,edf.edfsignals[s]->data, code,recs,duration,100.0);
} else if (edf.edfsignals[s]->label=="MV") {
code=CPAP_MinuteVentilation;
ToTimeDelta(mach,sess,edf,edf.edfsignals[s]->data, code,recs,duration,1.0);
} else if (edf.edfsignals[s]->label=="RR") {
//code=CPAP_Leak;
// ToTimeDelta(mach,sess,edf,edf.edfsignals[s]->data, code,recs,duration,1.0);
} else if (edf.edfsignals[s]->label=="Vt") {
code=CPAP_Leak;
ToTimeDelta(mach,sess,edf,edf.edfsignals[s]->data, code,recs,duration,1.0);
}
qDebug(("Unknown Signal "+edf.edfsignals[s]->label).toLatin1());
}
}

View File

@ -86,6 +86,8 @@ public:
virtual int Version() { return resmed_data_version; };
virtual const QString & ClassName() { return resmed_class_name; };
void ToTimeDelta(Machine *mach,Session *sess,EDFParser &edf, qint16 *data, MachineCode code, long recs,double duration,EventDataType divisor=1);
Machine *CreateMachine(QString serial,Profile *profile);
static void Register();

View File

@ -128,7 +128,7 @@ void InitMapsWithoutAwesomeInitializerLists()
DefaultMCShortNames[CPAP_Leak]=_("LR");
DefaultMCShortNames[CPAP_EAP]=_("EPAP");
DefaultMCShortNames[CPAP_IAP]=_("IPAP");
DefaultMCShortNames[PRS1_VSnore2]=_("VS2");
DefaultMCShortNames[CPAP_Snore]=_("VS2");
DefaultMCShortNames[PRS1_PressurePulse]=_("PP");
DefaultMCLongNames[CPAP_Obstructive]=_("Obstructive Apnea");
@ -142,7 +142,7 @@ void InitMapsWithoutAwesomeInitializerLists()
DefaultMCLongNames[CPAP_Leak]=_("Leak Rate");
DefaultMCLongNames[CPAP_EAP]=_("BIPAP EPAP");
DefaultMCLongNames[CPAP_IAP]=_("BIPAP IPAP");
DefaultMCLongNames[PRS1_VSnore2]=_("Vibratory Snore 2");
DefaultMCLongNames[CPAP_Snore]=_("Vibratory Snore 2");
DefaultMCLongNames[PRS1_PressurePulse]=_("Pressure Pulse");
DefaultMCLongNames[PRS1_Unknown0E]=_("Unknown 0E");
DefaultMCLongNames[PRS1_Unknown00]=_("Unknown 00");

View File

@ -35,6 +35,7 @@ enum MachineCode//:qint16
CPAP_Obstructive, CPAP_Hypopnea, CPAP_ClearAirway, CPAP_RERA, CPAP_VSnore, CPAP_FlowLimit,
CPAP_Leak, CPAP_Pressure, CPAP_EAP, CPAP_IAP, CPAP_CSR, CPAP_FlowRate, CPAP_MaskPressure,
CPAP_Snore,CPAP_MinuteVentilation,
CPAP_BreathsPerMinute,
// General CPAP Summary Information
@ -47,7 +48,7 @@ enum MachineCode//:qint16
BIPAP_EAPAverage,BIPAP_IAPAverage,BIPAP_EAPMin,BIPAP_EAPMax,BIPAP_IAPMin,BIPAP_IAPMax,CPAP_BrokenSummary,
// PRS1 Specific Codes
PRS1_PressurePulse=0x1000, PRS1_VSnore2,
PRS1_PressurePulse=0x1000,
PRS1_Unknown00, PRS1_Unknown01, PRS1_Unknown08, PRS1_Unknown09, PRS1_Unknown0B, PRS1_Unknown0E, PRS1_Unknown10, PRS1_Unknown12,
PRS1_SystemLockStatus, PRS1_SystemResistanceStatus, PRS1_SystemResistanceSetting, PRS1_HoseDiameter, PRS1_AutoOff, PRS1_MaskAlert, PRS1_ShowAHI,

View File

@ -63,8 +63,8 @@ Daily::Daily(QWidget *parent,QGLContext *context) :
AddCPAPData(flags[5]=new FlagData(CPAP_VSnore,2));
AddCPAPData(flags[6]=new FlagData(CPAP_RERA,1));
AddCPAPData(flags[7]=new FlagData(PRS1_PressurePulse,1));
AddCPAPData(flags[8]=new FlagData(PRS1_VSnore2,1));
AddCPAPData(flags[9]=new FlagData(PRS1_Unknown0E,1));
AddCPAPData(flags[8]=new FlagData(PRS1_Unknown0E,1));
AddCPAPData(flags[9]=new FlagData(CPAP_Snore,1)); // Snore Index
AddGraph(SF=new gGraphWindow(gSplitter,tr("Event Flags"),(QGLWidget *)NULL));
@ -72,12 +72,12 @@ Daily::Daily(QWidget *parent,QGLContext *context) :
SF->SetBlockZoom(true);
SF->AddLayer(new gXAxis());
bool extras=true;
bool extras=false; //true;
int sfc=7;
if (extras) {
sfc+=2;
SF->AddLayer(new gFlagsLine(flags[9],QColor("dark green"),"U0E",8,sfc));
SF->AddLayer(new gFlagsLine(flags[8],QColor("red"),"VS2",7,sfc));
sfc+=1;
SF->AddLayer(new gFlagsLine(flags[8],QColor("dark green"),"U0E",7,sfc));
//SF->AddLayer(new gFlagsLine(flags[8],QColor("red"),"VS2",7,sfc));
}
SF->AddLayer(new gFlagsLine(flags[6],QColor("gold"),"RE",6,sfc));
SF->AddLayer(new gFlagsLine(flags[5],QColor("red"),"VS",5,sfc));
@ -128,7 +128,7 @@ Daily::Daily(QWidget *parent,QGLContext *context) :
FRW->AddLayer(new gLineOverlayBar(flags[3],QColor("blue"),"H"));
FRW->AddLayer(new gLineOverlayBar(flags[7],QColor("red"),"PR",LOT_Dot));
FRW->AddLayer(new gLineOverlayBar(flags[6],QColor("gold"),"RE"));
FRW->AddLayer(new gLineOverlayBar(flags[9],QColor("dark green"),"U0E"));
//FRW->AddLayer(new gLineOverlayBar(flags[9],QColor("dark green"),"U0E"));
FRW->AddLayer(new gLineOverlayBar(flags[5],QColor("red"),"VS"));
FRW->AddLayer(new gLineOverlayBar(flags[4],QColor("black"),"FL"));
FRW->AddLayer(new gLineOverlayBar(flags[2],QColor("aqua"),"OA"));
@ -136,7 +136,7 @@ Daily::Daily(QWidget *parent,QGLContext *context) :
FRW->setMinimumHeight(190);
AddCPAPData(snore=new EventData(CPAP_SnoreGraph,0));
AddCPAPData(snore=new EventData(CPAP_Snore,0));
//snore->ForceMinY(0);
//snore->ForceMaxY(15);
AddGraph(SNORE=new gGraphWindow(gSplitter,tr("Snore"),SF));