mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 10:40:42 +00:00
Logger Tweaks, SummaryChart stuff
This commit is contained in:
parent
6b833cd886
commit
e02477cafd
@ -236,7 +236,7 @@ gToolTip::gToolTip(gGraphView * graphview)
|
||||
m_pos.setX(0);
|
||||
m_pos.setY(0);
|
||||
m_visible=false;
|
||||
m_spacer=5; // pixels around text area
|
||||
m_spacer=2; // pixels around text area
|
||||
timer=new QTimer(graphview);
|
||||
connect(timer,SIGNAL(timeout()),SLOT(timerDone()));
|
||||
}
|
||||
@ -257,7 +257,7 @@ void gToolTip::display(QString text, int x, int y, int timeout)
|
||||
GetTextExtent(m_text,tw,th);
|
||||
tw+=m_spacer*2;
|
||||
th+=m_spacer*2;
|
||||
th*=2;
|
||||
//th*=2;
|
||||
if (timer->isActive()) {
|
||||
timer->stop();
|
||||
}
|
||||
@ -298,7 +298,7 @@ void gToolTip::paint() //actually paints it.
|
||||
painter.setFont(*defaultfont);
|
||||
rect=painter.boundingRect(rect,Qt::AlignCenter,m_text);
|
||||
rect.setLeft(rect.x()-m_spacer);
|
||||
rect.setTop(rect.y()-rect.height()/1.33);
|
||||
rect.setTop(rect.y()-rect.height()/2);
|
||||
rect.setWidth(rect.width()+m_spacer*2);
|
||||
//rect.setHeight(rect.height());
|
||||
QBrush brush(QColor(255,255,128,200));
|
||||
|
@ -347,14 +347,25 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height)
|
||||
//lines->add(px,py,px+20,py,m_colors[j]);
|
||||
//lines->add(px,py+1,px+20,py+1,m_colors[j]);
|
||||
}
|
||||
a="";
|
||||
if (m_graphtype==GT_BAR) {
|
||||
if (m_type.size()>1) {
|
||||
float val=total_val/float(total_days);
|
||||
a=m_label+"="+QString::number(val,'f',2)+" ";
|
||||
GetTextExtent(a,x,y);
|
||||
px-=20+x;
|
||||
w.renderText(a,px+24,py+5);
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
a="";
|
||||
/*if (m_graphtype==GT_BAR) {
|
||||
if (m_type.size()>1) {
|
||||
float val=total_val/float(total_days);
|
||||
a+=m_label+"="+QString::number(val,'f',2)+" ";
|
||||
//
|
||||
}
|
||||
}
|
||||
}*/
|
||||
a+="Days="+QString::number(totalcounts[0],'f',0);
|
||||
GetTextExtent(a,x,y);
|
||||
px-=30+x;
|
||||
|
@ -517,7 +517,6 @@ bool ResmedLoader::LoadEVE(Session *sess,EDFParser &edf)
|
||||
t+=tolower(data[pos++]);
|
||||
} while ((data[pos]!=20) && (pos<recs)); // start code
|
||||
if (!t.isEmpty()) {
|
||||
//code=MC_UNKNOWN;
|
||||
if (t=="obstructive apnea") {
|
||||
if (!EL[0]) {
|
||||
if (!(EL[0]=sess->AddEventList(CPAP_Obstructive,EVL_Event))) return false;
|
||||
@ -584,7 +583,6 @@ bool ResmedLoader::LoadBRP(Session *sess,EDFParser &edf)
|
||||
continue;
|
||||
}
|
||||
double rate=double(duration)/double(recs);
|
||||
//es.gain=1;
|
||||
EventList *a=sess->AddEventList(code,EVL_Waveform,es.gain,es.offset,0,0,rate);
|
||||
a->setDimension(es.physical_dimension);
|
||||
a->AddWaveform(edf.startdate,es.data,recs,duration);
|
||||
@ -602,7 +600,6 @@ EventList * ResmedLoader::ToTimeDelta(Session *sess,EDFParser &edf, EDFSignal &
|
||||
double tt=edf.startdate;
|
||||
//sess->UpdateFirst(tt);
|
||||
EventDataType c,last;
|
||||
//if (gain==0) gain=1;
|
||||
|
||||
EventList *el=sess->AddEventList(code,EVL_Event,es.gain,es.offset,min,max);
|
||||
int startpos=0;
|
||||
@ -644,10 +641,8 @@ bool ResmedLoader::LoadSAD(Session *sess,EDFParser &edf)
|
||||
ChannelID code;
|
||||
if (edf.edfsignals[s]->label=="Pulse") {
|
||||
code=OXI_Pulse;
|
||||
//sess->machine()->registerChannel(code);
|
||||
} else if (edf.edfsignals[s]->label=="SpO2") {
|
||||
code=OXI_SPO2;
|
||||
//sess->machine()->registerChannel(code);
|
||||
} else {
|
||||
qDebug() << "Unobserved ResMed SAD Signal " << edf.edfsignals[s]->label;
|
||||
continue;
|
||||
@ -694,43 +689,23 @@ bool ResmedLoader::LoadPLD(Session *sess,EDFParser &edf)
|
||||
//qDebug() << "EVE:" << es.digital_maximum << es.digital_minimum << es.physical_maximum << es.physical_minimum << es.gain;
|
||||
if (es.label=="Snore Index") {
|
||||
code=CPAP_Snore;
|
||||
|
||||
//EventList *a=new EventList(code,EVL_Waveform,es.gain,es.offset,es.physical_minimum,es.physical_maximum,rate);
|
||||
//sess->eventlist[code].push_back(a);
|
||||
//a->AddWaveform(edf.startdate,es.data,recs,duration);
|
||||
a=ToTimeDelta(sess,edf,es, code,recs,duration,0,0);
|
||||
//a->setMax(1);
|
||||
//a->setMin(0);
|
||||
} else if (es.label=="Therapy Pres") {
|
||||
code=CPAP_Pressure; //TherapyPressure;
|
||||
//sess->settings[CPAP_Mode]=MODE_APAP;
|
||||
//EventList *a=new EventList(code,EVL_Waveform,es.gain,es.offset,es.physical_minimum,es.physical_maximum,rate);
|
||||
//sess->eventlist[code].push_back(a);
|
||||
//a->AddWaveform(edf.startdate,es.data,recs,duration);
|
||||
a=ToTimeDelta(sess,edf,es, code,recs,duration,0,0);
|
||||
} else if (es.label=="Insp Pressure") {
|
||||
code=CPAP_IPAP; //TherapyPressure;
|
||||
sess->settings[CPAP_Mode]=MODE_BIPAP;
|
||||
//EventList *a=new EventList(code,EVL_Waveform,es.gain,es.offset,es.physical_minimum,es.physical_maximum,rate);
|
||||
//sess->eventlist[code].push_back(a);
|
||||
//a->AddWaveform(edf.startdate,es.data,recs,duration);
|
||||
a=ToTimeDelta(sess,edf,es, code,recs,duration,0,0);
|
||||
} else if (es.label=="MV") {
|
||||
code=CPAP_MinuteVent;
|
||||
//EventList *a=new EventList(code,EVL_Waveform,es.gain,es.offset,es.physical_minimum,es.physical_maximum,rate);
|
||||
//sess->eventlist[code].push_back(a);
|
||||
//a->AddWaveform(edf.startdate,es.data,recs,duration);
|
||||
a=ToTimeDelta(sess,edf,es, code,recs,duration,0,0);
|
||||
} else if (es.label=="RR") {
|
||||
code=CPAP_RespRate;
|
||||
a=sess->AddEventList(code,EVL_Waveform,es.gain,es.offset,0,0,rate);
|
||||
a->AddWaveform(edf.startdate,es.data,recs,duration);
|
||||
//ToTimeDelta(sess,edf,es, code,recs,duration);
|
||||
} else if (es.label=="Vt") {
|
||||
code=CPAP_TidalVolume;
|
||||
//EventList *a=new EventList(code,EVL_Waveform,es.gain,es.offset,es.physical_minimum,es.physical_maximum,rate);
|
||||
//sess->eventlist[code].push_back(a);
|
||||
//a->AddWaveform(edf.startdate,es.data,recs,duration);
|
||||
es.physical_maximum=es.physical_minimum=0;
|
||||
es.gain*=1000.0;
|
||||
a=ToTimeDelta(sess,edf,es, code,recs,duration,0,0);
|
||||
@ -738,20 +713,12 @@ bool ResmedLoader::LoadPLD(Session *sess,EDFParser &edf)
|
||||
code=CPAP_Leak;
|
||||
es.gain*=60;
|
||||
es.physical_dimension="L/M";
|
||||
//es.gain=1;//10.0;
|
||||
//es.offset=-0.5;
|
||||
a=ToTimeDelta(sess,edf,es, code,recs,duration,0,0);
|
||||
//a->setMax(1);
|
||||
//a->setMin(0);
|
||||
} else if (es.label=="FFL Index") {
|
||||
code=CPAP_FLG;
|
||||
//es.gain=1;//10.0;
|
||||
a=ToTimeDelta(sess,edf,es, code,recs,duration,0,0);
|
||||
//a->setMax(1);
|
||||
//a->setMin(0);
|
||||
} else if (es.label.startsWith("Mask Pres")) {
|
||||
code=CPAP_MaskPressure;
|
||||
//es.gain=1;
|
||||
a=ToTimeDelta(sess,edf,es, code,recs,duration,0,0);
|
||||
} else if (es.label.startsWith("Exp Press")) {
|
||||
code=CPAP_EPAP;//ExpiratoryPressure;
|
||||
@ -787,7 +754,6 @@ bool ResmedLoader::LoadPLD(Session *sess,EDFParser &edf)
|
||||
a=NULL;
|
||||
}
|
||||
if (a) {
|
||||
//sess->machine()->registerChannel(code);
|
||||
sess->setMin(code,a->min());
|
||||
sess->setMax(code,a->max());
|
||||
a->setDimension(es.physical_dimension);
|
||||
|
@ -32,27 +32,24 @@ QStatusBar *qstatusbar;
|
||||
|
||||
void MainWindow::Log(QString s)
|
||||
{
|
||||
static QMutex loglock,strlock;
|
||||
static int start=QDateTime::currentDateTime().toTime_t();
|
||||
static QStringList slist;
|
||||
//if (!loglock.tryLock()) {
|
||||
//return;
|
||||
//}
|
||||
loglock.lock();
|
||||
// if (!loglock.tryLock()) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
strlock.lock();
|
||||
QString tmp=QString("%1: %2").arg(QDateTime::currentDateTime().toTime_t()-start,5,10,QChar('0')).arg(s);
|
||||
QString tmp=QString("%1: %2").arg(logtime.elapsed(),5,10,QChar('0')).arg(s);
|
||||
|
||||
slist.append(tmp); //QStringList appears not to be threadsafe
|
||||
logbuffer.append(tmp); //QStringList appears not to be threadsafe
|
||||
strlock.unlock();
|
||||
|
||||
strlock.lock();
|
||||
for (int i=0;i<slist.size();i++)
|
||||
ui->logText->appendPlainText(slist[i]);
|
||||
slist.clear();
|
||||
// only do this in the main thread?
|
||||
for (int i=0;i<logbuffer.size();i++)
|
||||
ui->logText->appendPlainText(logbuffer[i]);
|
||||
logbuffer.clear();
|
||||
strlock.unlock();
|
||||
|
||||
loglock.unlock();
|
||||
//loglock.unlock();
|
||||
|
||||
}
|
||||
|
||||
@ -61,6 +58,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
{
|
||||
logtime.start();
|
||||
ui->setupUi(this);
|
||||
this->setWindowTitle(tr("SleepyHead")+QString(" v%1.%2.%3").arg(major_version).arg(minor_version).arg(revision_number));
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
|
@ -104,6 +104,11 @@ private:
|
||||
bool first_load;
|
||||
Profile *profile;
|
||||
QNetworkAccessManager *netmanager;
|
||||
|
||||
QMutex loglock,strlock;
|
||||
QStringList logbuffer;
|
||||
QTime logtime;
|
||||
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
Loading…
Reference in New Issue
Block a user