コード例 #1
0
        /// <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);
            }
        }
コード例 #2
0
        /// <summary>
        /// Open the serial ports.
        /// </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 actions 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 serial ports...";

                        // If both ports are the same, send an error.
                        if (comboBoxAnalytePort.Text.Equals(comboBoxDiluentPort.Text))
                        {
                            throw new ArgumentException("Both ports can't be the same.");
                        }

                        // Open the Mass Flow Controllers (and let it know what serial port to use).
                        _mfcAnalyte.Open(Properties.Settings.Default.PortAnalyte);
                        _mfcDiluent.Open(Properties.Settings.Default.PortDiluent);

                        // Update the user interface.
                        comboBoxAnalytePort.Enabled    = false;
                        comboBoxDiluentPort.Enabled    = false;
                        groupBoxGasses.Enabled         = true;
                        groupBoxFlowAndMixture.Enabled = true;
                        toolStripStatusLabel1.Text     = "Port open.";
                    }
                    else if (((RadioButton)sender) == radioButtonClosed)
                    {
                        // Close the serial port.
                        _mfcAnalyte.Close();
                        _mfcDiluent.Close();

                        // Update the user interface.
                        comboBoxAnalytePort.Enabled    = true;
                        comboBoxDiluentPort.Enabled    = true;
                        groupBoxGasses.Enabled         = false;
                        groupBoxFlowAndMixture.Enabled = false;
                        toolStripStatusLabel1.Text     = "Port closed.";
                    }
                }
                // If an error occurs...
                catch (Exception ex)
                {
                    // Alert the user.
                    MessageBox.Show(ex.Message, ex.GetType().Name.ToString());

                    // Undo the user action.
                    radioButtonClosed.Checked = true;
                }
            }
        }
コード例 #3
0
ファイル: FormMassFlow.cs プロジェクト: JaydenChou/TestSuite
        /// <summary>
        /// Open the serial port.
        /// </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 actions 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 serial port...";

                        // Open the Mass Flow Controller (and let it know what serial port to use).
                        _massFlowController.Open(Properties.Settings.Default.Port);

                        // Update the user interface.
                        comboBoxSerialPort.Enabled = false;
                        groupBoxMassFlow.Enabled   = true;
                        toolStripStatusLabel1.Text = "Port open.";
                    }
                    else if (((RadioButton)sender) == radioButtonClosed)
                    {
                        // Alert the user.
                        toolStripStatusLabel1.Text = "Closing serial port...";

                        // Close the serial port.
                        _massFlowController.Close();

                        // Update user interface.
                        comboBoxSerialPort.Enabled = true;
                        groupBoxMassFlow.Enabled   = false;
                        toolStripStatusLabel1.Text = "Port closed.";
                    }
                }
                // If an error occurs...
                catch (Exception ex)
                {
                    // Alert the user.
                    MessageBox.Show(ex.Message, ex.GetType().Name.ToString());

                    // Undo the user action.
                    radioButtonClosed.Checked = true;
                }
            }
        }
コード例 #4
0
ファイル: Equipment.cs プロジェクト: LingChengye/TestSuite
        /// <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();
            }
        }