示例#1
0
文件: Form1.cs 项目: Pablini/mVengo
        private void btn_Config_Click(object sender, EventArgs e)
        {
            Byte d1 = (Byte)cbGPO1.SelectedIndex;

            IRP1.Gpo_800 msg1 = new IRP1.Gpo_800(0x01, d1);
            if (reader.Send(msg1))
            {
                lbl_msg.Text = "GPO1 set";
            }
            else
            {
                lbl_msg.Text = "Error setting GPO1";
            }



            Byte d2 = (Byte)cbGPO2.SelectedIndex;

            IRP1.Gpo_800 msg2 = new IRP1.Gpo_800(0x02, d2);
            if (reader.Send(msg2))
            {
                lbl_msg.Text = lbl_msg.Text + " GPO2 set";
            }
            else
            {
                lbl_msg.Text = lbl_msg.Text + " Error setting GPO2";
            }


            Byte d3 = (Byte)cbGPO3.SelectedIndex;

            IRP1.Gpo_800 msg3 = new IRP1.Gpo_800(0x03, d3);
            if (reader.Send(msg3))
            {
                lbl_msg.Text = lbl_msg.Text + " GPO3 set";
            }
            else
            {
                lbl_msg.Text = lbl_msg.Text + " Error setting GPO3";
            }


            Byte d4 = (Byte)cbGPO4.SelectedIndex;

            IRP1.Gpo_800 msg4 = new IRP1.Gpo_800(0x04, d4);
            if (reader.Send(msg4))
            {
                lbl_msg.Text = lbl_msg.Text + " GPO4 set";
            }
            else
            {
                lbl_msg.Text = lbl_msg.Text + " Error setting GPO4";
            }
        }
示例#2
0
        private void btn_Config_Click(object sender, EventArgs e)
        {
            String ms = "";
            String mf = "";

            #region 设置 IO输出状态
            if (cbIO1.Checked)
            {
                if (comboBox1.Text.Trim() == String.Empty)
                {
                    MessageBox.Show("请设置输出端口1");
                    return;
                }

                Byte         d   = (Byte)comboBox1.SelectedIndex;
                IRP1.Gpo_800 msg = new IRP1.Gpo_800(0x01, d);
                if (reader.Send(msg))
                {
                    ms = "1,";
                }
                else
                {
                    mf = "1,";
                }
            }
            if (cbIO2.Checked)
            {
                if (comboBox2.Text.Trim() == String.Empty)
                {
                    MessageBox.Show("请设置输出端口2");
                    return;
                }

                Byte         d   = (Byte)comboBox2.SelectedIndex;
                IRP1.Gpo_800 msg = new IRP1.Gpo_800(0x02, d);
                if (reader.Send(msg))
                {
                    ms += "2,";
                }
                else
                {
                    mf += "2,";
                }
            }
            if (cbIO3.Checked)
            {
                if (comboBox3.Text.Trim() == String.Empty)
                {
                    MessageBox.Show("请设置输出端口3");
                    return;
                }

                Byte         d   = (Byte)comboBox3.SelectedIndex;
                IRP1.Gpo_800 msg = new IRP1.Gpo_800(0x03, d);
                if (reader.Send(msg))
                {
                    ms += "3,";
                }
                else
                {
                    mf += "3,";
                }
            }
            if (cbIO4.Checked)
            {
                if (comboBox4.Text.Trim() == String.Empty)
                {
                    MessageBox.Show("请设置输出端口4");
                    return;
                }

                Byte         d   = (Byte)comboBox4.SelectedIndex;
                IRP1.Gpo_800 msg = new IRP1.Gpo_800(0x04, d);
                if (reader.Send(msg))
                {
                    ms += "4,";
                }
                else
                {
                    mf += "4,";
                }
            }
            #endregion
            String m = "";
            if (ms != "")
            {
                m = "输出端口" + ms.Trim(',') + "设置成功";
            }
            if (mf != "")
            {
                m += "\r\n" + "输出端口" + mf.Trim(',') + "设置失败";
            }
            if (m.Trim() != String.Empty)
            {
                MessageBox.Show(m);
            }
        }