protected void IDdiscont(object sender, EventArgs e) { if (combobox_avail.Active < 0) { return; } string port = combobox_avail.ActiveText; try { bool found = false; for (int i = 0; i < MainClass.devices.Length; i++) { NIRSDAQ.info info = MainClass.devices[i].GetInfo(); if (port == info.PortName) { MainClass.devices[i].IDmode(true); Thread.Sleep(3000); MainClass.devices[i].IDmode(false); found = true; } } if (!found) { XmlDocument doc = new XmlDocument(); doc.Load(@"BTNIRS_Config.xml"); NIRSDAQ.Instrument.Devices.TechEn.BTnirs bTnirs = new NIRSDAQ.Instrument.Devices.TechEn.BTnirs(doc); bTnirs.Connect(port); bTnirs.IDmode(true); Thread.Sleep(3000); bTnirs.IDmode(false); bTnirs.Destroy(); } } catch { } }
public PrefrencesWindow() : base(Gtk.WindowType.Toplevel) { this.Build(); XmlDocument doc = new XmlDocument(); doc.Load(@"BTNIRS_Config.xml"); device = new Instrument.Devices.TechEn.BTnirs(doc); // Get a list of serial port names. List <string> ports = device.ListPorts(); Gtk.ListStore ClearList = new Gtk.ListStore(typeof(string)); combobox_selectSerial.Model = ClearList; foreach (string s in ports) { combobox_selectSerial.AppendText(s); } combobox_selectSerial.Active = 0; if (!MainClass.win.settings.DEBUG) { frame_debug.Destroy(); } }
public ConnectDevices() { this.Build(); if (MainClass.win.settings.SYSTEM.Trim().ToLower().Equals("simulator")) { checkbutton_simMode.Active = true; vbox_devices.Sensitive = false; if (MainClass.devices == null) { spinbutton_numSimDevices.Value = 1; } else { spinbutton_numSimDevices.Value = MainClass.devices.Length; } } else if (MainClass.win.settings.SYSTEM.Trim().ToLower().Equals("simulatorhyperscan")) { checkbutton_simMode.Active = true; vbox_devices.Sensitive = false; spinbutton_numSimDevices.Value = 2; } else { checkbutton_simMode.Active = false; vbox_devices.Sensitive = true; spinbutton_numSimDevices.Value = 1; } XmlDocument doc = new XmlDocument(); doc.Load(@"BTNIRS_Config.xml"); NIRSDAQ.Instrument.Devices.TechEn.BTnirs bTnirs = new NIRSDAQ.Instrument.Devices.TechEn.BTnirs(doc); ports = bTnirs.ListPorts(); connected = new List <string>(); if (MainClass.devices != null) { for (int i = 0; i < MainClass.devices.Length; i++) { NIRSDAQ.info info = MainClass.devices[i].GetInfo(); connected.Add(info.PortName); if (ports.Contains(info.PortName)) { ports.Remove(info.PortName); } } } Gtk.ListStore ClearList = new Gtk.ListStore(typeof(string)); combobox_connected.Model = ClearList; foreach (string s in connected) { combobox_connected.AppendText(s); } Gtk.ListStore ClearList2 = new Gtk.ListStore(typeof(string)); combobox_avail.Model = ClearList2; foreach (string s in ports) { combobox_avail.AppendText(s); } combobox_avail.Active = ports.Count - 1; combobox_connected.Active = connected.Count - 1; }