import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
+import android.util.Log;
import com.ic.protocolSrv.Config;
import com.ic.protocolSrv.Constants;
ICLogger.d("result invalidate...");
runtime.getHRS().setHeartrateStat(heartRateStatus.HEARTRATE_WORKINGSTAT.HEARTRATE_TEST_FAILED);
uploadResult();
- }else {
+ } else {
//BY TrillGates
//判断是否有超出阀值
//如果超出的话,插入一条警告通知
} else {
ICLogger.i("PPG Failed for Timeout! send 0 message to server");
if (!Runtime.practising) {
- StringMessage PPGDATA = protocolAPIHelper.getPPG_ECG_MSG(runtime,0,0,0,0);
+ StringMessage PPGDATA = protocolAPIHelper.getPPG_ECG_MSG(runtime, 0, 0, 0, 0);
//因为协议中没有时间变量,所以只能实时传输,如果恰巧没有网络也只能丢弃,有时间变量的话,可以考虑通过deliver的buffer来进行缓存发送
if (PPGDATA == null) {
StringMessage ppgd = protocolAPIHelper.getPPG_MSG(0, this.runtime);
- StringMessage bloodd = protocolAPIHelper.getBlood_MSG(0,0, this.runtime);
+ StringMessage bloodd = protocolAPIHelper.getBlood_MSG(0, 0, this.runtime);
StringMessage oxd = protocolAPIHelper.getOxygen_MSG(0, this.runtime);
Deliver.sendLocationMSG(ppgd);
Deliver.sendLocationMSG(bloodd);
}
}
//开始去测试
- ICLogger.d("from == > " + from + " HeartRateManager ");
+ ICLogger.d("from == > " + from + " HeartRateManager "
+ + " " + Log.getStackTraceString(new Throwable()));
new Thread(() -> {
try {
if (heartRateSensorService != null) {
+++ /dev/null
-package com.ic.protocolSrv.utils;
-
-import android.annotation.SuppressLint;
-
-import com.ic.protocolSrv.LocationClient;
-import com.ic.protocolSrv.bean.StringMessage;
-import com.ic.protocolSrv.service.Deliver;
-
-import java.util.concurrent.LinkedBlockingDeque;
-
-public class ServiceUtil {
-
- public static boolean offerQueue(StringMessage paramStringMessage) {
- return offerQueue(paramStringMessage, false);
- }
-
- public static boolean offerQueue(StringMessage paramStringMessage, boolean paramBoolean) {
- if (paramBoolean) {
- if (!Deliver.queue.offerFirst(paramStringMessage)) {
-// Deliver.saveQueue();
-// Deliver.queue.offerFirst(paramStringMessage);
- return false;
- }
- } else if (!Deliver.queue.offerLast(paramStringMessage)) {
-// Deliver.saveQueue();
-// Deliver.queue.offerLast(paramStringMessage);
- return false;
- }
- return true;
- }
-
-
-
-// public static void offerVideoQueue(OssFileContent paramOssFileContent, LinkedBlockingDeque<OssFileContent> paramLinkedBlockingDeque, FileCache paramFileCache) {
-// if (!paramLinkedBlockingDeque.offerLast(paramOssFileContent)) {
-// (new Thread(new Runnable(paramLinkedBlockingDeque, paramFileCache) {
-// public void run() { SendOssMessage.saveVideoPathQueue(queue, fileCache); }
-// })).start();
-// paramLinkedBlockingDeque.offerLast(paramOssFileContent);
-// }
-// }
-//
-// public static void offerVideoQueueForThread(OssFileContent paramOssFileContent, LinkedBlockingDeque<OssFileContent> paramLinkedBlockingDeque, FileCache paramFileCache) {
-// if (!paramLinkedBlockingDeque.offerLast(paramOssFileContent)) {
-// SendOssMessage.saveVideoPathQueue(paramLinkedBlockingDeque, paramFileCache);
-// paramLinkedBlockingDeque.offerLast(paramOssFileContent);
-// }
-// }
-}
-
+++ /dev/null
-package com.ic.protocolSrv.utils;
-
-import android.text.TextUtils;
-import android.util.Log;
-
-import com.ic.protocolSrv.bean.TemperatureItem;
-import com.ic.jni.ICJniUtils;
-
-public class TempAlgUtil {
- private static String TAG = "TemperatureUtil";
-
- private static double temp_value_orig = 0.0f;
- 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;
- }
-
-
- public static void enableTemp() {
- if (ICJniUtils.isTemperatureDevAvailable() > ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_NONE.ordinal()) {
- ICJniUtils.disablePedometer();
- ICJniUtils.enableTemperature();
- mSleep(1000);
- }
- }
-
- public static void disableTemp() {
- if (ICJniUtils.isTemperatureDevAvailable() > ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_NONE.ordinal()) {
- ICJniUtils.disableTemperature();
- ICJniUtils.enablePedometer();
- }
- }
-
- public static void mSleep(int ms) {
- try {
- Thread.yield();
- Thread.sleep(ms);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- //thermal_zone0
- public static final String CMD_CPU_TEM = "/sys/class/thermal/thermal_zone0/temp";
- public static final String CMD_CPU_TYPE = "/sys/class/thermal/thermal_zone0/type";
- //thermal_zone1
- public static final String CMD_GPU_TEM = "/sys/class/thermal/thermal_zone1/temp";
- public static final String CMD_GPU_TYPE = "/sys/class/thermal/thermal_zone1/type";
- //thermal_zone2
- public static final String CMD_CHARGE_TEM = "/sys/class/thermal/thermal_zone2/temp";
- public static final String CMD_CHARGE_TYPE = "/sys/class/thermal/thermal_zone2/type";
- //thermal_zone3
- public static final String CMD_PA_TEM = "/sys/class/thermal/thermal_zone3/temp";
- public static final String CMD_PA_TYPE = "/sys/class/thermal/thermal_zone3/type";
- //thermal_zone4
- public static final String CMD_BOARD_TEM = "/sys/class/thermal/thermal_zone4/temp";
- public static final String CMD_BOARD_TYPE = "/sys/class/thermal/thermal_zone4/type";
-
-
- /**
- * 这里获取到CPU温度,主板温度,体温,外温的数据,然后写到log里,后面转成数据表,再转成函数表达式。
- */
- public static TemperatureItem doTempTest() {
- if (ICJniUtils.isTemperatureDevAvailable() > ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_NONE.ordinal()) {
-
- double bodyTemp/*体温*/ = 0.0f;
- double cpuTemp/*cpu温度*/ = 0.0f;
- double evnTemp/*环境温度*/ = 0.0f;
- double gpuTemp/*gpu温度*/ = 0.0f;
- double chargeTemp/*充电板的温度*/ = 0.0f;
- double paTemp/*射频的温度*/ = 0.0f;
- double boardTemp/*主板的温度*/ = 0.0f;
- try {
- String cpuTempType = TempFileUtils.readFile(CMD_CPU_TYPE);
- String cpuTempStr = TempFileUtils.readFile(CMD_CPU_TEM);
- String gpuTempType = TempFileUtils.readFile(CMD_GPU_TYPE);
- String gpuTempStr = TempFileUtils.readFile(CMD_GPU_TEM);
- String chargeTempType = TempFileUtils.readFile(CMD_CHARGE_TYPE);
- String chargeTempStr = TempFileUtils.readFile(CMD_CHARGE_TEM);
- String paTempType = TempFileUtils.readFile(CMD_PA_TYPE);
- String paTempStr = TempFileUtils.readFile(CMD_PA_TEM);
- String boardTempType = TempFileUtils.readFile(CMD_BOARD_TYPE);
- String boardTempStr = TempFileUtils.readFile(CMD_BOARD_TEM);
- //cpuTempType == > cpu-thmzone cpuTempStr == > 45295 gpuTempType == > gpu-thmzone gpuTempStr == > 43910
- ICLogger.d( " cpuTempType == > " + cpuTempType +
- " cpuTempStr == > " + cpuTempStr +
- "\n | " +
- " gpuTempType == > " + gpuTempType +
- " gpuTempStr == > " + gpuTempStr
- + "\n | "
- + "chargeTempType == > " + chargeTempType +
- " chargeTempStr == > " + chargeTempStr
- + "\n | "
- + "paTempType == > " + paTempType +
- " paTempStr == > " + paTempStr
- + "\n | "
- + "boardTempType == > " + boardTempType +
- " boardTempStr == > " + boardTempStr
- );
- //数据处理一下
- cpuTemp = Integer.parseInt(cpuTempStr) / 1000.0f;
- gpuTemp = Integer.parseInt(gpuTempStr) / 1000.0f;
- chargeTemp = Integer.parseInt(chargeTempStr) / 1000.0f;
- paTemp = Integer.parseInt(paTempStr) / 1000.0f;
- boardTemp = Integer.parseInt(boardTempStr) / 1000.0f;
- } catch (Exception e) {
- e.printStackTrace();
- }
- evnTemp = get_tempOut_value_origin();
- bodyTemp = get_temp_value_adjusted();
- //对数据进行处理=======================================================start
- // 环境温度计算公式:
- // Ut=St-(0.6205x-22.049),St为传感器温度,其中x主板温度,x∈[38,56]
- // 体温计算公式:
- // Ut = St-(Bt*0.4533-15.294) St为传感器温度,Bt为板子温度 Bt∈[38,56]
- // 系数不要抽成常量,以后如果有更好的公式可以替换。
- // 以上公式通过数据分析出来的,此公式仅适用于S123的产品,公式跟产品结构有关系
- //TODO:以上重要,所以同时对外可支持配置,如果没有配置不进行数据处理,直接返回原数值
- //TODO:配置格式:
- // PRODUCT_PROPERTY_OVERRIDES += persist.sys.envTempAlgSlope=系数(斜率)
- // PRODUCT_PROPERTY_OVERRIDES += persist.sys.envTempAlgDy=Y轴偏移值
- //========================================================================//
- //环境温度的斜率和Y轴偏移值
- String envSlope = Util.getSystemProperties("persist.sys.envAlgSlope", "");
- String envDy = Util.getSystemProperties("persist.sys.envAlgDy", "");
- ICLogger.d("envSlope == > " + envSlope + " envDy == > " + envDy);
- double resultEnvTemp = evnTemp;
- if (!TextUtils.isEmpty(envDy) && !TextUtils.isEmpty(envSlope) && boardTemp > 39) {
- //进行换算
- ICLogger.d("env temp with board temp...");
- resultEnvTemp = evnTemp - (Float.parseFloat(envSlope) * boardTemp + Float.parseFloat(envDy));
- // resultEnvTemp = evnTemp - (0.8492 * boardTemp - 25.204);
- } else if (boardTemp <= 39 && boardTemp >= 27) {
- ICLogger.d("in range of 27 to 39");
- //Ut = St-(Bt*0.869-27.167) Bt∈[32,38)
- resultEnvTemp = evnTemp - (0.2441 * boardTemp - 2.3248);
- } else {
- //TODO:主板温度低于27度的,如果测试有这样的case,再采集数据
- }
- String bodySlope = Util.getSystemProperties("persist.sys.bodyAlgSlope", "");
- String bodyDy = Util.getSystemProperties("persist.sys.bodyAlgDy", "");
- ICLogger.d("bodySlope == > " + bodySlope + " bodyDy == > " + bodyDy);
- double resultBodyTemp = bodyTemp;
- if (!TextUtils.isEmpty(bodyDy) && !TextUtils.isEmpty(bodySlope)) {
- ICLogger.d("body temp with board temp...");
- resultBodyTemp = bodyTemp - (Float.parseFloat(bodySlope) * boardTemp + Float.parseFloat(bodyDy));
- }
-
- //=======================================================================end
- ICLogger.d("evnTemp == > " + evnTemp + " resultEnvTemp = > " + resultEnvTemp);
- ICLogger.d("bodyTemp == > " + bodyTemp + " resultBodyTemp = > " + resultBodyTemp);
- if (resultBodyTemp < 0) {
- return null;
- }
-
- try {
- //发送消息给launcher显示
- TemperatureItem temperatureItem = new TemperatureItem(
- String.format("%.01f", resultBodyTemp),
- String.format("%.01f", cpuTemp),
- String.format("%.01f", resultEnvTemp),
- String.format("%.01f", gpuTemp),
- String.format("%.01f", chargeTemp),
- String.format("%.01f", boardTemp),
- String.format("%.01f", paTemp));
- return temperatureItem;
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- return null;
- }
-}
+++ /dev/null
-package com.ic.protocolSrv.utils;
-
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-public class sysProperties {
-
- private static Method sysPropGet;
- private static Method sysPropSet;
-
- private sysProperties() {
- }
-
- static {
- try {
- Class S = Class.forName("android.os.SystemProperties");
- Method M[] = S.getMethods();
- for (Method m : M) {
- String n = m.getName();
- if (n.equals("get")) {
- sysPropGet = m;
- } else if (n.equals("set")) {
- sysPropSet = m;
- }
- }
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- ICLogger.e(e.getMessage(),e);
- }
- }
-
- public static String get(String name, String default_value) {
- try {
- return (String) sysPropGet.invoke(null, name, default_value);
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- ICLogger.e(e.getMessage(),e);
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- ICLogger.e(e.getMessage(),e);
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- ICLogger.e(e.getMessage(),e);
- }
- return default_value;
- }
-
- public static void set(String name, String value) {
- try {
- sysPropSet.invoke(null, name, value);
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- ICLogger.e(e.getMessage(),e);
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- ICLogger.e(e.getMessage(),e);
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- ICLogger.e(e.getMessage(),e);
- }
- }
-}
\ No newline at end of file