diff --git a/oximetry.cpp b/oximetry.cpp index 456553c2..297bd0bd 100644 --- a/oximetry.cpp +++ b/oximetry.cpp @@ -217,13 +217,47 @@ void SerialOximeter::addPlethy(qint64 time, EventDataType pleth) session->set_last(lasttime); plethy->setLast(time); } -void SerialOximeter::compactEventList(EventList *el) +void SerialOximeter::compactToWaveform(EventList *el) { double rate=double(el->duration())/double(el->count()); el->setType(EVL_Waveform); el->setRate(rate); el->getTime().clear(); } +void SerialOximeter::compactToEvent(EventList *el) +{ + EventList nel(EVL_Waveform); + EventDataType t,lastt=el->data(0); + qint64 ti=el->time(0); + for (qint32 i=0;icount();i++) { + t=el->data(i); + if (t!=lastt) { + nel.AddEvent(ti,lastt); + ti=el->time(i); + } + + lastt=t; + } + nel.AddEvent(el->last(),t); + + el->getData().clear(); + el->getTime().clear(); + el->setCount(nel.count()); + + el->getData()=nel.getData(); + el->getTime()=nel.getTime(); + + +/* for (int i=0;igetData().push_back(nel.data(i)); + el->getTime().push_back(nel.g) + }*/ + + /*double rate=double(el->duration())/double(el->count()); + el->setType(EVL_Waveform); + el->setRate(rate); + el->getTime().clear();*/ +} void SerialOximeter::compactAll() { @@ -231,7 +265,11 @@ void SerialOximeter::compactAll() for (i=session->eventlist.begin();i!=session->eventlist.end();i++) { for (int j=0;jmin()min(); if (pulse->max()>plmax) plmax=pulse->max(); plcnt+=pulse->count(); - compactEventList(pulse); // converts to waveform.. + compactToEvent(pulse); // converts to waveform.. pulse=new EventList(EVL_Event); session->eventlist[OXI_Pulse].push_back(pulse); @@ -348,7 +386,7 @@ void CMS50Serial::on_import_process() if (spo2->min()min(); if (spo2->max()>o2max) o2max=spo2->max(); o2cnt+=spo2->count(); - compactEventList(spo2); // convert to waveform + compactToEvent(spo2); // convert to waveform spo2=new EventList(EVL_Event); session->eventlist[OXI_SPO2].push_back(spo2); } diff --git a/oximetry.h b/oximetry.h index bf51774a..efb198df 100644 --- a/oximetry.h +++ b/oximetry.h @@ -42,7 +42,8 @@ public: Session *createSession(); Session * getSession() { return session; } - void compactEventList(EventList *e); + void compactToWaveform(EventList *el); + void compactToEvent(EventList *el); void compactAll(); void setPortName(QString portname);