2020-06-04 18:32:03 +00:00
|
|
|
/* SleepLib MachineLoader Base Class Header
|
2014-05-25 16:20:33 +00:00
|
|
|
*
|
2018-03-28 07:10:52 +00:00
|
|
|
* Copyright (C) 2011-2018 Mark Watkins <mark@jedimark.net>
|
2021-11-02 20:34:12 +00:00
|
|
|
* Copyright (c) 2019-2022 The OSCAR Team
|
2014-05-25 16:20:33 +00:00
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
2018-06-04 20:48:38 +00:00
|
|
|
* License. See the file COPYING in the main directory of the source code
|
|
|
|
* for more details. */
|
2014-05-25 16:20:33 +00:00
|
|
|
|
|
|
|
#ifndef SERIALOXIMETER_H
|
|
|
|
#define SERIALOXIMETER_H
|
|
|
|
|
|
|
|
#include <QTimer>
|
2020-06-04 18:32:03 +00:00
|
|
|
#include "SleepLib/deviceconnection.h"
|
2014-05-25 16:20:33 +00:00
|
|
|
|
|
|
|
#include "SleepLib/machine_loader.h"
|
|
|
|
|
|
|
|
const int START_TIMEOUT = 30000;
|
|
|
|
|
2014-05-26 07:37:28 +00:00
|
|
|
|
|
|
|
struct OxiRecord
|
|
|
|
{
|
|
|
|
quint8 pulse;
|
|
|
|
quint8 spo2;
|
2014-08-21 14:59:18 +00:00
|
|
|
quint16 perf;
|
2014-08-18 08:00:21 +00:00
|
|
|
|
2014-08-18 16:10:47 +00:00
|
|
|
OxiRecord():pulse(0), spo2(0),perf(0) {}
|
2014-05-26 07:37:28 +00:00
|
|
|
OxiRecord(quint8 p, quint8 s): pulse(p), spo2(s) {}
|
2014-08-18 16:10:47 +00:00
|
|
|
OxiRecord(quint8 p, quint8 s, quint16 pi): pulse(p), spo2(s), perf(pi) {} // with perfusion index
|
|
|
|
OxiRecord(const OxiRecord & copy) { pulse = copy.pulse; spo2 = copy.spo2; perf = copy.perf; }
|
2014-05-26 07:37:28 +00:00
|
|
|
};
|
|
|
|
|
2014-05-25 16:20:33 +00:00
|
|
|
class SerialOximeter : public MachineLoader
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-05-26 07:37:28 +00:00
|
|
|
SerialOximeter() : MachineLoader() {
|
|
|
|
m_importing = m_streaming = false;
|
|
|
|
m_productID = m_vendorID = 0;
|
2014-08-18 16:10:47 +00:00
|
|
|
have_perfindex = false;
|
2014-05-26 07:37:28 +00:00
|
|
|
}
|
2014-05-25 16:20:33 +00:00
|
|
|
virtual ~SerialOximeter() {}
|
|
|
|
|
|
|
|
virtual bool Detect(const QString &path)=0;
|
2018-04-27 04:29:03 +00:00
|
|
|
virtual int Open(const QString & path)=0;
|
2014-05-25 16:20:33 +00:00
|
|
|
|
|
|
|
static void Register() {}
|
|
|
|
|
|
|
|
virtual int Version()=0;
|
2014-07-28 13:56:29 +00:00
|
|
|
virtual const QString &loaderName()=0;
|
2014-08-19 02:44:48 +00:00
|
|
|
|
|
|
|
virtual QDateTime getDateTime(int session) { Q_UNUSED(session); return QDateTime(); }
|
|
|
|
virtual int getDuration(int session) { Q_UNUSED(session); return 0; }
|
|
|
|
virtual int getSessionCount() { return 0; }
|
2014-08-20 04:26:48 +00:00
|
|
|
virtual QString getUser() { return QString(); }
|
2014-08-19 02:44:48 +00:00
|
|
|
virtual QString getModel() { return QString(); }
|
|
|
|
virtual QString getVendor() { return QString(); }
|
|
|
|
virtual QString getDeviceString() { return QString(); }
|
2014-09-18 10:53:59 +00:00
|
|
|
|
2014-08-19 02:44:48 +00:00
|
|
|
virtual void getSessionData(int session) { Q_UNUSED(session); }
|
2014-08-23 12:31:28 +00:00
|
|
|
virtual void syncClock() {}
|
2014-08-19 02:44:48 +00:00
|
|
|
|
2014-09-18 10:53:59 +00:00
|
|
|
virtual QString getDeviceID() { return QString(); }
|
2018-04-27 04:29:03 +00:00
|
|
|
virtual void setDeviceID(const QString &) {}
|
2014-09-18 10:53:59 +00:00
|
|
|
|
|
|
|
virtual void eraseSession(int /*user*/, int /*session*/) {}
|
|
|
|
|
|
|
|
|
2014-08-19 02:44:48 +00:00
|
|
|
|
|
|
|
virtual bool commandDriven() { return false; }
|
|
|
|
|
2014-07-28 13:56:29 +00:00
|
|
|
virtual MachineInfo newInfo() {
|
2014-08-03 13:00:13 +00:00
|
|
|
return MachineInfo(MT_OXIMETER, 0, "", QString(), QString(), QString(), QString(), "Generic", QDateTime::currentDateTime(), 0);
|
2014-07-28 13:56:29 +00:00
|
|
|
}
|
2014-05-25 16:20:33 +00:00
|
|
|
|
|
|
|
// Serial Stuff
|
|
|
|
virtual bool scanDevice(QString keyword="",quint16 vendor_id=0, quint16 product_id=0);
|
|
|
|
virtual bool openDevice();
|
|
|
|
virtual void closeDevice();
|
|
|
|
|
2014-05-26 07:37:28 +00:00
|
|
|
inline bool isStreaming() { return m_streaming; }
|
|
|
|
inline bool isImporting() { return m_importing; }
|
|
|
|
|
2014-08-18 16:10:47 +00:00
|
|
|
bool havePerfIndex() { return have_perfindex; }
|
2014-05-26 07:37:28 +00:00
|
|
|
|
2014-05-25 16:20:33 +00:00
|
|
|
virtual void process() {}
|
|
|
|
|
2014-07-28 13:56:29 +00:00
|
|
|
//virtual Machine *CreateMachine()=0;
|
2014-05-25 16:20:33 +00:00
|
|
|
|
2014-05-28 09:35:21 +00:00
|
|
|
// available sessions
|
|
|
|
QMap<QDateTime, QVector<OxiRecord> *> oxisessions;
|
|
|
|
|
|
|
|
// current session
|
|
|
|
QVector<OxiRecord> * oxirec;
|
2014-05-26 07:37:28 +00:00
|
|
|
|
|
|
|
QDateTime startTime() { return m_startTime; }
|
2014-05-28 09:35:21 +00:00
|
|
|
void setStartTime(QDateTime datetime) { m_startTime = datetime; }
|
2014-05-27 05:24:35 +00:00
|
|
|
virtual bool isStartTimeValid() { return true; }
|
2014-08-19 17:29:39 +00:00
|
|
|
virtual void setDuration(int) { }
|
2014-05-27 05:24:35 +00:00
|
|
|
|
2014-05-28 09:35:21 +00:00
|
|
|
virtual qint64 importResolution() { return 1000; }
|
|
|
|
virtual qint64 liveResolution() { return 20; }
|
|
|
|
|
|
|
|
void trashRecords();
|
2014-08-19 04:01:31 +00:00
|
|
|
virtual void resetDevice() {}
|
|
|
|
|
2014-05-25 16:20:33 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void noDeviceFound();
|
|
|
|
void deviceDetected();
|
|
|
|
void updatePlethy(QByteArray plethy);
|
2014-05-26 07:37:28 +00:00
|
|
|
void importComplete(SerialOximeter *);
|
2014-05-25 16:20:33 +00:00
|
|
|
|
|
|
|
protected slots:
|
|
|
|
virtual void dataAvailable();
|
|
|
|
virtual void resetImportTimeout() {}
|
|
|
|
virtual void startImportTimeout() {}
|
|
|
|
|
2014-05-26 07:37:28 +00:00
|
|
|
virtual void stopRecording();
|
2014-06-20 14:17:41 +00:00
|
|
|
virtual void shutdownPorts() {}
|
2014-05-26 07:37:28 +00:00
|
|
|
// virtual void abortTask();
|
|
|
|
|
2014-05-25 16:20:33 +00:00
|
|
|
protected:
|
|
|
|
virtual void processBytes(QByteArray buffer) { Q_UNUSED(buffer) }
|
|
|
|
|
|
|
|
virtual void killTimers() {}
|
|
|
|
virtual void requestData() {}
|
|
|
|
|
|
|
|
QString port;
|
2020-06-04 18:32:03 +00:00
|
|
|
SerialPort serial;
|
2014-05-25 16:20:33 +00:00
|
|
|
|
|
|
|
QTimer startTimer;
|
|
|
|
QTimer resetTimer;
|
|
|
|
|
2014-05-26 07:37:28 +00:00
|
|
|
QDateTime m_startTime;
|
|
|
|
|
2014-05-25 16:20:33 +00:00
|
|
|
quint16 m_productID;
|
|
|
|
quint16 m_vendorID;
|
2014-05-26 07:37:28 +00:00
|
|
|
|
|
|
|
bool m_streaming;
|
|
|
|
bool m_importing;
|
2014-08-18 16:10:47 +00:00
|
|
|
bool have_perfindex;
|
2014-05-26 07:37:28 +00:00
|
|
|
|
2014-05-25 16:20:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SERIALOXIMETER_H
|