mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-19 04:00:45 +00:00
Fixed hang in oximetry import
This commit is contained in:
parent
0af002fdda
commit
8a9e59d489
@ -54,6 +54,7 @@ if (win32-msvc2008|win32-msvc2010|win32-msvc2012):!equals(TEMPLATE_PREFIX, "vc")
|
|||||||
include(3rdparty/qextserialport/src/qextserialport.pri)
|
include(3rdparty/qextserialport/src/qextserialport.pri)
|
||||||
include(3rdparty/quazip-0.5.1/quazip/quazip.pri)
|
include(3rdparty/quazip-0.5.1/quazip/quazip.pri)
|
||||||
|
|
||||||
|
#include(SleepLib2/sleeplib.pri)
|
||||||
|
|
||||||
SOURCES += main.cpp\
|
SOURCES += main.cpp\
|
||||||
SleepLib/machine.cpp \
|
SleepLib/machine.cpp \
|
||||||
|
32
oximetry.cpp
32
oximetry.cpp
@ -404,11 +404,9 @@ Session *SerialOximeter::createSession(QDateTime date)
|
|||||||
|
|
||||||
bool SerialOximeter::startLive()
|
bool SerialOximeter::startLive()
|
||||||
{
|
{
|
||||||
modeLock.lock();
|
|
||||||
import_mode=false;
|
import_mode=false;
|
||||||
killTimers();
|
killTimers();
|
||||||
m_mode=SO_LIVE;
|
m_mode=SO_LIVE;
|
||||||
modeLock.unlock();
|
|
||||||
|
|
||||||
lastpr=lasto2=0;
|
lastpr=lasto2=0;
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
@ -421,10 +419,8 @@ bool SerialOximeter::startLive()
|
|||||||
|
|
||||||
void SerialOximeter::stopLive()
|
void SerialOximeter::stopLive()
|
||||||
{
|
{
|
||||||
modeLock.lock();
|
|
||||||
if (timer->isActive()) timer->stop();
|
if (timer->isActive()) timer->stop();
|
||||||
m_mode=SO_WAIT;
|
m_mode=SO_WAIT;
|
||||||
modeLock.unlock();
|
|
||||||
if (session) {
|
if (session) {
|
||||||
compactAll();
|
compactAll();
|
||||||
calcSPO2Drop(session);
|
calcSPO2Drop(session);
|
||||||
@ -612,7 +608,6 @@ void CMS50Serial::import_process()
|
|||||||
|
|
||||||
void CMS50Serial::ReadyRead()
|
void CMS50Serial::ReadyRead()
|
||||||
{
|
{
|
||||||
modeLock.lock();
|
|
||||||
if (m_mode==SO_OFF)
|
if (m_mode==SO_OFF)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -626,10 +621,8 @@ void CMS50Serial::ReadyRead()
|
|||||||
if (m_mode==SO_WAIT) {
|
if (m_mode==SO_WAIT) {
|
||||||
killTimers();
|
killTimers();
|
||||||
// Close();
|
// Close();
|
||||||
modeLock.unlock();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
modeLock.unlock();
|
|
||||||
|
|
||||||
m_callbacks++;
|
m_callbacks++;
|
||||||
if (!import_mode) {
|
if (!import_mode) {
|
||||||
@ -887,7 +880,6 @@ bool CMS50Serial::startImport()
|
|||||||
data.clear();
|
data.clear();
|
||||||
|
|
||||||
killTimers();
|
killTimers();
|
||||||
modeLock.lock();
|
|
||||||
|
|
||||||
m_mode=SO_IMPORT;
|
m_mode=SO_IMPORT;
|
||||||
import_mode=true;
|
import_mode=true;
|
||||||
@ -906,13 +898,10 @@ bool CMS50Serial::startImport()
|
|||||||
|
|
||||||
connect(this,SIGNAL(importProcess()),this,SLOT(import_process()));
|
connect(this,SIGNAL(importProcess()),this,SLOT(import_process()));
|
||||||
|
|
||||||
modeLock.unlock();
|
|
||||||
|
|
||||||
if (!m_opened && !Open(QextSerialPort::EventDriven)) {
|
if (!m_opened && !Open(QextSerialPort::EventDriven)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// doesn't need to happen until process..
|
// doesn't need to happen until process..
|
||||||
createSession();
|
createSession();
|
||||||
|
|
||||||
@ -928,23 +917,19 @@ void CMS50Serial::stopImport() // Silently stops import dead
|
|||||||
{
|
{
|
||||||
disconnect(this,SIGNAL(importProcess()),this,SLOT(import_process()));
|
disconnect(this,SIGNAL(importProcess()),this,SLOT(import_process()));
|
||||||
|
|
||||||
modeLock.lock();
|
|
||||||
m_mode=SO_OFF;
|
m_mode=SO_OFF;
|
||||||
// killTimers();
|
// killTimers();
|
||||||
started_import=false;
|
started_import=false;
|
||||||
import_mode=false;
|
import_mode=false;
|
||||||
finished_import=false;
|
finished_import=false;
|
||||||
modeLock.unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMS50Serial::startImportTimeout()
|
void CMS50Serial::startImportTimeout()
|
||||||
{
|
{
|
||||||
modeLock.lock();
|
|
||||||
if ((m_mode==SO_WAIT) || (m_mode==SO_OFF)
|
if ((m_mode==SO_WAIT) || (m_mode==SO_OFF)
|
||||||
||finished_import
|
||finished_import
|
||||||
||started_import) {
|
||started_import) {
|
||||||
|
|
||||||
modeLock.unlock();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Wait until events really are jammed on the CMS50D+ before re-requesting data.
|
// Wait until events really are jammed on the CMS50D+ before re-requesting data.
|
||||||
@ -954,18 +939,15 @@ void CMS50Serial::startImportTimeout()
|
|||||||
if (elapsed>30) { // Give up after ~20 seconds
|
if (elapsed>30) { // Give up after ~20 seconds
|
||||||
m_mode=SO_WAIT;
|
m_mode=SO_WAIT;
|
||||||
killTimers();
|
killTimers();
|
||||||
modeLock.unlock();
|
|
||||||
emit(importAborted());
|
emit(importAborted());
|
||||||
mainwin->getOximetry()->graphView()->setEmptyText(tr("Import Failed"));
|
mainwin->getOximetry()->graphView()->setEmptyText(tr("Import Failed"));
|
||||||
mainwin->getOximetry()->graphView()->timedRedraw(50);
|
mainwin->getOximetry()->graphView()->timedRedraw(50);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
modeLock.unlock();
|
|
||||||
QString a=tr("Set Oximeter to Upload");
|
QString a=tr("Set Oximeter to Upload");
|
||||||
for (int j=0;j<elapsed;j++) a+=".";
|
for (int j=0;j<elapsed;j++) a+=".";
|
||||||
mainwin->getOximetry()->graphView()->setEmptyText(a);
|
mainwin->getOximetry()->graphView()->setEmptyText(a);
|
||||||
mainwin->getOximetry()->graphView()->timedRedraw(50);
|
mainwin->getOximetry()->graphView()->timedRedraw(50);
|
||||||
modeLock.lock();
|
|
||||||
// Note: Newer CMS50 devices transmit from user input
|
// Note: Newer CMS50 devices transmit from user input
|
||||||
requestData();
|
requestData();
|
||||||
}
|
}
|
||||||
@ -973,13 +955,10 @@ void CMS50Serial::startImportTimeout()
|
|||||||
// Schedule another callback to make sure it's started
|
// Schedule another callback to make sure it's started
|
||||||
cms50timer->singleShot(1000,this,SLOT(startImportTimeout()));
|
cms50timer->singleShot(1000,this,SLOT(startImportTimeout()));
|
||||||
}
|
}
|
||||||
modeLock.unlock();
|
|
||||||
}
|
}
|
||||||
void CMS50Serial::resetImportTimeout()
|
void CMS50Serial::resetImportTimeout()
|
||||||
{
|
{
|
||||||
modeLock.lock();
|
|
||||||
if ((m_mode==SO_WAIT)||(finished_import)) {
|
if ((m_mode==SO_WAIT)||(finished_import)) {
|
||||||
modeLock.unlock();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1004,14 +983,12 @@ void CMS50Serial::resetImportTimeout()
|
|||||||
m_mode=SO_WAIT; // Temporarily pause until complete shutdown.
|
m_mode=SO_WAIT; // Temporarily pause until complete shutdown.
|
||||||
|
|
||||||
emit(importProcess());
|
emit(importProcess());
|
||||||
modeLock.unlock();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qDebug() << "Should CMS50 resetImportTimeout reach here?";
|
qDebug() << "Should CMS50 resetImportTimeout reach here?";
|
||||||
// else what???
|
// else what???
|
||||||
}
|
}
|
||||||
cb_reset=imp_callbacks;
|
cb_reset=imp_callbacks;
|
||||||
modeLock.unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1194,9 +1171,8 @@ void Oximetry::serialImport()
|
|||||||
connectDeviceMsgBox=new QMessageBox(QMessageBox::Information,tr("Connect Oximeter"),tr("Please connect oximeter device"),
|
connectDeviceMsgBox=new QMessageBox(QMessageBox::Information,tr("Connect Oximeter"),tr("Please connect oximeter device"),
|
||||||
QMessageBox::Cancel);
|
QMessageBox::Cancel);
|
||||||
connect(connectDeviceMsgBox,SIGNAL(buttonClicked(QAbstractButton*)),this,SLOT(cancel_CheckPorts(QAbstractButton*)));
|
connect(connectDeviceMsgBox,SIGNAL(buttonClicked(QAbstractButton*)),this,SLOT(cancel_CheckPorts(QAbstractButton*)));
|
||||||
connectDeviceMsgBox->setModal(false);
|
connectDeviceMsgBox->exec();
|
||||||
connectDeviceMsgBox->show();
|
// QApplication::processEvents();
|
||||||
QApplication::processEvents();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Oximetry::cancel_CheckPorts(QAbstractButton*b)
|
void Oximetry::cancel_CheckPorts(QAbstractButton*b)
|
||||||
@ -1246,10 +1222,8 @@ void Oximetry::timeout_CheckPorts()
|
|||||||
//connectDeviceMsgBox=NULL;
|
//connectDeviceMsgBox=NULL;
|
||||||
connectDeviceMsgBox=new QMessageBox(QMessageBox::Information,tr("Device Connected"),tr("Please make sure Oximeter device is in upload mode."),
|
connectDeviceMsgBox=new QMessageBox(QMessageBox::Information,tr("Device Connected"),tr("Please make sure Oximeter device is in upload mode."),
|
||||||
QMessageBox::Cancel);
|
QMessageBox::Cancel);
|
||||||
connectDeviceMsgBox->setModal(false);
|
|
||||||
connect(connectDeviceMsgBox,SIGNAL(buttonClicked(QAbstractButton*)),this,SLOT(cancel_CheckPorts(QAbstractButton*)));
|
connect(connectDeviceMsgBox,SIGNAL(buttonClicked(QAbstractButton*)),this,SLOT(cancel_CheckPorts(QAbstractButton*)));
|
||||||
connectDeviceMsgBox->show();
|
connectDeviceMsgBox->exec();
|
||||||
QApplication::processEvents();
|
|
||||||
//mainwin->Notify(tr("Please make sure Oximeter device is in upload mode."),tr("Device Connected"));
|
//mainwin->Notify(tr("Please make sure Oximeter device is in upload mode."),tr("Device Connected"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +213,6 @@ protected:
|
|||||||
EventDataType lasto2,lastpr;
|
EventDataType lasto2,lastpr;
|
||||||
|
|
||||||
QByteArray buffer;
|
QByteArray buffer;
|
||||||
QMutex modeLock;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! \class CMS50Serial
|
/*! \class CMS50Serial
|
||||||
|
Loading…
Reference in New Issue
Block a user