From: kfl_614 Date: Wed, 16 Dec 2020 09:32:28 +0000 (+0800) Subject: get temperature loope ten seconds. X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=8443a223dd2fb26a634ae7f80deaf5ce567f6173;p=protocol_srv.git get temperature loope ten seconds. --- diff --git a/app/src/main/java/com/enqualcomm/support/bean/Runtime.java b/app/src/main/java/com/enqualcomm/support/bean/Runtime.java index 0aa989b2..f5aa7e37 100644 --- a/app/src/main/java/com/enqualcomm/support/bean/Runtime.java +++ b/app/src/main/java/com/enqualcomm/support/bean/Runtime.java @@ -2,7 +2,6 @@ package com.enqualcomm.support.bean; import android.content.Context; -import android.support.constraint.solver.widgets.Helper; import com.enqualcomm.support.Config; import com.enqualcomm.support.adapter.LBSHelper; @@ -10,315 +9,316 @@ import com.enqualcomm.support.utils.ContextProxy; import com.enqualcomm.support.utils.DBHelper; import com.enqualcomm.support.utils.DnsUtil; import com.enqualcomm.support.utils.ICLogger; -import com.enqualcomm.support.utils.VibrateUtil; import java.io.File; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.Locale; public class Runtime { - private boolean debugflag=false; + private boolean debugflag = false; - public int temp_test_Cycle=60*60; - public int anti_test_cycle=30; + public int temp_test_Cycle = 60 * 60; + public int anti_test_cycle = 30; - public static String PushtxtMsg_srv_index=""; + public static String PushtxtMsg_srv_index = ""; public int SignalStrength; //上一次成功心跳时间,供系统重连机制使用。 - public long lastLoginSuccessTime=0; - public TemperatureInfo tempInfo=new TemperatureInfo(); - public boolean BindingStatus=false; - public BLEInfo bleInfo=new BLEInfo(); - private String battery="000"; - - private int batteryVoltage=0; - private boolean batteryLow; - - private boolean batterychanging; - - public String belong; - - private File cacheDir; - - private String cdmaInfo; - - public String cellidByAt; - - private String cellinfo; - - private String cid = ""; - - private ContextProxy contextProxy; - - private String currentCellInfo; - -// public String currentWifiInfo=""; - private static int ppgTestCycle; - - private DBHelper dbHelper; - - private String device_id; - - private String device_key; - - private File fileDir; - - private boolean haveBatteryChange; - - private String haveBuy; - - private String haveTry; - - private String host = "watch.jiai.pro"; //118.178.155.223 - - private String srvIP = "118.178.155.223";//"39.98.94.164"; - - private String imei = ""; - - private int port = 8090;//20048;//8888;//8090; - - - private boolean testServerProp=false; - - private String imei_cid = ""; - - private String imei_cid_key = ""; - - private String imsi = ""; - - public boolean isAirMode=false; - - - private String key = "867155030001063"; - - public String lacByAt; - - - private LBSHelper lbsHelper; - - - private heartRateStatus HRS=null; - - private boolean FactoryTestingStat=false; - - public void setFactoryTestingStat(boolean testing){ - FactoryTestingStat=testing; - } - public boolean getFactoryTestingStat(){ + public long lastLoginSuccessTime = 0; + public TemperatureInfo tempInfo = new TemperatureInfo(); + public boolean BindingStatus = false; + public BLEInfo bleInfo = new BLEInfo(); + private String battery = "000"; + + private int batteryVoltage = 0; + private boolean batteryLow; + + private boolean batterychanging; + + public String belong; + + private File cacheDir; + + private String cdmaInfo; + + public String cellidByAt; + + private String cellinfo; + + private String cid = ""; + + private ContextProxy contextProxy; + + private String currentCellInfo; + + // public String currentWifiInfo=""; + private static int ppgTestCycle; + + private DBHelper dbHelper; + + private String device_id; + + private String device_key; + + private File fileDir; + + private boolean haveBatteryChange; + + private String haveBuy; + + private String haveTry; + + private String host = "watch.jiai.pro"; //118.178.155.223 + + private String srvIP = "118.178.155.223";//"39.98.94.164"; + + private String imei = ""; + + private int port = 8090;//20048;//8888;//8090; + + + private boolean testServerProp = false; + + private String imei_cid = ""; + + private String imei_cid_key = ""; + + private String imsi = ""; + + public boolean isAirMode = false; + + + private String key = "867155030001063"; + + public String lacByAt; + + + private LBSHelper lbsHelper; + + + private heartRateStatus HRS = null; + + private boolean FactoryTestingStat = false; + + public void setFactoryTestingStat(boolean testing) { + FactoryTestingStat = testing; + } + + public boolean getFactoryTestingStat() { return FactoryTestingStat; } - private boolean UseQueue=false; - private boolean lockSimInfo=false; - private boolean ServerHeartBeadReceived=false; + private boolean UseQueue = false; + private boolean lockSimInfo = false; - public void setServerProtocolConnected(boolean received){ - ServerHeartBeadReceived=received; - } + private boolean ServerHeartBeadReceived = false; - public boolean isServerProtocolConnected(){ - return ServerHeartBeadReceived; - } + public void setServerProtocolConnected(boolean received) { + ServerHeartBeadReceived = received; + } - public void setPpgTestCycle(int cycle){ - ppgTestCycle=cycle; - } + public boolean isServerProtocolConnected() { + return ServerHeartBeadReceived; + } - public int getPpgTestCycle(){ - return ppgTestCycle; - } + public void setPpgTestCycle(int cycle) { + ppgTestCycle = cycle; + } + + public int getPpgTestCycle() { + return ppgTestCycle; + } - public boolean check_stat_do_ppg_test(){ - if(debugflag||(Config.noPPGSensor == false //有心率 - && ( (isNeedAntioff==true && isAntioff==false) ||(isNeedAntioff==false)) //不支持脱腕,或者支持脱腕且佩戴中 - )){ - return true; - } - ICLogger.i("不符合条件,跳过 心率检测!"+(Config.noPPGSensor==true?"无心率":"有心率")+" 有佩戴检测?"+isNeedAntioff+ " 脱落?"+isAntioff); - return false; - } + public boolean check_stat_do_ppg_test() { + if (debugflag || (Config.noPPGSensor == false //有心率 + && ((isNeedAntioff == true && isAntioff == false) || (isNeedAntioff == false)) //不支持脱腕,或者支持脱腕且佩戴中 + )) { + return true; + } + ICLogger.i("不符合条件,跳过 心率检测!" + (Config.noPPGSensor == true ? "无心率" : "有心率") + " 有佩戴检测?" + isNeedAntioff + " 脱落?" + isAntioff); + return false; + } - public boolean check_stat_do_temp_test(){ - if(debugflag||(Config.noTempSensor == false && //有体温 - ( isPowerConnected()==false && getMsAfterLastPowerPlugout()> 300000 )//没有充电至少5分钟 - && ( (isNeedAntioff==true && isAntioff==false) ||(isNeedAntioff==false)) //不支持脱腕,或者支持脱腕且佩戴中 - )){ + public boolean check_stat_do_temp_test() { + if (debugflag || (Config.noTempSensor == false //有体温 + && ((isNeedAntioff == true && isAntioff == false) || (isNeedAntioff == false)) //不支持脱腕,或者支持脱腕且佩戴中 + )) { return true; } - ICLogger.i("不符合条件,跳过 体温检测!"+(Config.noTempSensor==true?"无体温":"有体温")+" 充电?"+isPowerConnected()+ " 移除充电器时间?"+getMsAfterLastPowerPlugout()+"ms, 需要佩戴检测?"+isNeedAntioff+ ", 脱腕?"+isAntioff); + ICLogger.i("不符合条件,跳过 体温检测!" + (Config.noTempSensor == true ? "无体温" : "有体温") + " 充电?" + isPowerConnected() + " 移除充电器时间?" + getMsAfterLastPowerPlugout() + "ms, 需要佩戴检测?" + isNeedAntioff + ", 脱腕?" + isAntioff); return false; } - public void setUseQueue(boolean usequeue){ - UseQueue=usequeue; - } - public boolean getUseQueue(){ - return UseQueue; - } - private String mccAndMnc; - - private String language="zh-cn"; - public String getLanguage(){ - return language; - } - public void setLanguage(String _language){ - language=_language; - } + public void setUseQueue(boolean usequeue) { + UseQueue = usequeue; + } + + public boolean getUseQueue() { + return UseQueue; + } + + private String mccAndMnc; + private String language = "zh-cn"; + public String getLanguage() { + return language; + } + + public void setLanguage(String _language) { + language = _language; + } - //0 代表没有出围栏,如果出围栏则置1,每次报警再加1 - public int Fence_Warning_flag=0; + + //0 代表没有出围栏,如果出围栏则置1,每次报警再加1 + public int Fence_Warning_flag = 0; //0 代表佩戴,如果脱腕则置1,每次报警再加1 - public int Anti_off_flag=0; - public int Cut_off_flag=0; - - public enum AlarmType{ - ALARM_SOS, //sos - ALARM_LOWBATTERY, //低电 - ALARM_ANTIOFF, //脱腕报警 - ALARM_WEARED, //佩戴 - ALARM_CUTOFF,//剪断报警 - ALARM_FALL, //跌倒 - ALARM_ABNORMAL_HEART_RATE, //心率异常 - ALARM_HEART_RATE_HIGH, //心率高 - ALARM_HEART_RATE_LOW, //心率低 - ALARM_BPH_HIGH, //高压高 - ALARM_BPH_LOW, //高压低 - ALARM_BPL_HIGH, //低压高 - ALARM_BPL_LOW, //低压低 - ALARM_SEDENTARY, //久坐提醒 - ALARM_ILLEGAL_CUTOFF, //剪断 - ALARM_LOCK_WATCH, //锁定 - ALARM_TEMP_HIGH, //体温高 - ALARM_TEMP_LOW, //体温低 - ALARM_POWER_OFF, //关机 - ALARM_ESCAPE, //逃逸 - ALARM_UNREADMSG, //消息未读 - ALARM_MSGREAD, //消息已读 - ALARM_NONE, - ALARM_REMOVE_SOS,//附加的,专门给防走丢用来清除SOS标志用的 - }; - - private AlarmType g_alarm=AlarmType.ALARM_NONE; - - private String alarmType="00"; - public String getAlarmType(){ + public int Anti_off_flag = 0; + public int Cut_off_flag = 0; + + public enum AlarmType { + ALARM_SOS, //sos + ALARM_LOWBATTERY, //低电 + ALARM_ANTIOFF, //脱腕报警 + ALARM_WEARED, //佩戴 + ALARM_CUTOFF,//剪断报警 + ALARM_FALL, //跌倒 + ALARM_ABNORMAL_HEART_RATE, //心率异常 + ALARM_HEART_RATE_HIGH, //心率高 + ALARM_HEART_RATE_LOW, //心率低 + ALARM_BPH_HIGH, //高压高 + ALARM_BPH_LOW, //高压低 + ALARM_BPL_HIGH, //低压高 + ALARM_BPL_LOW, //低压低 + ALARM_SEDENTARY, //久坐提醒 + ALARM_ILLEGAL_CUTOFF, //剪断 + ALARM_LOCK_WATCH, //锁定 + ALARM_TEMP_HIGH, //体温高 + ALARM_TEMP_LOW, //体温低 + ALARM_POWER_OFF, //关机 + ALARM_ESCAPE, //逃逸 + ALARM_UNREADMSG, //消息未读 + ALARM_MSGREAD, //消息已读 + ALARM_NONE, + ALARM_REMOVE_SOS,//附加的,专门给防走丢用来清除SOS标志用的 + } + + ; + + private AlarmType g_alarm = AlarmType.ALARM_NONE; + + private String alarmType = "00"; + + public String getAlarmType() { return alarmType; } //32 bit 数据 - private int fzdDevStatus=0x00000000; + private int fzdDevStatus = 0x00000000; /*** - * 00为报警状态,00为无任何报警(01:SOS,02:低电,03:脱落报警,04:佩戴提醒,05:剪断报警,06:跌倒报警, - * 07:心率异常, 08:心率过高, 09:心率过低,10:收缩压过高,11:收缩压过低,12:舒张压过高,13:舒张压过低, - * 14:久坐提醒,15:非法解锁(剪断报警),16:锁定提醒(佩戴提醒),17:体温过高,18体温过低) 19 关机事件(非服务器指令关机), 20,escape逃跑事件(离开蓝牙管控范围) + * 00为报警状态,00为无任何报警(01:SOS,02:低电,03:脱落报警,04:佩戴提醒,05:剪断报警,06:跌倒报警, + * 07:心率异常, 08:心率过高, 09:心率过低,10:收缩压过高,11:收缩压过低,12:舒张压过高,13:舒张压过低, + * 14:久坐提醒,15:非法解锁(剪断报警),16:锁定提醒(佩戴提醒),17:体温过高,18体温过低) 19 关机事件(非服务器指令关机), 20,escape逃跑事件(离开蓝牙管控范围) * 21, 消息未读 , 22消息已读 - */ - public boolean setAlarmType(AlarmType alarm){ + */ + public boolean setAlarmType(AlarmType alarm) { // if ( !fall && !lowbattery && !sos && antioff) - g_alarm=alarm; - - if (Config.isAlarmTypeEnabled(alarm) == false){ - ICLogger.i(alarm.name()+" is disabled, skip!"); - return false; - } - //同时更新防走丢设备状态标志 - setFZDDevStatus(alarm); - - switch (alarm){ - case ALARM_SOS: - alarmType="01"; - break; - case ALARM_LOWBATTERY: - alarmType="02"; - break; - case ALARM_ANTIOFF: - alarmType="03"; - break; - case ALARM_WEARED: - alarmType="04"; - break; - case ALARM_CUTOFF: - alarmType="05"; - break; - case ALARM_FALL: - alarmType="06"; - break; - - case ALARM_ABNORMAL_HEART_RATE: - alarmType="07"; - break; - - case ALARM_HEART_RATE_HIGH: - alarmType="08"; - break; - - case ALARM_HEART_RATE_LOW: - alarmType="09"; - break; - - case ALARM_BPH_HIGH: - alarmType="10"; - break; - - case ALARM_BPH_LOW: - alarmType="11"; - break; - - case ALARM_BPL_HIGH: - alarmType="12"; - break; - - case ALARM_BPL_LOW: - alarmType="13"; - break; - - case ALARM_SEDENTARY: - alarmType="14"; - break; - - case ALARM_ILLEGAL_CUTOFF: - alarmType="15"; - break; - - case ALARM_LOCK_WATCH: - alarmType="16"; - break; - - case ALARM_TEMP_HIGH: - alarmType="17"; - break; - - case ALARM_TEMP_LOW: - alarmType="18"; - break; - case ALARM_POWER_OFF: - alarmType="19"; - break; - case ALARM_ESCAPE: - alarmType="20"; - break; - case ALARM_UNREADMSG: - alarmType="21"; - break; - case ALARM_MSGREAD: - alarmType="22"; - break; - default: - alarmType="00"; - break; - } - return true; - } + g_alarm = alarm; + + if (Config.isAlarmTypeEnabled(alarm) == false) { + ICLogger.i(alarm.name() + " is disabled, skip!"); + return false; + } + //同时更新防走丢设备状态标志 + setFZDDevStatus(alarm); + + switch (alarm) { + case ALARM_SOS: + alarmType = "01"; + break; + case ALARM_LOWBATTERY: + alarmType = "02"; + break; + case ALARM_ANTIOFF: + alarmType = "03"; + break; + case ALARM_WEARED: + alarmType = "04"; + break; + case ALARM_CUTOFF: + alarmType = "05"; + break; + case ALARM_FALL: + alarmType = "06"; + break; + + case ALARM_ABNORMAL_HEART_RATE: + alarmType = "07"; + break; + + case ALARM_HEART_RATE_HIGH: + alarmType = "08"; + break; + + case ALARM_HEART_RATE_LOW: + alarmType = "09"; + break; + + case ALARM_BPH_HIGH: + alarmType = "10"; + break; + + case ALARM_BPH_LOW: + alarmType = "11"; + break; + + case ALARM_BPL_HIGH: + alarmType = "12"; + break; + + case ALARM_BPL_LOW: + alarmType = "13"; + break; + + case ALARM_SEDENTARY: + alarmType = "14"; + break; + + case ALARM_ILLEGAL_CUTOFF: + alarmType = "15"; + break; + + case ALARM_LOCK_WATCH: + alarmType = "16"; + break; + + case ALARM_TEMP_HIGH: + alarmType = "17"; + break; + + case ALARM_TEMP_LOW: + alarmType = "18"; + break; + case ALARM_POWER_OFF: + alarmType = "19"; + break; + case ALARM_ESCAPE: + alarmType = "20"; + break; + case ALARM_UNREADMSG: + alarmType = "21"; + break; + case ALARM_MSGREAD: + alarmType = "22"; + break; + default: + alarmType = "00"; + break; + } + return true; + } /*** @@ -353,8 +353,8 @@ public class Runtime { public String getFZDDevStatus(Runtime runtime) { StringBuilder sb = new StringBuilder(); sb.append(Integer.toHexString(runtime.fzdDevStatus)); - if (sb.length() <8) { - for (int i=0;i< 8-sb.length();i++) + if (sb.length() < 8) { + for (int i = 0; i < 8 - sb.length(); i++) sb.insert(0, '0'); // pad with leading zero if needed } String hex = sb.toString(); @@ -362,49 +362,50 @@ public class Runtime { } - public void updateFZDDevStatusLowbat(boolean lowbattery){ + public void updateFZDDevStatusLowbat(boolean lowbattery) { - if(lowbattery){ - fzdDevStatus|=0x00000001; - fzdDevStatus|=0x00020000; - }else{ - fzdDevStatus&=~0x00000001; - fzdDevStatus&=~0x00020000; + if (lowbattery) { + fzdDevStatus |= 0x00000001; + fzdDevStatus |= 0x00020000; + } else { + fzdDevStatus &= ~0x00000001; + fzdDevStatus &= ~0x00020000; } } + public void updateFZDDevStatusWeared(boolean weared) { - if(weared){ - fzdDevStatus|=0x00000008; - }else{ - fzdDevStatus&=~0x00000008; + if (weared) { + fzdDevStatus |= 0x00000008; + } else { + fzdDevStatus &= ~0x00000008; } } public void updateFZDDevStatusMoving(boolean moving) { - if(moving){ - fzdDevStatus&=~0x00000010; - }else{ - fzdDevStatus|=0x00000010; + if (moving) { + fzdDevStatus &= ~0x00000010; + } else { + fzdDevStatus |= 0x00000010; } } - public void updateFZDDevStatusEscape(boolean escape){ - if(escape){ - fzdDevStatus|=0x00040000; - }else{ - fzdDevStatus&=~0x00040000; + public void updateFZDDevStatusEscape(boolean escape) { + if (escape) { + fzdDevStatus |= 0x00040000; + } else { + fzdDevStatus &= ~0x00040000; } } - public void setFZDDevStatus(AlarmType _alarmType){ + public void setFZDDevStatus(AlarmType _alarmType) { - switch (_alarmType){ + switch (_alarmType) { case ALARM_SOS: - fzdDevStatus |=0x00010000; + fzdDevStatus |= 0x00010000; break; case ALARM_LOWBATTERY: - fzdDevStatus |=0x00020000; + fzdDevStatus |= 0x00020000; break; case ALARM_ANTIOFF: // fzdDevStatus&=0x00000008; @@ -415,17 +416,17 @@ public class Runtime { // fzdDevStatus&=~0x00000008; break; case ALARM_LOCK_WATCH: - fzdDevStatus&=~0x00100000; + fzdDevStatus &= ~0x00100000; break; case ALARM_CUTOFF: case ALARM_ILLEGAL_CUTOFF: - fzdDevStatus|=0x00100000; + fzdDevStatus |= 0x00100000; break; case ALARM_FALL: - fzdDevStatus|=0x00200000; + fzdDevStatus |= 0x00200000; break; case ALARM_ABNORMAL_HEART_RATE: - fzdDevStatus|=0x01000000; + fzdDevStatus |= 0x01000000; break; case ALARM_HEART_RATE_HIGH: // alarmType1="08"; @@ -460,14 +461,14 @@ public class Runtime { // alarmType1="18"; break; case ALARM_POWER_OFF: - fzdDevStatus|=0x00800000; + fzdDevStatus |= 0x00800000; break; case ALARM_ESCAPE: updateFZDDevStatusEscape(true); break; case ALARM_REMOVE_SOS: - fzdDevStatus &=~0x00010000; + fzdDevStatus &= ~0x00010000; break; case ALARM_NONE: default: @@ -475,424 +476,566 @@ public class Runtime { break; } - ICLogger.i("setFZDDevStatus "+String.format("0x%x",fzdDevStatus)+" "+fzdDevStatus); + ICLogger.i("setFZDDevStatus " + String.format("0x%x", fzdDevStatus) + " " + fzdDevStatus); } - public void dumpDevStatus(){ - StringBuilder sb=new StringBuilder("get FZDStatus "); - if( (fzdDevStatus & 0x00800000 ) > 0 ){ + public void dumpDevStatus() { + StringBuilder sb = new StringBuilder("get FZDStatus "); + if ((fzdDevStatus & 0x00800000) > 0) { sb.append("ALARM_POWER_OFF "); } - if ((fzdDevStatus & 0x00040000 ) > 0 ){ + if ((fzdDevStatus & 0x00040000) > 0) { sb.append("ALARM_ESCAPE "); } - if ((fzdDevStatus & 0x01000000 ) > 0 ){ + if ((fzdDevStatus & 0x01000000) > 0) { sb.append("ALARM_ABNORMAL_HEART_RATE "); } - if ((fzdDevStatus & 0x00200000 ) > 0 ){ + if ((fzdDevStatus & 0x00200000) > 0) { sb.append("ALARM_FALL "); } - if ((fzdDevStatus & 0x00100000 ) > 0 ){ + if ((fzdDevStatus & 0x00100000) > 0) { sb.append("ALARM_ILLEGAL_CUTOFF "); } - if ((fzdDevStatus & 0x00100000 ) == 0 ){ + if ((fzdDevStatus & 0x00100000) == 0) { sb.append("ALARM_LOCK_WATCH "); } - if ((fzdDevStatus & 0x00020000 ) > 0 ){ + if ((fzdDevStatus & 0x00020000) > 0) { sb.append("ALARM_LOWBATTERY "); } - if ((fzdDevStatus & 0x00010000 ) > 0 ){ + if ((fzdDevStatus & 0x00010000) > 0) { sb.append("ALARM_SOS "); } - if ((fzdDevStatus & 0x00000008 ) > 0 ){ + if ((fzdDevStatus & 0x00000008) > 0) { sb.append("ALARM_ANTIOFF "); } - if ((fzdDevStatus & 0x00000008 ) == 0 ){ + if ((fzdDevStatus & 0x00000008) == 0) { sb.append("ALARM_WEARED "); } ICLogger.i(sb.toString()); } - public String preCdmaInfo; - - public String preCellInfo; - - public String preTime; - - public int saveStepCount; - - private boolean shutdown; - - public static long lastLinkReceiveStamp=0; - - private boolean PowerConnected=false; - - private long msPowerConnectionStatusChangedTime=0; - public void setPowerConnected(boolean connected){ - if (PowerConnected!=connected){ - msPowerConnectionStatusChangedTime=System.currentTimeMillis(); - PowerConnected=connected; - } - } - - //获取上次开始充电到现在的时间 ms - public long getMsAfterLastPowerPlugin(){ - if (isPowerConnected()){ - return (System.currentTimeMillis()-msPowerConnectionStatusChangedTime); - }else - return 0; - } - - //获取上次停止充电到现在的时间 ms - public long getMsAfterLastPowerPlugout(){ - if (!isPowerConnected()){ - return (System.currentTimeMillis()-msPowerConnectionStatusChangedTime); - }else - return 0; - } - - public boolean isPowerConnected(){ - return PowerConnected; - } - private DnsUtil dnsUtil=null; - - public void initDnsUtil(Context context){ - if (dnsUtil==null) - dnsUtil=new DnsUtil(5,context); - } - public DnsUtil getDnsUtil(){ - return dnsUtil; - } - private int lastStepCount=0; - private int lastStepCountForBT=0; - private long timestamp; - - public int totalStepCount; - - private int heartbeatCycle; - - - public int getHeartBeatCycle() - { - return heartbeatCycle; - } - public void setHeartBeatCycle(int cycle){ - heartbeatCycle=cycle; - } - public heartRateStatus getHRS(){ - return HRS; - } - - public void setHRS(heartRateStatus hrs){ - HRS=hrs; - } - public int getLastStepCount(){ - return lastStepCount; - } - public void setLastStepCount(int st){ - lastStepCount=st; - } - public int getLastStepCountForBT(){ + + public String preCdmaInfo; + + public String preCellInfo; + + public String preTime; + + public int saveStepCount; + + private boolean shutdown; + + public static long lastLinkReceiveStamp = 0; + + private boolean PowerConnected = false; + + private long msPowerConnectionStatusChangedTime = 0; + + public void setPowerConnected(boolean connected) { + if (PowerConnected != connected) { + msPowerConnectionStatusChangedTime = System.currentTimeMillis(); + PowerConnected = connected; + } + } + + //获取上次开始充电到现在的时间 ms + public long getMsAfterLastPowerPlugin() { + if (isPowerConnected()) { + return (System.currentTimeMillis() - msPowerConnectionStatusChangedTime); + } else + return 0; + } + + //获取上次停止充电到现在的时间 ms + public long getMsAfterLastPowerPlugout() { + if (!isPowerConnected()) { + return (System.currentTimeMillis() - msPowerConnectionStatusChangedTime); + } else + return 0; + } + + public boolean isPowerConnected() { + return PowerConnected; + } + + private DnsUtil dnsUtil = null; + + public void initDnsUtil(Context context) { + if (dnsUtil == null) + dnsUtil = new DnsUtil(5, context); + } + + public DnsUtil getDnsUtil() { + return dnsUtil; + } + + private int lastStepCount = 0; + private int lastStepCountForBT = 0; + private long timestamp; + + public int totalStepCount; + + private int heartbeatCycle; + + + public int getHeartBeatCycle() { + return heartbeatCycle; + } + + public void setHeartBeatCycle(int cycle) { + heartbeatCycle = cycle; + } + + public heartRateStatus getHRS() { + return HRS; + } + + public void setHRS(heartRateStatus hrs) { + HRS = hrs; + } + + public int getLastStepCount() { + return lastStepCount; + } + + public void setLastStepCount(int st) { + lastStepCount = st; + } + + public int getLastStepCountForBT() { return lastStepCountForBT; - } - public void setLastStepCountForBT(int st){ - lastStepCountForBT=st; - } - - public String IMEI() { return this.imei; } - - public String IMEI_CID() { return this.imei_cid; } - - public String IMEI_CID_KEY() { return this.imei_cid_key; } - - public String IMSI() { return this.imsi; } - - - private boolean noTurnOffWifiOnScreenOff=false; - - public void setNoTurnOffOnScreenOff(boolean bol){ - noTurnOffWifiOnScreenOff=bol; - } - public boolean isNoTurnOffWifiOnScreenOff(){ - return noTurnOffWifiOnScreenOff; - } - - public boolean isAntioff=false; - private boolean isNeedAntioff; - public boolean getNeedAntioff() { return this.isNeedAntioff; } - public void setNeedAntioff(boolean paramBoolean) { this.isNeedAntioff = paramBoolean; } - - private boolean isNeedReportcutoff=false; - public boolean needReportCutoff(){ - return this.isNeedReportcutoff; - } - - public void setNeddReportCutoff(boolean needreport){ - this.isNeedReportcutoff=needreport; - } - public String getBattery() { return this.battery; } - - public int getBatteryVotage(){ return this.batteryVoltage;} - public void setBatteryVoltage(int voltage){ - this.batteryVoltage=voltage; - } - public boolean getBatteryLow() { return this.batteryLow; } - - public boolean getBatterychanging() { return this.batterychanging; } - - - public File getCacheDir() { return this.cacheDir; } - - public String getCdmaInfo() { return this.cdmaInfo; } - - public String getCellidInfoByAt() { return this.cellidByAt; } - - - public ContextProxy getContextProxy() { return this.contextProxy; } - - public String getCurrentCellInfo() { return this.currentCellInfo; } - - public DBHelper getDbHelper() { return this.dbHelper; } - - public String getDevice_id() { return this.device_id; } - - public String getDevice_key() { return this.device_key; } - - public File getFileDir() { return this.fileDir; } - - public boolean getHaveBatteryChange() { return this.haveBatteryChange; } - - - public String getHost() { return this.testServerProp ? srvIP : this.host; } - - public void setSrvIP(String ip) { this.srvIP=ip;} - - public String getSrvIP(){ return this.srvIP;} - - public String getKey() { return this.key; } - - public String getLacInfoByAt() { return this.lacByAt; } - - public LBSHelper getLbsHelper() { return this.lbsHelper; } - - - public boolean getLockSimInfo() { return this.lockSimInfo; } - - - - public String getMccAndMnc() { return this.mccAndMnc; } - - public int getPort() { return this.port; } - - public int getSaveStepCount() { return this.saveStepCount; } - - public int getSignalStrength() { return this.SignalStrength; } - - private String SignalInfo=""; - public void setSignalInfo(String info){ - this.SignalInfo=info; - } - public String getSignalInfo() { return this.SignalInfo; } - public long getTimestamp() { return this.timestamp; } - - public int getTotalStepCount() { return this.totalStepCount; } - - - public boolean isShutdown() { return this.shutdown; } - - - private static int batterylevel=0; - public int getBatterylevel(){ - return batterylevel; - } - public void setBattery(String paramString) { this.battery = paramString; } - public void setBattery(int param) { this.batterylevel = param; } + } + + public void setLastStepCountForBT(int st) { + lastStepCountForBT = st; + } + + public String IMEI() { + return this.imei; + } + + public String IMEI_CID() { + return this.imei_cid; + } + + public String IMEI_CID_KEY() { + return this.imei_cid_key; + } + + public String IMSI() { + return this.imsi; + } + + + private boolean noTurnOffWifiOnScreenOff = false; + + public void setNoTurnOffOnScreenOff(boolean bol) { + noTurnOffWifiOnScreenOff = bol; + } + + public boolean isNoTurnOffWifiOnScreenOff() { + return noTurnOffWifiOnScreenOff; + } + + public boolean isAntioff = false; + private boolean isNeedAntioff; + + public boolean getNeedAntioff() { + return this.isNeedAntioff; + } + + public void setNeedAntioff(boolean paramBoolean) { + this.isNeedAntioff = paramBoolean; + } + + private boolean isNeedReportcutoff = false; + + public boolean needReportCutoff() { + return this.isNeedReportcutoff; + } + + public void setNeddReportCutoff(boolean needreport) { + this.isNeedReportcutoff = needreport; + } + + public String getBattery() { + return this.battery; + } + + public int getBatteryVotage() { + return this.batteryVoltage; + } + + public void setBatteryVoltage(int voltage) { + this.batteryVoltage = voltage; + } + + public boolean getBatteryLow() { + return this.batteryLow; + } + + public boolean getBatterychanging() { + return this.batterychanging; + } + + + public File getCacheDir() { + return this.cacheDir; + } + + public String getCdmaInfo() { + return this.cdmaInfo; + } + + public String getCellidInfoByAt() { + return this.cellidByAt; + } + + + public ContextProxy getContextProxy() { + return this.contextProxy; + } + + public String getCurrentCellInfo() { + return this.currentCellInfo; + } + + public DBHelper getDbHelper() { + return this.dbHelper; + } + + public String getDevice_id() { + return this.device_id; + } + + public String getDevice_key() { + return this.device_key; + } + + public File getFileDir() { + return this.fileDir; + } + + public boolean getHaveBatteryChange() { + return this.haveBatteryChange; + } + + + public String getHost() { + return this.testServerProp ? srvIP : this.host; + } + + public void setSrvIP(String ip) { + this.srvIP = ip; + } + + public String getSrvIP() { + return this.srvIP; + } + + public String getKey() { + return this.key; + } + + public String getLacInfoByAt() { + return this.lacByAt; + } + + public LBSHelper getLbsHelper() { + return this.lbsHelper; + } + + + public boolean getLockSimInfo() { + return this.lockSimInfo; + } + + + public String getMccAndMnc() { + return this.mccAndMnc; + } + + public int getPort() { + return this.port; + } + + public int getSaveStepCount() { + return this.saveStepCount; + } + + public int getSignalStrength() { + return this.SignalStrength; + } + + private String SignalInfo = ""; + + public void setSignalInfo(String info) { + this.SignalInfo = info; + } + + public String getSignalInfo() { + return this.SignalInfo; + } + + public long getTimestamp() { + return this.timestamp; + } + + public int getTotalStepCount() { + return this.totalStepCount; + } + + + public boolean isShutdown() { + return this.shutdown; + } + + + private static int batterylevel = 0; + + public int getBatterylevel() { + return batterylevel; + } + + public void setBattery(String paramString) { + this.battery = paramString; + } + + public void setBattery(int param) { + this.batterylevel = param; + } public void setBatteryLow(boolean paramBoolean) { - this.batteryLow = paramBoolean; - updateFZDDevStatusLowbat(batteryLow); //设置batterylow Alarm - } - - public void setBatterychanging(boolean paramBoolean) { this.batterychanging = paramBoolean; } - - public void setBelong(String paramString) { this.belong = paramString; } - - public void setCacheDir(File paramFile) { this.cacheDir = paramFile; } - - public void setCdmaInfo(String paramString) { this.cdmaInfo = paramString; } - - public void setCellinfo(String paramString) { this.cellinfo = paramString; } - - public void setCid(String paramString) { this.cid = paramString; } - - public void setContextProxy(ContextProxy paramContextProxy) { this.contextProxy = paramContextProxy; } - - public void setCurrentCellInfo(String paramString) { this.currentCellInfo = paramString; } - - public void setDBHelper(DBHelper paramDBHelper) { this.dbHelper = paramDBHelper; } - - public void setDevice_id(String paramString) { this.device_id = paramString; } - - public void setDevice_key(String paramString) { this.device_key = paramString; } - - public void setFileDir(File paramFile) { this.fileDir = paramFile; } - - public void setHaveBatteryChange(boolean paramBoolean) { this.haveBatteryChange = paramBoolean; } - - public void setHost(String _host){ - host=_host; - } - public void setHostAndPort(String paramString, int paramInt) { - this.host = paramString; - this.port = paramInt; - } - public void setPort(int _port){ - port=_port; - } - public void setImeiAndCid(String paramString1, String paramString2) { - this.imei = paramString1; - this.cid = paramString2; - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(paramString1); - stringBuilder.append(","); - stringBuilder.append(paramString2); - this.imei_cid = stringBuilder.toString(); - ICLogger.i("imei:"+imei+",cid:"+cid); - } - - public void setImsi(String paramString) { this.imsi = paramString; } - - public void setKey(String paramString) { - this.key = paramString; - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(this.imei_cid); - stringBuilder.append(","); - stringBuilder.append(paramString); - this.imei_cid_key = stringBuilder.toString(); - } - - public void setLbsHelper(LBSHelper paramLBSHelper) { this.lbsHelper = paramLBSHelper; } - - public void setLbsInfoByAt(String paramString1, String paramString2) { - this.lacByAt = paramString1; - this.cellidByAt = paramString2; - } - - - public void setLockSimInfo(boolean paramBoolean) { this.lockSimInfo = paramBoolean; } - - - public void setMccAndMnc(String MccMnc) { - this.mccAndMnc = MccMnc; - - String [] list=MccMnc.split(","); - if (list.length>=2){ - gpsp.setMCC(list[0]); - gpsp.setMNC(list[1]); - } - ICLogger.i("setMccAndMnc "+MccMnc); - } - - public void setSaveStepCount(int paramInt) { this.saveStepCount = paramInt; } - - public void setShutdown(boolean paramBoolean) { this.shutdown = paramBoolean; } - - public void setSignalStrength(int signal) { - this.SignalStrength = signal; + this.batteryLow = paramBoolean; + updateFZDDevStatusLowbat(batteryLow); //设置batterylow Alarm + } + + public void setBatterychanging(boolean paramBoolean) { + this.batterychanging = paramBoolean; + } + + public void setBelong(String paramString) { + this.belong = paramString; + } + + public void setCacheDir(File paramFile) { + this.cacheDir = paramFile; + } + + public void setCdmaInfo(String paramString) { + this.cdmaInfo = paramString; + } + + public void setCellinfo(String paramString) { + this.cellinfo = paramString; + } + + public void setCid(String paramString) { + this.cid = paramString; + } + + public void setContextProxy(ContextProxy paramContextProxy) { + this.contextProxy = paramContextProxy; + } + + public void setCurrentCellInfo(String paramString) { + this.currentCellInfo = paramString; + } + + public void setDBHelper(DBHelper paramDBHelper) { + this.dbHelper = paramDBHelper; + } + + public void setDevice_id(String paramString) { + this.device_id = paramString; + } + + public void setDevice_key(String paramString) { + this.device_key = paramString; + } + + public void setFileDir(File paramFile) { + this.fileDir = paramFile; + } + + public void setHaveBatteryChange(boolean paramBoolean) { + this.haveBatteryChange = paramBoolean; + } + + public void setHost(String _host) { + host = _host; + } + + public void setHostAndPort(String paramString, int paramInt) { + this.host = paramString; + this.port = paramInt; + } + + public void setPort(int _port) { + port = _port; + } + + public void setImeiAndCid(String paramString1, String paramString2) { + this.imei = paramString1; + this.cid = paramString2; + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(paramString1); + stringBuilder.append(","); + stringBuilder.append(paramString2); + this.imei_cid = stringBuilder.toString(); + ICLogger.i("imei:" + imei + ",cid:" + cid); + } + + public void setImsi(String paramString) { + this.imsi = paramString; + } + + public void setKey(String paramString) { + this.key = paramString; + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(this.imei_cid); + stringBuilder.append(","); + stringBuilder.append(paramString); + this.imei_cid_key = stringBuilder.toString(); + } + + public void setLbsHelper(LBSHelper paramLBSHelper) { + this.lbsHelper = paramLBSHelper; + } + + public void setLbsInfoByAt(String paramString1, String paramString2) { + this.lacByAt = paramString1; + this.cellidByAt = paramString2; + } + + + public void setLockSimInfo(boolean paramBoolean) { + this.lockSimInfo = paramBoolean; + } + + + public void setMccAndMnc(String MccMnc) { + this.mccAndMnc = MccMnc; + + String[] list = MccMnc.split(","); + if (list.length >= 2) { + gpsp.setMCC(list[0]); + gpsp.setMNC(list[1]); + } + ICLogger.i("setMccAndMnc " + MccMnc); + } + + public void setSaveStepCount(int paramInt) { + this.saveStepCount = paramInt; + } + + public void setShutdown(boolean paramBoolean) { + this.shutdown = paramBoolean; + } + + public void setSignalStrength(int signal) { + this.SignalStrength = signal; // ICLogger.i("setSignalStrength "+signal); - } - - public void setTestServerProp(boolean paramBoolean) { this.testServerProp = paramBoolean; } - - public void setTimestamp(long paramLong) { this.timestamp = paramLong; } - - public void setTotalStepCount(int paramInt) { this.totalStepCount = paramInt; } + } - private ICLocation gpsp = null; + public void setTestServerProp(boolean paramBoolean) { + this.testServerProp = paramBoolean; + } + + public void setTimestamp(long paramLong) { + this.timestamp = paramLong; + } - private String wifiInfo=""; + public void setTotalStepCount(int paramInt) { + this.totalStepCount = paramInt; + } - public void setWifiinfo(String info){ - wifiInfo=info; - } + private ICLocation gpsp = null; - public String getWifiInfo(){ return wifiInfo; } + private String wifiInfo = ""; - public Runtime() { - if (gpsp == null) gpsp = new ICLocation(); + public void setWifiinfo(String info) { + wifiInfo = info; } - public ICLocation getLocationInstance(){ - return gpsp; - } + public String getWifiInfo() { + return wifiInfo; + } - //暂时没有实现此功能 - public String getGPSLocationStarNums() { - return "000"; - } + public Runtime() { + if (gpsp == null) gpsp = new ICLocation(); + } - //此功能未实现 - public String getProtection() { - return "00"; - } + public ICLocation getLocationInstance() { + return gpsp; + } - // - public String getWorkModeStr() { - String gpsStr=String.format("%02d",getLocationInstance().getWorkingMod()); + //暂时没有实现此功能 + public String getGPSLocationStarNums() { + return "000"; + } - return gpsStr; - } + //此功能未实现 + public String getProtection() { + return "00"; + } - //未实现睡眠监测 - public String getRolltimes() { - return "00"; - } - /* AP03 心跳包 end */ + // + public String getWorkModeStr() { + String gpsStr = String.format("%02d", getLocationInstance().getWorkingMod()); - /* AP01 定位 */ + return gpsStr; + } + + //未实现睡眠监测 + public String getRolltimes() { + return "00"; + } + /* AP03 心跳包 end */ + /* AP01 定位 */ - public double temperature_adjustValue=0.0f; + public double temperature_adjustValue = 0.0f; - public boolean isGPSFixed(){ - return (gpsp.getLocationStat() == ICLocation.LOCATION_STAT.LOCATION_FIXED); - } + public boolean isGPSFixed() { + return (gpsp.getLocationStat() == ICLocation.LOCATION_STAT.LOCATION_FIXED); + } - public String getGPSData(){ + public String getGPSData() { // 2232.9806N11404.9355E000.1: 北纬22度32.9806分,东经114度04.9355分,速度为000.1 km/h,如经纬度无效,可默认全为0,如0000.0000N00000.0000E // 纬度格式为: ddmm.mmmm ,长度不足长度前补0 // 经度格式为:dddmm.mmmm,长度不足前补0 - StringBuilder sb=new StringBuilder(); - int lati=(int)gpsp.getLocation().lat; - int latl=(int) ((gpsp.getLocation().lat - lati)*10000); - int loni=(int)gpsp.getLocation().lon; - int lonl=(int) ((gpsp.getLocation().lon - loni)*10000); - int speedi=(int)gpsp.getLocation().speed; - int speedl=(int) ((gpsp.getLocation().speed - speedi)*10); - String latStr=gpsp.getLocation().latStr; - String lonStr=gpsp.getLocation().lonStr; - String latname=gpsp.getLocation().lat_name; - String lonname=gpsp.getLocation().lon_name; - if (isGPSFixed()) - { - if (gpsp.getLocation().lonStr.isEmpty()) { - String gpsStr = String.format("%04d.%04d%s%05d.%04d%s%03d.%01d", lati, latl,latname, loni, lonl,lonname, speedi, speedl); - sb.append("A").append(gpsStr); - }else{ - String gpsStr = String.format("%sN%sE%03d.%01d", latStr.substring(0,9), lonStr.substring(0,10), speedi, speedl); - sb.append("A").append(gpsStr); + StringBuilder sb = new StringBuilder(); + int lati = (int) gpsp.getLocation().lat; + int latl = (int) ((gpsp.getLocation().lat - lati) * 10000); + int loni = (int) gpsp.getLocation().lon; + int lonl = (int) ((gpsp.getLocation().lon - loni) * 10000); + int speedi = (int) gpsp.getLocation().speed; + int speedl = (int) ((gpsp.getLocation().speed - speedi) * 10); + String latStr = gpsp.getLocation().latStr; + String lonStr = gpsp.getLocation().lonStr; + String latname = gpsp.getLocation().lat_name; + String lonname = gpsp.getLocation().lon_name; + if (isGPSFixed()) { + if (gpsp.getLocation().lonStr.isEmpty()) { + String gpsStr = String.format("%04d.%04d%s%05d.%04d%s%03d.%01d", lati, latl, latname, loni, lonl, lonname, speedi, speedl); + sb.append("A").append(gpsStr); + } else { + String gpsStr = String.format("%sN%sE%03d.%01d", latStr.substring(0, 9), lonStr.substring(0, 10), speedi, speedl); + sb.append("A").append(gpsStr); + } + } else { + String gpsStr = String.format("%04d.%04dN%05d.%04dE%03d.%01d", 0, 0, 0, 0, 0, 0); + sb.append("V").append(gpsStr); } - }else{ - String gpsStr=String.format("%04d.%04dN%05d.%04dE%03d.%01d",0,0,0,0,0,0); - sb.append("V").append(gpsStr); - } - return sb.toString(); - } - public String getMqttGPSData(){ + return sb.toString(); + } + + public String getMqttGPSData() { /*** * A,22.570733,N,113.8626083,E,0.00,249.5,0.0,6 @@ -904,38 +1047,38 @@ public class Runtime { * 0.0,海拔 * 6,卫星个数 */ - StringBuilder sb=new StringBuilder(); - int speedi=(int)gpsp.getLocation().speed; - int speedl=(int) ((gpsp.getLocation().speed - speedi)*100); - - String latStr=gpsp.getLocation().latGPSStr; - String lonStr=gpsp.getLocation().lonGPSStr; - String latname=gpsp.getLocation().lat_name; - String lonname=gpsp.getLocation().lon_name; - ICLogger.i(" UD isfixed "+isGPSFixed()+" is in area "+bleInfo.is_in_area); - if(bleInfo.is_in_area==true){ - latStr=bleInfo.gps_n; - lonStr=bleInfo.gps_e; - latname=(latStr.trim().startsWith("-"))?"S":"N"; - lonname=(lonStr.trim().startsWith("-"))?"W":"E"; + StringBuilder sb = new StringBuilder(); + int speedi = (int) gpsp.getLocation().speed; + int speedl = (int) ((gpsp.getLocation().speed - speedi) * 100); + + String latStr = gpsp.getLocation().latGPSStr; + String lonStr = gpsp.getLocation().lonGPSStr; + String latname = gpsp.getLocation().lat_name; + String lonname = gpsp.getLocation().lon_name; + ICLogger.i(" UD isfixed " + isGPSFixed() + " is in area " + bleInfo.is_in_area); + if (bleInfo.is_in_area == true) { + latStr = bleInfo.gps_n; + lonStr = bleInfo.gps_e; + latname = (latStr.trim().startsWith("-")) ? "S" : "N"; + lonname = (lonStr.trim().startsWith("-")) ? "W" : "E"; } - String heading=String.valueOf(gpsp.getLocation().heading); - int starcount=gpsp.getLocation().used_gps_numbs; - if (isGPSFixed()|| bleInfo.is_in_area) - { - String gpsStr = String.format(",%s,%s,%s,%s,%d.%02d,%s,0.0,%d", latStr,latname, lonStr,lonname, speedi, speedl,heading,starcount); + String heading = String.valueOf(gpsp.getLocation().heading); + int starcount = gpsp.getLocation().used_gps_numbs; + if (isGPSFixed() || bleInfo.is_in_area) { + String gpsStr = String.format(",%s,%s,%s,%s,%d.%02d,%s,0.0,%d", latStr, latname, lonStr, lonname, speedi, speedl, heading, starcount); sb.append("A").append(gpsStr); - }else{ - String gpsStr=String.format(",0.000,N,0.000,E,0.0,0.0,0.0,0"); + } else { + String gpsStr = String.format(",0.000,N,0.000,E,0.0,0.0,0.0,0"); sb.append("V").append(gpsStr); } - ICLogger.i("UD "+sb.toString()); + ICLogger.i("UD " + sb.toString()); return sb.toString(); } - public String getFZDGPSData(){ + + public String getFZDGPSData() { /*** * A,22.570733,N,113.8626083,E,0.00,249.5,0.0,6 @@ -947,22 +1090,21 @@ public class Runtime { * 0.0,海拔 * 6,卫星个数 */ - StringBuilder sb=new StringBuilder(); - int speedi=(int)gpsp.getLocation().speed; - int speedl=(int) ((gpsp.getLocation().speed - speedi)*100); - String latStr=gpsp.getLocation().latGPSStr; - String lonStr=gpsp.getLocation().lonGPSStr; - String heading=String.valueOf(gpsp.getLocation().heading); - String latname=gpsp.getLocation().lat_name; - String lonname=gpsp.getLocation().lon_name; - int starcount=gpsp.getLocation().used_gps_numbs; - if (isGPSFixed()) - { - String gpsStr = String.format(",%s,%s,%s,%s,%d.%02d,%s,0.0,%d", latStr,latname, lonStr,lonname, speedi, speedl,heading,starcount); + StringBuilder sb = new StringBuilder(); + int speedi = (int) gpsp.getLocation().speed; + int speedl = (int) ((gpsp.getLocation().speed - speedi) * 100); + String latStr = gpsp.getLocation().latGPSStr; + String lonStr = gpsp.getLocation().lonGPSStr; + String heading = String.valueOf(gpsp.getLocation().heading); + String latname = gpsp.getLocation().lat_name; + String lonname = gpsp.getLocation().lon_name; + int starcount = gpsp.getLocation().used_gps_numbs; + if (isGPSFixed()) { + String gpsStr = String.format(",%s,%s,%s,%s,%d.%02d,%s,0.0,%d", latStr, latname, lonStr, lonname, speedi, speedl, heading, starcount); sb.append("A").append(gpsStr); - }else{ - String gpsStr=String.format(",0.000,N,0.000,E,0.0,0.0,0.0,0"); + } else { + String gpsStr = String.format(",0.000,N,0.000,E,0.0,0.0,0.0,0"); sb.append("V").append(gpsStr); } @@ -970,100 +1112,106 @@ public class Runtime { return sb.toString(); } - public String getGPSHeading(){ - int headingi=(int)gpsp.getLocation().heading; - int headingl=(int) ((gpsp.getLocation().heading - headingi)*100); - String gpsStr=String.format("%03d.%02d",headingi,headingl); - return gpsStr; - } - public String getFZDLBSMultiStationData(){ - if(mFZDLBSMultiStationData.trim().isEmpty()){ - mFZDLBSMultiStationData="0"; + public String getGPSHeading() { + int headingi = (int) gpsp.getLocation().heading; + int headingl = (int) ((gpsp.getLocation().heading - headingi) * 100); + String gpsStr = String.format("%03d.%02d", headingi, headingl); + return gpsStr; + } + + public String getFZDLBSMultiStationData() { + if (mFZDLBSMultiStationData.trim().isEmpty()) { + mFZDLBSMultiStationData = "0"; } return mFZDLBSMultiStationData; } - public String getFZDWifiData(){ + public String getFZDWifiData() { - int apsum=0; - String wifiinfo=getWifiInfo(); + int apsum = 0; + String wifiinfo = getWifiInfo(); if (!wifiinfo.isEmpty()) { String[] list = wifiinfo.split("&"); apsum = list.length; } - StringBuffer sb=new StringBuffer(); - if (apsum==0){ + StringBuffer sb = new StringBuffer(); + if (apsum == 0) { sb.append(apsum); - }else{ + } else { sb.append(apsum).append(","); - wifiinfo=wifiinfo.replace("&",",").replace("|",","); + wifiinfo = wifiinfo.replace("&", ",").replace("|", ","); sb.append(wifiinfo); } return sb.toString(); } - private static String mLBSMultiStationData=""; - public void setLBSMultiStationData(String data){ - mLBSMultiStationData=data; - } - private static String mFZDLBSMultiStationData=""; - public void setFZDLBSMultiStationData(String data){ - mFZDLBSMultiStationData=data; + private static String mLBSMultiStationData = ""; + + public void setLBSMultiStationData(String data) { + mLBSMultiStationData = data; } - //AP03 用的多基站定位数据 - public String getLBSMultiStationData(){ - // 7: 表示共有7组基站 + + private static String mFZDLBSMultiStationData = ""; + + public void setFZDLBSMultiStationData(String data) { + mFZDLBSMultiStationData = data; + } + + //AP03 用的多基站定位数据 + public String getLBSMultiStationData() { + // 7: 表示共有7组基站 // 460: MCC 国家码 // 0: MNC运营商代码 // 9520|3671|10: LAC|CID|dbm表示一组基站信息,后面数量需和基站组数地应 10:dbm为信号强度多基站信号强度建议从高到低排列后上传,信号强度转正数:150 – abs(dbm) - if(mLBSMultiStationData.trim().isEmpty()){ - mLBSMultiStationData="0,0,0,"; - } - return mLBSMultiStationData; - } + if (mLBSMultiStationData.trim().isEmpty()) { + mLBSMultiStationData = "0,0,0,"; + } + return mLBSMultiStationData; + } - public String getLBSData(){ + public String getLBSData() { // 460,0,9520,3671 : LBS基站数据,MCC国家码,460为中国,0:MNC,0为移动,9520:LAC,十进制,3671,CID,十进制 - StringBuilder sb=new StringBuilder(); - sb.append(gpsp.getMCC()).append(",") - .append(gpsp.getMNC()).append(",") - .append(gpsp.getLAC()).append(",") - .append(gpsp.getGSMStationCID()); - return sb.toString(); - } + StringBuilder sb = new StringBuilder(); + sb.append(gpsp.getMCC()).append(",") + .append(gpsp.getMNC()).append(",") + .append(gpsp.getLAC()).append(",") + .append(gpsp.getGSMStationCID()); + return sb.toString(); + } - public String getWifiData(){ - StringBuilder sb=new StringBuilder(); + public String getWifiData() { + StringBuilder sb = new StringBuilder(); - int i=0; - for (String mac : gpsp.getLBSdata().wifi_aps.keySet()){ - sb.append("AP").append(i).append("|").append(mac).append("|").append(gpsp.getLBSdata().wifi_aps.get(mac)).append(","); - i++; - } - if (i>0){ - int index=sb.lastIndexOf(","); - sb.replace(index,index+1,""); + int i = 0; + for (String mac : gpsp.getLBSdata().wifi_aps.keySet()) { + sb.append("AP").append(i).append("|").append(mac).append("|").append(gpsp.getLBSdata().wifi_aps.get(mac)).append(","); + i++; + } + if (i > 0) { + int index = sb.lastIndexOf(","); + sb.replace(index, index + 1, ""); + } + return sb.toString(); } - return sb.toString(); - } - public boolean sleepDataReported=false; + public boolean sleepDataReported = false; + + public static String lastSitCheckTiimeyyyyMMddHHmmss = ""; + public static long lastSitCheckStepCount = -1; - public static String lastSitCheckTiimeyyyyMMddHHmmss=""; - public static long lastSitCheckStepCount=-1; + public static HealthInfo healthInfo = null; - public static HealthInfo healthInfo=null; static { - healthInfo=new HealthInfo(); + healthInfo = new HealthInfo(); healthInfo.reset(); } - public static boolean practising=false; - public static int practice_cycle=60; + public static boolean practising = false; + public static int practice_cycle = 60; } diff --git a/app/src/main/java/com/enqualcomm/support/utils/TemperatureUtil.java b/app/src/main/java/com/enqualcomm/support/utils/TemperatureUtil.java index c3d15e51..969be7e5 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/TemperatureUtil.java +++ b/app/src/main/java/com/enqualcomm/support/utils/TemperatureUtil.java @@ -77,7 +77,12 @@ public class TemperatureUtil { CoreService.getInstance().sendBroadcast(pedIntent); } + + private static int loopTime; + + public static void DoTempTest() { + loopTime = 10; if (CoreService.getInstance() != null) { if (CoreService.getInstance().getRuntime().Anti_off_flag == 1) { ICLogger.i("未佩戴,取消TempTest!"); @@ -95,46 +100,55 @@ public class TemperatureUtil { double wrist_temp, body_temp, temout; temout = 0.0f; - - wrist_temp = TemperatureUtil.get_temp_value_adjusted(); - if (wrist_temp < 10) { - Util.mSleep(1000); - ICLogger.i("retry read temp for <10"); + 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()) { - //此处温度会走一个算法,跟主板挂钩,不同的主板有不同的公式,需要做实验,配置。 - //具体可以点击进去看里面的代码。 - TemperatureItem temperatureItem = TempAlgUtil.doTempTest(); - if (temperatureItem != null) { - body_temp = Float.parseFloat(temperatureItem.getBodyTemp()); - temout = Float.parseFloat(temperatureItem.getEvnTemp()); - } else { - ICLogger.log(TAG, "temperatureItem is null..."); - if (Config.disableWristTemp) { - body_temp = wrist_temp; + if (ICJniUtils.isTemperatureDevAvailable() == ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_IC68.ordinal()) { + //此处温度会走一个算法,跟主板挂钩,不同的主板有不同的公式,需要做实验,配置。 + //具体可以点击进去看里面的代码。 + TemperatureItem temperatureItem = TempAlgUtil.doTempTest(); + if (temperatureItem != null) { + body_temp = Float.parseFloat(temperatureItem.getBodyTemp()); + temout = Float.parseFloat(temperatureItem.getEvnTemp()); } 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); + ICLogger.log(TAG, "temperatureItem is null..."); + if (Config.disableWristTemp) { + body_temp = wrist_temp; } else { - body_temp = TemperatureUtil.getBodyTemp(wrist_temp, 26.0f); + 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); + } + try { + Thread.sleep(1000); + } catch (Exception e) { + e.printStackTrace(); + } + loopTime--; + if (loopTime <= 0) { + break; } - } else { - body_temp = TemperatureUtil.getBodyTemp(wrist_temp, 26.0f); } - if (Runtime.practising == true) { ICLogger.i("自由锻炼中,设置测量体温!" + String.format("%.1f", body_temp)); Runtime.healthInfo.setTemperatureData(body_temp);