Esempio n. 1
0
        public MainForm()
        {
            InitializeComponent();

            Text = "ADSB# v" + Assembly.GetExecutingAssembly().GetName().Version;

            _decoder.FrameReceived += delegate(byte[] frame, int length) {
                Interlocked.Increment(ref _frameCount);
                _frameSink.FrameReady(frame, length);
            };

            portNumericUpDown_ValueChanged(null, null);
            confidenceNumericUpDown_ValueChanged(null, null);
            timeoutNumericUpDown_ValueChanged(null, null);

            try {
                _rtlDevice.Open();

                DeviceDisplay[] devices = DeviceDisplay.GetActiveDevices();
                deviceComboBox.Items.Clear();
                deviceComboBox.Items.AddRange(devices);

                //_initialized = true;
                deviceComboBox.SelectedIndex = 0;
                deviceComboBox_SelectedIndexChanged(null, null);
            }
            catch (Exception e) {
                MessageBox.Show(e.Message);
            }
        }
Esempio n. 2
0
        public void Open()
        {
            var devices = DeviceDisplay.GetActiveDevices();

            foreach (var device in devices)
            {
                try
                {
                    SelectDevice(device.Index);
                    return;
                }
                catch (ApplicationException)
                {
                    // Just ignore it
                }
            }
            if (devices.Length > 0)
            {
                throw new ApplicationException(devices.Length + " compatible devices have been found but are all busy");
            }
            throw new ApplicationException("No compatible devices found");
        }
Esempio n. 3
0
        public MainForm()
        {
            InitializeComponent();

            _dataSet.Columns.Add("ICAO", typeof(string));
            _dataSet.Columns.Add("LastUpdate", typeof(DateTime));
            _dataSet.Columns.Add("Identification", typeof(string));
            _dataSet.Columns.Add("Category", typeof(string));
            _dataSet.Columns.Add("Squawk", typeof(string));
            _dataSet.Columns.Add("AirborneVelocity", typeof(string));
            _dataSet.Columns.Add("SIL", typeof(string));
            _dataSet.Columns.Add("SDA", typeof(string));
            _dataSet.Columns.Add("BarometricAltitude", typeof(string));
            _dataSet.Columns.Add("Lattitude", typeof(string));
            _dataSet.Columns.Add("Longitude", typeof(string));

            dataGridView1.DataSource = _dataSet;
            dataGridView1.Columns["LastUpdate"].DefaultCellStyle.Format = "dd/MM/yyyy HH:mm:ss";
            dataGridView1.Columns["LastUpdate"].Width = 130;

            var adsbTranslator = new AdsbTranslator();

            adsbTranslator.Statistics = new Statistics();

            Text = "ADSB# v" + Assembly.GetExecutingAssembly().GetName().Version;

            _decoder.FrameReceived += delegate(byte[] frame, int length)
            {
                Interlocked.Increment(ref _frameCount);

                var t = new ModeSTranslator();
                t.Statistics = new Statistics();
                var modeSMessage = t.Translate(frame, 0, null, false);

                AdsbTranslator t2 = new AdsbTranslator();
                t2.Statistics = new Statistics();
                AdsbMessage adsbMessage = t2.Translate(modeSMessage);

                if (adsbMessage != null)
                {
                    BeginInvoke(new Action(delegate
                    {
                        Debug.Print(adsbMessage.ToString());
                        UpdateView(adsbMessage);
                    }));
                }
            };

            confidenceNumericUpDown_ValueChanged(null, null);
            timeoutNumericUpDown_ValueChanged(null, null);

            try
            {
                _rtlDevice.Open();

                var devices = DeviceDisplay.GetActiveDevices();
                deviceComboBox.Items.Clear();
                deviceComboBox.Items.AddRange(devices);

                //_initialized = true;
                deviceComboBox.SelectedIndex = 0;
                deviceComboBox_SelectedIndexChanged(null, null);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }