コード例 #1
0
ファイル: Main.cs プロジェクト: weiyd/BLE-ECG
        void OnInitMasterEmulatorWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            this.Invoke((MethodInvoker) delegate()
            {
                log.Add(new StringValue(AppText.StartingUp));
            });

            masterEmulator = new MasterEmulator();
            RegisterEventHandlers();

            IEnumerable <string> usbDevices = masterEmulator.EnumerateUsb();

            this.Invoke((MethodInvoker) delegate()
            {
                PopulateUsbDevComboBox(usbDevices);
                //string usbSerial;
                if (masterEmulatorBoardsCount == 0)
                {
                    MessageBox.Show(AppText.NoDeviceSelected);
                    return;
                }
                btnOpenClose.Enabled = true;
                cboUsbSerial.Enabled = true;
            });

            initMasterEmulatorWorker.DoWork -= OnInitMasterEmulatorWorkerDoWork;
        }
コード例 #2
0
        /// <summary>
        /// Searching for master emulator devices attached to the pc.
        /// If more than one is connected it will simply return the first in the list.
        /// </summary>
        /// <returns>Returns the first master emulator device found.</returns>
        string FindUsbDevice()
        {
            /* The UsbDeviceType argument is used for filtering master emulator device types. */
            var devices = masterEmulator.EnumerateUsb(UsbDeviceType.AnyMasterEmulator);

            if (devices.Count > 0)
            {
                return(devices[0]);
            }
            else
            {
                return(string.Empty);
            }
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: eddyli5/eROCK-PC
        void OnInitMasterEmulatorDoWork(object sender, DoWorkEventArgs e)
        {
            this.Dispatcher.BeginInvoke((Action)delegate ()
            {
                AddLineToLog(AppText.StartingUp);
            });

            masterEmulator = new MasterEmulator();
            RegisterEventHandlers();

            IEnumerable<string> usbDevices = masterEmulator.EnumerateUsb();

            this.Dispatcher.BeginInvoke((Action)delegate ()
            {
                PopulateUsbDevComboBox(usbDevices);
            });

            initMasterEmulatorWorker.DoWork -= OnInitMasterEmulatorDoWork;
        }