From 8813529f670491b479fe22e1b183ccf878dc9882 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Tue, 13 Dec 2011 05:15:46 +1000 Subject: [PATCH] Make PRS1 User flags search for nearby events to avoid double ups --- SleepLib/calcs.cpp | 102 +++++++++++++++++++++++++++------------------ daily.cpp | 1 + docs/channels.xml | 1 + 3 files changed, 64 insertions(+), 40 deletions(-) diff --git a/SleepLib/calcs.cpp b/SleepLib/calcs.cpp index 3bdca176..5edd4d9f 100644 --- a/SleepLib/calcs.cpp +++ b/SleepLib/calcs.cpp @@ -7,10 +7,60 @@ #include #include "calcs.h" #include "profiles.h" +bool SearchApnea(Session *session, qint64 time, qint64 dist=15000) +{ + qint64 t; + QHash >::iterator it; + it=session->eventlist.find(CPAP_Obstructive); + if (it!=session->eventlist.end()) { + for (int i=0;icount();j++) { + t=el->time(j); + if (qAbs(time-t)eventlist.find(CPAP_Apnea); + if (it!=session->eventlist.end()) { + for (int i=0;icount();j++) { + t=el->time(j); + if (qAbs(time-t)eventlist.find(CPAP_ClearAirway); + if (it!=session->eventlist.end()) { + for (int i=0;icount();j++) { + t=el->time(j); + if (qAbs(time-t)eventlist.find(CPAP_Hypopnea); + if (it!=session->eventlist.end()) { + for (int i=0;icount();j++) { + t=el->time(j); + if (qAbs(time-t)count(); @@ -155,30 +205,6 @@ int filterFlow(EventList *in, EventList *out, EventList *tv, EventList *mv, doub breaths_max.push_back(max); min=0; -// ringmax[rpos]=max; -// ringtime[rpos]=peakmax; - -// int zz=ringsize; -// if (i4) { -// q--; -// q&=0xff; -// if ((peakmax-ringtime[q])>8000) { -// uf1->AddEvent(peakmax,(double(ringtime[q])/1000.0),max); -// } -// break; -// } -// } - -// rpos++; -// rpos &= 0xff; - } } else { if (c<=min) { @@ -206,7 +232,6 @@ int filterFlow(EventList *in, EventList *out, EventList *tv, EventList *mv, doub for (int i=0;iAddEvent(breaths_min_peak[i],0,min); } avgmin/=EventDataType(breaths_min.size()); @@ -226,12 +251,20 @@ int filterFlow(EventList *in, EventList *out, EventList *tv, EventList *mv, doub goodb.push_back(time); } } + EventList *uf=NULL; + qSort(goodb); for (int i=1;i=10000) { time=goodb[i-1]+len/2; - uf1->AddEvent(time,0,1); + if (!SearchApnea(session,time)) { + if (!uf) { + uf=new EventList(EVL_Event,1,0,0,0,0,true); + session->eventlist["UserFlag1"].push_back(uf); + } + uf->AddEvent(time,0,1); + } } } @@ -347,7 +380,7 @@ int calcRespRate(Session *session) if (session->eventlist.contains(CPAP_RespRate)) return 0; // already exists? - EventList *flow, *rr=NULL, *tv=NULL, *mv=NULL, *uf=NULL, *uf2=NULL; + EventList *flow, *rr=NULL, *tv=NULL, *mv=NULL; if (!session->eventlist.contains(CPAP_TidalVolume)) { tv=new EventList(EVL_Event); @@ -363,8 +396,6 @@ int calcRespRate(Session *session) if (rr) session->eventlist[CPAP_RespRate].push_back(rr); if (tv) session->eventlist[CPAP_TidalVolume].push_back(tv); if (mv) session->eventlist[CPAP_MinuteVent].push_back(mv); - uf=new EventList(EVL_Event,1,0,0,0,0,true); - session->eventlist["UserFlag1"].push_back(uf); //uf2=new EventList(EVL_Event,1,0,0,0,0,true); //session->eventlist["UserFlag2"].push_back(uf2); @@ -373,16 +404,7 @@ int calcRespRate(Session *session) for (int ws=0; ws < session->eventlist[CPAP_FlowRate].size(); ws++) { flow=session->eventlist[CPAP_FlowRate][ws]; if (flow->count() > 5) { - - - if (flow->count()==103200) { - int i=5; - } - cnt+=filterFlow(flow,rr,tv,mv,flow->rate(),uf,uf2); - - if (tv->count()==0) { - int i=5; - } + cnt+=filterFlow(session, flow,rr,tv,mv,flow->rate()); } } return cnt; diff --git a/daily.cpp b/daily.cpp index 6b7558f9..92b29d5d 100644 --- a/daily.cpp +++ b/daily.cpp @@ -417,6 +417,7 @@ void Daily::UpdateEventsTree(QTreeWidget *tree,Day *day) && (code!=CPAP_ClearAirway) && (code!=CPAP_CSR) && (code!=CPAP_RERA) + && (code!="UserFlag1") && (code!=CPAP_NRI) && (code!=CPAP_LeakFlag) && (code!=CPAP_ExP) diff --git a/docs/channels.xml b/docs/channels.xml index e742fa4f..8767d49f 100644 --- a/docs/channels.xml +++ b/docs/channels.xml @@ -21,6 +21,7 @@ One id code per item +