Ejemplo n.º 1
0
 //public IOdevice[] devices = {
 //        new IOdevice(1, 1, "EL1004", 4),
 //        new IOdevice(2, 2, "EL2004", 4),
 //        new IOdevice(3, 3, "EL3008", 8),
 //        new IOdevice(4, 4, "EL4002", 2),
 //    };
 public FormDevice()
 {
     InitializeComponent();
     ethercat = EtherCAT.getEtherCAT(true);
     //临时的
     ethercat.getAdapter();
     ethercat.setAdapter(2);
 }
Ejemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            int       selectedNic = dataGridView1.SelectedRows[0].Index;
            ErrorCode err         = ethercat.setAdapter(selectedNic);

            if (err != ErrorCode.NO_ERROR)
            {
                if (err == ErrorCode.ADAPTER_SELECT_FAIL)
                {
                    MessageBox.Show("选取失败");
                }
                else if (err == ErrorCode.NO_SLAVE_CONNECTED)
                {
                    MessageBox.Show("没有从站连接,请检查所选网卡");
                }
            }
            else
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }