采集WINCE设备GPS数据

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.IO;

namespace getgpsdata
{
    public partial class Form1 : Form
    {
        private delegate void FlushClient();//代理
        public Form1()
        {
            InitializeComponent();
        }
        Thread Online;
        private void btbegin_Click(object sender, EventArgs e)
        {
            if (!spgps.IsOpen)
                spgps.Open();
            spgps.DiscardInBuffer();//清除输入缓冲区
            spgps.DiscardOutBuffer();//清除输出缓冲区
            Online = new Thread(CrossThreadFlush);
            Online.IsBackground = true;
            Online.Start();

        }
        private void CrossThreadFlush()
        {
            while (true)
            {
                ThreadFunction();

                //将sleep和无限循环放在等待异步的外面
                //Thread.Sleep(7500);   //30秒
                //Thread.Sleep(3750); //15秒
                Thread.Sleep(1250);   //5秒
               // spgps.DiscardInBuffer();
            }
        }
        private void ThreadFunction()
        {
            if (this.txtdata.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(ThreadFunction);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                string record = spgps.ReadLine();
                if (record.StartsWith("$GPRMC"))
                {
                    txtdata.Text += record+"\n";
                    // 设置光标位置到文本最后 
                    txtdata.SelectionStart = txtdata.TextLength;
                    // 随文本滚动 
                    txtdata.ScrollToCaret();
                    spgps.DiscardInBuffer();
                }

            }
        }

        private void btstop_Click(object sender, EventArgs e)
        {
            //string gpsFile = "1秒" + DateTime.Now.ToString().Replace(@"/", @"-").Replace(@"\", @"-").Replace(@":", @"-") + ".txt";
            string gpsFile = "5秒" + DateTime.Now.ToString().Replace(@"/", @"-").Replace(@"\", @"-").Replace(@":", @"-") + ".txt";
            //string gpsFile = "15秒" + DateTime.Now.ToString().Replace(@"/", @"-").Replace(@"\", @"-").Replace(@":", @"-") + ".txt";
            //string gpsFile = "30秒" + DateTime.Now.ToString().Replace(@"/", @"-").Replace(@"\", @"-").Replace(@":", @"-") + ".txt";

            StreamWriter swFromFile = new StreamWriter("\\ResidentFlash\\" + gpsFile);
            swFromFile.Write(txtdata.Text);
            swFromFile.Flush();
            swFromFile.Close();
            this.Close();

            try
            {
                Online.Abort(Online);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            try
            {
                if (spgps.IsOpen)
                {
                    spgps.Close();
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
    }
}
 


 

Virace GPS Simulator V0.3.1 自述文件 2009.6.7 ====================================================================== Virace GPS Simulator是什么? ====================================================================== Virace GPS Simulator(以下简称为Virace)用软件模拟GPS接收器输出的GPS语 句,通过串行口输出到GPS应用软件。用鼠标或键盘控制Virace而模拟实际GPS接 收器的运动,或者重播已有的GPS航迹文件,从而在室内测试GPS导航软件等。 Virace具有手动实时控制及航迹重播两种方式。为了控制灵活方便,Virace定义 了许多鼠标及键盘动作。经过少许试用,就可以对照一个大比例尺的导航地图以 超过正常驾车速度行驶在市区及郊区路上。 ====================================================================== Virace运行在什么操作系统下? ====================================================================== Windows ====================================================================== Virace运行的方式 ====================================================================== 1. Windows下的GPS软件可通过Virace的虚拟串口直接测试。 2. Windows下有微软的Device Emulator,因此部分与Device Emulator兼容的 PPC、CE、SP软件可以在Device Emulator中模拟测试,由Virace提供GPS信号。 3. 可以将Virace输出到蓝牙的输出COM口,测试使用蓝牙GPS模块的PPC、SP及 Symbian S60等GPS软件。 4. Virace输出到PC的物理COM口,测试任何与PC物理串口连接的GPS设备 5. 用Virace将plt、gpx、kml、gpssim、trk格式的航迹文件,转为带速度、方 位角,及卫星状态的nmea文件,再在GpsGate内播放。 ====================================================================== Virace的特点 ====================================================================== 四种模式:自由驾驶模式 + 三种航迹重播模式(逐点重放航迹模式,手控速度 航迹模式,比例速度航迹模式)。运行中根据需要可在四种模式间无缝自由切换。 航迹文件支持plt、gpx(含gpx航迹及Garmin详细航线)、kml、gpssim、trk。 可将航迹文件另存为带速度、方位角,及卫星状态的nmea文件。 航迹重播时具有丰富的控制项,可快进、快退,选择某个段,反序,循环,亦可 人为加入左右偏移。 载入航迹时可选过滤掉点数少或距离小的段。 可选与PC版OziExplorer交互运行。通过Ozi API,在Ozi中双击地图上的某点, Virace就立即跳跃至该点(自由驾驶模式),或跳至离该点最近的航迹(航迹 重播模式);单击地图上的某点,则以当前速度向该点行驶(自由驾驶模式)。 最多3路COM口输出,加1路Ozi输出。每路的参数是独立选择的,且可以独立启停。 支持虚拟串口。与Eltima Virtual Serial Port ActiveX Control V2.5及对应的 Eltima Virtual Serial Port Driver兼容。注:Eltima Virtual Serial Port 是共享软件,一切权利归其所有人。Virace的发行包内不包括该虚拟串口驱动及 控件,请自行购买或下载试用版。 多种转向方式。鼠标滚轮,Ozi中单击,键盘左右箭头等。另有键盘45度及10度转 向键。键盘左右箭头及鼠标滚轮的转向灵敏度可自定义。 多个预设的速度键及上下箭头加减速,另外可随时暂停(速度为0,但依然输出GPS 信号)。 在退出时自动保存当前位置(经纬度、速度、方位角等)及所有
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值