Ejemplo n.º 1
0
        // поиск контроллеров DPI
        private void FindDPIInstruments()
        {
            контроллерToolStripMenuItem.DropDownItems.Clear();

            // создаём элемент списка, отвечающий за текущий контроллер
            if (CurrentDPI != null)
            {
                ToolStripMenuItem tsItem = new ToolStripMenuItem(CurrentDPI.ConnectString);
                tsItem.CheckOnClick = true;
                tsItem.Click       += new EventHandler(tsbtnSelectController_Click);
                tsItem.Checked      = true;
                контроллерToolStripMenuItem.DropDownItems.Add(tsItem);
            }

            // находим другие инструменты
            string[] foundInstr = CSDeviceBase.SearchInstruments();

            for (int i = 0; i < foundInstr.Length; i++)
            {
                // пропускаем активный задатчик
                if (CurrentDPI != null && CurrentDPI.ConnectString == foundInstr[i])
                {
                    continue;
                }

                // проверяем тип задатчика
                CSDeviceBase currentDev = CSDeviceBase.SetInstrumentType(foundInstr[i]);
                if (currentDev.TypeOfDevice != DeviceType.PRESSURE_CONTROLLER_DPI)
                {
                    currentDev.Close();
                    continue;
                }
                else
                {
                    currentDev.Close();

                    // добавляем элемент
                    ToolStripMenuItem tsItem = new ToolStripMenuItem(foundInstr[i]);
                    tsItem.CheckOnClick = true;
                    tsItem.Click       += new EventHandler(tsbtnSelectController_Click);
                    tsItem.Checked      = false;
                    контроллерToolStripMenuItem.DropDownItems.Add(tsItem);
                }
            }

            if (контроллерToolStripMenuItem.DropDownItems.Count < 1)
            {
                MessageBox.Show("Системе не удалось найти подключенных контроллеров DPI 520!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                FoundDPIs  = false;
                CurrentDPI = null;
            }
            else
            {
                FoundDPIs = true;
            }
        }
Ejemplo n.º 2
0
 static void Main(string[] args)
 {
     string[] strs = CSDeviceBase.SearchInstruments();
 }