private void ConnectDisconnect()
        {
            if (_port != null && _port.IsOpen)
            {
                _port.Close();
                _port.Dispose();
                _nmea.Dispose();

                _port = null;
                _nmea = null;

                ButtonText = "Connect";
                StatusText = "Not Connected.";
            }
            else
            {
                try
                {
                    _port = new SerialPort(Port, Baud);
                    _port.Open();
                    _nmea = new StreamDevice(_port.BaseStream);
                    _nmea.OpenAsync().Wait();

                    _nmea.MessageReceived += (sender, args) => { Received?.Invoke(sender, args); };
                    ButtonText             = "Disconnect";
                    StatusText             = $"Connected to {Port}";
                }
                catch (Exception e)
                {
                    StatusText = $"Not connected: {e.GetType()}";
                    _port      = null;
                    _nmea      = null;
                }
            }
        }
Exemplo n.º 2
0
        private static void Uut_MessageReceived(object sender, EventArgs e)
        {
            NmeaDevice  device  = (NmeaDevice)sender;
            NmeaMessage message = ((NmeaMessageReceivedEventArgs)e).Message;

            Console.WriteLine(message.ToString());
            list.Add(message);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            NmeaDevice uut = new NmeaDevice(new ComPort(7, 115200), @"C:\Users\Adam\Downloads\trash\uut_DIRECT.raw", @"C:\Users\Adam\Downloads\trash\uut.parerr", "uut");

            uut.MessageReceived += Uut_MessageReceived;
            uut.OpenPort();
            Console.ReadLine();
            uut.Close();
        }
Exemplo n.º 4
0
 private void InitNmeaProvider(NmeaDevice oldDevice, NmeaDevice newDevice)
 {
     mapView.LocationDisplay.IsEnabled = false;
     if (newDevice != null)
     {
         mapView.LocationDisplay.DataSource = new NmeaLocationProvider(newDevice);
         mapView.LocationDisplay.IsEnabled  = true;
     }
 }
Exemplo n.º 5
0
        private bool m_isLearning = true; // Indicates that we still haven't seen a full round of location messages yet

        /// <summary>
        /// Initializes a new instance of the <see cref="GnssMonitor"/> class.
        /// </summary>
        /// <param name="device">The NMEA device to monitor for GNSS messages</param>
        public GnssMonitor(NmeaDevice device)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }
            Device = device;
            Device.MessageReceived += NmeaMessageReceived;
            SynchronizationContext  = SynchronizationContext.Current;
        }
Exemplo n.º 6
0
        private void NmeaMessageReceived(object sender_, EventArgs args_)
        {
            DateTime time = DateTime.UtcNow;

            NmeaDevice  device   = (NmeaDevice)sender_;
            NmeaMessage message_ = ((NmeaMessageReceivedEventArgs)args_).Message;

            if (message_.MessageType == "GPINF")
            {
                PpsInfo message = (PpsInfo)message_;
                logger.LogLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}",
                               time.ToString("yyyy/MM/dd HH:mm:ss"),
                               message.delay,
                               message.average_90,
                               message.average_500,
                               message.average_1000,
                               message.temperature
                               );
            }
        }
Exemplo n.º 7
0
        public PpsCard(string inputResourceLocator, string logFilePath, string rawFilePath, string errFilePath)
        {
            InputResourceLocator = inputResourceLocator;

            logger = new ThreadedLogger(logFilePath, "PpsCardLogger");
            logger.Start();

            logger.LogLine("time(UTC)\tdelay\taverage (N=90)\taverage (N=500)\taverage (N=1000)\ttemperature");


            if (int.TryParse(inputResourceLocator, out int comPortNumber))
            {
                card = new NmeaDevice(new ComPort(comPortNumber, 115200, Parity.NOPARITY, 8, StopBits.ONESTOPBIT), rawFilePath, errFilePath, "PpsCard");
            }
            else
            {
                card = new NmeaDevice(inputResourceLocator, rawFilePath, errFilePath, "PpsCard");
            }

            card.MessageReceived += NmeaMessageReceived;
            card.OpenPort();
            card.startLogging();
            card.ResetInputStream();
        }