Esempio n. 1
0
        /// <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).
                        _powerSupply.Open(Properties.Settings.Default.Port, 9600);

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

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

                        // Update user interface.
                        comboBoxSerialPort.Enabled  = true;
                        groupBoxOutput.Enabled      = false;
                        groupBoxPowerSupply.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;
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Close all equipment.
 /// </summary>
 public void Close()
 {
     _mfcAnalyte?.Close();
     _mfcDiluent?.Close();
     _datalogger?.Close();
     _powerSupply?.Close();
 }