mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 10:40:42 +00:00
Clean up oximeter import date/time handling
This commit is contained in:
parent
240f6db3d5
commit
258b549967
@ -591,7 +591,9 @@ bool CMS50Loader::readSpoRFile(QString path)
|
|||||||
if (dchr[0]) {
|
if (dchr[0]) {
|
||||||
QString dstr(dchr);
|
QString dstr(dchr);
|
||||||
m_startTime = QDateTime::fromString(dstr, "MM/dd/yy HH:mm:ss");
|
m_startTime = QDateTime::fromString(dstr, "MM/dd/yy HH:mm:ss");
|
||||||
if (m_startTime.date().year() < 2000) { m_startTime = m_startTime.addYears(100); }
|
if (m_startTime.date().year() < 2000) {
|
||||||
|
m_startTime = m_startTime.addYears(100);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
m_startTime = QDateTime(QDate::currentDate(), QTime(0,0,0));
|
m_startTime = QDateTime(QDate::currentDate(), QTime(0,0,0));
|
||||||
cms50dplus = true;
|
cms50dplus = true;
|
||||||
@ -614,7 +616,7 @@ bool CMS50Loader::readSpoRFile(QString path)
|
|||||||
in >> hour >> minute >> second;
|
in >> hour >> minute >> second;
|
||||||
|
|
||||||
if ( year == 0 ) { // typically from a CMS50D+
|
if ( year == 0 ) { // typically from a CMS50D+
|
||||||
m_startTime = QDateTime(QDate::currentDate(), QTime(0, 0, 0));
|
m_startTime = QDateTime(QDate::currentDate(), QTime(hour, minute, second));
|
||||||
cms50dplus = true;
|
cms50dplus = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// that change loader behaviour or modify channels.
|
// that change loader behaviour or modify channels.
|
||||||
//********************************************************************************************
|
//********************************************************************************************
|
||||||
|
|
||||||
#include <QProgressBar>
|
// #include <QProgressBar>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@ -167,20 +167,20 @@ unsigned char cms50_sequence[] = { 0xa7, 0xa2, 0xa0, 0xb0, 0xac, 0xb3, 0xad, 0xa
|
|||||||
const int TIMEOUT = 2000;
|
const int TIMEOUT = 2000;
|
||||||
|
|
||||||
|
|
||||||
// const quint8 COMMAND_GET_VERSION = 0xa0; // not entirely sure of this one
|
const quint8 COMMAND_GET_VERSION = 0xA0; // not sure of this one
|
||||||
const quint8 COMMAND_CMS50_HELLO2 = 0xa2; // stop live data stream
|
const quint8 COMMAND_CMS50_HELLO2 = 0xA2; // stop live data stream
|
||||||
const quint8 COMMAND_GET_SESSION_COUNT = 0xA3;
|
const quint8 COMMAND_GET_SESSION_COUNT = 0xA3;
|
||||||
const quint8 COMMAND_GET_SESSION_DURATION = 0xA4;
|
const quint8 COMMAND_GET_SESSION_DURATION = 0xA4;
|
||||||
const quint8 COMMAND_GET_SESSION_TIME = 0xA5;
|
const quint8 COMMAND_GET_SESSION_TIME = 0xA5;
|
||||||
const quint8 COMMAND_GET_SESSION_DATA = 0xA6;
|
const quint8 COMMAND_GET_SESSION_DATA = 0xA6;
|
||||||
const quint8 COMMAND_CMS50_HELLO1 = 0xa7; // stop stored data stream
|
const quint8 COMMAND_CMS50_HELLO1 = 0xA7; // stop stored data stream
|
||||||
const quint8 COMMAND_GET_OXIMETER_MODEL = 0xA8;
|
const quint8 COMMAND_GET_OXIMETER_MODEL = 0xA8;
|
||||||
const quint8 COMMAND_GET_OXIMETER_VENDOR = 0xA9;
|
const quint8 COMMAND_GET_OXIMETER_VENDOR = 0xA9;
|
||||||
const quint8 COMMAND_GET_OXIMETER_DEVICEID = 0xAA;
|
const quint8 COMMAND_GET_OXIMETER_DEVICEID = 0xAA;
|
||||||
const quint8 COMMAND_GET_USER_INFO = 0xAB;
|
const quint8 COMMAND_GET_USER_INFO = 0xAB;
|
||||||
const quint8 COMMAND_GET_USER_COUNT = 0xAD; // for future check and use
|
const quint8 COMMAND_GET_USER_COUNT = 0xAD; // for future check and use
|
||||||
const quint8 COMMAND_SESSION_ERASE = 0xAE;
|
const quint8 COMMAND_SESSION_ERASE = 0xAE;
|
||||||
const quint8 COMMAND_GET_OXIMETER_INFO = 0xb0;
|
const quint8 COMMAND_GET_OXIMETER_INFO = 0xB0;
|
||||||
|
|
||||||
|
|
||||||
int cms50_seqlength = sizeof(cms50_sequence);
|
int cms50_seqlength = sizeof(cms50_sequence);
|
||||||
@ -188,7 +188,7 @@ int cms50_seqlength = sizeof(cms50_sequence);
|
|||||||
|
|
||||||
QString CMS50F37Loader::getUser()
|
QString CMS50F37Loader::getUser()
|
||||||
{
|
{
|
||||||
if (!user.isEmpty()) return user;
|
if (!userName.isEmpty()) return userName;
|
||||||
|
|
||||||
sendCommand(COMMAND_GET_USER_INFO);
|
sendCommand(COMMAND_GET_USER_INFO);
|
||||||
|
|
||||||
@ -196,10 +196,10 @@ QString CMS50F37Loader::getUser()
|
|||||||
time.start();
|
time.start();
|
||||||
do {
|
do {
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
} while (user.isEmpty() && (time.elapsed() < TIMEOUT));
|
} while (userName.isEmpty() && (time.elapsed() < TIMEOUT));
|
||||||
|
|
||||||
qDebug() << "User 0 is " << user;
|
qDebug() << "User " << userIdx << " is " << userName;
|
||||||
return user;
|
return userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CMS50F37Loader::getVendor()
|
QString CMS50F37Loader::getVendor()
|
||||||
@ -343,11 +343,11 @@ QDateTime CMS50F37Loader::getDateTime(int session)
|
|||||||
} while ((imp_date.isNull() || imp_time.isNull()) && (time.elapsed() < TIMEOUT));
|
} while ((imp_date.isNull() || imp_time.isNull()) && (time.elapsed() < TIMEOUT));
|
||||||
|
|
||||||
if (imp_date.isNull() && imp_time.isNull())
|
if (imp_date.isNull() && imp_time.isNull())
|
||||||
datetime = QDateTime(QDate::currentDate(), QTime(0,0,0));
|
datetime = QDateTime(QDate::currentDate(), QTime::currentTime());
|
||||||
else if ( imp_date.isNull() )
|
else if ( imp_date.isNull() )
|
||||||
datetime = QDateTime(QDate::currentDate(), imp_time);
|
datetime = QDateTime(QDate::currentDate(), imp_time);
|
||||||
else if ( imp_time.isNull() )
|
else if ( imp_time.isNull() )
|
||||||
datetime = QDateTime(imp_date, QTime(0,0,0));
|
datetime = QDateTime(imp_date, QTime::currentTime());
|
||||||
else
|
else
|
||||||
datetime = QDateTime(imp_date, imp_time);
|
datetime = QDateTime(imp_date, imp_time);
|
||||||
|
|
||||||
@ -434,8 +434,8 @@ void CMS50F37Loader::processBytes(QByteArray bytes)
|
|||||||
// COMMAND_GET_USER_INFO
|
// COMMAND_GET_USER_INFO
|
||||||
case 0x05: // 5,80,80,f5,f3,e5,f2,80,80
|
case 0x05: // 5,80,80,f5,f3,e5,f2,80,80
|
||||||
userIdx = buffer.at(idx+2); // for future use
|
userIdx = buffer.at(idx+2); // for future use
|
||||||
user = QString(buffer.mid(idx+3).trimmed());
|
userName = QString(buffer.mid(idx+3).trimmed());
|
||||||
qDebug() << "pB: 0x05:" << user;
|
qDebug() << "pB: 0x05:" << userName;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Command GET_VERSION
|
// Command GET_VERSION
|
||||||
|
@ -46,7 +46,7 @@ Q_OBJECT
|
|||||||
|
|
||||||
virtual void process();
|
virtual void process();
|
||||||
|
|
||||||
virtual bool isStartTimeValid() { return true; }
|
virtual bool isStartTimeValid() { return !cms50dplus; }
|
||||||
|
|
||||||
virtual QString getUser();
|
virtual QString getUser();
|
||||||
virtual QString getModel();
|
virtual QString getModel();
|
||||||
@ -132,7 +132,7 @@ protected:
|
|||||||
QDate imp_date;
|
QDate imp_date;
|
||||||
QTime imp_time;
|
QTime imp_time;
|
||||||
|
|
||||||
QString user;
|
QString userName;
|
||||||
|
|
||||||
unsigned char current_command;
|
unsigned char current_command;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// loader that change loader behaviour or modify channels.
|
// loader that change loader behaviour or modify channels.
|
||||||
//********************************************************************************************
|
//********************************************************************************************
|
||||||
|
|
||||||
#include <QProgressBar>
|
// #include <QProgressBar>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@ -193,7 +193,9 @@ bool MD300W1Loader::readDATFile(const QString & path)
|
|||||||
int gap;
|
int gap;
|
||||||
for (int pos = 0; pos < n; ++pos) {
|
for (int pos = 0; pos < n; ++pos) {
|
||||||
int i = 3 + (pos * 11);
|
int i = 3 + (pos * 11);
|
||||||
QString datestr = QString().sprintf("%02d/%02d/%02d %02d:%02d:%02d",(unsigned char)data.at(i+4),(unsigned char)data.at(i+5),(unsigned char)data.at(i+3),(unsigned char)data.at(i+6),(unsigned char)data.at(i+7),(unsigned char)data.at(i+8));
|
QString datestr = QString().sprintf("%02d/%02d/%02d %02d:%02d:%02d",
|
||||||
|
(unsigned char)data.at(i+4),(unsigned char)data.at(i+5),(unsigned char)data.at(i+3),
|
||||||
|
(unsigned char)data.at(i+6),(unsigned char)data.at(i+7),(unsigned char)data.at(i+8));
|
||||||
QDateTime datetime = QDateTime::fromString(datestr,"MM/dd/yy HH:mm:ss");
|
QDateTime datetime = QDateTime::fromString(datestr,"MM/dd/yy HH:mm:ss");
|
||||||
if (datetime.date().year() < 2000) datetime = datetime.addYears(100);
|
if (datetime.date().year() < 2000) datetime = datetime.addYears(100);
|
||||||
ts = datetime.toTime_t();
|
ts = datetime.toTime_t();
|
||||||
@ -208,7 +210,7 @@ bool MD300W1Loader::readDATFile(const QString & path)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Create a new session, always for first record
|
// Create a new session, always for first record
|
||||||
qDebug() << "Create session for " << datetime.toString("yyyy.MM.dd HH:mm:ss");
|
qDebug() << "Create session for " << datetime.toString("yyyy-MMM-dd HH:mm:ss");
|
||||||
oxirec = new QVector<OxiRecord>;
|
oxirec = new QVector<OxiRecord>;
|
||||||
oxisessions[datetime] = oxirec;
|
oxisessions[datetime] = oxirec;
|
||||||
m_startTime = datetime; // works for single session files...
|
m_startTime = datetime; // works for single session files...
|
||||||
|
Loading…
Reference in New Issue
Block a user