欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

c# 数据写入三菱PLC

程序员文章站 2022-03-04 16:44:57
public void Data_Write_Value(int[] m_write_data) { int lSize = 2; string[] AddressArray = new string[18] { "D720", "D721", "D722", "D723", "D724", "D7 ......

 public void Data_Write_Value(int[] m_write_data)
        {
            int lSize = 2;

            string[] AddressArray = new string[18] { "D720", "D721", "D722", "D723", "D724", "D725", "D726", "D727", "D728", "D729"
            ,"D730", "D731", "D732", "D733", "D734", "D735", "D736", "D737"};

            for (int k = 0; k < m_write_data.Length; k++)
            {

                
                int ReturnValue;
                lock (lockobj)
                {
                    ReturnValue = _ActUtlType.WriteDeviceBlock(AddressArray[k], lSize, m_write_data[k]);
                }

    if (ReturnValue != 0)    //返回0,写入成功。
                {
                    throw new Exception("PC Left Write Data Error!");
                }
            }

        }