Exemplo n.º 1
0
        /// <summary>
        /// 将要发送的命令变成字节数组
        /// </summary>
        /// <returns></returns>
        public List <byte> GetBytesDebug()
        {
            //先计算Payload长度
            UpdatePayloadLength(6);
            //命令头部(payload length(含)之前)
            this.m_Channel = 0x3F;

            List <byte> basebuffer = base.GetBytes();

            if (m_PumpStatusList == null)
            {
                m_PumpStatusList = new List <PumpStatus>();
            }
            m_PumpStatusList.Clear();
            m_PumpStatusList.Add(PumpStatus.Stop);
            m_PumpStatusList.Add(PumpStatus.Run);
            m_PumpStatusList.Add(PumpStatus.Stop);
            m_PumpStatusList.Add(PumpStatus.Run);
            m_PumpStatusList.Add(PumpStatus.Stop);
            m_PumpStatusList.Add(PumpStatus.Run);

            for (int i = 0; i < m_PumpStatusList.Count; i++)
            {
                basebuffer.Add((byte)(m_PumpStatusList[i]));
            }
            //取checksum字节
            uint checksum = CRC32.CalcCRC32Partial(basebuffer, basebuffer.Count, CRC32.CRC32_SEED);

            checksum ^= CRC32.CRC32_SEED;
            byte[] arrChecksum = StructConverter.StructureToByte <uint>(checksum);
            basebuffer.AddRange(arrChecksum);
            return(basebuffer);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 将要发送的命令变成字节数组,用于带序列号的测试
        /// </summary>
        /// <returns></returns>
        public override List <byte> GetBytesEx()
        {
            //先计算Payload长度
            UpdatePayloadLength(0);
            //命令头部(payload length(含)之前)
            List <byte> basebuffer = base.GetBytesEx();
            //取checksum字节
            uint checksum = CRC32.CalcCRC32Partial(basebuffer, basebuffer.Count, CRC32.CRC32_SEED);

            checksum ^= CRC32.CRC32_SEED;
            byte[] arrChecksum = StructConverter.StructureToByte <uint>(checksum);
            basebuffer.AddRange(arrChecksum);
            return(basebuffer);
        }
Exemplo n.º 3
0
        public List <byte> GetBytesDebug()
        {
            byte payloadLength = (byte)(m_PumpPackages.Count * this.m_Channel);

            this.m_Direction = 0;
            //先计算Payload长度
            UpdatePayloadLength(payloadLength);
            //命令头部(payload length(含)之前)
            List <byte> basebuffer = base.GetBytes();

            for (int i = 0; i < m_PumpPackages.Count; i++)
            {
                basebuffer.AddRange(m_PumpPackages[i].GetBytes());
            }
            //取checksum字节
            uint checksum = CRC32.CalcCRC32Partial(basebuffer, basebuffer.Count, CRC32.CRC32_SEED);

            checksum ^= CRC32.CRC32_SEED;
            byte[] arrChecksum = StructConverter.StructureToByte <uint>(checksum);
            basebuffer.AddRange(arrChecksum);
            return(basebuffer);
        }