Exemple #1
0
        /// <summary>
        /// Build a read command bytes
        /// </summary>
        /// <param name="address">the address of the tag name</param>
        /// <param name="length">Array information, if not arrays, is 1 </param>
        /// <returns>Message information that contains the result object </returns>
        public OperateResult <byte[]> BuildReadCommand(string[] address, int[] length)
        {
            if (address == null || length == null)
            {
                return(new OperateResult <byte[]>("address or length is null"));
            }
            if (address.Length != length.Length)
            {
                return(new OperateResult <byte[]>("address and length is not same array"));
            }

            try
            {
                List <byte[]> cips = new List <byte[]>( );
                for (int i = 0; i < address.Length; i++)
                {
                    cips.Add(AllenBradleyHelper.PackRequsetRead(address[i], length[i]));
                }
                byte[] commandSpecificData = AllenBradleyHelper.PackCommandSpecificData(Slot, cips.ToArray( ));

                return(OperateResult.CreateSuccessResult(AllenBradleyHelper.PackRequestHeader(0x6F, SessionHandle, commandSpecificData)));
            }
            catch (Exception ex)
            {
                return(new OperateResult <byte[]>("Address Wrong:" + ex.Message));
            }
        }
        /// <summary>
        /// 创建一个读取的报文指令
        /// </summary>
        /// <param name="address">tag名的地址</param>
        /// <returns>包含结果对象的报文信息</returns>
        public OperateResult <byte[]> BuildReadCommand(string[] address)
        {
            List <byte[]> cips = new List <byte[]>( );

            foreach (var add in address)
            {
                cips.Add(AllenBradleyHelper.PackRequsetRead(add));
            }
            byte[] commandSpecificData = AllenBradleyHelper.PackCommandSpecificData(cips.ToArray( ));

            return(OperateResult.CreateSuccessResult(AllenBradleyHelper.PackRequestHeader(0x6F, SessionHandle, commandSpecificData)));
        }
Exemple #3
0
 /// <summary>
 /// 创建一个读取的报文指令
 /// </summary>
 /// <param name="address">tag名的地址</param>
 /// <returns>包含结果对象的报文信息</returns>
 public OperateResult <byte[]> BuildReadCommand(string address)
 {
     byte[] cip = AllenBradleyHelper.PackRequsetRead(address);
     return(OperateResult.CreateSuccessResult(AllenBradleyHelper.PackRequestHeader(0x6F, SessionHandle, AllenBradleyHelper.PackCommandSpecificData2(NetWorkConnectionID, cip))));
 }