From: TrillGates Date: Mon, 27 Sep 2021 06:35:47 +0000 (+0800) Subject: update mw13c algorithm. X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=bd339cf2ef244770f767bda59f15d6741291b7ed;p=icworkservice.git update mw13c algorithm. --- 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 1c1711e..9e75de4 100644 --- a/app/src/main/java/com/ic/work/utils/AlgorithmUtils.java +++ b/app/src/main/java/com/ic/work/utils/AlgorithmUtils.java @@ -134,12 +134,13 @@ 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) { + public double MW13C(double wristTemp, double boardTemp, double batteryTemp) throws TempValueException { + if (wristTemp == 0.0) { zeroTime++; return 0.0; } else { @@ -149,40 +150,51 @@ public class AlgorithmUtils { //超过20次,我们就认为传感器检测不到温度了 zeroTime = 0; throw new TempValueException( - mContext.getString(R.string.sensor_break) + ":" + bodyTemp, + mContext.getString(R.string.sensor_break) + ":" + wristTemp, ERROR_HARD_WEAR_ERROR); } - //对体温值进行检查 - if (bodyTemp <= 28.0f) { + + //对体温值进行检查,如果温度小于某个阀值 + //那么我们认为用户佩戴时间不够长 + if (wristTemp <= 32.0f) { throw new TempValueException( - mContext.getString(R.string.body_sensor_value_too_low_text) + ":" + bodyTemp, - ERROR_SENSOR_TOO_LOW); - } else if (bodyTemp > 39.0f) { + mContext.getString(R.string.wear_time_too_short) + ":" + wristTemp, + ERROR_WEAR_TIME_TOO_SHORT); + } else if (wristTemp > 39.0f) { throw new TempValueException( - mContext.getString(R.string.body_sensor_value_too_high_text) + ":" + bodyTemp, + mContext.getString(R.string.body_sensor_value_too_high_text) + ":" + wristTemp, ERROR_SENSOR_TOO_HIGH); } + + //如果电池温度小于腕温,那么我们认为传感器温度是不受影响的 + //if (batteryTemp <= wristTemp) { + //当主板温度比较低的时候,可以认为主板对传感器温度不影响 + // return wristTemp; + //} + //对主板温度值进行检查 if (boardTemp > 53.4) { throw new TempValueException( mContext.getString(R.string.board_temperature_high_text) + ":" + boardTemp, ERROR_HARD_WEAR_TOO_HIGH); } - - //当主板温度比较低的时候,可以认为主板对传感器温度不影响 - double dx = 0.5326 * boardTemp - 22.51114f; - if (boardTemp < 40.3) { - //对此温度没有影响,直接返回传感器的温度即可 - return bodyTemp; - } - //可以计算 - return bodyTemp - dx; +// if (boardTemp > 41.0f) { +// double dx = 0.5326 * boardTemp - 22.51114f; +// //可以计算 +// return wristTemp - dx; +// } else { +// //当主板温度小于41度时: +// double dx = -0.6458f * boardTemp + 26.606f; +// return wristTemp + dx; +// } + return wristTemp; } 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; + public static final int ERROR_WEAR_TIME_TOO_SHORT = 5; public static class TempValueException extends Exception { private final int mCode; 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 2bb87c9..b9ca0cb 100644 --- a/app/src/main/java/com/ic/work/utils/TemperatureUtil.java +++ b/app/src/main/java/com/ic/work/utils/TemperatureUtil.java @@ -1,5 +1,8 @@ package com.ic.work.utils; +import android.content.Intent; +import android.content.IntentFilter; +import android.os.BatteryManager; import android.util.Log; import com.ic.jni.ICJniUtils; @@ -55,6 +58,8 @@ public class TemperatureUtil { return boardTemp; } + private static final IntentFilter batteryFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); + /** * 这里获取到CPU温度,主板温度,体温,外温的数据,然后写到log里,后面转成数据表,再转成函数表达式。 */ @@ -62,12 +67,17 @@ public class TemperatureUtil { if (ICJniUtils.isTemperatureDevAvailable() > ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_NONE.ordinal()) { double wristTemp/*腕温*/ = 0.0f; double cpuTemp/*cpu温度*/ = 0.0f; - double evnTemp/*环境温度*/ = 0.0f; + double envTemp/*环境温度*/ = 0.0f; double gpuTemp/*gpu温度*/ = 0.0f; //double chargeTemp/*充电板的温度*/ = 0.0f; // double paTemp/*射频的温度*/ = 0.0f; double boardTemp/*主板的温度*/ = 0.0f; + double batteryTemp/*电池温度*/ = 0.0f; try { + Intent intent = WorkServiceApp.sContext.registerReceiver(null, batteryFilter); + batteryTemp = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, -1); + batteryTemp /= 10; + ICLogger.d("batteryTemperature==> " + batteryTemp); String cpuTempType = TempFileUtils.readFile(CMD_CPU_TYPE); String cpuTempStr = TempFileUtils.readFile(CMD_CPU_TEM); String gpuTempType = TempFileUtils.readFile(CMD_GPU_TYPE); @@ -93,6 +103,7 @@ public class TemperatureUtil { + "\n | " + "boardTempType == > " + boardTempType + " boardTempStr == > " + boardTempStr + + " batteryTemp==> " + batteryTemp ); //数据处理一下 cpuTemp = Integer.parseInt(cpuTempStr) / 1000.0f; @@ -101,7 +112,7 @@ public class TemperatureUtil { } catch (Exception e) { //no crash is okay. } - evnTemp = get_tempOut_value_origin(); + envTemp = get_tempOut_value_origin(); wristTemp = get_temp_value_adjusted(); String property = Utils.getSystemProperties("persist.sys.id_num", null); @@ -110,7 +121,7 @@ public class TemperatureUtil { ICLogger.d("property == > " + property); double lastBodyTemp = 0.0; if ("l004pt".equals(property)) { - double bodyTempResult = AlgorithmUtils.l004Pt(wristTemp, evnTemp); + double bodyTempResult = AlgorithmUtils.l004Pt(wristTemp, envTemp); ICLogger.d("bodyTempResult == > " + bodyTempResult); //这个是换算后的腕温 if (bodyTempResult != -1) { @@ -121,7 +132,7 @@ public class TemperatureUtil { ICLogger.d("final wrist temp == > " + bodyTempResult); } } else if ("q3ft".equals(property)) { - resultEnvTemp = AlgorithmUtils.s123GetEnvData(evnTemp, boardTemp); + resultEnvTemp = AlgorithmUtils.s123GetEnvData(envTemp, boardTemp); resultWristTemp = AlgorithmUtils.s123GetBodyTemp(wristTemp, boardTemp); if (resultEnvTemp > 0.0f) { lastBodyTemp = TemperatureUtil.getBodyTemp(resultWristTemp, resultEnvTemp); @@ -129,10 +140,10 @@ public class TemperatureUtil { lastBodyTemp = TemperatureUtil.getBodyTemp(resultWristTemp, 26.0f); } - IcLog.d(TAG, "evnTemp == > " + evnTemp + " resultEnvTemp = > " + resultEnvTemp); + IcLog.d(TAG, "evnTemp == > " + envTemp + " resultEnvTemp = > " + resultEnvTemp); IcLog.d(TAG, "bodyTemp == > " + wristTemp + " resultWristTemp = > " + lastBodyTemp); } else if ("L56A".equals(property)) { - double bodyTempResult = AlgorithmUtils.l56A(wristTemp, evnTemp); + double bodyTempResult = AlgorithmUtils.l56A(wristTemp, envTemp); wristTemp = bodyTempResult; ICLogger.d("bodyTempResult == > " + bodyTempResult); if (bodyTempResult != -1) { @@ -143,11 +154,12 @@ public class TemperatureUtil { ICLogger.d("final wrist temp == > " + bodyTempResult); } } else if ("MW13C".equals(property)) { - wristTemp = AlgorithmUtils.getInstance(WorkServiceApp.sContext).MW13C(wristTemp, boardTemp); + wristTemp = AlgorithmUtils.getInstance(WorkServiceApp.sContext).MW13C(wristTemp, + boardTemp, batteryTemp); if (wristTemp == 0) { return null; } - lastBodyTemp = getBodyTemp(wristTemp, 26.1f); + lastBodyTemp = ICJniUtils.getBodyTempFromWristTemp(wristTemp, envTemp); } else { // double bodyTempResult = AlgorithmUtils.l004Pt(bodyTemp, evnTemp); ICLogger.d("wrist TempResult == > " + wristTemp); diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml index 12d2965..8dac462 100644 --- a/app/src/main/res/values-en/strings.xml +++ b/app/src/main/res/values-en/strings.xml @@ -4,4 +4,5 @@ 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 4b04937..1cefa39 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -5,4 +5,5 @@ 体温传感器温度过高 主板温度过高 传感器检测不到温度 + 佩戴时间过短