修改温度检测逻辑,去掉无用检测操作
authorsnickersun <scy@incartech.cn>
Mon, 28 Dec 2020 13:18:10 +0000 (21:18 +0800)
committersnickersun <scy@incartech.cn>
Mon, 28 Dec 2020 13:18:10 +0000 (21:18 +0800)
app/src/main/java/com/enqualcomm/support/utils/TempAlgUtil.java
app/src/main/java/com/enqualcomm/support/utils/TemperatureUtil.java

index 95b6031..e72eed0 100644 (file)
@@ -13,13 +13,21 @@ public class TempAlgUtil {
     private static double tempOut_value = 0.0f;
 
     public static double get_tempOut_value_origin() {
+        long tmp=System.currentTimeMillis();
         tempOut_value = ICJniUtils.getTemperatureOrigin();
+        long tmp1=System.currentTimeMillis()-tmp;
+        if (tmp1>1000)
+            ICLogger.i("测量环境温度 原始值 " + tempOut_value+" 超过1秒 "+tmp1);
         ICLogger.i( "测量环境温度 原始值 " + tempOut_value);
         return tempOut_value;
     }
 
     public static double get_temp_value_adjusted() {
+        long tmp=System.currentTimeMillis();
         temp_value_orig = ICJniUtils.getTemperature();
+        long tmp1=System.currentTimeMillis()-tmp;
+        if (tmp1>1000)
+            ICLogger.i("测量体温 原始值 " + temp_value_orig+" 超过1秒 "+tmp1);
         ICLogger.i("测量体温 原始值 " + temp_value_orig);
         return temp_value_orig;
     }
index 891dcde..5fec64d 100644 (file)
@@ -23,17 +23,26 @@ public class TemperatureUtil {
     private static double tempOut_value = 0.0f;
 
     public static double get_tempOut_value_origin() {
+        long tmp=System.currentTimeMillis();
         tempOut_value = ICJniUtils.getTemperatureOrigin();
-        ICLogger.i("测量环境温度 原始值 " + tempOut_value);
+        long tmp1=System.currentTimeMillis()-tmp;
+        if (tmp1>1000)
+            ICLogger.i("1测量环境温度 原始值 " + tempOut_value+" 超过1秒 "+tmp1);
+        ICLogger.i( "1测量环境温度 原始值 " + tempOut_value);
         return tempOut_value;
     }
 
     public static double get_temp_value_adjusted() {
+        long tmp=System.currentTimeMillis();
         temp_value_orig = ICJniUtils.getTemperature();
-        ICLogger.i("测量体温 原始值 " + temp_value_orig);
+        long tmp1=System.currentTimeMillis()-tmp;
+        if (tmp1>1000)
+            ICLogger.i("1测量体温 原始值 " + temp_value_orig+" 超过1秒 "+tmp1);
+        ICLogger.i("1测量体温 原始值 " + temp_value_orig);
         return temp_value_orig;
     }
 
+
     public static double getTempAdjustValue() {
 
         //   temp_adjust_value=ICJniUtils.getTemperatureAdjustValue();
@@ -51,13 +60,12 @@ public class TemperatureUtil {
 
     public static void doTempTestInThread() {
 
-        new Handler().postDelayed(new Runnable() {
+        ThreadPool.newInstance().submitThreadPool(new Runnable() {
             @Override
             public void run() {
-
                 DoTempTest();
             }
-        }, 500);
+        });
     }
 
     public static final String ACTION_TEMP_RESULT = "com.ic.action.temp_result";
@@ -100,14 +108,9 @@ public class TemperatureUtil {
 
             double wrist_temp, body_temp, temout;
             temout = 0.0f;
+            wrist_temp=0.0f;
+            body_temp=0.0f;
             while (true) {
-                wrist_temp = TemperatureUtil.get_temp_value_adjusted();
-                if (wrist_temp < 10) {
-                    Util.mSleep(1000);
-                    ICLogger.i("retry read temp for <10");
-                    wrist_temp = TemperatureUtil.get_temp_value_adjusted();
-                }
-
                 if (ICJniUtils.isTemperatureDevAvailable() == ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_IC68.ordinal()) {
                     //此处温度会走一个算法,跟主板挂钩,不同的主板有不同的公式,需要做实验,配置。
                     //具体可以点击进去看里面的代码。
@@ -123,29 +126,20 @@ public class TemperatureUtil {
                         } else {
                             body_temp = TemperatureUtil.getBodyTemp(wrist_temp, 26.0f);
                         }
-                    } else {
-                        ICLogger.log(TAG, "temperatureItem is null...");
-                        if (Config.disableWristTemp) {
-                            body_temp = wrist_temp;
-                        } else {
-                            temout = TemperatureUtil.get_tempOut_value_origin();
-                            if (temout < 10) {
-                                Util.mSleep(1000);
-                                ICLogger.i("retry read tempOut for <10");
-                                temout = TemperatureUtil.get_tempOut_value_origin();
-                            }
-                            if (temout > 60 || temout < 10) {
-                                temout = 0.0f;
-                            }
-                            if (temout > 10) {
-                                body_temp = TemperatureUtil.getBodyTemp(wrist_temp, temout);
-                            } else {
-                                body_temp = TemperatureUtil.getBodyTemp(wrist_temp, 26.0f);
-                            }
-                        }
                     }
                 } else {
-                    body_temp = TemperatureUtil.getBodyTemp(wrist_temp, 26.0f);
+                    wrist_temp = TemperatureUtil.get_temp_value_adjusted();
+                    if (wrist_temp < 10) {
+                        Util.mSleep(1000);
+                        ICLogger.i("retry read temp for <10");
+                        wrist_temp = TemperatureUtil.get_temp_value_adjusted();
+                    }
+                    ICLogger.log(TAG, "temperatureItem is null...");
+                    if (Config.disableWristTemp) {
+                        body_temp = wrist_temp;
+                    } else {
+                        body_temp = TemperatureUtil.getBodyTemp(wrist_temp, 26.0f);
+                    }
                 }
                 try {
                     Thread.sleep(1000);