OSCAR-code/SleepLib/loader_plugins/resmed_loader.h

126 lines
3.1 KiB
C
Raw Normal View History

2011-06-28 02:21:38 +00:00
/*
SleepLib RESMED Loader Header
Author: Mark Watkins <jedimark64@users.sourceforge.net>
License: GPL
*/
#ifndef RESMED_LOADER_H
#define RESMED_LOADER_H
//#include <map>
//using namespace std;
#include <QVector>
2011-06-28 02:21:38 +00:00
#include "SleepLib/machine.h" // Base class: MachineLoader
#include "SleepLib/machine_loader.h"
#include "SleepLib/profiles.h"
//********************************************************************************************
/// IMPORTANT!!!
//********************************************************************************************
// Please INCREMENT the following value when making changes to this loaders implementation.
//
const int resmed_data_version=5;
2011-06-28 02:21:38 +00:00
//
//********************************************************************************************
const QString resmed_class_name="ResMed";
struct EDFHeader {
char version[8];
char patientident[80];
char recordingident[80];
char datetime[16];
char num_header_bytes[8];
char reserved[44];
char num_data_records[8];
char dur_data_records[8];
char num_signals[4];
2011-12-17 14:50:59 +00:00
};// __attribute__ ((packed));
const int EDFHeaderSize=sizeof(EDFHeader);
2011-06-29 14:19:38 +00:00
struct EDFSignal {
public:
QString label;
QString transducer_type;
QString physical_dimension;
2011-07-27 09:21:53 +00:00
double physical_minimum;
double physical_maximum;
double digital_minimum;
double digital_maximum;
double gain;
double offset;
2011-06-29 14:19:38 +00:00
QString prefiltering;
long nr;
QString reserved;
qint16 * data;
2011-06-29 16:19:57 +00:00
int pos;
2011-06-29 14:19:38 +00:00
};
class EDFParser
{
public:
EDFParser(QString filename);
~EDFParser();
bool Open(QString name);
QString Read(int si);
2011-06-29 16:19:57 +00:00
qint16 Read16();
2011-06-29 14:19:38 +00:00
QVector<EDFSignal *> edfsignals;
2011-09-17 12:39:00 +00:00
QHash<QString,EDFSignal *> lookup;
EDFSignal * lookupSignal(ChannelID);
2011-06-29 14:19:38 +00:00
2011-07-27 09:21:53 +00:00
long GetNumSignals() { return num_signals; }
long GetNumDataRecords() { return num_data_records; }
qint64 GetDuration() { return dur_data_record; }
QString GetPatient() { return patientident; }
2011-09-17 12:39:00 +00:00
2011-06-29 14:19:38 +00:00
bool Parse();
char *buffer;
EDFHeader header;
2011-06-29 14:19:38 +00:00
QString filename;
long filesize;
long datasize;
long pos;
2011-06-29 14:19:38 +00:00
long version;
long num_header_bytes;
long num_data_records;
qint64 dur_data_record;
2011-06-29 14:19:38 +00:00
long num_signals;
QString patientident;
QString recordingident;
QString serialnumber;
qint64 startdate;
2011-07-03 02:43:50 +00:00
qint64 enddate;
2011-06-29 14:19:38 +00:00
QString reserved44;
};
2011-06-28 02:21:38 +00:00
class ResmedLoader : public MachineLoader
{
public:
ResmedLoader();
virtual ~ResmedLoader();
2011-07-15 13:30:41 +00:00
virtual int Open(QString & path,Profile *profile);
2011-06-28 02:21:38 +00:00
2011-07-27 09:21:53 +00:00
virtual int Version() { return resmed_data_version; }
virtual const QString & ClassName() { return resmed_class_name; }
EventList * ToTimeDelta(Session *sess,EDFParser &edf, EDFSignal & es, ChannelID code, long recs,qint64 duration,EventDataType min=0,EventDataType max=0,bool square=false);
2011-06-29 20:30:23 +00:00
2011-06-28 02:21:38 +00:00
Machine *CreateMachine(QString serial,Profile *profile);
static void Register();
protected:
QHash<QString,Machine *> ResmedList;
2011-07-01 10:10:44 +00:00
bool LoadEVE(Session *sess,EDFParser &edf);
bool LoadBRP(Session *sess,EDFParser &edf);
bool LoadSAD(Session *sess,EDFParser &edf);
bool LoadPLD(Session *sess,EDFParser &edf);
2011-06-29 14:19:38 +00:00
2011-06-28 02:21:38 +00:00
};
#endif // RESMED_LOADER_H