/// <summary> /// Initializes all equipment. /// </summary> public void Open(bool useDatalogger = false) { // Remember what equipment to use. _useDatalogger = useDatalogger; // Configure the mass flow controllers. if ((UseGasMixer) && (_mfcAnalyte != null) && (_mfcDiluent != null)) { _mfcAnalyte?.Open(_settings.GasMixer.AnalyteMFC.SerialPort); _mfcDiluent?.Open(_settings.GasMixer.DiluentMFC.SerialPort); } // Configure the datalogger. if ((_useDatalogger == true) && (_datalogger != null)) { _datalogger.Bank = _settings.Datalogger.Bank; _datalogger.Open(); } // Configure the power supply. if (UsePowerSupply && (_powerSupply != null)) { _powerSupply.Channel = 1; _powerSupply.Open(_settings.PowerSupply.SerialPort, _settings.PowerSupply.BaudRate); } }
/// <summary> /// Connect or disconnect from the instrument. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void radioButton_CheckedChanged(object sender, EventArgs e) { // Do stuff only if the radio button is checked. // (Otherwise the action will run twice.) if (((RadioButton)sender).Checked) { try { // If the "Open" radio button has been checked... if (((RadioButton)sender) == radioButtonOpen) { // Alert the user. toolStripStatusLabel1.Text = "Opening VISA connection..."; // Open the connection. _datalogger.Open(comboBoxResources.Text); // Update the user interface. groupBoxConfiguration.Enabled = true; toolStripStatusLabel1.Text = "VISA connection opened."; } // If the "Closed" radio button has been checked... else if (((RadioButton)sender) == radioButtonClosed) { // Alert the user. toolStripStatusLabel1.Text = "Closing serial port..."; // Close the connection. _datalogger.Close(); // Update user interface. groupBoxConfiguration.Enabled = false; toolStripStatusLabel1.Text = "VISA connection closed."; } } // If an error occurs... catch (Exception ex) { // Alert the user. MessageBox.Show(ex.Message, "Error"); toolStripStatusLabel1.Text = ex.Message; // Undo the user action. radioButtonClosed.Checked = true; } } }
/// <summary> /// Initializes all equipment. /// </summary> public void Open(bool useDatalogger) { // Remember whether we're using the datalogger or not. _useDatalogger = useDatalogger; // Configure the mass flow controllers. _mfcAnalyte?.Open(_settings.GasMixer.AnalyteMFC.SerialPort); _mfcDiluent?.Open(_settings.GasMixer.DiluentMFC.SerialPort); // Configure the gas mixer. if (_gasMixer != null) { _gasMixer.AnalyteBottleConcentration = _settings.GasMixer.AnalyteBottleConcentration; } // Configure the datalogger. if ((_useDatalogger == true) && (_datalogger != null)) { _datalogger.Bank = _settings.Datalogger.Bank; _datalogger.Open(); } }