/// <summary>
        /// 创建一个写入的报文指令
        /// </summary>
        /// <param name="address">起始地址</param>
        /// <param name="typeCode">类型数据</param>
        /// <param name="data">数据</param>
        /// <returns>包含结果对象的报文信息</returns>
        public OperateResult <byte[]> BuildWriteCommand(string address, ushort typeCode, byte[] data)
        {
            byte[] cip = AllenBradleyHelper.PackRequestWrite(address, typeCode, data);
            byte[] commandSpecificData = AllenBradleyHelper.PackCommandSpecificData(cip);

            return(OperateResult.CreateSuccessResult(AllenBradleyHelper.PackRequestHeader(0x6F, SessionHandle, commandSpecificData)));
        }
Beispiel #2
0
        /// <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)
        {
            try
            {
                byte[] cip = AllenBradleyHelper.PackRequestWrite(address, typeCode, data, length);
                byte[] commandSpecificData = AllenBradleyHelper.PackCommandSpecificData(Slot, cip);

                return(OperateResult.CreateSuccessResult(AllenBradleyHelper.PackRequestHeader(0x6F, SessionHandle, commandSpecificData)));
            }
            catch (Exception ex)
            {
                return(new OperateResult <byte[]>("Address Wrong:" + ex.Message));
            }
        }