在 WM 平台上开发 GPS 导航系统
2010-02-21 22:52:00 来源:WEB开发网78 Return Checksum.ToString("X2")
79 End Function
80 End Class
81
无线原子时
时间是GPS技术的基石,因为距离以光速来测量。每个GPS卫星载有4个原子钟,它用来测定几纳秒内的无线传输。一个有趣的特点是只需几行代码,这些原子钟可用于同步电脑毫秒级精确度的时钟。$GPRMC语句的第二字,“040302.663”,以压缩格式包含卫星导出的时间。前两个字符代表时,紧接着两个字符代表分钟,再接着两个代表秒,小数点后的一切代表毫秒。因此,时间是上午4:03:02.663。然而,卫星报告的时间为通用时间(GMT +0),所以时间必须适应当地的时区。列表1-4增加了对卫星导出时间的支持,并使用DateTime.ToLocalTime方法将卫星时间转换为本地时区。
代码片段:
1 ********************************************************
2
3 '** Listing 1-4. Add support for satellite-derived time
4
5 '********************************************************
6
7 Public Class NmeaInterpreter
8 ' Raised when the current location has changed
9 Public Event PositionReceived(ByVal latitude As String, _
10 ByVal longitude As String)
11 Public Event DateTimeChanged(ByVal dateTime As DateTime)
12 ' Processes information from the GPS receiver
13 Public Function Parse(ByVal sentence As String) As Boolean
14 ' Discard the sentence if its checksum does not match our
15 ' calculated checksum
16 If Not IsValid(sentence) Then Return False
17 ' Look at the first word to decide where to go next
18 Select Case GetWords(sentence)(0)
19 Case "$GPRMC" ' A "Recommended Minimum" sentence was found!
20 Return ParseGPRMC(sentence)
21 Case Else
22 ' Indicate that the sentence was not recognized
23 Return False
24 End Select
25 End Function
26 ' Divides a sentence into individual words
27 Public Function GetWords(ByVal sentence As String) As String()
更多精彩
赞助商链接