Esempio n. 1
0
 /// <summary>
 /// Включаем анализ данных датчика GPS с записью в текстовое поле
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void GPSPortButton_Click(object sender, EventArgs e)
 {
     if (GPSInterSerialPort.IsOpen)
     {
         GPSInterSerialPort.Close();
         gpsportopen        = false;
         GPSPortButton.Text = Resources.GPS_Read_Stirng;
         GPSTextBox.Text    = string.Empty;
     }
     else
     {
         GPSInterSerialPort.Open();
         GPSPortButton.Text = Resources.GPS_Clear_String;
         gpsportopen        = true;
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Изменение порта датчика GPS
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GPSPortComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            KeyValuePair <string, string> gpcb = (KeyValuePair <string, string>)GPSPortComboBox.SelectedItem;

            if (gpcb.Value != GPSInterSerialPort.PortName)
            {
                if (GPSInterSerialPort.IsOpen)
                {
                    GPSInterSerialPort.Close();
                    gpsportopen = false;
                }
                GPSTextBox.Text             = string.Empty;
                GPSInterSerialPort.PortName = gpcb.Value;
                GPSPortButton.Text          = Resources.GPS_Read_Stirng;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Слушаем GPS порт
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void GPSInterSerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
 {
     if (gpsportopen)
     {
         Thread.Sleep(10);// Небольшая задержка перед чтением
         try
         {
             if (GPSInterSerialPort.BytesToRead > 0)
             {
                 string incomingString = GPSInterSerialPort.ReadLine();
                 this.BeginInvoke(new SetDelegateText(gpsData), new object[] { incomingString });
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("Ошибка чтения GPS-порта." + Environment.NewLine + ex.Message);
         }
     }
 }