mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 10:40:42 +00:00
Improve prisma smart loader
This commit is contained in:
parent
befa225434
commit
b4914c0970
@ -563,6 +563,27 @@ MachineInfo PrismaLoader::PeekInfoFromConfig(const QString & selectedPath)
|
|||||||
return MachineInfo();
|
return MachineInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrismaLoader::ImportDataDir(QDir& dataDir, QSet<SessionID>& sessions, QHash<SessionID, QString>& eventFiles, QHash<SessionID, QString>& signalFiles) {
|
||||||
|
dataDir.setFilter(QDir::NoDotAndDotDot | QDir::Files | QDir::NoSymLinks);
|
||||||
|
dataDir.setSorting(QDir::Name);
|
||||||
|
|
||||||
|
if (dataDir.exists()) {
|
||||||
|
for (auto & inputFile : dataDir.entryInfoList()) {
|
||||||
|
QString fileName = inputFile.fileName().toLower();
|
||||||
|
if (fileName.startsWith("event_") && fileName.endsWith(".xml")) {
|
||||||
|
SessionID sid = fileName.mid(6,fileName.size()-4-6).toLong();
|
||||||
|
sessions += sid;
|
||||||
|
eventFiles[sid] = inputFile.canonicalFilePath();
|
||||||
|
}
|
||||||
|
if (inputFile.fileName().toLower().startsWith("signal_") && inputFile.fileName().toLower().endsWith(".wmedf")) {
|
||||||
|
SessionID sid = fileName.mid(7,fileName.size()-6-7).toLong();
|
||||||
|
sessions += sid;
|
||||||
|
signalFiles[sid] = inputFile.canonicalFilePath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO AXT PrismaSmart specific, extract it into a parser class with the config files
|
// TODO AXT PrismaSmart specific, extract it into a parser class with the config files
|
||||||
void PrismaLoader::ScanFiles(const MachineInfo& info, const QString & machinePath)
|
void PrismaLoader::ScanFiles(const MachineInfo& info, const QString & machinePath)
|
||||||
{
|
{
|
||||||
@ -588,33 +609,13 @@ void PrismaLoader::ScanFiles(const MachineInfo& info, const QString & machinePat
|
|||||||
dayDir.setFilter(QDir::NoDotAndDotDot | QDir::Dirs | QDir::NoSymLinks);
|
dayDir.setFilter(QDir::NoDotAndDotDot | QDir::Dirs | QDir::NoSymLinks);
|
||||||
dayDir.setSorting(QDir::Name);
|
dayDir.setSorting(QDir::Name);
|
||||||
QFileInfoList subDirs = dayDir.entryInfoList();
|
QFileInfoList subDirs = dayDir.entryInfoList();
|
||||||
QDir dataDir;
|
|
||||||
|
|
||||||
if (subDirs.size() == 0) {
|
if (subDirs.size() == 0) {
|
||||||
dataDir = dayDir;
|
ImportDataDir(dayDir, sessions, eventFiles, signalFiles);
|
||||||
} else if (subDirs.size() == 1) {
|
|
||||||
dataDir = QDir(subDirs.at(0).canonicalFilePath());
|
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "PrismaLoader: Directory structure not recognized!";
|
for (auto & dataDirInfo: subDirs) {
|
||||||
continue;
|
QDir dataDir(dataDirInfo.canonicalFilePath());
|
||||||
}
|
ImportDataDir(dataDir, sessions, eventFiles, signalFiles);
|
||||||
|
|
||||||
dataDir.setFilter(QDir::NoDotAndDotDot | QDir::Files | QDir::NoSymLinks);
|
|
||||||
dataDir.setSorting(QDir::Name);
|
|
||||||
|
|
||||||
if (dataDir.exists()) {
|
|
||||||
for (auto & inputFile : dataDir.entryInfoList()) {
|
|
||||||
QString fileName = inputFile.fileName().toLower();
|
|
||||||
if (fileName.startsWith("event_") && fileName.endsWith(".xml")) {
|
|
||||||
SessionID sid = fileName.mid(6,fileName.size()-4-6).toLong();
|
|
||||||
sessions += sid;
|
|
||||||
eventFiles[sid] = inputFile.canonicalFilePath();
|
|
||||||
}
|
|
||||||
if (inputFile.fileName().toLower().startsWith("signal_") && inputFile.fileName().toLower().endsWith(".wmedf")) {
|
|
||||||
SessionID sid = fileName.mid(7,fileName.size()-6-7).toLong();
|
|
||||||
sessions += sid;
|
|
||||||
signalFiles[sid] = inputFile.canonicalFilePath();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#define PRISMA_LOADER_H
|
#define PRISMA_LOADER_H
|
||||||
#include "SleepLib/machine_loader.h"
|
#include "SleepLib/machine_loader.h"
|
||||||
#include "SleepLib/loader_plugins/edfparser.h"
|
#include "SleepLib/loader_plugins/edfparser.h"
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
#ifdef UNITTEST_MODE
|
#ifdef UNITTEST_MODE
|
||||||
#define private public
|
#define private public
|
||||||
@ -188,6 +189,8 @@ class PrismaLoader : public CPAPLoader
|
|||||||
|
|
||||||
MachineInfo PeekInfoFromConfig(const QString & selectedPath);
|
MachineInfo PeekInfoFromConfig(const QString & selectedPath);
|
||||||
|
|
||||||
|
void ImportDataDir(QDir& dataDir, QSet<SessionID>& sessions, QHash<SessionID, QString>& eventFiles, QHash<SessionID, QString>& signalFiles);
|
||||||
|
|
||||||
//! \brief Scans the given directories for session data and create an import task for each logical session.
|
//! \brief Scans the given directories for session data and create an import task for each logical session.
|
||||||
void ScanFiles(const MachineInfo& info, const QString & path);
|
void ScanFiles(const MachineInfo& info, const QString & path);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user