F&P Move backup to end of import functions

This commit is contained in:
Mark Watkins 2014-05-19 03:53:09 +10:00
parent 23e23f8210
commit 10db88005b
7 changed files with 64 additions and 57 deletions

View File

@ -40,11 +40,11 @@ void gSegmentChart::SetDay(Day *d)
m_values[c] = 0; m_values[c] = 0;
for (QList<Session *>::iterator s = m_day->begin(); s != m_day->end(); ++s) { for (QList<Session *>::iterator s = m_day->begin(); s != m_day->end(); ++s) {
if (!(*s)->enabled()) { continue; } if ((*s)->enabled() && (*s)->channelExists(m_codes[c])) {
int cnt = (*s)->count(m_codes[c]);
int cnt = (*s)->count(m_codes[c]); m_values[c] += cnt;
m_values[c] += cnt; m_total += cnt;
m_total += cnt; }
} }
} }

View File

@ -767,7 +767,7 @@ int Day::count(ChannelID code)
for (QList<Session *>::iterator it = sessions.begin(); it != end; ++it) { for (QList<Session *>::iterator it = sessions.begin(); it != end; ++it) {
Session & sess = *(*it); Session & sess = *(*it);
if (sess.enabled() && sess.channelDataExists(code)) { if (sess.enabled() && sess.channelExists(code)) {
sum += sess.count(code); sum += sess.count(code);
} }
} }

View File

