2014-04-09 21:01:57 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
|
|
|
*
|
|
|
|
* SleepLib (DeVilbiss) Intellipap Loader Implementation
|
|
|
|
* Notes: Intellipap requires the SmartLink attachment to access this data.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2011-2014 Mark Watkins <jedimark@users.sourceforge.net>
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file COPYING in the main directory of the Linux
|
|
|
|
* distribution for more details. */
|
2011-11-20 02:59:00 +00:00
|
|
|
|
2011-11-21 02:15:10 +00:00
|
|
|
#include <QDir>
|
2011-11-21 10:20:11 +00:00
|
|
|
#include <QProgressBar>
|
2011-11-21 02:15:10 +00:00
|
|
|
|
2011-11-20 02:59:00 +00:00
|
|
|
#include "intellipap_loader.h"
|
|
|
|
|
2011-11-21 10:20:11 +00:00
|
|
|
extern QProgressBar *qprogress;
|
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
Intellipap::Intellipap(Profile *p, MachineID id)
|
|
|
|
: CPAP(p, id)
|
2011-11-20 02:59:00 +00:00
|
|
|
{
|
2014-04-17 05:58:57 +00:00
|
|
|
m_class = intellipap_class_name;
|
2011-11-20 02:59:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Intellipap::~Intellipap()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
IntellipapLoader::IntellipapLoader()
|
|
|
|
{
|
2014-04-23 13:19:56 +00:00
|
|
|
m_buffer = nullptr;
|
2014-05-25 07:07:08 +00:00
|
|
|
m_type = MT_CPAP;
|
2011-11-20 02:59:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
IntellipapLoader::~IntellipapLoader()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-04-28 19:24:39 +00:00
|
|
|
bool IntellipapLoader::Detect(const QString & givenpath)
|
2014-04-26 09:54:08 +00:00
|
|
|
{
|
2014-04-28 19:24:39 +00:00
|
|
|
QDir dir(givenpath);
|
|
|
|
|
|
|
|
if (!dir.exists()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Intellipap has a folder called SL in the root directory
|
|
|
|
if (!dir.cd("SL")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check for the settings file inside the SL folder
|
|
|
|
if (!dir.exists("SET1")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2014-04-26 09:54:08 +00:00
|
|
|
}
|
|
|
|
|
2014-05-25 07:07:08 +00:00
|
|
|
int IntellipapLoader::Open(QString path, Profile *profile)
|
2011-11-20 02:59:00 +00:00
|
|
|
{
|
2011-11-21 02:15:10 +00:00
|
|
|
// Check for SL directory
|
2011-11-21 10:20:11 +00:00
|
|
|
// Check for DV5MFirm.bin?
|
2011-11-21 02:15:10 +00:00
|
|
|
QString newpath;
|
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
path = path.replace("\\", "/");
|
2013-09-14 23:32:14 +00:00
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
QString dirtag = "SL";
|
|
|
|
|
|
|
|
if (path.endsWith("/" + dirtag)) {
|
2011-11-21 02:15:10 +00:00
|
|
|
return 0;
|
|
|
|
//newpath=path;
|
|
|
|
} else {
|
2014-04-17 05:58:57 +00:00
|
|
|
newpath = path + "/" + dirtag;
|
2011-11-21 02:15:10 +00:00
|
|
|
}
|
|
|
|
|
2011-11-21 10:20:11 +00:00
|
|
|
QString filename;
|
|
|
|
|
|
|
|
//////////////////////////
|
|
|
|
// Parse the Settings File
|
|
|
|
//////////////////////////
|
2014-04-17 05:58:57 +00:00
|
|
|
filename = newpath + "/SET1";
|
2011-11-21 02:15:10 +00:00
|
|
|
QFile f(filename);
|
2014-04-17 05:58:57 +00:00
|
|
|
|
|
|
|
if (!f.exists()) { return 0; }
|
|
|
|
|
2011-11-21 10:20:11 +00:00
|
|
|
f.open(QFile::ReadOnly);
|
|
|
|
QTextStream tstream(&f);
|
|
|
|
|
2014-05-06 17:39:05 +00:00
|
|
|
QHash<QString, QString> lookup;
|
|
|
|
lookup["Sn"]=STR_PROP_Serial;
|
|
|
|
lookup["Mn"]=STR_PROP_ModelNumber;
|
|
|
|
lookup["Mo"]="PAPMode"; // 0 cpap, 1 auto
|
|
|
|
//lookup["Pn"]="??";
|
|
|
|
lookup["Pu"]="MaxPressure";
|
|
|
|
lookup["Pl"]="MaxPressure";
|
|
|
|
//lookup["Ds"]="??";
|
|
|
|
//lookup["Pc"]="??";
|
|
|
|
lookup["Pd"]="RampPressure"; // Pressure Delay
|
|
|
|
lookup["Dt"]="RampTime";
|
|
|
|
//lookup["Ld"]="??";
|
|
|
|
//lookup["Lh"]="??";
|
|
|
|
//lookup["FC"]="??";
|
|
|
|
//lookup["FE"]="??";
|
|
|
|
//lookup["FL"]="??";
|
|
|
|
lookup["A%"]="ApneaThreshold";
|
|
|
|
lookup["Ad"]="ApneaDuration";
|
|
|
|
lookup["H%"]="HypopneaThreshold";
|
|
|
|
lookup["Hd"]="HypopneaDuration";
|
|
|
|
//lookup["Pi"]="??";
|
|
|
|
//lookup["Pe"]="??";
|
|
|
|
lookup["Ri"]="SmartFlexIRnd"; // Inhale Rounding (0-5)
|
|
|
|
lookup["Re"]="SmartFlexERnd"; // Inhale Rounding (0-5)
|
|
|
|
//lookup["Bu"]="??"; // WF
|
|
|
|
//lookup["Ie"]="??"; // 20
|
|
|
|
//lookup["Se"]="??"; // 05
|
|
|
|
//lookup["Si"]="??"; // 05
|
|
|
|
//lookup["Mi"]="??"; // 0
|
|
|
|
lookup["Uh"]="HoursMeter"; // 0000.0
|
|
|
|
lookup["Up"]="ComplianceMeter"; // 0000.00
|
|
|
|
//lookup["Er"]="ErrorCode";, // E00
|
|
|
|
//lookup["El"]="LastErrorCode"; // E00 00/00/0000
|
|
|
|
//lookup["Hp"]="??";, // 1
|
|
|
|
//lookup["Hs"]="??";, // 02
|
|
|
|
//lookup["Lu"]="LowUseThreshold"; // defaults to 0 (4 hours)
|
|
|
|
lookup["Sf"]="SmartFlex";
|
|
|
|
lookup["Sm"]="SmartFlexMode";
|
|
|
|
lookup["Ks=s"]="Ks_s";
|
|
|
|
lookup["Ks=i"]="ks_i";
|
2014-04-17 05:58:57 +00:00
|
|
|
|
|
|
|
QHash<QString, QString> set1;
|
|
|
|
QHash<QString, QString>::iterator hi;
|
2011-11-21 10:20:11 +00:00
|
|
|
|
|
|
|
while (1) {
|
2014-04-17 05:58:57 +00:00
|
|
|
QString line = tstream.readLine();
|
|
|
|
|
|
|
|
if ((line.length() <= 2) ||
|
|
|
|
(line.isNull())) { break; }
|
|
|
|
|
|
|
|
QString key = line.section("\t", 0, 0).trimmed();
|
|
|
|
hi = lookup.find(key);
|
|
|
|
|
|
|
|
if (hi != lookup.end()) {
|
|
|
|
key = hi.value();
|
2011-11-21 10:20:11 +00:00
|
|
|
}
|
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
QString value = line.section("\t", 1).trimmed();
|
|
|
|
set1[key] = value;
|
2011-11-21 10:20:11 +00:00
|
|
|
qDebug() << key << "=" << value;
|
|
|
|
}
|
2011-11-21 02:15:10 +00:00
|
|
|
|
2014-04-23 13:19:56 +00:00
|
|
|
Machine *mach = nullptr;
|
2014-04-17 05:58:57 +00:00
|
|
|
|
2011-12-21 14:24:09 +00:00
|
|
|
if (set1.contains(STR_PROP_Serial)) {
|
2014-04-17 05:58:57 +00:00
|
|
|
mach = CreateMachine(set1[STR_PROP_Serial], profile);
|
2011-11-21 10:20:11 +00:00
|
|
|
}
|
2014-04-17 05:58:57 +00:00
|
|
|
|
2011-11-21 10:20:11 +00:00
|
|
|
if (!mach) {
|
|
|
|
qDebug() << "Couldn't get Intellipap machine record";
|
|
|
|
return 0;
|
|
|
|
}
|
2011-11-21 02:15:10 +00:00
|
|
|
|
2011-11-21 10:20:11 +00:00
|
|
|
// Refresh properties data..
|
2014-04-17 05:58:57 +00:00
|
|
|
for (QHash<QString, QString>::iterator i = set1.begin(); i != set1.end(); i++) {
|
|
|
|
mach->properties[i.key()] = i.value();
|
2011-11-21 10:20:11 +00:00
|
|
|
}
|
2014-04-17 05:58:57 +00:00
|
|
|
|
|
|
|
mach->properties[STR_PROP_Model] = STR_MACH_Intellipap + " " +
|
|
|
|
mach->properties[STR_PROP_ModelNumber];
|
2011-11-21 10:20:11 +00:00
|
|
|
|
|
|
|
f.close();
|
|
|
|
|
|
|
|
//////////////////////////
|
|
|
|
// Parse the Session Index
|
|
|
|
//////////////////////////
|
|
|
|
unsigned char buf[27];
|
2014-04-17 05:58:57 +00:00
|
|
|
filename = newpath + "/U";
|
2011-11-21 10:20:11 +00:00
|
|
|
f.setFileName(filename);
|
2014-04-17 05:58:57 +00:00
|
|
|
|
|
|
|
if (!f.exists()) { return 0; }
|
2011-11-21 10:20:11 +00:00
|
|
|
|
|
|
|
QVector<quint32> SessionStart;
|
|
|
|
QVector<quint32> SessionEnd;
|
2014-04-17 05:58:57 +00:00
|
|
|
QHash<SessionID, Session *> Sessions;
|
2011-11-21 10:20:11 +00:00
|
|
|
|
|
|
|
quint32 ts1, ts2;//, length;
|
|
|
|
//unsigned char cs;
|
2011-11-21 02:15:10 +00:00
|
|
|
f.open(QFile::ReadOnly);
|
2014-04-17 05:58:57 +00:00
|
|
|
int cnt = 0;
|
|
|
|
QDateTime epoch(QDate(2002, 1, 1), QTime(0, 0, 0), Qt::UTC); // Intellipap Epoch
|
|
|
|
int ep = epoch.toTime_t();
|
|
|
|
|
2011-11-21 02:15:10 +00:00
|
|
|
do {
|
2014-04-17 05:58:57 +00:00
|
|
|
cnt = f.read((char *)buf, 9);
|
|
|
|
ts1 = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
|
|
|
|
ts2 = (buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7];
|
|
|
|
ts1 += ep;
|
|
|
|
ts2 += ep;
|
2011-11-21 10:20:11 +00:00
|
|
|
SessionStart.append(ts1);
|
|
|
|
SessionEnd.append(ts2);
|
|
|
|
//cs=buf[8];
|
2014-04-17 05:58:57 +00:00
|
|
|
} while (cnt > 0);
|
|
|
|
|
2011-11-21 10:20:11 +00:00
|
|
|
qDebug() << "U file logs" << SessionStart.size() << "sessions.";
|
2011-11-21 02:15:10 +00:00
|
|
|
f.close();
|
|
|
|
|
2011-11-21 10:20:11 +00:00
|
|
|
//////////////////////////
|
|
|
|
// Parse the Session Data
|
|
|
|
//////////////////////////
|
2014-04-17 05:58:57 +00:00
|
|
|
filename = newpath + "/L";
|
2011-11-21 02:15:10 +00:00
|
|
|
f.setFileName(filename);
|
2014-04-17 05:58:57 +00:00
|
|
|
|
|
|
|
if (!f.exists()) { return 0; }
|
2011-11-21 02:15:10 +00:00
|
|
|
|
|
|
|
f.open(QFile::ReadOnly);
|
2014-04-17 05:58:57 +00:00
|
|
|
long size = f.size();
|
|
|
|
int recs = size / 26;
|
|
|
|
m_buffer = new unsigned char [size];
|
2011-11-21 02:15:10 +00:00
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
if (size != f.read((char *)m_buffer, size)) {
|
|
|
|
qDebug() << "Couldn't read 'L' data" << filename;
|
2011-11-21 10:20:11 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Session *sess;
|
|
|
|
SessionID sid;
|
2014-04-17 05:58:57 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < SessionStart.size(); i++) {
|
|
|
|
sid = SessionStart[i];
|
|
|
|
|
2011-11-21 10:20:11 +00:00
|
|
|
if (mach->SessionExists(sid)) {
|
|
|
|
// knock out the already imported sessions..
|
2014-04-17 05:58:57 +00:00
|
|
|
SessionStart[i] = 0;
|
|
|
|
SessionEnd[i] = 0;
|
2011-11-21 10:20:11 +00:00
|
|
|
} else if (!Sessions.contains(sid)) {
|
2014-04-17 05:58:57 +00:00
|
|
|
sess = Sessions[sid] = new Session(mach, sid);
|
2011-11-21 10:20:11 +00:00
|
|
|
sess->SetChanged(true);
|
2014-04-17 05:58:57 +00:00
|
|
|
sess->AddEventList(CPAP_IPAP, EVL_Event);
|
|
|
|
sess->AddEventList(CPAP_EPAP, EVL_Event);
|
|
|
|
sess->AddEventList(CPAP_Pressure, EVL_Event);
|
|
|
|
|
|
|
|
sess->AddEventList(INTELLIPAP_Unknown1, EVL_Event);
|
|
|
|
sess->AddEventList(INTELLIPAP_Unknown2, EVL_Event);
|
|
|
|
|
|
|
|
sess->AddEventList(CPAP_LeakTotal, EVL_Event);
|
|
|
|
sess->AddEventList(CPAP_MaxLeak, EVL_Event);
|
|
|
|
sess->AddEventList(CPAP_TidalVolume, EVL_Event);
|
|
|
|
sess->AddEventList(CPAP_MinuteVent, EVL_Event);
|
|
|
|
sess->AddEventList(CPAP_RespRate, EVL_Event);
|
|
|
|
sess->AddEventList(CPAP_Snore, EVL_Event);
|
2011-11-21 10:20:11 +00:00
|
|
|
} else {
|
|
|
|
// If there is a double up, null out the earlier session
|
|
|
|
// otherwise there will be a crash on shutdown.
|
2014-04-17 05:58:57 +00:00
|
|
|
for (int z = 0; z < SessionStart.size(); z++) {
|
|
|
|
if (SessionStart[z] == (quint32)sid) {
|
|
|
|
SessionStart[z] = 0;
|
|
|
|
SessionEnd[z] = 0;
|
2011-11-21 10:20:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-04-17 05:58:57 +00:00
|
|
|
|
|
|
|
QDateTime d = QDateTime::fromTime_t(sid);
|
2011-11-21 10:20:11 +00:00
|
|
|
qDebug() << sid << "has double ups" << d;
|
|
|
|
/*Session *sess=Sessions[sid];
|
|
|
|
Sessions.erase(Sessions.find(sid));
|
|
|
|
delete sess;
|
|
|
|
SessionStart[i]=0;
|
|
|
|
SessionEnd[i]=0; */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
long pos = 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < recs; i++) {
|
2011-11-21 10:20:11 +00:00
|
|
|
// convert timestamp to real epoch
|
2014-04-17 05:58:57 +00:00
|
|
|
ts1 = ((m_buffer[pos] << 24) | (m_buffer[pos + 1] << 16) | (m_buffer[pos + 2] << 8) | m_buffer[pos
|
|
|
|
+ 3]) + ep;
|
|
|
|
|
|
|
|
for (int j = 0; j < SessionStart.size(); j++) {
|
|
|
|
sid = SessionStart[j];
|
|
|
|
|
|
|
|
if (!sid) { continue; }
|
2011-11-21 10:20:11 +00:00
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
if ((ts1 >= (quint32)sid) && (ts1 <= SessionEnd[j])) {
|
|
|
|
Session *sess = Sessions[sid];
|
|
|
|
qint64 time = quint64(ts1) * 1000L;
|
|
|
|
sess->eventlist[CPAP_Pressure][0]->AddEvent(time, m_buffer[pos + 0xd] / 10.0); // current pressure
|
|
|
|
sess->eventlist[CPAP_EPAP][0]->AddEvent(time, m_buffer[pos + 0x13] / 10.0); // epap / low
|
|
|
|
sess->eventlist[CPAP_IPAP][0]->AddEvent(time, m_buffer[pos + 0x14] / 10.0); // ipap / high
|
2011-11-21 10:20:11 +00:00
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
sess->eventlist[CPAP_LeakTotal][0]->AddEvent(time, m_buffer[pos + 0x7]); // "Average Leak"
|
|
|
|
sess->eventlist[CPAP_MaxLeak][0]->AddEvent(time, m_buffer[pos + 0x6]); // "Max Leak"
|
2011-11-21 10:20:11 +00:00
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
int rr = m_buffer[pos + 0xa];
|
|
|
|
sess->eventlist[CPAP_RespRate][0]->AddEvent(time, rr); // Respiratory Rate
|
|
|
|
sess->eventlist[INTELLIPAP_Unknown1][0]->AddEvent(time, m_buffer[pos + 0xf]); //
|
|
|
|
sess->eventlist[INTELLIPAP_Unknown1][0]->AddEvent(time, m_buffer[pos + 0xc]);
|
2011-11-21 10:20:11 +00:00
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
sess->eventlist[CPAP_Snore][0]->AddEvent(time, m_buffer[pos + 0x4]); //4/5??
|
2011-11-21 02:15:10 +00:00
|
|
|
|
2011-11-24 12:47:25 +00:00
|
|
|
// 0x0f == Leak Event
|
|
|
|
// 0x04 == Snore?
|
2014-04-17 05:58:57 +00:00
|
|
|
if (m_buffer[pos + 0xf] > 0) { // Leak Event
|
2011-11-24 12:47:25 +00:00
|
|
|
if (!sess->eventlist.contains(CPAP_LeakFlag)) {
|
2014-04-17 05:58:57 +00:00
|
|
|
sess->AddEventList(CPAP_LeakFlag, EVL_Event);
|
2011-11-21 10:20:11 +00:00
|
|
|
}
|
2014-04-17 05:58:57 +00:00
|
|
|
|
|
|
|
sess->eventlist[CPAP_LeakFlag][0]->AddEvent(time, m_buffer[pos + 0xf]);
|
2011-11-24 12:47:25 +00:00
|
|
|
}
|
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
if (m_buffer[pos + 0x5] > 4) { // This matches Exhale Puff.. not sure why 4
|
2011-11-24 12:47:25 +00:00
|
|
|
if (!sess->eventlist.contains(CPAP_ExP)) {
|
2014-04-17 05:58:57 +00:00
|
|
|
sess->AddEventList(CPAP_ExP, EVL_Event);
|
2011-11-24 12:47:25 +00:00
|
|
|
}
|
2011-11-30 12:32:16 +00:00
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
for (int q = 0; q < m_buffer[pos + 0x5]; q++) {
|
|
|
|
sess->eventlist[CPAP_ExP][0]->AddEvent(time, m_buffer[pos + 0x5]);
|
|
|
|
}
|
2011-11-21 10:20:11 +00:00
|
|
|
}
|
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
if (m_buffer[pos + 0x10] > 0) {
|
2011-11-21 10:20:11 +00:00
|
|
|
if (!sess->eventlist.contains(CPAP_Obstructive)) {
|
2014-04-17 05:58:57 +00:00
|
|
|
sess->AddEventList(CPAP_Obstructive, EVL_Event);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int q = 0; q < m_buffer[pos + 0x10]; q++) {
|
|
|
|
sess->eventlist[CPAP_Obstructive][0]->AddEvent(time, m_buffer[pos + 0x10]);
|
2011-11-21 10:20:11 +00:00
|
|
|
}
|
|
|
|
}
|
2011-11-30 12:32:16 +00:00
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
if (m_buffer[pos + 0x11] > 0) {
|
2011-11-21 10:20:11 +00:00
|
|
|
if (!sess->eventlist.contains(CPAP_Hypopnea)) {
|
2014-04-17 05:58:57 +00:00
|
|
|
sess->AddEventList(CPAP_Hypopnea, EVL_Event);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int q = 0; q < m_buffer[pos + 0x11]; q++) {
|
|
|
|
sess->eventlist[CPAP_Hypopnea][0]->AddEvent(time, m_buffer[pos + 0x11]);
|
2011-11-21 10:20:11 +00:00
|
|
|
}
|
|
|
|
}
|
2014-04-17 05:58:57 +00:00
|
|
|
|
|
|
|
if (m_buffer[pos + 0x12] > 0) { // NRI // is this == to RERA?? CA??
|
2011-11-24 12:47:25 +00:00
|
|
|
if (!sess->eventlist.contains(CPAP_NRI)) {
|
2014-04-17 05:58:57 +00:00
|
|
|
sess->AddEventList(CPAP_NRI, EVL_Event);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int q = 0; q < m_buffer[pos + 0x12]; q++) {
|
|
|
|
sess->eventlist[CPAP_NRI][0]->AddEvent(time, m_buffer[pos + 0x12]);
|
2011-11-21 10:20:11 +00:00
|
|
|
}
|
|
|
|
}
|
2011-11-30 12:32:16 +00:00
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
quint16 tv = (m_buffer[pos + 0x8] << 8) | m_buffer[pos + 0x9]; // correct
|
2011-11-30 12:32:16 +00:00
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
sess->eventlist[CPAP_TidalVolume][0]->AddEvent(time, tv);
|
|
|
|
|
|
|
|
EventDataType mv = tv * rr; // MinuteVent=TidalVolume * Respiratory Rate
|
|
|
|
sess->eventlist[CPAP_MinuteVent][0]->AddEvent(time, mv / 1000.0);
|
2011-11-21 10:20:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2014-04-17 05:58:57 +00:00
|
|
|
|
|
|
|
pos += 26;
|
2011-11-21 10:20:11 +00:00
|
|
|
}
|
2014-04-17 05:58:57 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < SessionStart.size(); i++) {
|
|
|
|
SessionID sid = SessionStart[i];
|
|
|
|
|
2011-11-21 10:20:11 +00:00
|
|
|
if (sid) {
|
2014-04-17 05:58:57 +00:00
|
|
|
sess = Sessions[sid];
|
2011-11-21 10:20:11 +00:00
|
|
|
//if (sess->eventlist.size()==0) {
|
2014-04-17 05:58:57 +00:00
|
|
|
// delete sess;
|
|
|
|
// continue;
|
2011-11-21 10:20:11 +00:00
|
|
|
//}
|
2014-04-17 05:58:57 +00:00
|
|
|
quint64 first = qint64(sid) * 1000L;
|
|
|
|
quint64 last = qint64(SessionEnd[i]) * 1000L;
|
|
|
|
|
|
|
|
sess->settings[CPAP_PresReliefType] = (PRTypes)PR_SMARTFLEX;
|
|
|
|
int i = set1["SmartFlex"].toInt();
|
|
|
|
sess->settings[CPAP_PresReliefSet] = i;
|
|
|
|
int sfm = set1["SmartFlexMode"].toInt();
|
|
|
|
|
|
|
|
if (sfm == 0) {
|
|
|
|
sess->settings[CPAP_PresReliefMode] = PM_FullTime;
|
2011-12-30 23:02:45 +00:00
|
|
|
} else {
|
2014-04-17 05:58:57 +00:00
|
|
|
sess->settings[CPAP_PresReliefMode] = PM_RampOnly;
|
2011-12-30 23:02:45 +00:00
|
|
|
}
|
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
EventDataType max = sess->Max(CPAP_IPAP);
|
|
|
|
EventDataType min = sess->Min(CPAP_EPAP);
|
|
|
|
EventDataType pres = sess->Min(CPAP_Pressure);
|
|
|
|
|
|
|
|
if (max == min) {
|
|
|
|
sess->settings[CPAP_Mode] = (int)MODE_CPAP;
|
|
|
|
sess->settings[CPAP_Pressure] = min;
|
2011-12-27 13:21:10 +00:00
|
|
|
} else {
|
2014-04-17 05:58:57 +00:00
|
|
|
sess->settings[CPAP_Mode] = (int)MODE_APAP;
|
|
|
|
sess->settings[CPAP_PressureMin] = min;
|
|
|
|
sess->settings[CPAP_PressureMax] = max;
|
2011-12-27 13:21:10 +00:00
|
|
|
}
|
2014-04-17 05:58:57 +00:00
|
|
|
|
2011-12-27 13:21:10 +00:00
|
|
|
sess->eventlist.erase(sess->eventlist.find(CPAP_IPAP));
|
|
|
|
sess->eventlist.erase(sess->eventlist.find(CPAP_EPAP));
|
|
|
|
sess->m_min.erase(sess->m_min.find(CPAP_EPAP));
|
|
|
|
sess->m_max.erase(sess->m_max.find(CPAP_EPAP));
|
2014-04-17 05:58:57 +00:00
|
|
|
|
|
|
|
if (pres < min) {
|
|
|
|
sess->settings[CPAP_RampPressure] = pres;
|
2011-12-27 13:21:10 +00:00
|
|
|
}
|
|
|
|
|
2011-12-14 04:54:17 +00:00
|
|
|
//quint64 len=last-first;
|
2011-11-21 10:20:11 +00:00
|
|
|
//if (len>0) {
|
2014-04-17 05:58:57 +00:00
|
|
|
//if (!sess->first()) {
|
|
|
|
sess->set_first(first);
|
|
|
|
sess->set_last(last);
|
|
|
|
// }
|
|
|
|
sess->UpdateSummaries();
|
|
|
|
mach->AddSession(sess, profile);
|
2011-11-21 10:20:11 +00:00
|
|
|
/*} else {
|
|
|
|
delete sess;
|
|
|
|
}*/
|
|
|
|
}
|
|
|
|
}
|
2014-04-17 05:58:57 +00:00
|
|
|
|
|
|
|
mach->properties[STR_PROP_DataVersion] = QString().sprintf("%i", intellipap_data_version);
|
2011-11-21 10:20:11 +00:00
|
|
|
|
|
|
|
mach->Save();
|
|
|
|
|
|
|
|
delete [] m_buffer;
|
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
if (qprogress) { qprogress->setValue(100); }
|
2011-11-21 10:20:11 +00:00
|
|
|
|
|
|
|
f.close();
|
2011-11-20 23:39:55 +00:00
|
|
|
|
2011-11-21 02:15:10 +00:00
|
|
|
return 1;
|
2011-11-20 02:59:00 +00:00
|
|
|
}
|
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
Machine *IntellipapLoader::CreateMachine(QString serial, Profile *profile)
|
2011-11-20 02:59:00 +00:00
|
|
|
{
|
2014-04-17 05:58:57 +00:00
|
|
|
if (!profile) {
|
2014-04-23 13:19:56 +00:00
|
|
|
return nullptr;
|
2014-04-17 05:58:57 +00:00
|
|
|
}
|
|
|
|
|
2011-11-20 02:59:00 +00:00
|
|
|
qDebug() << "Create Machine " << serial;
|
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
QList<Machine *> ml = profile->GetMachines(MT_CPAP);
|
|
|
|
bool found = false;
|
2011-12-08 04:10:35 +00:00
|
|
|
QList<Machine *>::iterator i;
|
2014-04-23 13:19:56 +00:00
|
|
|
Machine *m = nullptr;
|
2014-04-17 05:58:57 +00:00
|
|
|
|
|
|
|
for (i = ml.begin(); i != ml.end(); i++) {
|
|
|
|
if (((*i)->GetClass() == intellipap_class_name) && ((*i)->properties[STR_PROP_Serial] == serial)) {
|
|
|
|
MachList[serial] = *i; //static_cast<CPAP *>(*i);
|
|
|
|
found = true;
|
|
|
|
m = *i;
|
2011-11-20 02:59:00 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-04-17 05:58:57 +00:00
|
|
|
|
2013-10-13 16:35:53 +00:00
|
|
|
if (!found) {
|
2014-04-17 05:58:57 +00:00
|
|
|
m = new Intellipap(profile, 0);
|
2013-10-13 16:35:53 +00:00
|
|
|
}
|
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
m->properties[STR_PROP_Brand] = "DeVilbiss";
|
|
|
|
m->properties[STR_PROP_Series] = STR_MACH_Intellipap;
|
|
|
|
|
|
|
|
if (found) {
|
2013-10-13 16:35:53 +00:00
|
|
|
return m;
|
2014-04-17 05:58:57 +00:00
|
|
|
}
|
2011-11-20 02:59:00 +00:00
|
|
|
|
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
MachList[serial] = m;
|
2011-11-20 02:59:00 +00:00
|
|
|
profile->AddMachine(m);
|
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
m->properties[STR_PROP_Serial] = serial;
|
|
|
|
m->properties[STR_PROP_DataVersion] = QString::number(intellipap_data_version);
|
2012-01-05 04:37:22 +00:00
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
QString path = "{" + STR_GEN_DataFolder + "}/" + m->GetClass() + "_" + serial + "/";
|
|
|
|
m->properties[STR_PROP_Path] = path;
|
|
|
|
m->properties[STR_PROP_BackupPath] = path + "Backup/";
|
2011-12-22 10:29:12 +00:00
|
|
|
|
2011-11-20 02:59:00 +00:00
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-17 05:58:57 +00:00
|
|
|
bool intellipap_initialized = false;
|
2011-11-20 02:59:00 +00:00
|
|
|
void IntellipapLoader::Register()
|
|
|
|
{
|
2014-04-17 05:58:57 +00:00
|
|
|
if (intellipap_initialized) { return; }
|
|
|
|
|
2011-11-20 02:59:00 +00:00
|
|
|
qDebug() << "Registering IntellipapLoader";
|
|
|
|
RegisterLoader(new IntellipapLoader());
|
|
|
|
//InitModelMap();
|
2014-04-17 05:58:57 +00:00
|
|
|
intellipap_initialized = true;
|
2011-11-20 02:59:00 +00:00
|
|
|
}
|