public string AutoOpen(AutoConnect_Window myLoadScreen) { int iterration = 10; //NI-Karte muss nicht geöffnet werden (immer Verbunden) //--> Abfragen ob Kanal ausgewählt wurde Communication_LOG += "Try to connect NI_USB6281:\n"; if (Channel_select.Text == "") //Wenn kein Port gewählt ist { return("No Channel selected!"); } myLoadScreen.ChangeTask("Change UI ...", iterration); Channel_Name = Channel_select.Text; Communication_LOG += "Seccessful\n"; IsConnected = true; //UI anpassen Channel_select.Enabled = false; Voltage_Trigger.Enabled = true; //Text und Kontext-Menü auf Button ändern button_OpenClose.Text = "Close"; return(""); }
public override string AutoOpen(AutoConnect_Window myLoadScreen) { int iterration = 2; Communication_LOG += "Try to connect NI_USB6281:\n"; //Öffnen if (ComPort_select.Text == "") //Wenn kein Port gewählt ist { MessageBox.Show("No Channel selected! \nTry again.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return("DAQ-Unit: Connection was not found!" + Environment.NewLine); } VISA_or_Channel_Name = ComPort_select.Text; Communication_LOG += "Seccessful\n"; myLoadScreen.ChangeTask("Change UI ...", iterration); IsConnected = true; //UI anpassen ComPort_select.Enabled = false; comboBox_Frequency.Enabled = true; comboBox_Range.Enabled = true; numericUpDown_Trigger.Enabled = true; //Text und Kontext-Menü auf Button ändern button_OpenClose.Text = "Close"; return(""); }
public override string AutoOpen(AutoConnect_Window myLoadScreen) { int iterration = 7; Communication_LOG += "Try to connect SPECTRUM:\n"; //Öffnen try { H_Device = Drv.spcm_hOpen(VISA_or_Channel_Name); } catch (System.DllNotFoundException) { Communication_LOG += "FAILED!\n"; return("DAQ-Unit: Connection was not found!" + Environment.NewLine); } //Prüfen ob verbindung erfolgreich war, sonst abbrechen if ((long)H_Device == 0) { Communication_LOG += "FAILED!\n"; return("DAQ-Unit: Connection was not seccessfull!" + Environment.NewLine); } Communication_LOG += "Seccessful\n"; myLoadScreen.ChangeTask("Reset ...", iterration); //Reseten ErrorCode_Spectrum += Reset(); myLoadScreen.ChangeTask("Change UI ...", iterration); //Ab hier verbunden IsConnected = true; //UI anpassen button_OpenClose.Text = "Close"; comboBox_Frequency.Enabled = true; comboBox_Range.Enabled = true; numericUpDown_Trigger.Enabled = true; return(""); }
//******************************************************************************************************************** // AutoConnect //******************************************************************************************************************** public string AutoOpen(AutoConnect_Window myLoadScreen) { int iterration = 5; if (ComPort_select.Text == "") //Wenn kein Port gewählt ist { return("Rth-Rack: No COM-Port selected!" + Environment.NewLine); } //COMPort anpassen Serial_Interface.PortName = ComPort_select.Text; //Verbindung herstellen try { Serial_Interface.Open(); } catch (UnauthorizedAccessException) { return("Rth-Rack: COM Port is allready in use!" + Environment.NewLine); } catch (System.IO.IOException) { return("Rth-Rack: COM Port is not available!" + Environment.NewLine); } myLoadScreen.ChangeTask("Checking device ...", iterration); //Abfragen ob richtiges Gerät DeviceType = Write_N_Read("GID"); //Checken ob vom richtigen Typ if (!DeviceType.Contains("RthTEC TTA-Equipment")) { Serial_Interface.Close(); return("Rth-Rack: COM Port represents no Rth-Rack!" + Environment.NewLine); } myLoadScreen.ChangeTask("Reset ...", iterration); //Reset Write_N_Read("RST"); //Delay Thread.Sleep(2000); //Default Einstellungen setzen SetEnable(false); //SetDefaultSetup(); myLoadScreen.ChangeTask("Change GUI ...", iterration); //Oberfläche anpassen IsConnected = true; //Reset_Button.Enabled = true; TestPulse.Enabled = true; Enable_Button.Enabled = true; UI_KindOfComponent.Enabled = true; UI_Heat_Time.Enabled = true; UI_Heat_Current.Enabled = true; UI_Heat_Voltage.Enabled = true; UI_Meas_Time.Enabled = true; UI_Meas_Current.Enabled = true; UI_Meas_Voltage.Enabled = true; UI_Cycles.Enabled = true; UI_Offset_Voltage.Enabled = true; ComPort_select.Enabled = false; OpenClose.Text = "Close"; cm.Items["Reset"].Enabled = true; return(""); }