From: TrillGates Date: Thu, 23 Sep 2021 09:17:28 +0000 (+0800) Subject: update MW13C algorithm. X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=adc9854121c5f332436f281bc5b90f9f77317196;p=icworkservice.git update MW13C algorithm. --- diff --git a/app/src/main/java/com/ic/work/SensorDataService.java b/app/src/main/java/com/ic/work/SensorDataService.java index abf9b06..d9c98d0 100644 --- a/app/src/main/java/com/ic/work/SensorDataService.java +++ b/app/src/main/java/com/ic/work/SensorDataService.java @@ -199,7 +199,11 @@ public class SensorDataService extends Service implements TemperatureHelper.Temp } sendTempBroadcast(wristTemp, bodyTemp, envTemp); //写到设置项里,供各个地方获取 - temperatureSave2Db(wristTemp, bodyTemp, envTemp); + try { + temperatureSave2Db(wristTemp, bodyTemp, envTemp); + } catch (Exception e) { + //有可能没有数据库 + } } public static final String PATH = "settings"; diff --git a/app/src/main/java/com/ic/work/utils/AlgorithmUtils.java b/app/src/main/java/com/ic/work/utils/AlgorithmUtils.java index 517405f..1c1711e 100644 --- a/app/src/main/java/com/ic/work/utils/AlgorithmUtils.java +++ b/app/src/main/java/com/ic/work/utils/AlgorithmUtils.java @@ -134,7 +134,24 @@ public class AlgorithmUtils { return sInstance; } + private final int ZERO_MAX_TIME = 20; + + private int zeroTime = 0; + public double MW13C(double bodyTemp, double boardTemp) throws TempValueException { + if (bodyTemp == 0.0) { + zeroTime++; + return 0.0; + } else { + zeroTime = 0; + } + if (zeroTime > ZERO_MAX_TIME) { + //超过20次,我们就认为传感器检测不到温度了 + zeroTime = 0; + throw new TempValueException( + mContext.getString(R.string.sensor_break) + ":" + bodyTemp, + ERROR_HARD_WEAR_ERROR); + } //对体温值进行检查 if (bodyTemp <= 28.0f) { throw new TempValueException( @@ -163,6 +180,7 @@ public class AlgorithmUtils { } public static final int ERROR_HARD_WEAR_TOO_HIGH = 1; + public static final int ERROR_HARD_WEAR_ERROR = 2; public static final int ERROR_SENSOR_TOO_HIGH = 3; public static final int ERROR_SENSOR_TOO_LOW = 4; diff --git a/app/src/main/java/com/ic/work/utils/TemperatureUtil.java b/app/src/main/java/com/ic/work/utils/TemperatureUtil.java index d2ddf1e..a16e331 100644 --- a/app/src/main/java/com/ic/work/utils/TemperatureUtil.java +++ b/app/src/main/java/com/ic/work/utils/TemperatureUtil.java @@ -136,7 +136,11 @@ public class TemperatureUtil { ICLogger.d("final wrist temp == > " + bodyTempResult); } } else if ("MW13C".equals(property)) { - AlgorithmUtils.getInstance(WorkServiceApp.sContext).MW13C(bodyTemp, boardTemp); + bodyTemp = AlgorithmUtils.getInstance(WorkServiceApp.sContext).MW13C(bodyTemp, boardTemp); + if (bodyTemp == 0) { + return null; + } + lastBodyTemp = getBodyTemp(bodyTemp, 26.1f); } else { // double bodyTempResult = AlgorithmUtils.l004Pt(bodyTemp, evnTemp); ICLogger.d("wrist TempResult == > " + bodyTemp); diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml new file mode 100644 index 0000000..12d2965 --- /dev/null +++ b/app/src/main/res/values-en/strings.xml @@ -0,0 +1,7 @@ + + IcWorkService + sensor temperature too low + sensor temperature too high + board temperature too high + 传感器检测不到温度 + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3f41099..4b04937 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,8 +1,8 @@ IcWorkService - 很抱歉,程序出现异常,即将退出 + 很抱歉,程序出现异常,即将退出 体温传感器温度过低 体温传感器温度过高 - 主板温度低影响测试结果 主板温度过高 + 传感器检测不到温度