Enabled new SdAlgHr checks in SdDataSource - needs testing!

This commit is contained in:
Graham Jones
2023-04-28 20:37:01 +01:00
parent 2bac4a9522
commit 591b4a8319
3 changed files with 23 additions and 7 deletions

View File

@@ -49,6 +49,9 @@ public class CircBuf {
}
public int getNumVals() {
/**
* Returns the total count of values stored in the buffer (including error values).
*/
int numElements;
if (mIsFull) {
numElements = mBuffLen;
@@ -78,6 +81,10 @@ public class CircBuf {
}
public double getAverageVal() {
/**
* Returns the average of the values stored in the buffer, which do not equal the error value mErrVal.
* Error values are ignored.
*/
double hrSum = 0.;
int hrCount = 0;
double valArr[] = getVals();

View File

@@ -106,6 +106,8 @@ public class SdData implements Parcelable {
public boolean mHRAlarmStanding = false;
public boolean mHRFaultStanding = false;
public boolean mAdaptiveHRAlarmStanding = false;
public boolean mAverageHRAlarmStanding = false;
public double mHR = 0;
public boolean mO2SatAlarmStanding = false;
@@ -318,6 +320,9 @@ public class SdData implements Parcelable {
jsonObj.put("alarmRatioThresh", alarmRatioThresh);
jsonObj.put("hrAlarmActive", mHRAlarmActive);
jsonObj.put("hrAlarmStanding", mHRAlarmStanding);
jsonObj.put("adaptiveHrAlarmStanding", mAdaptiveHRAlarmStanding);
jsonObj.put("averageHrAlarmStanding", mAverageHRAlarmStanding);
jsonObj.put("hrAlarmStanding", mHRAlarmStanding);
jsonObj.put("hrThreshMin", mHRThreshMin);
jsonObj.put("hrThreshMax", mHRThreshMax);
jsonObj.put("hr", mHR);

View File

@@ -39,6 +39,7 @@ import org.json.JSONException;
import org.json.JSONObject;
import org.jtransforms.fft.DoubleFFT_1D;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Timer;
import java.util.TimerTask;
@@ -589,25 +590,28 @@ public abstract class SdDataSource {
*/
public void hrCheck() {
Log.v(TAG, "hrCheck()");
/* Check Heart Rate against alarm settings */
ArrayList<Boolean> checkResults;
checkResults = mSdAlgHr.checkHr(mSdData.mHR);
/* Check for heart rate fault condition */
if (mSdData.mHRAlarmActive) {
if (mSdData.mHR < 0) {
if (mSdData.mHRNullAsAlarm) {
Log.i(TAG, "Heart Rate Null - Alarming");
mSdData.mHRFaultStanding = false;
mSdData.mHRAlarmStanding = true;
mSdData.mAdaptiveHRAlarmStanding = false;
mSdData.mAverageHRAlarmStanding = false;
} else {
Log.i(TAG, "Heart Rate Fault (HR<0)");
mSdData.mHRFaultStanding = true;
mSdData.mHRAlarmStanding = false;
mSdData.mAdaptiveHRAlarmStanding = false;
mSdData.mAverageHRAlarmStanding = false;
}
} else if ((mSdData.mHR > mSdData.mHRThreshMax) || (mSdData.mHR < mSdData.mHRThreshMin)) {
Log.i(TAG, "Heart Rate Abnormal - " + mSdData.mHR + " bpm");
mSdData.mHRFaultStanding = false;
mSdData.mHRAlarmStanding = true;
} else {
mSdData.mHRFaultStanding = false;
mSdData.mHRAlarmStanding = false;
mSdData.mHRAlarmStanding = checkResults.get(0);
mSdData.mAdaptiveHRAlarmStanding = checkResults.get(1);
mSdData.mAverageHRAlarmStanding = checkResults.get(2);
}
}
}