Exemplo n.º 1
0
 internal void StopDevice()
 {
     if (_currentDevice != null)
     {
         _currentDevice.MessageReceived -= Device_MessageReceived;
         _currentDevice.Dispose();
     }
 }
Exemplo n.º 2
0
 internal void StopDevice()
 {
     if (_currentDevice != null)
     {
         // _serialPortTimer.Stop();
         // _serialPortTimer.Enabled = false;
         // _serialPortTimer.Dispose();
         _currentDevice.MessageReceived -= Device_MessageReceived;
         _currentDevice.Dispose();
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Unloads the current device, and opens the next device
        /// </summary>
        /// <param name="device"></param>
        private void StartDevice(NmeaParser.NmeaDevice device)
        {
            //Clean up old device
            if (currentDevice != null)
            {
                currentDevice.MessageReceived -= device_MessageReceived;
                currentDevice.Dispose();
            }
            output.Text = "";
            messages.Clear();
            gprmcView.Message     = null;
            gpggaView.Message     = null;
            gpgsaView.Message     = null;
            gpgllView.Message     = null;
            pgrmeView.Message     = null;
            satView.GpgsvMessages = null;
            //Start new device
            currentDevice = device;
            currentDevice.MessageReceived += device_MessageReceived;
            var _ = currentDevice.OpenAsync();

            if (device is NmeaParser.NmeaFileDevice)
            {
                currentDeviceInfo.Text = string.Format("NmeaFileDevice( file={0} )", ((NmeaParser.NmeaFileDevice)device).FileName);
            }
            else if (device is NmeaParser.SerialPortDevice)
            {
                currentDeviceInfo.Text = string.Format("SerialPortDevice( port={0}, baud={1} )",
                                                       ((NmeaParser.SerialPortDevice)device).Port.PortName,
                                                       ((NmeaParser.SerialPortDevice)device).Port.BaudRate);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Unloads the current device, and opens the next device
        /// </summary>
        /// <param name="device"></param>
        private async Task StartDevice(NmeaParser.NmeaDevice device)
        {
            //Clean up old device
            if (currentDevice != null)
            {
                currentDevice.MessageReceived -= device_MessageReceived;
                if (currentDevice.IsOpen)
                {
                    await currentDevice.CloseAsync();
                }
                currentDevice.Dispose();
                if (gnssMonitorView.Monitor != null)
                {
                    gnssMonitorView.Monitor.LocationChanged -= Monitor_LocationChanged;
                    gnssMonitorView.Monitor = monitor = null;
                }
                mapplot.Clear();
            }
            output.Text = "";
            messages.Clear();
            gprmcView.Message = null;
            gpggaView.Message = null;
            gpgsaView.Message = null;
            gpgllView.Message = null;
            pgrmeView.Message = null;
            satView.ClearGsv();
            satSnr.ClearGsv();
            //Start new device
            currentDevice = device;
            foreach (var child in MessagePanel.Children.OfType <UnknownMessageControl>().ToArray())
            {
                MessagePanel.Children.Remove(child);
            }
            currentDevice.MessageReceived += device_MessageReceived;

            if (device is NmeaParser.NmeaFileDevice)
            {
                currentDeviceInfo.Text = string.Format("NmeaFileDevice( file={0} )", ((NmeaParser.NmeaFileDevice)device).FileName);
            }
            else if (device is NmeaParser.SerialPortDevice)
            {
                currentDeviceInfo.Text = string.Format("SerialPortDevice( port={0}, baud={1} )",
                                                       ((NmeaParser.SerialPortDevice)device).Port.PortName,
                                                       ((NmeaParser.SerialPortDevice)device).Port.BaudRate);
            }
            else if (device is BluetoothDevice bd)
            {
                currentDeviceInfo.Text = $"Bluetooth {bd.Service.Device.Name}";
            }
            await device.OpenAsync();

            gnssMonitorView.Monitor = monitor = new GnssMonitor(device);
            gnssMonitorView.Monitor.LocationChanged += Monitor_LocationChanged;
            view2d.GnssMonitor = monitor;
            view3d.GnssMonitor = monitor;
        }