Skip to content

Commit d3ec2d1

Browse files
author
wenlong
committed
解决行程记录不准的问题
1 parent 148e1d9 commit d3ec2d1

File tree

3 files changed

+37
-8
lines changed

3 files changed

+37
-8
lines changed

src/com/obd/app/bean/RSOInfo.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,8 @@ public String getQ(){
7979
vbat = (int)(Float.parseFloat(VBAT)*1000);
8080
rmp = (int)(Float.parseFloat(RPM)*4);
8181
spd = Integer.parseInt(SPD);
82-
}catch (Exception e) {
83-
// TODO: handle exception
84-
}
82+
}catch (Exception e) {}
83+
8584
StringBuffer buffer = new StringBuffer();
8685
buffer.append("&Q");
8786
//buffer.append(String.format("0x050x%02x",ect));

src/com/obd/utils/QuickShPref.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,16 @@ public class QuickShPref {
2424
public static String LON = "lon";
2525
public static String Time = "time";
2626
public static String TimeGPS = "TimeGPS";
27+
28+
public static String StartTme = "StartTme";
29+
public static String StartLat = "StartLat";
30+
public static String StartLon = "StartLon";
31+
2732
private static SharedPreferences sSharedPreferences;
2833
private static Editor sEditor;
34+
35+
36+
2937

3038
public static void init(Context c){
3139
sSharedPreferences = c.getSharedPreferences(c.getPackageName(),Context.MODE_PRIVATE);

src/com/obd/widget/GetLoaction.java

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.obd.widget;
22

3+
import java.io.IOException;
34
import java.nio.Buffer;
45
import java.text.SimpleDateFormat;
56
import java.util.Date;
@@ -75,12 +76,16 @@ public String uploadPos(BDLocation location) {
7576
int lonFenInt = (int) lonFen;
7677
String lonString = String.format("%03d%02d%04d", lonDu, lonFenInt,
7778
(int) ((lonFen - lonFenInt) * 10000));
78-
79+
String lonStartString = String.format("%03d%02d.%04d", lonDu, lonFenInt,
80+
(int) ((lonFen - lonFenInt) * 10000));
81+
7982
int latDu = (int) lat;
8083
float latFen = (float) (lat - latDu) * 60;
8184
int latFenInt = (int) latFen;
8285
String latString = String.format("%02d%02d%04d", latDu, latFenInt,
8386
(int) ((latFen - latFenInt) * 10000));
87+
String latStartString = String.format("%02d%02d.%04d", latDu, latFenInt,
88+
(int) ((latFen - latFenInt) * 10000));
8489

8590
String speed = String.format("%02d",
8691
Math.round(location.getSpeed()*3.6f / 3.704f));
@@ -115,13 +120,30 @@ public String uploadPos(BDLocation location) {
115120
if(StatusInface.getInstance().getStartS1() != null){
116121
buffer.append("&S1,0,,"+StatusInface.getInstance().getTime());
117122
DBmanager.getInase().insertBackup(buffer.toString());
123+
QuickShPref.putValueObject(QuickShPref.StartTme, StatusInface.getInstance().getTime());
124+
QuickShPref.putValueObject(QuickShPref.StartLat, latStartString);
125+
QuickShPref.putValueObject(QuickShPref.StartLon, lonStartString);
126+
try {
127+
Runtime.getRuntime().exec("sync");
128+
} catch (IOException e) {
129+
// TODO Auto-generated catch block
130+
e.printStackTrace();
131+
}
118132
}else{
119133
DROInfo mDROInfo = StatusInface.getInstance().getDROInfo();
120134
if(mDROInfo != null){
121-
buffer.append(String.format("&S2,%s,%sE,%sN,%d,%d,5,%s,%s,%s,%s,0", StatusInface.getInstance().getTime(),
122-
lonString,latString,mDROInfo.getMILESM(),mDROInfo.getFuleSmL(),
123-
mDROInfo.RACLS,mDROInfo.BRAKES,mDROInfo.STARTS,mDROInfo.STARTS));
124-
DBmanager.getInase().insertBackupNote(buffer.toString(),mDROInfo.note);
135+
String startLon = QuickShPref.getString(QuickShPref.StartLon);
136+
String startLat = QuickShPref.getString(QuickShPref.StartLat);
137+
String startTime = QuickShPref.getString(QuickShPref.StartTme);
138+
139+
if(startTime != null || startLat != null || startLon != null){
140+
buffer.append(String.format("&S2,%s,%sE,%sN,%d,%d,5,%s,%s,%s,%s,0", startTime,
141+
startLon,startLat,mDROInfo.getMILESM(),mDROInfo.getFuleSmL(),
142+
mDROInfo.RACLS,mDROInfo.BRAKES,mDROInfo.STARTS,mDROInfo.STARTS));
143+
DBmanager.getInase().insertBackupNote(buffer.toString(),mDROInfo.note);
144+
}else{
145+
MyLog.E("startTime="+startTime+",startLat="+startLat+",startLon="+startLon);
146+
}
125147
}else{
126148
buffer.append("&O"+SatelliteNumber);
127149
buffer.append("&N"+mGSMsingle);

0 commit comments

Comments
 (0)