コード例 #1
0
        private void ScanComplite(object sender, TiEventArgs e)
        {
            if (grdTargets.InvokeRequired)
            {
                Invoke(new MethodInvoker(delegate { ScanComplite(sender, e); }));
            }
            else
            {
                _in_scan = false;
                if (_in_test == false)
                {
                    btnScan.Enabled  = true;
                    btnStart.Enabled = true;
                    btnStop.Enabled  = true;
                }
                else
                {
                    foreach (DataGridViewRow row in grdTargets.Rows)
                    {
                        if (row.Tag == null)
                        {
                            row.Tag = 0;
                        }
                        BleDevice device = BleDevices.GetDeviceByMac(row.Cells["colMac"].Value.ToString());
                        if ((int)row.Tag > 0 || ((device != null) && (device.Connected)))
                        {
                            row.DefaultCellStyle.BackColor = Color.White;
                        }
                        else
                        {
                            row.DefaultCellStyle.BackColor = Color.OrangeRed;
                        }
                        if (csv != null)
                        {
                            string line = string.Format("{4,3},{0,8},{1,-15},{2,4},{5,12},{6,-7},{3}" /*+ Environment.NewLine*/,
                                                        row.Cells["colMAC"].Value.ToString(),
                                                        row.Cells["colDeviceName"].Value.ToString(),
                                                        row.Cells["colRSSI"].Value.ToString(),
                                                        DateTime.Now.ToString(),
                                                        (int)row.Tag,
                                                        (row.Cells["colVersion"].Value == null ? "" : row.Cells["colVersion"].Value.ToString()),
                                                        device != null ? device.Connected.ToString() : "false");
                            try
                            {
                                UpdateDeviceRssi(row.Cells["colMAC"].Value.ToString(), 0);
                            }
                            catch (Exception ex)
                            {
                                logger.Error(ex, "Failed to set RSSI to 0");
                            }
                            File.AppendAllText(CsvFilename, line + Environment.NewLine);
                            //csv.Info(line);
                        }
                        row.Tag = 0;
                    }

                    TestConnection();
                }
            }
        }
コード例 #2
0
 private void HardwareInitComplite(object sender, TiEventArgs e)
 {
     if (this.InvokeRequired)
     {
         Invoke(new MethodInvoker(delegate { HardwareInitComplite(sender, e); }));
     }
     else
     {
         btnScan.Enabled  = true;
         btnStart.Enabled = false;
         btnStop.Enabled  = false;
     }
 }