protocol_ic AP10 报警类型添加到18种
authorsnickersun <snickersun@qq.com>
Wed, 12 Aug 2020 01:16:27 +0000 (09:16 +0800)
committersnickersun <snickersun@qq.com>
Wed, 12 Aug 2020 01:16:27 +0000 (09:16 +0800)
添加血压,心率高低压 超阈值报警
添加体温阈值设置及报警
优化体温检测,统一接口。

app/src/main/java/com/enqualcomm/support/CoreService.java
app/src/main/java/com/enqualcomm/support/bean/Runtime.java
app/src/main/java/com/enqualcomm/support/bean/TemperatureInfo.java [new file with mode: 0644]
app/src/main/java/com/enqualcomm/support/bean/heartRateStatus.java
app/src/main/java/com/enqualcomm/support/service/HeartRateManager.java
app/src/main/java/com/enqualcomm/support/utils/TemperatureUtil.java
app/src/main/java/com/ic/protocols/protocol_beehome.java
app/src/main/java/com/ic/protocols/protocol_fzd.java
app/src/main/java/com/ic/protocols/protocol_ic.java

index 68837ef..89cf000 100644 (file)
@@ -918,11 +918,12 @@ public class CoreService extends Service {
                 if (this.mKeepAlive != null) {\r
                     if (connection.isServerConnected() && runtime.isServerProtocolConnected()) {\r
                         //测试温度并上报\r
-                        double wrist_temp=TemperatureUtil.get_temp_value_adjusted();\r
-                        double body_temp=TemperatureUtil.getBodyTemp(wrist_temp,26.0f);\r
-                        String temperatureMsg=getTemperatureMSG(wrist_temp,body_temp);\r
-                        ICLogger.i("发送体温测量值 "+temperatureMsg);\r
-                        Deliver.sendLocationMSG(temperatureMsg);\r
+                        TemperatureUtil.doTempTestInThread();\r
+//                        double wrist_temp=TemperatureUtil.get_temp_value_adjusted();\r
+//                        double body_temp=TemperatureUtil.getBodyTemp(wrist_temp,26.0f);\r
+//                        String temperatureMsg=getTemperatureMSG(wrist_temp,body_temp);\r
+//                        ICLogger.i("发送体温测量值 "+temperatureMsg);\r
+//                        Deliver.sendLocationMSG(temperatureMsg);\r
                     }\r
                     setTempAlarm();\r
                     if (Config.LOG_TOFILE)\r
index 145a380..fb9da50 100644 (file)
@@ -22,8 +22,9 @@ public class Runtime {
     public int temp_test_Cycle=60*60;\r
     public int anti_test_cycle=30;\r
 \r
- public int SignalStrength;\r
+    public int SignalStrength;\r
 \r
+    public TemperatureInfo tempInfo=new TemperatureInfo();\r
   public boolean BindingStatus=false;\r
   private String battery="000";\r
 \r
@@ -152,11 +153,28 @@ public class Runtime {
       ALARM_LOWBATTERY,\r
       ALARM_ANTIOFF,\r
       ALARM_WEARED,\r
+      ALARM_CUTOFF,//剪断报警\r
       ALARM_FALL,\r
+      ALARM_ABNORMAL_HEART_RATE,\r
+      ALARM_HEART_RATE_HIGH,\r
+      ALARM_HEART_RATE_LOW,\r
+      ALARM_BPH_HIGH,\r
+      ALARM_BPH_LOW,\r
+      ALARM_BPL_HIGH,\r
+      ALARM_BPL_LOW,\r
+      ALARM_SEDENTARY, //久坐提醒\r
+      ALARM_ILLEGAL_CUTOFF,\r
+      ALARM_LOCK_WATCH,\r
+      ALARM_TEMP_HIGH,\r
+      ALARM_TEMP_LOW,\r
       ALARM_NONE,\r
     };\r
-//  00为无任何报警(01:SOS,02:低电,03:脱落报警,04:佩戴提醒,05/06:跌倒报警))\r
-  public void setAlarmType(AlarmType alarm){\r
+/***\r
+ *    00为报警状态,00为无任何报警(01:SOS,02:低电,03:脱落报警,04:佩戴提醒,05:剪断报警,06:跌倒报警,\r
+ *    07:心率异常, 08:心率过高, 09:心率过低,10:收缩压过高,11:收缩压过低,12:舒张压过高,13:舒张压过低,\r
+ *    14:久坐提醒,15:非法解锁(剪断报警),16:锁定提醒(佩戴提醒),17:体温过高,18体温过低)\r
+  */\r
+   public void setAlarmType(AlarmType alarm){\r
 //    if ( !fall && !lowbattery && !sos && antioff)\r
 \r
       switch (alarm){\r
@@ -172,9 +190,60 @@ public class Runtime {
           case ALARM_WEARED:\r
               alarmType="04";\r
               break;\r
-          case ALARM_FALL:\r
+          case ALARM_CUTOFF:\r
               alarmType="05";\r
               break;\r
+          case ALARM_FALL:\r
+              alarmType="06";\r
+              break;\r
+\r
+          case ALARM_ABNORMAL_HEART_RATE:\r
+              alarmType="07";\r
+              break;\r
+\r
+          case ALARM_HEART_RATE_HIGH:\r
+              alarmType="08";\r
+              break;\r
+\r
+          case ALARM_HEART_RATE_LOW:\r
+              alarmType="09";\r
+              break;\r
+\r
+          case ALARM_BPH_HIGH:\r
+              alarmType="10";\r
+              break;\r
+\r
+          case ALARM_BPH_LOW:\r
+              alarmType="11";\r
+              break;\r
+\r
+          case ALARM_BPL_HIGH:\r
+              alarmType="12";\r
+              break;\r
+\r
+          case ALARM_BPL_LOW:\r
+              alarmType="13";\r
+              break;\r
+\r
+          case ALARM_SEDENTARY:\r
+              alarmType="14";\r
+              break;\r
+\r
+          case ALARM_ILLEGAL_CUTOFF:\r
+              alarmType="15";\r
+              break;\r
+\r
+          case ALARM_LOCK_WATCH:\r
+              alarmType="16";\r
+              break;\r
+\r
+          case ALARM_TEMP_HIGH:\r
+              alarmType="17";\r
+              break;\r
+\r
+          case ALARM_TEMP_LOW:\r
+              alarmType="18";\r
+              break;\r
           case ALARM_NONE:\r
           default:\r
               alarmType="00";\r
diff --git a/app/src/main/java/com/enqualcomm/support/bean/TemperatureInfo.java b/app/src/main/java/com/enqualcomm/support/bean/TemperatureInfo.java
new file mode 100644 (file)
index 0000000..349e31a
--- /dev/null
@@ -0,0 +1,33 @@
+package com.enqualcomm.support.bean;
+
+public class TemperatureInfo {
+
+    public double currentBodyTemp;
+    public double currentWristTemp;
+    public String measureTime;
+    public double bodyTempThresholdMax=0;
+    public double bodyTempThresholdMin=0;
+
+    public void setBodyTempThreshold(double max,double min){
+        bodyTempThresholdMax=max;
+        bodyTempThresholdMin=min;
+    }
+
+    public void setTemp(double bodytemp,double wristtemp){
+        currentBodyTemp=bodytemp;
+        currentWristTemp=wristtemp;
+    }
+    /***
+     *
+     * @return 0 normal , 1 过高,2 过低
+     */
+    public int isBodyTempAbnormal(){
+        if( bodyTempThresholdMax >0 && currentBodyTemp >bodyTempThresholdMax){
+            return 1;
+        }else if (bodyTempThresholdMin>0 && currentBodyTemp < bodyTempThresholdMin){
+            return 2;
+        }else {
+            return 0;
+        }
+    }
+}
index dea43c1..6881146 100644 (file)
@@ -19,6 +19,13 @@ public class heartRateStatus {
     private int bph_adjust=0;\r
     private int bpl_adjust=0;\r
 \r
+    public int ppg_threshold_max=0;\r
+    public int ppg_threshold_min=0;\r
+    public int bph_threshold_max=0;\r
+    public int bph_threshold_min=0;\r
+    public int bpl_threshold_max=0;\r
+    public int bpl_threshold_min=0;\r
+\r
     public void setXY_Ref(int refBPH,int refBPL,int refSex,int refAge){\r
         BPH_ref=refBPH;\r
         BPL_ref=refBPL;\r
@@ -122,4 +129,19 @@ public class heartRateStatus {
         lastBPL=bpl;\r
         lastSpo2=sp02;\r
     }\r
+\r
+//心率低阀值,低于该阀值上传心率,如果未设置,则留空\r
+//心率高阀值,高于该阀值上传心率,如果未设置,则留空\r
+//低压阀值,低压低于该阀值上传血压,如果未设置,则留空\r
+//低压阀值,低压高于该阀值上传血压,如果未设置,则留空\r
+//高压阀值,高压低于该阀值上传血压,如果未设置,则留空\r
+//高压阀值,高压高于该阀值上传血压,如果未设置,则留空\r
+    public void setWarningThreshold(int _ppg_threshold_max,int _ppg_threshold_min,int _bph_threshold_max,int _bph_threshold_min,int _bpl_threshold_max,int _bpl_threshold_min){\r
+        ppg_threshold_max=_ppg_threshold_max;\r
+        ppg_threshold_min=_ppg_threshold_min;\r
+        bph_threshold_max=_bph_threshold_max;\r
+        bph_threshold_min=_bph_threshold_min;\r
+        bpl_threshold_max=_bpl_threshold_max;\r
+        bpl_threshold_min=_bpl_threshold_min;\r
+    }\r
 }\r
index 21afdc8..6168d7e 100644 (file)
@@ -17,6 +17,7 @@ import android.os.PowerManager;
 import com.enqualcomm.support.Config;\r
 import com.enqualcomm.support.Constants;\r
 import com.enqualcomm.support.CoreService;\r
+import com.enqualcomm.support.utils.Util;\r
 import com.ic.jni.ICJniUtils;\r
 import com.ic.protocols.protocolAPIHelper;\r
 import com.enqualcomm.support.bean.Runtime;\r
@@ -52,7 +53,48 @@ public class HeartRateManager extends AbstractInvokeHandlerService implements Se
   private ScheduledThreadPoolExecutor timerPPG=null;\r
   private static Handler mHandler=null;\r
 \r
+  private void checkWarning(){\r
+    //ppg\r
+    if(runtime.getHRS().ppg_threshold_max>0 && runtime.getHRS().getPPG() >runtime.getHRS().ppg_threshold_max){\r
 \r
+      runtime.setAlarmType(Runtime.AlarmType.ALARM_HEART_RATE_HIGH);\r
+      //trigger AP10 报警定位\r
+      CoreService.getInstance().getConnection().send(protocolAPIHelper.genStringMessage("AP10", protocolAPIHelper.getWarningMSG(runtime)));\r
+\r
+    }else if ( runtime.getHRS().ppg_threshold_min>0 && runtime.getHRS().getPPG()<runtime.getHRS().ppg_threshold_min) {\r
+      runtime.setAlarmType(Runtime.AlarmType.ALARM_HEART_RATE_LOW);\r
+      //trigger AP10 报警定位\r
+      CoreService.getInstance().getConnection().send(protocolAPIHelper.genStringMessage("AP10", protocolAPIHelper.getWarningMSG(runtime)));\r
+    }\r
+\r
+    //bph\r
+    if(runtime.getHRS().bph_threshold_max>0 && runtime.getHRS().getBPH() >runtime.getHRS().bph_threshold_max){\r
+\r
+      runtime.setAlarmType(Runtime.AlarmType.ALARM_BPH_HIGH);\r
+      //trigger AP10 报警定位\r
+      CoreService.getInstance().getConnection().send(protocolAPIHelper.genStringMessage("AP10", protocolAPIHelper.getWarningMSG(runtime)));\r
+\r
+    }else if ( runtime.getHRS().bph_threshold_min>0 && runtime.getHRS().getBPH()<runtime.getHRS().bph_threshold_min) {\r
+      runtime.setAlarmType(Runtime.AlarmType.ALARM_BPH_LOW);\r
+      //trigger AP10 报警定位\r
+      CoreService.getInstance().getConnection().send(protocolAPIHelper.genStringMessage("AP10", protocolAPIHelper.getWarningMSG(runtime)));\r
+\r
+    }\r
+\r
+    //bpl\r
+    if(runtime.getHRS().bpl_threshold_max>0 && runtime.getHRS().getBPL() >runtime.getHRS().bpl_threshold_max){\r
+\r
+      runtime.setAlarmType(Runtime.AlarmType.ALARM_BPL_HIGH);\r
+      //trigger AP10 报警定位\r
+      CoreService.getInstance().getConnection().send(protocolAPIHelper.genStringMessage("AP10", protocolAPIHelper.getWarningMSG(runtime)));\r
+\r
+    }else if ( runtime.getHRS().bpl_threshold_min>0 && runtime.getHRS().getBPL()<runtime.getHRS().bpl_threshold_min) {\r
+      runtime.setAlarmType(Runtime.AlarmType.ALARM_BPL_LOW);\r
+      //trigger AP10 报警定位\r
+      CoreService.getInstance().getConnection().send(protocolAPIHelper.genStringMessage("AP10", protocolAPIHelper.getWarningMSG(runtime)));\r
+\r
+    }\r
+  }\r
   public HeartRateManager(Runtime _runtime,NettyConnection _connection){\r
     runtime=_runtime;\r
     connection=_connection;\r
@@ -81,9 +123,13 @@ public class HeartRateManager extends AbstractInvokeHandlerService implements Se
                   connection.send(protocolAPIHelper.genStringMessage("ppg", ppgd));\r
                   connection.send(protocolAPIHelper.genStringMessage("blood", bloodd));\r
                   connection.send(protocolAPIHelper.genStringMessage("oxygen", oxd));\r
+\r
+                  checkWarning();\r
+\r
                 }else {\r
                   connection.send(protocolAPIHelper.genStringMessage("APHT", PPGDATA));\r
                   ICLogger.i("Send PPG " + PPGDATA);\r
+                  checkWarning();\r
                 }\r
                 ICLogger.i("Send PPG " + PPGDATA);\r
               } else {\r
@@ -184,7 +230,6 @@ public class HeartRateManager extends AbstractInvokeHandlerService implements Se
       if (isWared ) {\r
         if (PPG > 0) {\r
           currentStat = heartRateStatus.HEARTRATE_WORKINGSTAT.HEARTRATE_TEST_SUCCESS;\r
-\r
         } else {\r
           currentStat = heartRateStatus.HEARTRATE_WORKINGSTAT.HEARTRATE_WARED_AND_TESTING;\r
         }\r
index d379990..07eae29 100644 (file)
@@ -5,6 +5,7 @@ import android.content.Intent;
 \r
 import com.enqualcomm.support.Constants;\r
 import com.enqualcomm.support.CoreService;\r
+import com.enqualcomm.support.bean.Runtime;\r
 import com.ic.jni.ICJniUtils;\r
 import com.ic.protocols.protocolAPIHelper;\r
 import com.sina.util.dnscache.log.FileUtil;\r
@@ -66,11 +67,30 @@ public class TemperatureUtil {
 \r
                     wrist_temp=TemperatureUtil.get_temp_value_adjusted();\r
                     body_temp=TemperatureUtil.getBodyTemp(wrist_temp,26.0f);\r
+                    ICJniUtils.disableTemperature();\r
+\r
                     String temperatureMsg= protocolAPIHelper.getTemperatureMSG(wrist_temp, body_temp);\r
                     CoreService.getInstance().getConnection().send(protocolAPIHelper.genStringMessage("APTP",temperatureMsg));\r
                     ICLogger.i("发送体温测量值 "+temperatureMsg);\r
 \r
-                    ICJniUtils.disableTemperature();\r
+                    Runtime runtime=CoreService.getInstance().getRuntime();\r
+                    runtime.tempInfo.setTemp(body_temp,wrist_temp);\r
+\r
+                    switch( runtime.tempInfo.isBodyTempAbnormal()){\r
+                        case 0:\r
+                            break;\r
+                        case 1:\r
+                            runtime.setAlarmType(Runtime.AlarmType.ALARM_HEART_RATE_HIGH);\r
+                            //trigger AP10 报警定位\r
+                            CoreService.getInstance().getConnection().send(protocolAPIHelper.genStringMessage("AP10", protocolAPIHelper.getWarningMSG(runtime)));\r
+                            break;\r
+                        case 2:\r
+                            runtime.setAlarmType(Runtime.AlarmType.ALARM_HEART_RATE_LOW);\r
+                            //trigger AP10 报警定位\r
+                            CoreService.getInstance().getConnection().send(protocolAPIHelper.genStringMessage("AP10", protocolAPIHelper.getWarningMSG(runtime)));\r
+                            break;\r
+                    }\r
+\r
                 }else{\r
                     double wrist_temp,body_temp;\r
 \r
@@ -79,6 +99,24 @@ public class TemperatureUtil {
                     String temperatureMsg= protocolAPIHelper.getTemperatureMSG(wrist_temp, body_temp);\r
                     CoreService.getInstance().getConnection().send(protocolAPIHelper.genStringMessage("APTP",temperatureMsg));\r
                     ICLogger.i("发送体温测量值 "+temperatureMsg);\r
+\r
+                    Runtime runtime=CoreService.getInstance().getRuntime();\r
+                    runtime.tempInfo.setTemp(body_temp,wrist_temp);\r
+\r
+                    switch( runtime.tempInfo.isBodyTempAbnormal()){\r
+                        case 0:\r
+                            break;\r
+                        case 1:\r
+                            runtime.setAlarmType(Runtime.AlarmType.ALARM_TEMP_HIGH);\r
+                            //trigger AP10 报警定位\r
+                            CoreService.getInstance().getConnection().send(protocolAPIHelper.genStringMessage("AP10", protocolAPIHelper.getWarningMSG(runtime)));\r
+                            break;\r
+                        case 2:\r
+                            runtime.setAlarmType(Runtime.AlarmType.ALARM_TEMP_LOW);\r
+                            //trigger AP10 报警定位\r
+                            CoreService.getInstance().getConnection().send(protocolAPIHelper.genStringMessage("AP10", protocolAPIHelper.getWarningMSG(runtime)));\r
+                            break;\r
+                    }\r
                 }\r
 \r
             }\r
index 3ff7a93..5aa37f0 100644 (file)
@@ -1621,12 +1621,15 @@ public class protocol_beehome {
             ICLogger.i("收到服务器指令:测量体温 "+freq+"分钟一次。");\r
             Config.setTemperatureTestCycle(runtime,freq*60);\r
             CoreService.getInstance().setTempAlarm();\r
-            double wrist_temp,body_temp;\r
-            wrist_temp=TemperatureUtil.get_temp_value_adjusted();\r
-            body_temp=TemperatureUtil.getBodyTemp(wrist_temp,26.0f);\r
-            String temperatureMsg=APTP(wrist_temp,body_temp);\r
-            connection.send(genStringMessage("APTP",temperatureMsg));\r
-            ICLogger.i("发送体温测量值 "+temperatureMsg);\r
+\r
+            TemperatureUtil.doTempTestInThread();\r
+\r
+//            double wrist_temp,body_temp;\r
+//            wrist_temp=TemperatureUtil.get_temp_value_adjusted();\r
+//            body_temp=TemperatureUtil.getBodyTemp(wrist_temp,26.0f);\r
+//            String temperatureMsg=APTP(wrist_temp,body_temp);\r
+//            connection.send(genStringMessage("APTP",temperatureMsg));\r
+//            ICLogger.i("发送体温测量值 "+temperatureMsg);\r
         }else{\r
             ICLogger.i("BP89 format error!");\r
         }\r
index 993f87e..3cb2633 100644 (file)
@@ -1,12 +1,12 @@
 package com.ic.protocols;\r
 \r
 import android.content.ComponentName;\r
-import android.content.IClipboard;\r
+//import android.content.IClipboard;\r
 import android.content.Intent;\r
 import android.net.Uri;\r
 import android.os.Environment;\r
 \r
-import com.android.internal.telephony.uicc.RuimFileHandler;\r
+//import com.android.internal.telephony.uicc.RuimFileHandler;\r
 import com.enqualcomm.support.Config;\r
 import com.enqualcomm.support.CoreService;\r
 import com.enqualcomm.support.bean.Alarm;\r
@@ -528,11 +528,14 @@ public class protocol_fzd {
 \r
         Config.setTemperatureTestCycle(runtime,freq);\r
         CoreService.getInstance().setTempAlarm();\r
-        double wrist_temp,body_temp;\r
-        wrist_temp= TemperatureUtil.get_temp_value_adjusted();\r
-        body_temp=TemperatureUtil.getBodyTemp(wrist_temp,26.0f);\r
-        String temperatureMsg=temp(body_temp);\r
-        connection.send(genStringMessage("temp",temperatureMsg));\r
+\r
+        TemperatureUtil.doTempTestInThread();\r
+//\r
+//        double wrist_temp,body_temp;\r
+//        wrist_temp= TemperatureUtil.get_temp_value_adjusted();\r
+//        body_temp=TemperatureUtil.getBodyTemp(wrist_temp,26.0f);\r
+//        String temperatureMsg=temp(body_temp);\r
+//        connection.send(genStringMessage("temp",temperatureMsg));\r
     }\r
     public static String hrtstart(){\r
         return genFZDCMD(cmdMap.get(CMD_TYPE.hrtstart));\r
index e6bceca..7e84210 100644 (file)
@@ -450,7 +450,7 @@ public class protocol_ic {
          * IWAP10080524A2232.9806N11404.9355E000.1061830323.8706000908000502,\r
          * 460,0,9520,3671,\r
          * 00,zh-cn,00,\r
-         * 00为报警状态,00为无任何报警(01:SOS,02:低电,03:脱落报警,04:佩戴提醒,05/06:跌倒报警))\r
+         * 00为报警状态,00为无任何报警(01:SOS,02:低电,03:脱落报警,04:佩戴提醒,05:剪断报警,06:跌倒报警,07:心率异常, 08:心率过高, 09:心率过低,10:收缩压过高,11:收缩压过低,12:舒张压过高,13:舒张压过低,14:久坐提醒,15:非法解锁(剪断报警),16:锁定提醒(佩戴提醒),17:体温过高,18体温过低)\r
          * zh-cn:设备语言\r
          * 00:第一个0:是否需要回复地址信息,0:不回复,1回复.\r
          * HOME|74-DE-2B-44-88-8C|97&HOME1|74-DE-2B-44-88-8C|97&HOME2|74-DE-2B-44-88-8C|97&HOME3|74-DE-2B-44-88-8C|97#\r
@@ -1627,6 +1627,9 @@ public class protocol_ic {
             String BPL_H=list[7];\r
             String BPL_L=list[8];\r
             connection.send(genStringMessage("AP89",AP89(index)));\r
+\r
+\r
+            \r
             ICLogger.i("收到服务器指令:心率/血压阀值 "+PPGH+","+PPGL+","+BPH_H+","+BPH_L+","+BPL_H+","+BPL_L);\r
         }else{\r
             ICLogger.i("BP89 format error!");\r