stringBuilder.append("runtime.preCellInfo=");\r
stringBuilder.append(runtime.preCellInfo);\r
Logger.i(stringBuilder.toString());\r
- handlerH12();\r
+ handlerH12();//update StepCount\r
this.gSensorListener.startListen(paramWakeLock);\r
performAlarm(paramWakeLock);\r
}\r
+\r
+\r
+\r
+\r
public void startLocationProcess(int mod){\r
\r
- if (isLocating ) return;\r
+ Logger.i("isLocating "+isLocating+", lastStep"+runtime.getLastStepCount()+", currentStep"+ runtime.getTotalStepCount());\r
+ if (isLocating ) {\r
+ Logger.i("locating ,skip location!");\r
+ return;\r
+ }\r
+\r
+\r
+ if (runtime.getLastStepCount() == runtime.getTotalStepCount()){\r
+\r
+ Logger.i("No Move ,skip location!");\r
+ return ;\r
+ }\r
isLocating=true;\r
+\r
+ runtime.setLastStepCount(runtime.getTotalStepCount());\r
updateSimSignalInfo();\r
\r
updateCellInfo();\r
import com.ic.jni.ICJniUtils;
import com.ic.protocol.service.protocolMainServer;
+import com.ic.protocol.utils.Logger;
import java.util.Timer;
import java.util.TimerTask;
public class MainActivity extends AppCompatActivity {
+ TextView tv;
+ Handler handler=new Handler(new Handler.Callback() {
+ @Override
+ public boolean handleMessage(Message message) {
+
+
+ StringBuilder sb=new StringBuilder();
+ try {
+
+
+
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+
+
+ sb.append("ppg is available ").append(ICJniUtils.isPPGavailable())
+ .append(", ppg isstarted ").append(ICJniUtils.isPPGStarted())
+ .append(",ppg ").append(ICJniUtils.getPPG())
+ .append("weared ").append(ICJniUtils.isWeared())
+ .append(",spo2 ").append(ICJniUtils.getSPO2())
+ .append(",bph ").append(ICJniUtils.getHighBloodPressure())
+ .append(",bpl ").append(ICJniUtils.getLowBloodPressure())
+ .append("\n");
+ sb.append(protocolMainServer.getInstance().getServerAlive());
+ tv.setText( sb.toString());
+ return false;
+ }
+ });
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btnConnect = (Button) findViewById(R.id.btnConnect);
- TextView tv = (TextView)findViewById(R.id.textView);
+ tv = (TextView)findViewById(R.id.textView);
btnConnect.setOnClickListener(clickListener);
startService(new Intent(this,protocolMainServer.class));// protocol service
-
- Handler handler=new Handler(new Handler.Callback() {
- @Override
- public boolean handleMessage(Message message) {
-
-
- StringBuilder sb=new StringBuilder();
- try {
-
-
-
- }catch(Exception e){
- e.printStackTrace();
- }
-
-
- sb.append("ppg is available ").append(ICJniUtils.isPPGavailable())
- .append(", ppg isstarted ").append(ICJniUtils.isPPGStarted())
- .append(",ppg ").append(ICJniUtils.getPPG())
- .append("weared ").append(ICJniUtils.isWeared())
- .append(",spo2 ").append(ICJniUtils.getSPO2())
- .append(",bph ").append(ICJniUtils.getHighBloodPressure())
- .append(",bpl ").append(ICJniUtils.getLowBloodPressure())
- .append("\n");
-
- sb.append(protocolMainServer.getInstance().getServerAlive());
- tv.setText( sb.toString());
-
- return false;
- }
- });
+// double longitude=113.878339f;
+// double latitude=22.580827f;
+// double intfen= ((int)(longitude*100) - ((int)longitude)*100)*60/100f;
+// double miao= (longitude*100 - (int)(longitude*100));
+// double last= ((int)longitude)*100 +intfen+miao;
+// longitude =last;
+// intfen= ((int)(latitude*100) - ((int)latitude)*100)*60/100f;
+// miao= (latitude*100 - (int)(latitude*100));
+// last= ((int)latitude)*100 +intfen+miao;
+// latitude=last;
+//
+// Logger.i(" lat="+latitude+",lon="+longitude);
TimerTask tmt=new TimerTask() {
@Override
public void run() {
package com.ic.protocol;\r
\r
-import android.annotation.SuppressLint;\r
import android.location.Criteria;\r
import android.location.GpsSatellite;\r
import android.location.GpsStatus;\r
import android.os.Bundle;\r
import android.os.Handler;\r
import android.os.Message;\r
-import android.text.TextUtils;\r
-import android.util.Log;\r
-import android.widget.TextView;\r
-\r
import com.ic.protocol.bean.ICLocation;\r
import com.ic.protocol.bean.Runtime;\r
import com.ic.protocol.utils.FileOutputUtil;\r
import com.ic.protocol.utils.Logger;\r
+import com.ic.protocol.utils.TimeUtil;\r
\r
import java.text.DecimalFormat;\r
import java.util.ArrayList;\r
private double longitude;\r
private double latitude;\r
\r
- private int SearchTimeout = 400;\r
+ private int SearchTimeout = 120;\r
private int noSignalCount=0;\r
private int searchCout=0;\r
- GPS_CURRENT_STATUS gpsMode;\r
+ private GPS_CURRENT_STATUS gpsMode;\r
int numberOfSatellites;\r
Runtime runtime;\r
\r
// +" cost "+status.getTimeToFirstFix()+"ms");\r
// 定位算通过\r
gpsMode = GPS_CURRENT_STATUS.GPS_FIXED;\r
- runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_FIXED);\r
\r
- getBestLocation(locationManager,status);\r
\r
- stop();\r
+ delaystop();\r
\r
break;\r
case GpsStatus.GPS_EVENT_STARTED:\r
@Override\r
public boolean handleMessage(Message message) {\r
\r
+ if( message.what== 100|| message.what==200){\r
+ //no start\r
+ //do nothing\r
+\r
+ }else if (message.what==300){\r
+ //fixed\r
+ /*\r
+ 只有当前GPS已经定位,且location不为空才给 runtime赋值GPS坐标。\r
+ 延迟三秒后才设置runtime的定位标志,以便稳定坐标值。\r
+ */\r
+ runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_FIXED);\r
+\r
+ }\r
+\r
NMEAListener.this.stopListen();\r
return false;\r
}\r
\r
if (searchCout>SearchTimeout){\r
sb2.append(" 搜索"+searchCout+"次,超过"+SearchTimeout+"限制退出GPS定位");\r
- FileOutputUtil.fileOutput(this.runtime.getContextProxy().context,"GPS",sb2.toString());\r
gpsMode=GPS_CURRENT_STATUS.GPS_TIMEOUT;\r
runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_GPS_TIEMOUT);\r
\r
- stop();\r
+ stop(100);\r
}\r
- if (noSignalCount> 5){\r
+ if (noSignalCount> 10){\r
sb2.append(" 搜索"+searchCout+"次,超过"+noSignalCount+"次没有收到星,退出GPS定位");\r
- FileOutputUtil.fileOutput(this.runtime.getContextProxy().context,"GPS",sb2.toString());\r
gpsMode=GPS_CURRENT_STATUS.GPS_NOSINGAL;\r
runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_GPS_TIEMOUT);\r
\r
- stop();\r
+ stop(200);\r
}\r
+ FileOutputUtil.fileOutput(this.runtime.getContextProxy().context,"GPS",sb2.toString());\r
\r
- Log.e("dxc", sb2.toString());\r
+ Logger.i( sb2.toString());\r
+ getBestLocation(locationManager,status);\r
\r
return 0;\r
}\r
\r
//停止定位\r
- private void stop(){\r
+ private void stop(int id){\r
\r
// 经纬度 保留6位小数点\r
// DecimalFormat df = new DecimalFormat("#.000000");\r
//\r
// Logger.i("Location " +runtime.getLocationInstance().getLocationStat().name());\r
//发送停止消息\r
- NMEAListener.this.temHandler.sendMessage(new Message());\r
+ NMEAListener.this.temHandler.sendEmptyMessage(id);\r
}\r
+ private void delaystop(){\r
\r
+ /*\r
+ 只有当前GPS已经定位,且location不为空才给 runtime赋值GPS坐标。\r
+ 延迟三秒后才设置runtime的定位标志,以便稳定坐标值。\r
+ */\r
+ //发送停止消息\r
+ NMEAListener.this.temHandler.sendEmptyMessageDelayed(300,3000L);\r
+ }\r
boolean isFrist = true;\r
\r
/**\r
private void getBestLocation(LocationManager locationManager,GpsStatus status) {\r
Location location = null;\r
if (locationManager != null) {\r
- location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);\r
- if (location == null) {\r
-\r
-\r
- location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);\r
-\r
- }\r
+ location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);\r
+ if (location == null) {\r
+ location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);\r
+ }\r
\r
- if (location != null) {\r
- longitude = location.getLongitude();\r
- latitude = location.getLatitude();\r
- if (longitude > 0 && latitude > 0 ) {\r
- //sucess\r
- stop();// 定位成功,自动跳转2016.9.19 tyy\r
+ /*\r
+ 只有当前GPS已经定位,且location不为空才给 runtime赋值GPS坐标。\r
+ 延迟三秒后才设置runtime的定位标志,以便稳定坐标值。\r
+ */\r
+ if (location != null && gpsMode == GPS_CURRENT_STATUS.GPS_FIXED ) {\r
+ longitude = location.getLongitude();\r
+ latitude = location.getLatitude();\r
+// 转换单位,从度转换到分\r
+ double intfen= ((int)(longitude*100) - ((int)longitude)*100)*60/100f;\r
+ double miao= (longitude*100 - (int)(longitude*100));\r
+ double last= ((int)longitude)*100 +intfen+miao;\r
+ longitude =last;\r
+ intfen= ((int)(latitude*100) - ((int)latitude)*100)*60/100f;\r
+ miao= (latitude*100 - (int)(latitude*100));\r
+ last= ((int)latitude)*100 +intfen+miao;\r
+ latitude=last;\r
+\r
+ if (longitude > 0 && latitude > 0 ) {\r
+ //sucess\r
+ long gpsTime = location.getTime();\r
+\r
+ double altitude = location.getAltitude();// 海拔\r
+\r
+ // 速度\r
+ float speed = location.getSpeed();// 速度 单位 m/s\r
+ speed = (speed * 60) / 1000; // 单位转换 km/h\r
+ // 保留一位小数点\r
+ DecimalFormat dfSpeed = new DecimalFormat("#.0");\r
+ String strSpeed = dfSpeed.format(speed);\r
+ speed = Float.parseFloat(strSpeed);\r
+ int intSpeed = (int) (speed * 10);\r
+ // SimpleLogger.d("intSpeed:"+intSpeed);\r
+\r
+ // 经纬度 保留6位小数点\r
+ DecimalFormat df = new DecimalFormat("#.0000");\r
+ String strLatitude = df.format(latitude);\r
+ String strLongitude = df.format(longitude);\r
+\r
+ StringBuffer sb = new StringBuffer();\r
+ sb.append("gps time "+TimeUtil.getLocalTime(gpsTime)+" lon " + strLongitude + " lat " + strLatitude +" TimeToFirstFix "+status.getTimeToFirstFix());\r
+\r
+\r
+\r
+ // Logger.i("satelliteInfo:"+);\r
+ Logger.i( sb.toString());\r
+\r
+ FileOutputUtil.fileOutput(this.runtime.getContextProxy().context,"GPS",sb.toString());\r
+ runtime.getLocationInstance().setLocation(location.getLatitude(),location.getLongitude(),location.getSpeed(),0,status.getMaxSatellites());\r
}\r
\r
}\r
-\r
- long gpsTime = location.getTime();\r
-\r
- double altitude = location.getAltitude();// 海拔\r
-\r
- // 速度\r
- float speed = location.getSpeed();// 速度 单位 m/s\r
- speed = (speed * 60) / 1000; // 单位转换 km/h\r
- // 保留一位小数点\r
- DecimalFormat dfSpeed = new DecimalFormat("#.0");\r
- String strSpeed = dfSpeed.format(speed);\r
- speed = Float.parseFloat(strSpeed);\r
- int intSpeed = (int) (speed * 10);\r
- // SimpleLogger.d("intSpeed:"+intSpeed);\r
-\r
- // 经纬度 保留6位小数点\r
- DecimalFormat df = new DecimalFormat("#.000000");\r
- String strLatitude = df.format(latitude);\r
- String strLongitude = df.format(longitude);\r
-\r
- StringBuffer sb = new StringBuffer();\r
- sb.append("lon " + strLongitude + " lat " + strLatitude +" TimeToFirstFix "+status.getTimeToFirstFix());\r
-\r
-// Logger.i("satelliteInfo:"+);\r
- Logger.i( sb.toString());\r
-\r
- FileOutputUtil.fileOutput(this.runtime.getContextProxy().context,"GPS",sb.toString());\r
- runtime.getLocationInstance().setLocation(location.getLatitude(),location.getLongitude(),location.getSpeed(),0,status.getMaxSatellites());\r
-\r
}\r
}\r
\r
private boolean shutdown;\r
\r
\r
- \r
+ private int lastStepCount=0;\r
private long timestamp;\r
\r
public int totalStepCount;\r
- \r
- private String videoID;\r
- \r
+\r
+\r
+ public int getLastStepCount(){\r
+ return lastStepCount;\r
+ }\r
+ public void setLastStepCount(int st){\r
+ lastStepCount=st;\r
+ }\r
public String IMEI() { return this.imei; }\r
\r
public String IMEI_CID() { return this.imei_cid; }\r
public boolean getBatteryLow() { return this.batteryLow; }\r
\r
public boolean getBatterychanging() { return this.batterychanging; }\r
- \r
- public String getBelong() { return this.belong; }\r
+\r
\r
public File getCacheDir() { return this.cacheDir; }\r
\r
public String getCdmaInfo() { return this.cdmaInfo; }\r
\r
public String getCellidInfoByAt() { return this.cellidByAt; }\r
- \r
- public String getCellinfo() { return this.cellinfo; }\r
- \r
- public String getCid() { return this.cid; }\r
+\r
\r
public ContextProxy getContextProxy() { return this.contextProxy; }\r
\r
public File getFileDir() { return this.fileDir; }\r
\r
public boolean getHaveBatteryChange() { return this.haveBatteryChange; }\r
- \r
- public String getHaveBuy() { return this.haveBuy; }\r
- \r
- public String getHaveTry() { return this.haveTry; }\r
+\r
\r
public String getHost() { return this.testServerProp ? srvIP : this.host; }\r
\r
public String getKey() { return this.key; }\r
\r
public String getLacInfoByAt() { return this.lacByAt; }\r
- \r
- public String getLatitude() { return this.latitude; }\r
- \r
+\r
public LBSHelper getLbsHelper() { return this.lbsHelper; }\r
- \r
-// public String getLocation() { return this.location; }\r
+\r
\r
public boolean getLockSimInfo() { return this.lockSimInfo; }\r
\r
- public String getLongitude() { return this.longitude; }\r
+\r
\r
public String getMccAndMnc() { return this.mccAndMnc; }\r
\r
public int getSaveStepCount() { return this.saveStepCount; }\r
\r
public int getSignalStrength() { return this.SignalStrength; }\r
- \r
- public boolean getTestServerProp() { return this.testServerProp; }\r
+\r
\r
public long getTimestamp() { return this.timestamp; }\r
\r
public int getTotalStepCount() { return this.totalStepCount; }\r
- \r
- public String getVideoID() { return this.videoID; }\r
+\r
\r
public boolean isShutdown() { return this.shutdown; }\r
\r
public void setFileDir(File paramFile) { this.fileDir = paramFile; }\r
\r
public void setHaveBatteryChange(boolean paramBoolean) { this.haveBatteryChange = paramBoolean; }\r
- \r
- public void setHaveBuy(String paramString) { this.haveBuy = paramString; }\r
- \r
- public void setHaveTry(String paramString) { this.haveTry = paramString; }\r
- \r
+\r
public void setHostAndPort(String paramString, int paramInt) {\r
this.host = paramString;\r
this.port = paramInt;\r
stringBuilder.append(paramString);\r
this.imei_cid_key = stringBuilder.toString();\r
}\r
- \r
- public void setLatitude(String paramString) { this.latitude = paramString; }\r
- \r
+\r
public void setLbsHelper(LBSHelper paramLBSHelper) { this.lbsHelper = paramLBSHelper; }\r
\r
public void setLbsInfoByAt(String paramString1, String paramString2) {\r
public void setTimestamp(long paramLong) { this.timestamp = paramLong; }\r
\r
public void setTotalStepCount(int paramInt) { this.totalStepCount = paramInt; }\r
- \r
- public void setVideoID(String paramString) { this.videoID = paramString; }\r
-\r
-\r
-\r
-\r
-\r
\r
\r
private final String UserDebug = "userdebug";\r
public ICLocation getLocationInstance(){\r
return gpsp;\r
}\r
- public String getIMEI() {\r
- return imei;\r
- }\r
-\r
-\r
- public boolean isNetworkAvailable() {\r
- return true;\r
- }\r
\r
\r
/*\r
return "C41-GW-V0.0.1";\r
}\r
\r
- public String getBatteryLevel() {\r
- return "100";\r
- }\r
+\r
\r
/* AP03 心跳包 */\r
- public String getGSMSignal() {\r
- return "060";\r
- }\r
+\r
\r
public String getGPSLocationStarNums() {\r
return "000";\r
return "00";\r
}\r
\r
- public String getStepCount() {\r
- return "23425";\r
- }\r
\r
public String getRolltimes() {\r
return "00";\r
import com.ic.protocol.utils.NettyConnection;\r
import com.ic.protocol.utils.SharPreferenceUtil;\r
import com.ic.protocol.utils.SimSignalUtil;\r
+import com.ic.protocol.utils.TimeUtil;\r
import com.ic.protocol.utils.Util;\r
\r
import java.lang.ref.WeakReference;\r
\r
\r
public String getServerAlive(){\r
- return new StringBuilder().append("Connecttion status is ").append(this.connection.isServerConnected())\r
+ return new StringBuilder()\r
+ .append(TimeUtil.getLocalTime())\r
+ .append(" Connecttion status is ").append(this.connection.isServerConnected())\r
.append("\n KeepAlive ").append(KeepAlive.isConnected)\r
- .append( "\n Working Mode ").append(runtime.getLocationInstance().getWorkingMod()).append(" queue size ").append(LocationClient.queue.size())\r
+ .append( "\n Working Mode ").append(runtime.getLocationInstance().getWorkingMod()).append(" StepCount ").append(runtime.getTotalStepCount())\r
.append("\n AP01 = ").append(protocolAPIHelper.AP01(runtime))\r
.toString();\r
}\r
android:textOn="SimOn" />
</LinearLayout>
- <TextView
- android:id="@+id/textView"
+ <HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:scrollbarAlwaysDrawVerticalTrack="true"
- android:scrollbars="vertical"
- android:textAlignment="viewStart"
- android:textSize="18sp"
- android:verticalScrollbarPosition="right" />
+ android:scrollbars="horizontal|vertical">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="horizontal">
+
+ <TextView
+ android:id="@+id/textView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scrollbarAlwaysDrawVerticalTrack="true"
+ android:scrollbarSize="10dp"
+ android:scrollbarStyle="outsideOverlay"
+ android:scrollbars="vertical"
+ android:textAlignment="viewStart"
+ android:textSize="18sp"
+ android:verticalScrollbarPosition="right"
+ android:visibility="visible" />
+ </LinearLayout>
+ </HorizontalScrollView>
</LinearLayout>