Finally, this should fix CMS50 import freezing the oximeter

This commit is contained in:
Mark Watkins 2011-12-04 02:14:51 +10:00
parent 6d40ffcaf9
commit 310c40f8a4
2 changed files with 31 additions and 12 deletions

View File

@ -77,6 +77,7 @@ bool SerialOximeter::Open(QextSerialPort::QueryMode mode)
}
m_portmode=mode;
m_callbacks=0;
m_port=new QextSerialPort(m_portname,m_portmode);
m_port->setBaudRate(m_baud);
@ -469,6 +470,8 @@ void CMS50Serial::ReadyRead()
m_port->read(bytes.data(), bytes.size());
m_callbacks++;
if (m_mode==SO_WAIT) return;
int i=0;
// Was going out of sync previously.. To fix this unfortunately requires 4.7
@ -646,24 +649,37 @@ void CMS50Serial::requestData()
bool CMS50Serial::startImport()
{
m_mode=SO_IMPORT;
import_mode=true;
waitf6=true;
done_import=false;
cntf6=0;
failcnt=0;
//QMessageBox::information(0,"Get Ready","Please make sure your oximeter is switched on and in the correct mode for data transfer.",QMessageBox::Ok);
m_mode=SO_WAIT;
if (!Open(QextSerialPort::EventDriven)) return false;
QTimer::singleShot(200,this,SLOT(startImportTimeout()));
//make sure there is a data stream first..
createSession();
connect(this,SIGNAL(importProcess()),this,SLOT(import_process()));
requestData();
return true;
}
void CMS50Serial::startImportTimeout()
{
if (m_callbacks>0) {
connect(this,SIGNAL(importProcess()),this,SLOT(import_process()));
m_mode=SO_IMPORT;
import_mode=true;
waitf6=true;
done_import=false;
cntf6=0;
failcnt=0;
requestData();
} else {
resetDevice();
delete session;
qDebug() << "No oximeter signal!!!!!!!!!!!!!!!!";
emit(importAborted());
}
}
Oximetry::Oximetry(QWidget *parent,gGraphView * shared) :
QWidget(parent),
@ -1058,10 +1074,11 @@ void Oximetry::import_finished()
void Oximetry::import_aborted()
{
oximeter->disconnect(oximeter,SIGNAL(importProcess()),0,0);
day->getSessions().clear();
//QMessageBox::warning(mainwin,"Oximeter Error","Please make sure your oximeter is switched on, and able to transmit data.\n(You may need to enter the oximeters Settings screen for it to be able to transmit.)",QMessageBox::Ok);
mainwin->Notify("Oximeter Error!\n\nPlease make sure your oximeter is switched on, and in the right mode to transmit data.");
//qDebug() << "Oximetry import failed";
oximeter->disconnect(oximeter,SIGNAL(importProcess()),0,0);
import_finished();
}

View File

@ -20,7 +20,7 @@
#include "Graphs/gLineChart.h"
#include "Graphs/gFooBar.h"
enum SerialOxMode { SO_OFF, SO_IMPORT, SO_LIVE };
enum SerialOxMode { SO_OFF, SO_IMPORT, SO_LIVE, SO_WAIT };
class SerialOximeter:public QObject
{
Q_OBJECT
@ -90,6 +90,7 @@ protected slots:
virtual void ReadyRead()=0;
virtual void import_process()=0;
virtual void Timeout();
virtual void startImportTimeout()=0;
protected:
//virtual void addEvents(EventDataType pr, EventDataType o2, EventDataType pleth=-1000000);
@ -135,6 +136,7 @@ public:
virtual void requestData();
protected:
virtual void startImportTimeout();
virtual void import_process();
virtual void ReadyRead();