Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!int.TryParse(textBox2.Text, out int baudRate))
            {
                MessageBox.Show(DemoUtils.BaudRateInputWrong);
                return;
            }

            if (!int.TryParse(textBox16.Text, out int dataBits))
            {
                MessageBox.Show(DemoUtils.DataBitsInputWrong);
                return;
            }

            if (!int.TryParse(textBox17.Text, out int stopBits))
            {
                MessageBox.Show(DemoUtils.StopBitInputWrong);
                return;
            }


            melsecA3C?.Close( );
            melsecA3C = new MelsecA3CNet( );

            try
            {
                melsecA3C.SerialPortInni(sp =>
                {
                    sp.PortName  = comboBox3.Text;
                    sp.BaudRate  = baudRate;
                    sp.DataBits  = dataBits;
                    sp.StopBits  = stopBits == 0 ? StopBits.None : (stopBits == 1 ? StopBits.One : StopBits.Two);
                    sp.Parity    = comboBox1.SelectedIndex == 0 ? Parity.None : (comboBox1.SelectedIndex == 1 ? Parity.Odd : Parity.Even);
                    sp.RtsEnable = true;
                });
                melsecA3C.Station  = byte.Parse(textBox15.Text);
                melsecA3C.SumCheck = checkBox1.Checked;
                melsecA3C.Format   = int.Parse(comboBox2.SelectedItem.ToString( ));

                melsecA3C.Open( );
                button2.Enabled = true;
                button1.Enabled = false;
                panel2.Enabled  = true;
                userControlReadWriteOp1.SetReadWriteNet(melsecA3C, "D100", false);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
 public FormMelsec3C( )
 {
     InitializeComponent( );
     melsecA3C = new MelsecA3CNet( );
 }