import com.ic.work.domain.Temperature;
interface ITempSensorCallback {
-
+ oneway void onTemperatureTestError(in String message,in int code);
oneway void onTemperatureGet(in Temperature temperature);
oneway void onTemperatureUpdating(in Temperature temperature);
oneway void onGettingData();
checkContinue();
}
+ @Override
+ public void onTemperatureError(String message, int code) {
+ //通知监听的地方,测试出错
+ ICLogger.d("message==> " + message + " code==> " + code);
+ dispatchTemperatureTestError(message, code);
+ }
+
+ private void dispatchTemperatureTestError(String message, int code) {
+ synchronized (mLock) {
+ int i = temperatureCallbacks.beginBroadcast();
+ ICLogger.d("dispatchTemperatureTestError==> " + message);
+ try {
+ while (i > 0) {
+ i--;
+ temperatureCallbacks.getBroadcastItem(i).onTemperatureTestError(message, code);
+ }
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ } finally {
+ temperatureCallbacks.finishBroadcast();
+ }
+ }
+ }
+
@Override
public void onHeartRateUpdate(int high, int low, int heart, int oxygen) {
ICLogger.d("onHeartRateUpdate == > "
import com.ic.jni.ICJniUtils;
import com.ic.work.domain.TemperatureItem;
+import com.ic.work.utils.AlgorithmUtils;
import com.ic.work.utils.HardwareUtils;
import com.ic.work.utils.ICLogger;
import com.ic.work.utils.IcLog;
if (typeOrder == ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_IC68.ordinal()) {
//IC68走这个
IcLog.d(TAG, "type is == > IC68");
- temperatureItem = TemperatureUtil.doTempTest();
+ try {
+ temperatureItem = TemperatureUtil.doTempTest();
+ } catch (AlgorithmUtils.TempValueException e) {
+ //输出信息
+ if (mListener != null) {
+ mListener.onTemperatureError(e.getMessage(), e.getCode());
+ }
+ //停止测试,跳出循环以后,就会指定到Listener的onTemperatureResult结束
+ delayTimesInSeconds = 0;
+ continue;
+ }
if (temperatureItem != null) {
lastBodyTemp = Double.parseDouble(temperatureItem.getBodyTemp());
lastTempOut = Double.parseDouble(temperatureItem.getEvnTemp());
void onTemperatureUpdate(double wristTemp, double bodyTemp, double envTemp);
void onTemperatureResult(double wristTemp, double bodyTemp, double envTemp);
+
+ void onTemperatureError(String message, int code);
}
}
package com.ic.work.utils;
+import android.content.Context;
import android.text.TextUtils;
+import com.ic.work.R;
+
public class AlgorithmUtils {
private static final String TAG = "AlgorithmUtils";
//36.18~38.64:result = 0.0472*sourceTemp-0.1094
if (innerTemp >= 39.21f && innerTemp < 43.12f) {
//dx = (0.0472f * innerTemp - 0.1094f);
- dx = (0.749f * innerTemp)-26.592f;
+ dx = (0.749f * innerTemp) - 26.592f;
} else
//38.64~43.46:result = 0.0178*result+1.3565
if (innerTemp >= 43.12f && innerTemp < 43.61) {
}
-
public static double l56A(double bodyTemp, double innerTemp) {
double dx;
if (innerTemp <= 40.5f) {
return bodyTemp - dx;
}
+ private final Context mContext;
+
+ private AlgorithmUtils(Context context) {
+ this.mContext = context;
+ }
+
+
+ private static AlgorithmUtils sInstance = null;
+
+
+ public static AlgorithmUtils getInstance(Context context) {
+ if (sInstance == null) {
+ sInstance = new AlgorithmUtils(context);
+ }
+ return sInstance;
+ }
+
+ public double MW13C(double bodyTemp, double boardTemp) throws TempValueException {
+ //对体温值进行检查
+ if (bodyTemp <= 28.0f) {
+ throw new TempValueException(
+ mContext.getString(R.string.body_sensor_value_too_low_text) + ":" + bodyTemp,
+ ERROR_SENSOR_TOO_LOW);
+ } else if (bodyTemp > 39.0f) {
+ throw new TempValueException(
+ mContext.getString(R.string.body_sensor_value_too_high_text) + ":" + bodyTemp,
+ ERROR_SENSOR_TOO_HIGH);
+ }
+ //对主板温度值进行检查
+ 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;
+ }
+
+ public static final int ERROR_HARD_WEAR_TOO_HIGH = 1;
+ public static final int ERROR_SENSOR_TOO_HIGH = 3;
+ public static final int ERROR_SENSOR_TOO_LOW = 4;
+
+ public static class TempValueException extends Exception {
+ private final int mCode;
+
+ public int getCode() {
+ return mCode;
+ }
+
+
+ public TempValueException(String description, int code) {
+ super(description);
+ this.mCode = code;
+ }
+ }
+
}
import android.util.Log;
import com.ic.jni.ICJniUtils;
+import com.ic.work.WorkServiceApp;
import com.ic.work.domain.TemperatureItem;
public class TemperatureUtil {
/**
* 这里获取到CPU温度,主板温度,体温,外温的数据,然后写到log里,后面转成数据表,再转成函数表达式。
*/
- public static TemperatureItem doTempTest() {
+ public static TemperatureItem doTempTest() throws AlgorithmUtils.TempValueException {
if (ICJniUtils.isTemperatureDevAvailable() > ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_NONE.ordinal()) {
-
double bodyTemp/*体温*/ = 0.0f;
double cpuTemp/*cpu温度*/ = 0.0f;
double evnTemp/*环境温度*/ = 0.0f;
ICLogger.d("final body temp == > " + lastBodyTemp);
ICLogger.d("final wrist temp == > " + bodyTempResult);
}
+ } else if ("MW13C".equals(property)) {
+ AlgorithmUtils.getInstance(WorkServiceApp.sContext).MW13C(bodyTemp, boardTemp);
} else {
// double bodyTempResult = AlgorithmUtils.l004Pt(bodyTemp, evnTemp);
ICLogger.d("wrist TempResult == > " + bodyTemp);
lastBodyTemp = getBodyTemp(bodyTemp, 26.1f);
ICLogger.d("final body temp == > " + lastBodyTemp);
}
-
}
-
if (lastBodyTemp <= 0) {
return null;
}
<resources>
<string name="app_name">IcWorkService</string>
-
<string name="program_abnormal">很抱歉,程序出现异常,即将退出</string>
+ <string name="body_sensor_value_too_low_text">体温传感器温度过低</string>
+ <string name="body_sensor_value_too_high_text">体温传感器温度过高</string>
+ <string name="board_temperature_low_text">主板温度低影响测试结果</string>
+ <string name="board_temperature_high_text">主板温度过高</string>
</resources>