Пример #1
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            string port  = cboPortName.Text;
            int    bd    = Convert.ToInt32(cboBaudRate.Text);
            Int32  index = cboHandshake.SelectedIndex;

            serialPort = new Serial(cboPortName.Text,
                                    Convert.ToInt32(cboBaudRate.Text),
                                    Convert.ToInt32(cboDataSize.Text),
                                    (Handshake)cboHandshake.SelectedIndex,
                                    (Parity)cboParity.SelectedIndex);

            serialMenager = new MyClass01.CommuManager(serialPort);
            serialMenager.Connect();

            //TODO: !!! add this every time when add new Communication type !!!
            Form1.CommuManager = Form1.CommuSwitch.Switch(serialMenager);
            ///////////////////

            if (serialPort.SerialPort.IsOpen)
            {
                lblStatus.Visible  = true;
                btnConnect.Enabled = false;
            }
        }
Пример #2
0
        private void btnColorUpload_Click(object sender, EventArgs e)
        {
            // Add red
            _cmd[0] = (Convert.ToByte(_red));
            // Add green
            _cmd[1] = (Convert.ToByte(_grn));
            // Add blue
            _cmd[2] = (Convert.ToByte(_blu));
            // Add power
            _cmd[3] = (Convert.ToByte(_pow));

            try
            {
                lab01Commu = Form1.CommuManager;
                lab01Commu.Write(_cmd);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error : " + ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //throw;
            }
        }