mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 18:50:44 +00:00
Selection area time shown in status bar, Oximeter live view autoscaling Pulse+SPO2
This commit is contained in:
parent
3cac6bbffb
commit
bbc0b0e6d4
@ -6,10 +6,14 @@
|
||||
|
||||
#include <math.h>
|
||||
#include <QDebug>
|
||||
#include <QStatusBar>
|
||||
#include <QMouseEvent>
|
||||
#include "SleepLib/profiles.h"
|
||||
#include "graphwindow.h"
|
||||
#include "Graphs/gTitle.h"
|
||||
|
||||
extern QStatusBar *qstatusbar;
|
||||
|
||||
gGraphWindow::gGraphWindow(QWidget *parent, const QString & title, QGLWidget * shared,Qt::WindowFlags f)
|
||||
: QGLWidget(parent,shared, f )
|
||||
{
|
||||
@ -357,6 +361,28 @@ void gGraphWindow::mouseMoveEvent(QMouseEvent * event)
|
||||
|
||||
QRect r(t1-1, m_marginBottom, t2-t1, m_scrY-m_marginBottom-m_marginTop);
|
||||
|
||||
double z;
|
||||
if (m_block_zoom) {
|
||||
z=rmax_x-rmin_x;
|
||||
} else {
|
||||
z=max_x-min_x;
|
||||
}
|
||||
double q=double(t2-t1)/width();
|
||||
double f=(q*z)*24.0;
|
||||
int hours,minutes,seconds;
|
||||
hours=int(f);
|
||||
minutes=int(f*60.0) % 60;
|
||||
seconds=int(f*3600.0) % 60;
|
||||
QString s;
|
||||
if (z>1) {
|
||||
s.sprintf("%.1f days",q*z);
|
||||
} else if (z>(1.0/(24.0*12.0))) {
|
||||
s.sprintf("%02i:%02i:%02i",hours,minutes,seconds);
|
||||
} else {
|
||||
int milli=int(f*3600000.0) % 1000;
|
||||
s.sprintf("%02i:%02i:%02i:%04i",hours,minutes,seconds,milli);
|
||||
}
|
||||
qstatusbar->showMessage(s,3000);
|
||||
m_mouseRBlast=m_mouseRBrect;
|
||||
m_mouseRBrect=r;
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
QProgressBar *qprogress;
|
||||
QLabel *qstatus;
|
||||
QStatusBar *qstatusbar;
|
||||
|
||||
void MainWindow::Log(QString s)
|
||||
{
|
||||
@ -49,6 +50,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
shared_context=new QGLContext(fmt);
|
||||
|
||||
//ui->tabWidget->setCurrentWidget(daily);
|
||||
qstatusbar=ui->statusbar;
|
||||
qprogress=new QProgressBar(this);
|
||||
qprogress->setMaximum(100);
|
||||
qstatus=new QLabel("",this);
|
||||
|
@ -18,6 +18,8 @@ namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
extern QStatusBar *qstatusbar;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
24
overview.cpp
24
overview.cpp
@ -145,17 +145,8 @@ void Overview::ReloadGraphs()
|
||||
// session_times->Reload(NULL);
|
||||
on_rbLastWeek_clicked();
|
||||
}
|
||||
|
||||
void Overview::UpdateGraphs()
|
||||
void Overview::UpdateHTML()
|
||||
{
|
||||
QDate first=ui->drStart->date();
|
||||
QDate last=ui->drEnd->date();
|
||||
for (list<HistoryData *>::iterator h=Data.begin();h!=Data.end();h++) {
|
||||
//(*h)->Update(dummyday);
|
||||
(*h)->SetDateRange(first,last);
|
||||
}
|
||||
session_times->SetDateRange(first,last);
|
||||
RedrawGraphs();
|
||||
QString html="<html><body><div align=center>";
|
||||
html+="<table width='100%' cellpadding=2 cellspacing=0 border=0>";
|
||||
html+="<tr align=center><td colspan=4><b><i>Statistics</i></b></td></tr>";
|
||||
@ -180,7 +171,18 @@ void Overview::UpdateGraphs()
|
||||
html+="</table>"
|
||||
"</div></body></html>";
|
||||
ui->webView->setHtml(html);
|
||||
|
||||
}
|
||||
void Overview::UpdateGraphs()
|
||||
{
|
||||
QDate first=ui->drStart->date();
|
||||
QDate last=ui->drEnd->date();
|
||||
for (list<HistoryData *>::iterator h=Data.begin();h!=Data.end();h++) {
|
||||
//(*h)->Update(dummyday);
|
||||
(*h)->SetDateRange(first,last);
|
||||
}
|
||||
session_times->SetDateRange(first,last);
|
||||
RedrawGraphs();
|
||||
UpdateHTML();
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,6 +48,7 @@ private:
|
||||
void AddData(HistoryData *d) { Data.push_back(d); };
|
||||
void AddGraph(gGraphWindow *w) { Graphs.push_back(w); };
|
||||
void RedrawGraphs();
|
||||
void UpdateHTML();
|
||||
|
||||
HistoryData *ahidata,*pressure,*leak,*usage,*bedtime,*waketime,*pressure_iap,*pressure_eap;
|
||||
HistoryData *pressure_min,*pressure_max;
|
||||
|
78
oximetry.cpp
78
oximetry.cpp
@ -91,7 +91,7 @@ void Oximetry::on_RefreshPortsButton_clicked()
|
||||
int z=0;
|
||||
QString firstport;
|
||||
bool current_found=false;
|
||||
#if (Q_WS_WINDOWS)
|
||||
#if (Q_WS_WIN32)
|
||||
#define qesPORTNAME portName
|
||||
#else
|
||||
#define qesPORTNAME physName
|
||||
@ -244,6 +244,12 @@ void Oximetry::UpdatePlethy(qint8 d)
|
||||
PLETHY->MinX();
|
||||
PLETHY->MaxX();
|
||||
PLETHY->RealMaxX();
|
||||
pulse->SetRealMaxX(PLETHY->RealMaxX());
|
||||
spo2->SetRealMaxX(PLETHY->RealMaxX());
|
||||
PULSE->SetMinX(PLETHY->MinX());
|
||||
SPO2->SetMinX(PLETHY->MinX());
|
||||
PULSE->SetMaxX(PLETHY->MaxX());
|
||||
SPO2->SetMaxX(PLETHY->MaxX());
|
||||
if (plethy->np[0]>max_data_points) {
|
||||
//TODO: Stop Serial recording..
|
||||
|
||||
@ -253,16 +259,36 @@ void Oximetry::UpdatePlethy(qint8 d)
|
||||
}
|
||||
//PLETHY->updateGL(); // Move this to a timer.
|
||||
}
|
||||
bool Oximetry::UpdatePulseSPO2(qint8 pul,qint8 sp)
|
||||
bool Oximetry::UpdatePulse(qint8 pul)
|
||||
{
|
||||
bool ret=false;
|
||||
|
||||
// Don't block zeros.. If the data is used, it's needed
|
||||
// Can make the graph can skip them.
|
||||
if (lastpulse!=pul) {
|
||||
if (lastpulse!=pul)
|
||||
{
|
||||
pulse->point[0][pulse->np[0]].setX(double(lasttime)/86400000.0);
|
||||
pulse->point[0][pulse->np[0]++].setY(pul);
|
||||
PULSE->updateGL();
|
||||
if (pul!=0) {
|
||||
if (pulse->MinY()==0) {
|
||||
pulse->SetMinY((pul/10) * 10);
|
||||
pulse->SetMaxY((pul/10+1) * 10);
|
||||
PULSE->MinY();
|
||||
PULSE->MaxY();
|
||||
} else {
|
||||
if (pul<pulse->MinY()) {
|
||||
pulse->SetMinY((pul/10) * 10);
|
||||
PULSE->MinY();
|
||||
}
|
||||
if (pul>pulse->MaxY()) {
|
||||
pulse->SetMaxY((pul/10+1) * 10);
|
||||
PULSE->MaxY();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// PULSE->updateGL();
|
||||
if (pulse->np[0]>max_data_points) {
|
||||
//TODO: Stop Serial recording..
|
||||
|
||||
@ -273,10 +299,38 @@ bool Oximetry::UpdatePulseSPO2(qint8 pul,qint8 sp)
|
||||
ret=true;
|
||||
//qDebug() << "Pulse=" << int(bytes[0]);
|
||||
}
|
||||
if (lastspo2!=sp) {
|
||||
lastpulse=pul;
|
||||
return ret;
|
||||
}
|
||||
bool Oximetry::UpdateSPO2(qint8 sp)
|
||||
{
|
||||
bool ret=false;
|
||||
|
||||
if (lastspo2!=sp)
|
||||
{
|
||||
spo2->point[0][spo2->np[0]].setX(double(lasttime)/86400000.0);
|
||||
spo2->point[0][spo2->np[0]++].setY(sp);
|
||||
SPO2->updateGL();
|
||||
|
||||
if (sp!=0) {
|
||||
if (spo2->MinY()==0) {
|
||||
spo2->SetMinY((sp/10) * 10);
|
||||
spo2->SetMaxY((sp/10+1) * 10);
|
||||
SPO2->MinY();
|
||||
SPO2->MaxY();
|
||||
} else {
|
||||
if (sp<spo2->MinY()) {
|
||||
spo2->SetMinY((sp/10) * 10);
|
||||
SPO2->MinY();
|
||||
}
|
||||
if (sp>spo2->MaxY()) {
|
||||
spo2->SetMaxY((sp/10+1) * 10);
|
||||
SPO2->MaxY();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//SPO2->updateGL();
|
||||
if (spo2->np[0]>max_data_points) {
|
||||
//TODO: Stop Serial recording..
|
||||
|
||||
@ -288,7 +342,6 @@ bool Oximetry::UpdatePulseSPO2(qint8 pul,qint8 sp)
|
||||
//qDebug() << "SpO2=" << int(bytes[1]);
|
||||
}
|
||||
|
||||
lastpulse=pul;
|
||||
lastspo2=sp;
|
||||
return ret;
|
||||
}
|
||||
@ -301,22 +354,25 @@ void Oximetry::onReadyRead()
|
||||
port->read(bytes.data(), bytes.size());
|
||||
|
||||
int i=0;
|
||||
bool redraw_ps=false;
|
||||
bool redraw_pulse,redraw_spo2;
|
||||
redraw_pulse=redraw_spo2=false;
|
||||
while (i<bytes.size()) {
|
||||
if (bytes[i]&0x80) {
|
||||
EventDataType d=bytes[i+1] & 0x7f;
|
||||
UpdatePlethy(d);
|
||||
i+=3;
|
||||
} else {
|
||||
if (UpdatePulseSPO2(bytes[i], bytes[i+1])) redraw_ps=true;
|
||||
if (UpdatePulse(bytes[i])) redraw_pulse=true;
|
||||
if (UpdateSPO2(bytes[i+1])) redraw_spo2=true;
|
||||
i+=2;
|
||||
}
|
||||
}
|
||||
PLETHY->updateGL();
|
||||
if (redraw_ps) {
|
||||
if (redraw_pulse)
|
||||
PULSE->updateGL();
|
||||
if (redraw_spo2)
|
||||
SPO2->updateGL();
|
||||
}
|
||||
|
||||
/*if (bytes.size()==3) {
|
||||
} else if (bytes.size()==2) { // Data bytes in live mode
|
||||
// Plethy data
|
||||
|
@ -40,7 +40,8 @@ private slots:
|
||||
void on_ImportButton_clicked();
|
||||
|
||||
private:
|
||||
bool UpdatePulseSPO2(qint8 pulse,qint8 spo2);
|
||||
bool UpdatePulse(qint8 pulse);
|
||||
bool UpdateSPO2(qint8 spo2);
|
||||
void UpdatePlethy(qint8 plethy);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user