using SLH.SSDMS.Common; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SLH.SSDMS.Services.serviceImpl { public class ReturnBuffer : IReturnBuffer { public byte[] HeartAnalysisResult(int status, byte terminal) { byte[] buffer = new byte[10]; buffer[0] = 0xA5; buffer[1] = 0x5A; buffer[2] = 0x00; buffer[3] = 0x04; buffer[4] = 0x62; buffer[5] = terminal; buffer[6] = Convert.ToByte(status); //状态 //取数据长度 byte[] dataLength = new byte[2]; dataLength[0] = buffer[2]; dataLength[1] = buffer[3]; int dataLen = StringChange.bytesToHexStr(dataLength, dataLength.Length).ToInt() + 1; //取长度、类型、数据计算校验 byte[] calByte = new byte[dataLen]; Array.Copy(buffer, 2, calByte, 0, dataLen); buffer[7] = Convert.ToByte(checkUtil.BCC(calByte));//校验 buffer[8] = 0x0D; buffer[9] = 0x0A; return buffer; } public byte[] ReadAnalysisResult(int status, byte terminal) { byte[] buffer = new byte[10]; buffer[0] = 0xA5; buffer[1] = 0x5A; buffer[2] = 0x00; buffer[3] = 0x04; buffer[4] = 0x84; buffer[5] = terminal; buffer[6] = Convert.ToByte(status); //状态 //取数据长度 byte[] dataLength = new byte[2]; dataLength[0] = buffer[2]; dataLength[1] = buffer[3]; int dataLen = StringChange.bytesToHexStr(dataLength, dataLength.Length).ToInt() + 1; //取长度、类型、数据计算校验 byte[] calByte = new byte[dataLen]; Array.Copy(buffer, 2, calByte, 0, dataLen); buffer[7] = Convert.ToByte(checkUtil.BCC(calByte));//校验 buffer[8] = 0x0D; buffer[9] = 0x0A; return buffer; } public byte[] HaltBuffer() { byte[] buffer = new byte[14]; buffer[0] = 0xA5; buffer[1] = 0x5A; buffer[2] = 0x00; buffer[3] = 0x08; buffer[4] = 0xA4; buffer[5] = 0xFF; buffer[6] = 0x01; buffer[7] = 0x01; buffer[8] = 0x00; buffer[9] = 0x00; buffer[10] = 0x00; buffer[11] = 0x53; buffer[12] = 0x0D; buffer[13] = 0x0A; return buffer; } } }