2011-08-05 00:12:23 +00:00
|
|
|
/*
|
|
|
|
Oximetry GUI Headers
|
|
|
|
Copyright (c)2011 Mark Watkins <jedimark@users.sourceforge.net>
|
|
|
|
License: GPL
|
|
|
|
*/
|
|
|
|
|
2011-07-13 05:27:27 +00:00
|
|
|
#ifndef OXIMETRY_H
|
|
|
|
#define OXIMETRY_H
|
2011-07-29 14:58:44 +00:00
|
|
|
|
2011-07-13 05:27:27 +00:00
|
|
|
#include <QWidget>
|
2011-07-22 13:46:17 +00:00
|
|
|
#include <QGLContext>
|
2011-08-30 17:22:54 +00:00
|
|
|
#include <QHBoxLayout>
|
2011-07-13 17:42:49 +00:00
|
|
|
#include <QSplitter>
|
|
|
|
#include <qextserialport/qextserialport.h>
|
|
|
|
|
|
|
|
#include "SleepLib/profiles.h"
|
2011-07-29 14:58:44 +00:00
|
|
|
#include "SleepLib/day.h"
|
|
|
|
#include "SleepLib/session.h"
|
|
|
|
|
|
|
|
#include "Graphs/gLineChart.h"
|
2011-08-29 07:13:58 +00:00
|
|
|
#include "Graphs/gFooBar.h"
|
2011-07-13 05:27:27 +00:00
|
|
|
|
2011-12-01 01:47:09 +00:00
|
|
|
enum SerialOxMode { SO_OFF, SO_IMPORT, SO_LIVE };
|
2011-11-24 12:47:25 +00:00
|
|
|
class SerialOximeter:public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit SerialOximeter(QObject * parent,QString oxiname, QString portname="",BaudRateType baud=BAUD19200, FlowType flow=FLOW_OFF, ParityType parity=PAR_ODD, DataBitsType databits=DATA_8, StopBitsType stopbits=STOP_1);
|
|
|
|
virtual ~SerialOximeter();
|
|
|
|
|
|
|
|
virtual bool Open(QextSerialPort::QueryMode mode=QextSerialPort::EventDriven);
|
|
|
|
virtual void Close();
|
|
|
|
|
|
|
|
virtual bool startImport()=0;
|
|
|
|
virtual void stopImport() {} // abort, default do nothing.
|
|
|
|
|
|
|
|
virtual bool startLive();
|
|
|
|
virtual void stopLive();
|
|
|
|
|
2011-12-03 15:48:36 +00:00
|
|
|
virtual void resetDevice()=0;
|
|
|
|
virtual void requestData()=0;
|
|
|
|
|
2011-12-01 01:47:09 +00:00
|
|
|
SerialOxMode mode() { return m_mode; }
|
2011-12-01 06:06:13 +00:00
|
|
|
void destroySession() { delete session; session=NULL; }
|
2011-12-01 01:47:09 +00:00
|
|
|
|
|
|
|
bool isOpen() { return m_opened; }
|
|
|
|
int callbacks() { return m_callbacks; }
|
|
|
|
|
2011-11-24 12:47:25 +00:00
|
|
|
qint64 lastTime() { return lasttime; }
|
|
|
|
Machine * getMachine() { return machine; }
|
|
|
|
|
|
|
|
Session *createSession();
|
|
|
|
Session * getSession() { return session; }
|
2011-11-24 21:19:45 +00:00
|
|
|
|
2011-11-24 22:00:37 +00:00
|
|
|
void compactToWaveform(EventList *el);
|
|
|
|
void compactToEvent(EventList *el);
|
2011-11-24 21:19:45 +00:00
|
|
|
void compactAll();
|
2011-11-24 12:47:25 +00:00
|
|
|
|
|
|
|
void setPortName(QString portname);
|
|
|
|
void setBaudRate(BaudRateType baud);
|
|
|
|
void setFlowControl(FlowType flow);
|
|
|
|
void setParity(ParityType parity);
|
|
|
|
void setDataBits(DataBitsType databits);
|
|
|
|
void setStopBits(StopBitsType stopbits);
|
|
|
|
|
|
|
|
QString portName() { return m_portname; }
|
|
|
|
BaudRateType baudRate() { return m_baud; }
|
|
|
|
FlowType flowControl() { return m_flow; }
|
|
|
|
ParityType parity() { return m_parity; }
|
|
|
|
DataBitsType dataBits() { return m_databits; }
|
|
|
|
StopBitsType stopBits() { return m_stopbits; }
|
|
|
|
|
2011-12-01 06:06:13 +00:00
|
|
|
EventList * Pulse() { return pulse; }
|
|
|
|
EventList * Spo2() { return spo2; }
|
|
|
|
EventList * Plethy() { return plethy; }
|
|
|
|
|
2011-11-24 12:47:25 +00:00
|
|
|
signals:
|
|
|
|
void sessionCreated(Session *);
|
|
|
|
void dataChanged();
|
|
|
|
void importProcess();
|
|
|
|
void importComplete(Session *);
|
|
|
|
void importAborted();
|
|
|
|
void updateProgress(float f); // between 0 and 1.
|
|
|
|
void liveStopped(Session *);
|
|
|
|
|
|
|
|
void updatePulse(float p);
|
|
|
|
void updateSpO2(float p);
|
|
|
|
|
|
|
|
protected slots:
|
2011-12-03 15:48:36 +00:00
|
|
|
virtual void ReadyRead()=0;
|
2011-12-03 08:52:24 +00:00
|
|
|
virtual void import_process()=0;
|
2011-12-03 14:13:14 +00:00
|
|
|
virtual void Timeout();
|
2011-11-24 12:47:25 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
//virtual void addEvents(EventDataType pr, EventDataType o2, EventDataType pleth=-1000000);
|
|
|
|
|
|
|
|
virtual void addPulse(qint64 time, EventDataType pr);
|
|
|
|
virtual void addSpO2(qint64 time, EventDataType o2);
|
|
|
|
virtual void addPlethy(qint64 time, EventDataType pleth);
|
|
|
|
|
|
|
|
|
|
|
|
Session * session;
|
|
|
|
|
|
|
|
EventList * pulse;
|
|
|
|
EventList * spo2;
|
|
|
|
EventList * plethy;
|
|
|
|
QextSerialPort *m_port;
|
2011-12-01 01:47:09 +00:00
|
|
|
SerialOxMode m_mode;
|
2011-11-24 12:47:25 +00:00
|
|
|
bool m_opened;
|
|
|
|
QString m_oxiname;
|
|
|
|
QString m_portname;
|
|
|
|
BaudRateType m_baud;
|
|
|
|
FlowType m_flow;
|
|
|
|
ParityType m_parity;
|
|
|
|
DataBitsType m_databits;
|
|
|
|
StopBitsType m_stopbits;
|
2011-12-01 01:47:09 +00:00
|
|
|
QextSerialPort::QueryMode m_portmode;
|
2011-11-24 12:47:25 +00:00
|
|
|
Machine *machine;
|
|
|
|
|
|
|
|
qint64 lasttime;
|
|
|
|
bool import_mode;
|
2011-12-01 01:47:09 +00:00
|
|
|
|
|
|
|
int m_callbacks;
|
2011-12-03 14:13:14 +00:00
|
|
|
bool done_import;
|
|
|
|
QTimer *timer;
|
2011-11-24 12:47:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CMS50Serial:public SerialOximeter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit CMS50Serial(QObject * parent,QString portname);
|
|
|
|
virtual ~CMS50Serial();
|
|
|
|
virtual bool startImport();
|
2011-12-03 15:48:36 +00:00
|
|
|
virtual void resetDevice();
|
|
|
|
virtual void requestData();
|
2011-11-24 12:47:25 +00:00
|
|
|
|
|
|
|
protected:
|
2011-12-03 08:52:24 +00:00
|
|
|
virtual void import_process();
|
2011-11-24 12:47:25 +00:00
|
|
|
|
2011-12-03 08:52:24 +00:00
|
|
|
virtual void ReadyRead();
|
2011-11-24 12:47:25 +00:00
|
|
|
bool waitf6;
|
|
|
|
short cntf6;
|
2011-11-25 12:13:35 +00:00
|
|
|
short failcnt;
|
2011-11-24 12:47:25 +00:00
|
|
|
|
|
|
|
QByteArray data;
|
|
|
|
QVector<QDateTime> f2time;
|
|
|
|
int datasize;
|
|
|
|
|
|
|
|
int received_bytes;
|
|
|
|
};
|
|
|
|
|
2011-07-13 05:27:27 +00:00
|
|
|
namespace Ui {
|
|
|
|
class Oximetry;
|
|
|
|
}
|
|
|
|
|
2011-07-13 17:42:49 +00:00
|
|
|
enum PORTMODE { PM_LIVE, PM_RECORDING };
|
2011-07-17 15:57:45 +00:00
|
|
|
const int max_data_points=1000000;
|
2011-07-13 17:42:49 +00:00
|
|
|
|
2011-07-13 05:27:27 +00:00
|
|
|
class Oximetry : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2011-10-05 07:41:56 +00:00
|
|
|
explicit Oximetry(QWidget *parent, gGraphView * shared=NULL);
|
2011-07-13 05:27:27 +00:00
|
|
|
~Oximetry();
|
|
|
|
|
2011-07-13 17:42:49 +00:00
|
|
|
void RedrawGraphs();
|
|
|
|
|
2011-11-27 14:35:25 +00:00
|
|
|
gGraphView *graphView() { return GraphView; }
|
|
|
|
|
2011-07-13 05:27:27 +00:00
|
|
|
private slots:
|
|
|
|
void on_RefreshPortsButton_clicked();
|
2011-12-03 14:13:14 +00:00
|
|
|
void on_RunButton_toggled(bool checked); // Live mode button
|
2011-07-13 17:42:49 +00:00
|
|
|
|
|
|
|
void on_SerialPortsCombo_activated(const QString &arg1);
|
|
|
|
void on_ImportButton_clicked();
|
2011-12-03 14:13:14 +00:00
|
|
|
void on_saveButton_clicked();
|
2011-07-13 17:42:49 +00:00
|
|
|
|
2011-12-03 14:13:14 +00:00
|
|
|
void data_changed();
|
|
|
|
void pulse_changed(float p);
|
|
|
|
void spo2_changed(float o2);
|
2011-11-24 12:47:25 +00:00
|
|
|
|
2011-12-03 14:13:14 +00:00
|
|
|
void update_progress(float f);
|
2011-12-03 08:52:24 +00:00
|
|
|
void import_aborted();
|
|
|
|
void import_complete(Session *session);
|
2011-07-17 15:57:45 +00:00
|
|
|
|
2011-12-01 01:47:09 +00:00
|
|
|
void oximeter_running_check();
|
2011-12-03 14:13:14 +00:00
|
|
|
void live_stopped(Session *session);
|
2011-12-01 01:47:09 +00:00
|
|
|
|
2011-11-24 12:47:25 +00:00
|
|
|
private:
|
|
|
|
void import_finished();
|
2011-07-13 05:27:27 +00:00
|
|
|
Ui::Oximetry *ui;
|
2011-08-29 07:13:58 +00:00
|
|
|
|
|
|
|
gGraphView *GraphView;
|
|
|
|
MyScrollBar *scrollbar;
|
|
|
|
QHBoxLayout *layout;
|
|
|
|
|
2011-07-29 14:58:44 +00:00
|
|
|
gLineChart *pulse,*spo2,*plethy;
|
2011-11-28 13:16:50 +00:00
|
|
|
Layer *lo1,*lo2;
|
2011-08-29 07:13:58 +00:00
|
|
|
gGraph *PULSE,*SPO2,*PLETHY,*CONTROL;
|
2011-07-29 14:58:44 +00:00
|
|
|
|
2011-07-31 20:24:43 +00:00
|
|
|
QVector<gLineChart *> Data;
|
2011-07-29 14:58:44 +00:00
|
|
|
|
2011-07-13 17:42:49 +00:00
|
|
|
QextSerialPort *port;
|
|
|
|
QString portname;
|
|
|
|
PORTMODE portmode;
|
2011-10-07 07:10:36 +00:00
|
|
|
double lasttime,starttime;
|
2011-07-17 08:53:20 +00:00
|
|
|
int lastpulse, lastspo2;
|
|
|
|
|
2011-07-29 14:58:44 +00:00
|
|
|
Day * day;
|
2011-11-24 12:47:25 +00:00
|
|
|
//Session * session;
|
|
|
|
//EventList * ev_pulse;
|
|
|
|
//EventList * ev_spo2;
|
|
|
|
//EventList * ev_plethy;
|
2011-08-29 07:13:58 +00:00
|
|
|
Layer * foobar;
|
|
|
|
gGraphView * m_shared;
|
2011-11-24 12:47:25 +00:00
|
|
|
|
|
|
|
SerialOximeter *oximeter;
|
|
|
|
bool firstSPO2Update;
|
|
|
|
bool firstPulseUpdate;
|
|
|
|
bool secondPulseUpdate;
|
|
|
|
bool secondSPO2Update;
|
|
|
|
|
2011-07-13 05:27:27 +00:00
|
|
|
};
|
2011-07-29 14:58:44 +00:00
|
|
|
|
2011-07-13 05:27:27 +00:00
|
|
|
#endif // OXIMETRY_H
|