static extern int nmea_parse(ref nmeaPARSER parser, string buff, int buff_sz, ref nmeaINFO info);
//根据解码结果更新gps信息 private void UpdateInfo(ref nmeaINFO gpsInfo) { nmeaTIME beiJingTime = new nmeaTIME(); //转换成北京时间 GMTconvert(ref gpsInfo.utc, ref beiJingTime, 8, 1); timeLabel.Content = Convert.ToString(beiJingTime.year) + "年" + Convert.ToString(beiJingTime.mon) + "月" + Convert.ToString(beiJingTime.day) + "日" + Convert.ToString(beiJingTime.hour) + ":" + Convert.ToString(beiJingTime.min) + ":" + Convert.ToString(beiJingTime.sec); //经度 longitudeLabel.Content = Convert.ToString(DegreeConvert(gpsInfo.lon)) + " E"; //纬度 latitudeLabel.Content = Convert.ToString(DegreeConvert(gpsInfo.lat)) + " N"; elevatiionLabel.Content = Convert.ToString(gpsInfo.elv) + " 米"; speedLabel.Content = Convert.ToString(gpsInfo.speed) + " km/h"; directionLabel.Content = Convert.ToString(gpsInfo.declination); switch (gpsInfo.sig) { case 0: signalLevalLabel.Content = "未定位"; break; case 1: signalLevalLabel.Content = "标准GPS定位"; break; case 2: signalLevalLabel.Content = "差分GPS定位"; break; default: break; } switch (gpsInfo.fix) { case 1: operationModeLabel.Content = "未定位"; break; case 2: operationModeLabel.Content = "2D定位"; break; case 3: operationModeLabel.Content = "3D定位"; break; default: break; } sateliteInView.Content = Convert.ToString(gpsInfo.satinfo.inview) + " 颗"; sateliteInUse.Content = Convert.ToString(gpsInfo.satinfo.inuse) + " 颗"; positionPrecisionLabel.Content = Convert.ToString(gpsInfo.PDOP); horizontalPrecisionLabel.Content = Convert.ToString(gpsInfo.HDOP); verticalPrecisionLabel.Content = Convert.ToString(gpsInfo.VDOP); if (baiDuMap.IsLoaded) { //非零时才作标注 if (gpsInfo.lon != 0 && gpsInfo.lat != 0) { //调用javascritpt函数标注地图 WebBrowser mapWB = (WebBrowser)baiDuMap.Content; mapWB.InvokeScript("theLocation", new object[] { DegreeConvert(gpsInfo.lon), DegreeConvert(gpsInfo.lat) }); } } }
static extern void nmea_zero_INFO(ref nmeaINFO info);