@ -471,16 +471,6 @@ bool FPIconLoader::OpenFLW(Machine *mach, QString filename, Profile *profile)
ts = convertFLWDate(ts); ts = convertFLWDate(ts);
if (profile->session->backupCardData()) {
QString backup = PROFILE.Get(mach->properties[STR_PROP_BackupPath])+"FPHCARE/ICON/"+serial.right(serial.size()-4)+"/";
QDir dir;
QString newname = QString("FLW%1.FPH").arg(ts);
dir.mkpath(backup);
if (!dir.exists(newname)) {
file.copy(backup+newname);
}
}
ti = qint64(ts) * 1000L; ti = qint64(ts) * 1000L;
QMap<SessionID, Session *>::iterator sit = Sessions.find(ts); QMap<SessionID, Session *>::iterator sit = Sessions.find(ts);
@ -595,6 +585,17 @@ bool FPIconLoader::OpenFLW(Machine *mach, QString filename, Profile *profile)
mach->AddSession(sess, profile); mach->AddSession(sess, profile);
} }
if (profile->session->backupCardData()) {
QString backup = PROFILE.Get(mach->properties[STR_PROP_BackupPath])+"FPHCARE/ICON/"+serial.right(serial.size()-4)+"/";
QDir dir;
QString newname = QString("FLW%1.FPH").arg(ts);
dir.mkpath(backup);
if (!dir.exists(newname)) {
file.copy(backup+newname);
}
}
return true; return true;
} }
@ -640,17 +641,6 @@ bool FPIconLoader::OpenSummary(Machine *mach, QString filename, Profile *profile
htxt >> type; htxt >> type;
mach->properties[STR_PROP_Model] = model + " " + type; mach->properties[STR_PROP_Model] = model + " " + type;
if (profile->session->backupCardData()) {
QString backup = PROFILE.Get(mach->properties[STR_PROP_BackupPath])+"FPHCARE/ICON/"+serial.right(serial.size()-4)+"/";
QDir dir;
QString newname = QString("SUM%1.FPH").arg(QDate::currentDate().year(),4,10,QChar('0'));
dir.mkpath(backup);
dir.cd(backup);
if (!dir.exists(newname)) {
file.copy(backup+newname);
}
}
QByteArray data; QByteArray data;
data = file.readAll(); data = file.readAll();
//long size=data.size(),pos=0; //long size=data.size(),pos=0;
@ -738,6 +728,17 @@ bool FPIconLoader::OpenSummary(Machine *mach, QString filename, Profile *profile
} }
} while (!in.atEnd()); } while (!in.atEnd());
if (profile->session->backupCardData()) {
QString backup = PROFILE.Get(mach->properties[STR_PROP_BackupPath])+"FPHCARE/ICON/"+serial.right(serial.size()-4)+"/";
QDir dir;
QString newname = QString("SUM%1.FPH").arg(QDate::currentDate().year(),4,10,QChar('0'));
dir.mkpath(backup);
dir.cd(backup);
if (!dir.exists(newname)) {
file.copy(backup+newname);
}
}
return true; return true;
} }
@ -785,21 +786,6 @@ bool FPIconLoader::OpenDetail(Machine *mach, QString filename, Profile *profile)
QDataStream in(index); QDataStream in(index);
quint32 ts; quint32 ts;
if (profile->session->backupCardData()) {
unsigned char *data = (unsigned char *)index.data();
ts = data[0] | data[1] << 8 | data[2] << 16 | data[3] << 24;
ts = convertDate(ts);
QString backup = PROFILE.Get(mach->properties[STR_PROP_BackupPath])+"FPHCARE/ICON/"+serial.right(serial.size()-4)+"/";
QDir dir;
QString newname = QString("DET%1.FPH").arg(ts);
dir.mkpath(backup);
dir.cd(backup);
if (!dir.exists(newname)) {
file.copy(backup+newname);
}
}
in.setVersion(QDataStream::Qt_4_6); in.setVersion(QDataStream::Qt_4_6);
in.setByteOrder(QDataStream::LittleEndian); in.setByteOrder(QDataStream::LittleEndian);
@ -877,10 +863,10 @@ bool FPIconLoader::OpenDetail(Machine *mach, QString filename, Profile *profile)
a3 = data[idx + 4]; // [0..5] Flow Limitation, [6..7] SensAwake bitflags, 1 per minute a3 = data[idx + 4]; // [0..5] Flow Limitation, [6..7] SensAwake bitflags, 1 per minute
// Sure there isn't 6 SenseAwake bits? // Sure there isn't 6 SenseAwake bits?
a4 = (a1 >> 6) << 4 | ((a2 >> 6) << 2) | (a3 >> 6); // a4 = (a1 >> 6) << 4 | ((a2 >> 6) << 2) | (a3 >> 6);
// this does the same thing as behaviour // this does the same thing as behaviour
//a4 = (a3 >> 7) << 3 | ((a3 >> 6)&1); a4 = (a3 >> 7) << 3 | ((a3 >> 6) & 1);
bitmask = 1; bitmask = 1;
for (int k = 0; k < 6; k++) { // There are 6 flag sets per 2 minutes for (int k = 0; k < 6; k++) { // There are 6 flag sets per 2 minutes
@ -901,6 +887,20 @@ bool FPIconLoader::OpenDetail(Machine *mach, QString filename, Profile *profile)
// sess->SetChanged(true); // sess->SetChanged(true);
// mach->AddSession(sess,profile); // mach->AddSession(sess,profile);
} }
if (profile->session->backupCardData()) {
unsigned char *data = (unsigned char *)index.data();
ts = data[0] | data[1] << 8 | data[2] << 16 | data[3] << 24;
ts = convertDate(ts);
QString backup = PROFILE.Get(mach->properties[STR_PROP_BackupPath])+"FPHCARE/ICON/"+serial.right(serial.size()-4)+"/";
QDir dir;
QString newname = QString("DET%1.FPH").arg(ts);
dir.mkpath(backup);
dir.cd(backup);
if (!dir.exists(newname)) {
file.copy(backup+newname);
}
}
return 1; return 1;
} }

View File

