mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-06 19:20:45 +00:00
Remove remaining Machine dependencies from PRS1 loader.
Now that properties are in the MachineInfo record, we don't need to call PeekProperties a second time to fill out the machine record. Also remove some unused variables and methods from class definition.
This commit is contained in:
parent
a4fdb03c49
commit
749c6a3358
@ -650,7 +650,7 @@ bool PRS1Loader::PeekProperties(const QString & filename, QHash<QString,QString>
|
|||||||
return props.size() > 0;
|
return props.size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PRS1Loader::PeekProperties(MachineInfo & info, const QString & filename, Machine * mach)
|
bool PRS1Loader::PeekProperties(MachineInfo & info, const QString & filename)
|
||||||
{
|
{
|
||||||
QHash<QString,QString> props;
|
QHash<QString,QString> props;
|
||||||
if (!PeekProperties(filename, props)) {
|
if (!PeekProperties(filename, props)) {
|
||||||
@ -674,9 +674,9 @@ bool PRS1Loader::PeekProperties(MachineInfo & info, const QString & filename, Ma
|
|||||||
if (!ok) qWarning() << "ProductType" << props[key];
|
if (!ok) qWarning() << "ProductType" << props[key];
|
||||||
skip = true;
|
skip = true;
|
||||||
}
|
}
|
||||||
if (!mach || skip) continue;
|
if (skip) continue;
|
||||||
|
|
||||||
mach->info.properties[key] = props[key];
|
info.properties[key] = props[key];
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!modelnum.isEmpty()) {
|
if (!modelnum.isEmpty()) {
|
||||||
@ -769,8 +769,8 @@ int PRS1Loader::OpenMachine(const QString & path)
|
|||||||
int sessionid_base;
|
int sessionid_base;
|
||||||
sessionid_base = FindSessionDirsAndProperties(path, paths, propertyfile);
|
sessionid_base = FindSessionDirsAndProperties(path, paths, propertyfile);
|
||||||
|
|
||||||
Machine *m = CreateMachineFromProperties(propertyfile);
|
bool supported = CreateMachineFromProperties(propertyfile);
|
||||||
if (m == nullptr) {
|
if (!supported) {
|
||||||
// Device is unsupported.
|
// Device is unsupported.
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -838,7 +838,7 @@ int PRS1Loader::FindSessionDirsAndProperties(const QString & path, QStringList &
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Machine* PRS1Loader::CreateMachineFromProperties(QString propertyfile)
|
bool PRS1Loader::CreateMachineFromProperties(QString propertyfile)
|
||||||
{
|
{
|
||||||
MachineInfo info = newInfo();
|
MachineInfo info = newInfo();
|
||||||
QHash<QString,QString> props;
|
QHash<QString,QString> props;
|
||||||
@ -858,7 +858,7 @@ Machine* PRS1Loader::CreateMachineFromProperties(QString propertyfile)
|
|||||||
info.modelnumber = QObject::tr("unknown model");
|
info.modelnumber = QObject::tr("unknown model");
|
||||||
}
|
}
|
||||||
emit deviceIsUnsupported(info);
|
emit deviceIsUnsupported(info);
|
||||||
return nullptr;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Have a peek first to get the model number.
|
// Have a peek first to get the model number.
|
||||||
@ -869,17 +869,14 @@ Machine* PRS1Loader::CreateMachineFromProperties(QString propertyfile)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Which is needed to get the right machine record..
|
// Which is needed to get the right machine record..
|
||||||
Machine *m = m_ctx->CreateMachineFromInfo(info);
|
m_ctx->CreateMachineFromInfo(info);
|
||||||
|
|
||||||
// This time supply the machine object so it can populate machine properties..
|
|
||||||
PeekProperties(m->info, propertyfile, m);
|
|
||||||
|
|
||||||
if (!s_PRS1ModelInfo.IsTested(props)) {
|
if (!s_PRS1ModelInfo.IsTested(props)) {
|
||||||
qDebug() << info.modelnumber << "untested";
|
qDebug() << info.modelnumber << "untested";
|
||||||
emit deviceIsUntested(info);
|
emit deviceIsUntested(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
return m;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,11 +9,7 @@
|
|||||||
|
|
||||||
#ifndef PRS1LOADER_H
|
#ifndef PRS1LOADER_H
|
||||||
#define PRS1LOADER_H
|
#define PRS1LOADER_H
|
||||||
//#include <map>
|
|
||||||
//using namespace std;
|
|
||||||
#include "SleepLib/machine.h" // Base class: MachineLoader
|
|
||||||
#include "SleepLib/machine_loader.h"
|
#include "SleepLib/machine_loader.h"
|
||||||
#include "SleepLib/profiles.h"
|
|
||||||
|
|
||||||
#ifdef UNITTEST_MODE
|
#ifdef UNITTEST_MODE
|
||||||
#define private public
|
#define private public
|
||||||
@ -28,20 +24,6 @@
|
|||||||
const int prs1_data_version = 20;
|
const int prs1_data_version = 20;
|
||||||
//
|
//
|
||||||
//********************************************************************************************
|
//********************************************************************************************
|
||||||
#if 0 // Apparently unused
|
|
||||||
/*! \class PRS1
|
|
||||||
\brief PRS1 customized machine object (via CPAP)
|
|
||||||
*/
|
|
||||||
class PRS1: public CPAP
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PRS1(Profile *, MachineID id = 0);
|
|
||||||
virtual ~PRS1();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
const int max_load_buffer_size = 1024 * 1024;
|
|
||||||
#endif
|
|
||||||
const QString prs1_class_name = STR_MACH_PRS1;
|
const QString prs1_class_name = STR_MACH_PRS1;
|
||||||
|
|
||||||
QString ts(qint64 msecs);
|
QString ts(qint64 msecs);
|
||||||
@ -177,7 +159,7 @@ class PRS1Loader : public CPAPLoader
|
|||||||
bool PeekProperties(const QString & filename, QHash<QString,QString> & props);
|
bool PeekProperties(const QString & filename, QHash<QString,QString> & props);
|
||||||
|
|
||||||
//! \brief Peek into PROP.TXT or properties.txt at given path, and use it to fill MachineInfo structure
|
//! \brief Peek into PROP.TXT or properties.txt at given path, and use it to fill MachineInfo structure
|
||||||
bool PeekProperties(MachineInfo & info, const QString & path, Machine * mach = nullptr);
|
bool PeekProperties(MachineInfo & info, const QString & path);
|
||||||
|
|
||||||
//! \brief Detect if the given path contains a valid Folder structure
|
//! \brief Detect if the given path contains a valid Folder structure
|
||||||
virtual bool Detect(const QString & path);
|
virtual bool Detect(const QString & path);
|
||||||
@ -226,9 +208,6 @@ class PRS1Loader : public CPAPLoader
|
|||||||
QHash<SessionID, PRS1Import*> sesstasks;
|
QHash<SessionID, PRS1Import*> sesstasks;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString last;
|
|
||||||
QHash<QString, Machine *> PRS1List;
|
|
||||||
|
|
||||||
//! \brief Returns the path of the P-Series folder (whatever case) if present on the card
|
//! \brief Returns the path of the P-Series folder (whatever case) if present on the card
|
||||||
QString GetPSeriesPath(const QString & path);
|
QString GetPSeriesPath(const QString & path);
|
||||||
|
|
||||||
@ -241,25 +220,12 @@ class PRS1Loader : public CPAPLoader
|
|||||||
//! \brief Finds the P0,P1,... session paths and property pathname and returns the base (10 or 16) of the session filenames
|
//! \brief Finds the P0,P1,... session paths and property pathname and returns the base (10 or 16) of the session filenames
|
||||||
int FindSessionDirsAndProperties(const QString & path, QStringList & paths, QString & propertyfile);
|
int FindSessionDirsAndProperties(const QString & path, QStringList & paths, QString & propertyfile);
|
||||||
|
|
||||||
//! \brief Reads the model number from the property file, evaluates its capabilities, and returns a machine instance
|
//! \brief Reads the model number from the property file, evaluates its capabilities, and returns true if the machine is supported
|
||||||
Machine* CreateMachineFromProperties(QString propertyfile);
|
bool CreateMachineFromProperties(QString propertyfile);
|
||||||
|
|
||||||
//! \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 QStringList & paths, int sessionid_base);
|
void ScanFiles(const QStringList & paths, int sessionid_base);
|
||||||
|
|
||||||
// //! \brief Parses "properties.txt" file containing machine information
|
|
||||||
// bool ParseProperties(Machine *m, QString filename);
|
|
||||||
|
|
||||||
//! \brief Parse a .005 waveform file, extracting Flow Rate waveform (and Mask Pressure data if available)
|
|
||||||
bool OpenWaveforms(SessionID sid, const QString & filename);
|
|
||||||
|
|
||||||
//! \brief Parse a data chunk from the .000 (brick) and .001 (summary) files.
|
|
||||||
bool ParseSummary(Machine *mach, qint32 sequence, quint32 timestamp, unsigned char *data,
|
|
||||||
quint16 size, int family, int familyVersion);
|
|
||||||
|
|
||||||
|
|
||||||
QHash<SessionID, Session *> extra_session;
|
|
||||||
|
|
||||||
//! \brief PRS1 Data files can store multiple sessions, so store them in this list for later processing.
|
//! \brief PRS1 Data files can store multiple sessions, so store them in this list for later processing.
|
||||||
QHash<SessionID, Session *> new_sessions;
|
QHash<SessionID, Session *> new_sessions;
|
||||||
};
|
};
|
||||||
|
@ -107,11 +107,12 @@ void parseAndEmitSessionYaml(const QString & path)
|
|||||||
int sessionid_base;
|
int sessionid_base;
|
||||||
sessionid_base = s_loader->FindSessionDirsAndProperties(path, paths, propertyfile);
|
sessionid_base = s_loader->FindSessionDirsAndProperties(path, paths, propertyfile);
|
||||||
|
|
||||||
Machine *m = s_loader->CreateMachineFromProperties(propertyfile);
|
bool supported = s_loader->CreateMachineFromProperties(propertyfile);
|
||||||
if (m == nullptr) {
|
if (!supported) {
|
||||||
qWarning() << "*** Skipping unsupported machine!";
|
qWarning() << "*** Skipping unsupported machine!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Machine* m = ctx->m_machine;
|
||||||
|
|
||||||
s_loader->ScanFiles(paths, sessionid_base);
|
s_loader->ScanFiles(paths, sessionid_base);
|
||||||
|
|
||||||
@ -293,11 +294,12 @@ void parseAndEmitChunkYaml(const QString & path)
|
|||||||
int sessionid_base;
|
int sessionid_base;
|
||||||
sessionid_base = s_loader->FindSessionDirsAndProperties(path, paths, propertyfile);
|
sessionid_base = s_loader->FindSessionDirsAndProperties(path, paths, propertyfile);
|
||||||
|
|
||||||
Machine *m = s_loader->CreateMachineFromProperties(propertyfile);
|
bool supported = s_loader->CreateMachineFromProperties(propertyfile);
|
||||||
if (m == nullptr) {
|
if (!supported) {
|
||||||
qWarning() << "*** Skipping unsupported machine!";
|
qWarning() << "*** Skipping unsupported machine!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Machine* m = ctx->m_machine;
|
||||||
|
|
||||||
// This mirrors the functional bits of PRS1Loader::ScanFiles.
|
// This mirrors the functional bits of PRS1Loader::ScanFiles.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user