/// <summary>
        /// Create a written message instruction
        /// </summary>
        /// <param name="address">The address of the tag name </param>
        /// <param name="typeCode">Data type</param>
        /// <param name="data">Source Data </param>
        /// <param name="length">In the case of arrays, the length of the array </param>
        /// <returns>Message information that contains the result object</returns>
        public OperateResult <byte[]> BuildWriteCommand(string address, ushort typeCode, byte[] data, int length = 1)
        {
            byte[] cip = AllenBradleyHelper.PackRequestWrite(address, typeCode, data, length);
            byte[] commandSpecificData = AllenBradleyHelper.PackCommandSpecificData(Slot, cip);

            return(OperateResult.CreateSuccessResult(AllenBradleyHelper.PackRequestHeader(0x6F, SessionHandle, commandSpecificData)));
        }
        /// <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"));
            }

            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)));
        }
 /// <summary>
 /// 获取卸载一个已注册的会话的报文 ->
 /// Get a message to uninstall a registered session
 /// </summary>
 /// <returns>字节报文信息 -> BYTE message information </returns>
 public byte[] UnRegisterSessionHandle( )
 {
     return(AllenBradleyHelper.PackRequestHeader(0x66, SessionHandle, new byte[0]));
 }
 /// <summary>
 /// 向PLC注册会话ID的报文 ->
 /// Register a message with the PLC for the session ID
 /// </summary>
 /// <returns>报文信息 -> Message information </returns>
 public byte[] RegisterSessionHandle( )
 {
     byte[] commandSpecificData = new byte[] { 0x01, 0x00, 0x00, 0x00, };
     return(AllenBradleyHelper.PackRequestHeader(0x65, 0, commandSpecificData));
 }