예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            gpsp1 = new GPSParser("COM9", this);
            gpsp1.GPSStringReceived += new GPSParser.GPSStringReceivedEventHandler(gpsp1_GPSStringReceived);

            gpsp2 = new GPSParser("COM11", this);
            gpsp2.GPSStringReceived += new GPSParser.GPSStringReceivedEventHandler(gpsp2_GPSStringReceived);
        }
예제 #2
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            try
            {
                File.Delete("COM9_GPS.txt");
            }
            catch (Exception ex)
            {

            }
            gpsp = new GPSParser(comboBox1.SelectedItem.ToString(), this);
            gpsp.GPSStringReceived += new GPSParser.GPSStringReceivedEventHandler(gpsp_GPSStringReceived);
        }
예제 #3
0
        void gpsp2_GPSStringReceived(object sender, GPSParser.GPSStringReceivedEventArgs e)
        {
            double Longitude = -(e.data.Long.Degrees + (e.data.Long.Minutes + (e.data.Long.FractionalMinutes / 10000.0)) / 60.0);
            double Latitude = e.data.Lat.Degrees + (e.data.Lat.Minutes + (e.data.Lat.FractionalMinutes / 10000.0)) / 60.0;

            gmc.SetMarkerAtLoc(Latitude, Longitude);
            textBox2.Clear();
            string gpsdata =
                "Altitude: " + e.data.Altitude.ToString() + "\r\n" +
                "course: " + e.data.Course.ToString() + "\r\n" +
                "date/time: " + e.data.GPSDateTime.ToString() + "\r\n" +
                "Lat: DD: " + e.data.Lat.Degrees + " MM: " + e.data.Lat.Minutes + " RM: " + e.data.Lat.FractionalMinutes + "\r\n" +
                "Long: DD: " + e.data.Long.Degrees + " MM: " + e.data.Long.Minutes + " RM: " + e.data.Long.FractionalMinutes + "\r\n" +
                "Velocity: " + e.data.Velocity.ToString() + "\r\n";
            textBox2.AppendText(gpsdata);

            File.AppendAllText("COM11_GPS.txt", "Longitude: " + Longitude.ToString() + "\r\n" + "Latitude: " + Latitude.ToString() + "\r\n" + gpsdata + "\r\n");
        }
예제 #4
0
 void Load_GPS_Parser()
 {
     GPSP = new GPSParser("COM11", this);
     GPSP.GPSStringReceived += new GPSParser.GPSStringReceivedEventHandler(GPSP_GPSStringReceived);
 }
예제 #5
0
        void GPSP_GPSStringReceived(object sender, GPSParser.GPSStringReceivedEventArgs e)
        {
            if (e.data.Long.Degrees != 0 && e.data.Lat.Degrees != 0)
            {
                Lon = e.data.Long;
                Lat = e.data.Lat;

                if (GoogleMapCtrl.BaseStationSet)
                {
                    RequestInfoTimer.Enabled = false;

                    double Longitude = -(Lon.Degrees + ((Lon.Minutes + (Lon.FractionalMinutes / 10000.0)) / 60.0));
                    double Latitude = Lat.Degrees + ((Lat.Minutes + (Lat.FractionalMinutes / 10000.0)) / 60.0);
                    GoogleMapCtrl.SetMarkerAtLoc(Latitude, Longitude);
                    double LatCorrection = 0;//GoogleMapCtrl.BaseStation.latitude - Latitude;
                    double LongCorrection = 0;//GoogleMapCtrl.BaseStation.longitude - Longitude;

                    GPSCorrection gpsc = new GPSCorrection();
                    if (AltitudeSamples < 10)
                    {
                        gpsc.Altitude = 0;//zero correction until we have enough base station samples
                        BaseStationAltitude += e.data.Altitude;
                        AltitudeSamples++;

                    }
                    if (AltitudeSamples == 10)
                    {
                        gpsc.Altitude = 0;//zero correction until we have enough base station samples
                        AltitudeSamples = 11;
                        BaseStationAltitude = BaseStationAltitude / 10.0;
                    }

                    if (AltitudeSamples == 11)
                    {
                        gpsc.Altitude = Convert.ToInt16((e.data.Altitude * 10) - (BaseStationAltitude * 10));
                        txtAltitudeCorrection.Text = gpsc.Altitude.ToString();
                    }
                    gpsc.Time = new DateTime();
                    gpsc.Time.AddSeconds(e.data.GPSDateTime.Second);

                    gpsc.LatMinutes = (short)(LatCorrection * 60.0 * 10000.0);
                    gpsc.LongMinutes = (short)-(LongCorrection * 60.0 * 10000.0);

                    txtLatCorrection.Text = gpsc.LatMinutes.ToString();
                    txtLongCorrection.Text = gpsc.LongMinutes.ToString();

                    if (ComProt != null)
                    {
                        int timeout = 0;
                        while (ComProt.ExpectedResponse.ResponseExpected)
                        {
                            if (timeout > 1000)
                            {
                                break;
                            }
                            timeout++;
                        }
                        ComProt.SendGPSCorrectionFactor(gpsc);

                        RequestInfoTimer.Enabled = true;
                    }
                }
            }
        }
예제 #6
0
        void gpsp2_GPSStringReceived(object sender, GPSParser.GPSStringReceivedEventArgs e)
        {
            double Longitude = -(e.data.Long.Degrees + (e.data.Long.Minutes + (e.data.Long.FractionalMinutes / 10000.0)) / 60.0);
            double Latitude = e.data.Lat.Degrees + (e.data.Lat.Minutes + (e.data.Lat.FractionalMinutes / 10000.0)) / 60.0;

            DataRow newGPSDataRow = GPS2DataTable.NewRow();
            newGPSDataRow["Latitude"] = Latitude;
            newGPSDataRow["Longitude"] = Longitude;
            newGPSDataRow["Altitude"] = e.data.Altitude;
            newGPSDataRow["Velocity"] = e.data.Velocity;
            newGPSDataRow["Time"] = e.data.GPSDateTime;
            GPS2DataTable.Rows.Add(newGPSDataRow);

            textBox1.AppendText("GPS2 data: ");
            foreach (object o in newGPSDataRow.ItemArray)
            {
                textBox1.AppendText(o.ToString() + "\t");
            }
            textBox1.AppendText("\r\n");
        }