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 {
//超过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;
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;
return boardTemp;
}
+ private static final IntentFilter batteryFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
+
/**
* 这里获取到CPU温度,主板温度,体温,外温的数据,然后写到log里,后面转成数据表,再转成函数表达式。
*/
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);
+ "\n | "
+ "boardTempType == > " + boardTempType +
" boardTempStr == > " + boardTempStr
+ + " batteryTemp==> " + batteryTemp
);
//数据处理一下
cpuTemp = Integer.parseInt(cpuTempStr) / 1000.0f;
} 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);
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) {
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);
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) {
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);