@ -261,9 +261,20 @@ void ResmedLoader::ParseSTR(Machine *mach, QStringList strfiles)
R.epr_set = EventDataType(sig->data[rec]) * sig->gain + sig->offset; R.epr_set = EventDataType(sig->data[rec]) * sig->gain + sig->offset;
} }
if ((sig = str.lookupSignal(CPAP_Mode))) { if ((sig = str.lookupSignal(CPAP_Mode))) {
int mode = EventDataType(sig->data[rec]) * sig->gain + sig->offset; int mod = EventDataType(sig->data[rec]) * sig->gain + sig->offset;
// convert this CPAPMode mode;
if (mod >= 7) {
mode = MODE_ASV;
} else if (mod >= 5) {
mode = MODE_BIPAP;
} else if (mod >= 1) {
mode = MODE_APAP;
} else {
mode = MODE_CPAP;
}
R.mode = mode; R.mode = mode;
} }
if ((sig = str.lookupLabel("AHI"))) { if ((sig = str.lookupLabel("AHI"))) {
R.ahi = EventDataType(sig->data[rec]) * sig->gain + sig->offset; R.ahi = EventDataType(sig->data[rec]) * sig->gain + sig->offset;

View File

@ -1287,7 +1287,7 @@ QDate Profile::FirstGoodDay(MachineType mt)
} }
QDate Profile::LastGoodDay(MachineType mt) QDate Profile::LastGoodDay(MachineType mt)
{ {
if (mt == MT_UNKNOWN) { //|| (!m_last.isValid()) || (!m_first.isValid())) if (mt == MT_UNKNOWN) {
return FirstDay(); return FirstDay();
} }
@ -1306,7 +1306,7 @@ QDate Profile::LastGoodDay(MachineType mt)
d = d.addDays(-1); d = d.addDays(-1);
} while (d >= f); } while (d >= f);
return f; //m_first; return f;
} }
bool Profile::hasChannel(ChannelID code) bool Profile::hasChannel(ChannelID code)
{ {

View File

@ -1044,10 +1044,10 @@ EventDataType Session::Max(ChannelID id)
int evec_size=evec.size(); int evec_size=evec.size();
for (int i = 0; i < evec_size; ++i) { for (int i = 0; i < evec_size; ++i) {
if (evec[i]->count() != 0) { if (evec.at(i)->count() != 0) {
t1 = evec[i]->Max(); t1 = evec.at(i)->Max();
if (t1 == 0 && t1 == evec[i]->Min()) { continue; } if (t1 == 0 && t1 == evec.at(i)->Min()) { continue; }
if (first) { if (first) {
max = t1; max = t1;
@ -1522,7 +1522,7 @@ int Session::count(ChannelID id)
QHash<ChannelID, QVector<EventList *> >::iterator j = eventlist.find(id); QHash<ChannelID, QVector<EventList *> >::iterator j = eventlist.find(id);
if (j == eventlist.end()) { if (j == eventlist.end()) {
m_cnt[id] = 0; // m_cnt[id] = 0;
return 0; return 0;
} }

View File

@ -228,7 +228,6 @@ struct RXChange {
days = copy.days; days = copy.days;
ahi = copy.ahi; ahi = copy.ahi;
fl = copy.fl; fl = copy.fl;
sa = copy.sa;
mode = copy.mode; mode = copy.mode;
min = copy.min; min = copy.min;
max = copy.max; max = copy.max;
@ -248,7 +247,6 @@ struct RXChange {
int days; int days;
EventDataType ahi; EventDataType ahi;
EventDataType fl; EventDataType fl;
EventDataType sa;
CPAPMode mode; CPAPMode mode;
EventDataType min; EventDataType min;
EventDataType max; EventDataType max;
@ -760,7 +758,6 @@ QString Statistics::GenerateHTML()
rx.days = days; rx.days = days;
rx.ahi = calcAHI(first, last); rx.ahi = calcAHI(first, last);
rx.fl = calcFL(first, last); rx.fl = calcFL(first, last);
rx.sa = calcSA(first, last);
rx.mode = cmode; rx.mode = cmode;
rx.min = cmin; rx.min = cmin;
rx.max = cmax; rx.max = cmax;
@ -819,7 +816,6 @@ QString Statistics::GenerateHTML()
rx.days = days; rx.days = days;
rx.ahi = calcAHI(first, last); rx.ahi = calcAHI(first, last);
rx.fl = calcFL(first, last); rx.fl = calcFL(first, last);
rx.sa = calcSA(first, last);
rx.mode = mode; rx.mode = mode;
rx.min = min; rx.min = min;
rx.max = max; rx.max = max;
@ -1166,7 +1162,7 @@ QString Statistics::GenerateHTML()
html += QString("<td>%1</td>").arg(rx.fl, 0, 'f', decimals); // Not the best way to do this.. Todo: Add an extra field for data.. html += QString("<td>%1</td>").arg(rx.fl, 0, 'f', decimals); // Not the best way to do this.. Todo: Add an extra field for data..
if (PROFILE.hasChannel(CPAP_SensAwake)) { if (PROFILE.hasChannel(CPAP_SensAwake)) {
html += QString("<td>%1</td>").arg(rx.sa, 0, 'f', decimals); html += QString("<td>%1</td>").arg(calcSA(rx.first, rx.last), 0, 'f', decimals);
} }
html += QString("<td>%1</td>").arg(rx.machine->GetClass()); html += QString("<td>%1</td>").arg(rx.machine->GetClass());
html += QString("<td>%1</td>").arg(presrel); html += QString("<td>%1</td>").arg(presrel);