mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-06 19:20:45 +00:00
Remove tabs in Viatom loader and normalize whitespace to OSCAR convensions.
Also change from using sprintf/QDateTime::fromString to using Qt native objects. No change in output.
This commit is contained in:
parent
9cb7de950b
commit
ae8ce0e9d6
@ -1,6 +1,7 @@
|
||||
/* SleepLib Viatom Loader Implementation
|
||||
*
|
||||
* Copyright (c) 2019 The OSCAR Team (written by dave madden <dhm@mersenne.com>)
|
||||
* Copyright (c) 2019-2020 The OSCAR Team
|
||||
* (Initial importer written by dave madden <dhm@mersenne.com>)
|
||||
*
|
||||
* 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 source code
|
||||
@ -27,7 +28,7 @@ ViatomLoader::Detect(const QString & path)
|
||||
}
|
||||
|
||||
int
|
||||
ViatomLoader::Open( const QString & dirpath )
|
||||
ViatomLoader::Open(const QString & dirpath)
|
||||
{
|
||||
// I don't know under what circumstances this is called...
|
||||
qDebug() << "ViatomLoader::Open(" << dirpath << ")";
|
||||
@ -35,7 +36,7 @@ ViatomLoader::Open( const QString & dirpath )
|
||||
}
|
||||
|
||||
int
|
||||
ViatomLoader::OpenFile( const QString & filename )
|
||||
ViatomLoader::OpenFile(const QString & filename)
|
||||
{
|
||||
qDebug() << "ViatomLoader::OpenFile(" << filename << ")";
|
||||
|
||||
@ -51,7 +52,7 @@ Session* ViatomLoader::ParseFile(const QString & filename)
|
||||
{
|
||||
QFile file(filename);
|
||||
|
||||
if (!file.open( QFile::ReadOnly )) {
|
||||
if (!file.open(QFile::ReadOnly)) {
|
||||
qDebug() << "Couldn't open Viatom data file" << filename;
|
||||
return nullptr;
|
||||
}
|
||||
@ -77,38 +78,35 @@ Session* ViatomLoader::ParseFile(const QString & filename)
|
||||
( H > 23) ||
|
||||
( M > 60) ||
|
||||
( S > 61)) {
|
||||
qDebug( ) << filename << "does not appear to be a Viatom data file";
|
||||
qDebug() << filename << "does not appear to be a Viatom data file";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char dchr[32];
|
||||
sprintf( dchr, "%02u/%02u/%04u %02u:%02u:%02u", m, d, Y, H, M, S );
|
||||
|
||||
QDateTime data_timestamp = QDateTime::fromString( QString( dchr ), "MM/dd/yyyy HH:mm:ss" );
|
||||
quint64 time_s = data_timestamp.toTime_t( );
|
||||
QDateTime data_timestamp = QDateTime(QDate(Y, m, d), QTime(H, M, S));
|
||||
quint64 time_s = data_timestamp.toTime_t();
|
||||
quint64 time_ms = time_s * 1000L;
|
||||
SessionID sid = time_s;
|
||||
|
||||
qDebug( ) << filename << "looks like a Viatom file, size" << filesize << "bytes signature" << sig
|
||||
qDebug() << filename << "looks like a Viatom file, size" << filesize << "bytes signature" << sig
|
||||
<< "start date/time" << data_timestamp << "(" << time_ms << ")";
|
||||
|
||||
in.skipRawData( 41 ); // total 50 byte header, not sure what the rest is.
|
||||
in.skipRawData(41); // total 50 byte header, not sure what the rest is.
|
||||
|
||||
MachineInfo info = newInfo( );
|
||||
Machine *mach = p_profile->CreateMachine( info );
|
||||
Session *sess = mach->SessionExists( sid );
|
||||
MachineInfo info = newInfo();
|
||||
Machine *mach = p_profile->CreateMachine(info);
|
||||
Session *sess = mach->SessionExists(sid);
|
||||
|
||||
if (!sess) {
|
||||
qDebug( ) << "Session at" << data_timestamp << "not found...create new session" << sid;
|
||||
sess = new Session( mach, sid );
|
||||
sess->really_set_first( time_ms );
|
||||
qDebug() << "Session at" << data_timestamp << "not found...create new session" << sid;
|
||||
sess = new Session(mach, sid);
|
||||
sess->really_set_first(time_ms);
|
||||
} else {
|
||||
qDebug( ) << "Session" << sid << "found...add data to it";
|
||||
qDebug() << "Session" << sid << "found...add data to it";
|
||||
}
|
||||
|
||||
EventList *ev_hr = sess->AddEventList( OXI_Pulse, EVL_Waveform, 1.0, 0.0, 0.0, 0.0, 2000.0 );
|
||||
EventList *ev_o2 = sess->AddEventList( OXI_SPO2, EVL_Waveform, 1.0, 0.0, 0.0, 0.0, 2000.0 );
|
||||
EventList *ev_mv = sess->AddEventList( POS_Motion, EVL_Waveform, 1.0, 0.0, 0.0, 0.0, 2000.0 );
|
||||
EventList *ev_hr = sess->AddEventList(OXI_Pulse, EVL_Waveform, 1.0, 0.0, 0.0, 0.0, 2000.0);
|
||||
EventList *ev_o2 = sess->AddEventList(OXI_SPO2, EVL_Waveform, 1.0, 0.0, 0.0, 0.0, 2000.0);
|
||||
EventList *ev_mv = sess->AddEventList(POS_Motion, EVL_Waveform, 1.0, 0.0, 0.0, 0.0, 2000.0);
|
||||
|
||||
unsigned char o2, hr, x, motion;
|
||||
unsigned char o2_ = 99, hr_ = 60, motion_ = 0;
|
||||
@ -123,10 +121,10 @@ Session* ViatomLoader::ParseFile(const QString & filename)
|
||||
if (hr < 20 || hr > 200) hr = hr_;
|
||||
if (motion > 200) motion = motion_;
|
||||
|
||||
sess->set_last( time_ms );
|
||||
ev_hr->AddEvent( time_ms, hr );
|
||||
ev_o2->AddEvent( time_ms, o2 );
|
||||
ev_mv->AddEvent( time_ms, motion );
|
||||
sess->set_last(time_ms);
|
||||
ev_hr->AddEvent(time_ms, hr);
|
||||
ev_o2->AddEvent(time_ms, o2);
|
||||
ev_mv->AddEvent(time_ms, motion);
|
||||
|
||||
o2_ = o2;
|
||||
hr_ = hr;
|
||||
@ -135,18 +133,18 @@ Session* ViatomLoader::ParseFile(const QString & filename)
|
||||
n_rec += 1;
|
||||
} while (!in.atEnd());
|
||||
|
||||
qDebug( ) << "Read Viatom data from" << data_timestamp << "to" << (QDateTime::fromSecsSinceEpoch( time_ms / 1000L ))
|
||||
qDebug() << "Read Viatom data from" << data_timestamp << "to" << (QDateTime::fromSecsSinceEpoch( time_ms / 1000L))
|
||||
<< n_rec << "records"
|
||||
<< ev_mv->Min( ) << "<=Motion<=" << ev_mv->Max( );
|
||||
<< ev_mv->Min() << "<=Motion<=" << ev_mv->Max();
|
||||
|
||||
sess->setMin( OXI_Pulse, ev_hr->Min( ) );
|
||||
sess->setMax( OXI_Pulse, ev_hr->Max( ) );
|
||||
sess->setMin( OXI_SPO2, ev_o2->Min( ) );
|
||||
sess->setMax( OXI_SPO2, ev_o2->Max( ) );
|
||||
sess->setMin( POS_Motion, ev_mv->Min( ) );
|
||||
sess->setMax( POS_Motion, ev_mv->Max( ) );
|
||||
sess->setMin(OXI_Pulse, ev_hr->Min());
|
||||
sess->setMax(OXI_Pulse, ev_hr->Max());
|
||||
sess->setMin(OXI_SPO2, ev_o2->Min());
|
||||
sess->setMax(OXI_SPO2, ev_o2->Max());
|
||||
sess->setMin(POS_Motion, ev_mv->Min());
|
||||
sess->setMax(POS_Motion, ev_mv->Max());
|
||||
|
||||
sess->really_set_last( time_ms );
|
||||
sess->really_set_last(time_ms);
|
||||
|
||||
return sess;
|
||||
}
|
||||
@ -155,19 +153,19 @@ void ViatomLoader::SaveSessionToDatabase(Session* sess)
|
||||
{
|
||||
Machine* mach = sess->machine();
|
||||
|
||||
sess->SetChanged( true );
|
||||
mach->AddSession( sess );
|
||||
mach->Save( );
|
||||
sess->SetChanged(true);
|
||||
mach->AddSession(sess);
|
||||
mach->Save();
|
||||
}
|
||||
|
||||
static bool viatom_initialized = false;
|
||||
|
||||
void
|
||||
ViatomLoader::Register( )
|
||||
ViatomLoader::Register()
|
||||
{
|
||||
if (!viatom_initialized) {
|
||||
qDebug( "Registering ViatomLoader" );
|
||||
RegisterLoader( new ViatomLoader( ) );
|
||||
qDebug("Registering ViatomLoader");
|
||||
RegisterLoader(new ViatomLoader());
|
||||
//InitModelMap();
|
||||
viatom_initialized = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user