//public MonitorPlatformMessage Serializable(string Msg) //{ // MonitorPlatformMessage tmp = new MonitorPlatformMessage(); // string[] msgItem = Msg.Split('|'); // if (msgItem.Length > 0) // { // tmp.FILENAME = msgItem[0].Split('~')[1].Split('.')[0]; // tmp.SRVPHYSICALCODE = msgItem[1].Split('~')[1]; // byte[] startIndex = new byte[4]; // if (msgItem[2].Split('~')[1].Length > 0) // { // for (int i = 0; i < msgItem[2].Split('~')[1].Length / 2; i++) // { // startIndex[i] = (byte)Convert.ToInt32(msgItem[2].Split('~')[1].Substring(2 * i, 2), 16); // } // } // tmp.PACKSTARTINDEX = startIndex; // } // return tmp; //} public void Serialize(string Msg) { if (Msg.Contains("UPGRADE")) { UpdateCode tmp = new UpdateCode(); string[] msgItem = Msg.Split('|'); if (msgItem.Length > 0) { foreach (var item in msgItem) { switch (item.Split('~')[0]) { case "PACKETTYPE": tmp.PACKETTYPE = item.Split('~')[1]; break; case "NEWVERSION": tmp.NEWVERSION = item.Split('~')[1]; break; case "OLDVERSION": tmp.OLDVERSION = item.Split('~')[1]; break; case "UPGRADEMODE": tmp.UPGRADEMODE = item.Split('~')[1]; break; case "HTTPURL": tmp.HTTPURL = item.Split('~')[1]; break; case "LIST": string[] str = item.Split('~')[1].Split('&'); tmp.LIST = new List <string>(); foreach (var code in str) { tmp.LIST.Add(code); } break; } } SendbackDetail sendbackDetail = new SendbackDetail(); sendbackDetail.tag = Equipment.OnlineUpdate; sendbackDetail.Extras = tmp; DataDealHelper.MyEvent(sendbackDetail); } } else if (Msg.Contains("TRANSFER")) { TransferCode tmp = new TransferCode(); string[] msgItem = Msg.Split('|'); if (msgItem.Length > 0) { foreach (var item in msgItem) { switch (item.Split('~')[0]) { case "PACKETTYPE": tmp.PACKETTYPE = item.Split('~')[1]; break; case "FILENAME": tmp.FILENAME = item.Split('~')[1]; break; case "SRVPHYSICALCODE": tmp.SRVPHYSICALCODE = item.Split('~')[1]; break; case "PACKSTARTINDEX": byte[] startIndex = new byte[4]; if (item.Split('~')[1].Length > 0) { for (int i = 0; i < item.Split('~')[1].Length / 2; i++) { startIndex[i] = (byte)Convert.ToInt32(item.Split('~')[1].Substring(2 * i, 2), 16); } } tmp.PACKSTARTINDEX = startIndex; break; case "AUDIOREBACKSERVERIP": tmp.AUDIOREBACKSERVERIP = item.Split('~')[1]; break; case "AUDIOREBACKPORT": tmp.AUDIOREBACKPORT = Convert.ToInt32(item.Split('~')[1]); break; } } if (tmp.AUDIOREBACKSERVERIP != null && tmp.AUDIOREBACKPORT != null) { string name = Dns.GetHostName(); IPAddress[] ipadrlist = Dns.GetHostAddresses(name); foreach (var item in ipadrlist) { if (item.ToString() == tmp.AUDIOREBACKSERVERIP) { OpenReceiveTool(tmp.AUDIOREBACKSERVERIP, Convert.ToInt32(tmp.AUDIOREBACKPORT)); } } } tmp.Audio_reback_mode = 1;//1 UDP;2 TCP;3串口;其它值预留 现暂时默认设置为udp 20180129 SendbackDetail sendbackDetail = new SendbackDetail(); sendbackDetail.tag = Equipment.FileName; sendbackDetail.Extras = tmp; DataDealHelper.MyEvent(sendbackDetail); } } else if (Msg.Contains("TTS")) { TTSC tmp = new TTSC(); string[] msgItem = Msg.Split('|'); if (msgItem.Length > 0) { foreach (var item in msgItem) { switch (item.Split('~')[0]) { case "PACKETTYPE": tmp.PACKETTYPE = item.Split('~')[1]; break; case "TsCmd_Params": tmp.TsCmd_Params = item.Split('~')[1]; break; case "TsCmd_Mode": tmp.TsCmd_Mode = item.Split('~')[1]; break; case "TsCmd_ValueID": tmp.DeviceIdList = new List <int>(); if (tmp.TsCmd_Mode == "区域") { string strAreaId = item.Split('~')[1]; string[] ids = strAreaId.Split(','); List <int> tt = new List <int>(); for (int i = 0; i < ids.Length; i++) { tt.Add(Convert.ToInt32(ids[i])); } tmp.DeviceIdList = db.AeraCode2DeviceID(tt); } else { string strDeviceID = item.Split('~')[1]; string[] ids = strDeviceID.Split(','); foreach (var id in ids) { tmp.DeviceIdList.Add(Convert.ToInt32(id)); } } break; case "TsCmd_PlayCount": tmp.TsCmd_PlayCount = Convert.ToInt32(item.Split('~')[1]); break; } } tmp.FileID = (SingletonInfo.GetInstance().FileID + 1).ToString("X").PadLeft(4, '0'); SingletonInfo.GetInstance().FileID += 1; SendbackDetail sendbackDetail = new SendbackDetail(); sendbackDetail.tag = Equipment.TTS; sendbackDetail.Extras = tmp; log.Error("收到文本转语音MQ指令"); DataDealHelper.MyEvent(sendbackDetail); } } }
/// <summary> /// 终端和服务器握手 应答发送 /// </summary> /// <param name="data"></param> private void SendDataResponse(object data) { SendbackDetail SendObject = (SendbackDetail)data; switch ((Equipment)SendObject.tag) { case Equipment.terminal2serverhandshake: { EquipmentDetail ob = SendObject.Rebackdata; byte[] SendCommandShakehandsList = new byte[21] { 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; for (int m = 0; m < 9; m++) { SendCommandShakehandsList[1 + m] = ob.HeaderData[1 + m]; } SendCommandShakehandsList[10] = ob.HeaderData[16]; string datatmp2 = "10040041030102"; //20180125应朱红彪需求 数据长度的大小端转换 高低位换位置 以后对外对接可能存在问题 string crcdata = "10040041030102"; datatmp2 += HexHelper.crc16(crcdata); //算CRC byte[] byteArray = new byte[datatmp2.Length / 2]; for (int l = 0; l < byteArray.Length; l++) { SendCommandShakehandsList[12 + l] = (byte)Convert.ToInt32(datatmp2.Substring(l * 2, 2).ToString(), 16); } string physicalAddress = ob.PhysicalAddressFormat; IntPtr connId = default(IntPtr); if (physicalAddress != null) { if (this.dataHelper.Clients.TryGetValue(physicalAddress, out connId)) { byte[] bytes2 = SendCommandShakehandsList; this.netServer.Send(connId, bytes2, bytes2.Length); //日志打印 20180305 log.Info("握手应答指令已发送"); } } break; } case Equipment.OnlineUpdate: //在线升级指令下发 UpdateCode uc = (UpdateCode)SendObject.Extras; if (uc.LIST.Count > 0) { foreach (var item in uc.LIST) { if (Encoding.Default.GetBytes(uc.HTTPURL).Length < 128) //url长度小于128字节 { byte[] HeaderData = new byte[] { }; if (!this.dataHelper.ClientHD.TryGetValue(item, out HeaderData)) { break; } string codestr = uc.UPGRADEMODE + "," + item + "," + uc.OLDVERSION + "," + uc.NEWVERSION + "," + uc.HTTPURL; byte[] DataList = Encoding.Default.GetBytes(codestr);//字符串转ASCII List <byte> SendCommandListUpdate = new List <byte>(); SendCommandListUpdate.Add(38); for (int k = 0; k < 9; k++) { SendCommandListUpdate.Add(HeaderData[1 + k]); //9位资源码 } SendCommandListUpdate.Add(HeaderData[16]); //协议版本号 //补全整个发送帧 for (int i = 0; i < 6 + 2 + DataList.Length + 1; i++) { SendCommandListUpdate.Add(0); } byte[] sendcommand = SendCommandListUpdate.ToArray(); string datalenth = (DataList.Length + 3).ToString("x").PadLeft(4, '0'); sendcommand[12] = (byte)Convert.ToInt32("10", 16); sendcommand[13] = (byte)Convert.ToInt32(datalenth.Substring(2, 2), 16); sendcommand[14] = (byte)Convert.ToInt32(datalenth.Substring(0, 2), 16); sendcommand[15] = (byte)Convert.ToInt32("42", 16); sendcommand[16] = 3; sendcommand[17] = (byte)DataList.Length; for (int l = 0; l < DataList.Length; l++) { sendcommand[18 + l] = DataList[l]; } sendcommand = HexHelper.crc16(sendcommand, 12); IntPtr connIdFile = default(IntPtr); if (this.dataHelper.Clients.TryGetValue(item, out connIdFile)) { byte[] bytes = sendcommand; var str = DateTime.Now.ToString(); var encode = Encoding.UTF8; StringBuilder ret = new StringBuilder(); foreach (byte b in bytes) { //{0:X2} 大写 ret.AppendFormat("{0:x2}", b); } string hex = ret.ToString(); this.netServer.Send(connIdFile, bytes, bytes.Length); //日志打印 20180305 log.Info("在线升级指令已发送:" + ret); } } } } break; case Equipment.FileName: //文件调取 //根据物理码找到 曾经有过的连接 和包头 // TransferCode select = (TransferCode)SendObject.DataEntity; TransferCode select = (TransferCode)SendObject.Extras; byte[] HeadDataFile = new byte[] { }; if (!this.dataHelper.ClientHD.TryGetValue(select.SRVPHYSICALCODE, out HeadDataFile)) { break; } List <byte> SendCommandFilesList2 = new List <byte>(); SendCommandFilesList2.Add(38); for (int k = 0; k < 9; k++) { SendCommandFilesList2.Add(HeadDataFile[1 + k]); //9位资源码 } SendCommandFilesList2.Add(HeadDataFile[16]); //协议版本号 SendCommandFilesList2.Add(0); //预留字段 //补全整个发送帧 for (int i = 0; i < 55; i++) { SendCommandFilesList2.Add(0); } byte[] sendcommandFile = SendCommandFilesList2.ToArray(); sendcommandFile[12] = (byte)Convert.ToInt32("10", 16); string datalenthFile = (50).ToString("x").PadLeft(4, '0'); sendcommandFile[12] = (byte)Convert.ToInt32("03", 16); sendcommandFile[13] = (byte)Convert.ToInt32(datalenthFile.Substring(2, 2), 16); sendcommandFile[14] = (byte)Convert.ToInt32(datalenthFile.Substring(0, 2), 16); sendcommandFile[15] = (byte)Convert.ToInt32("17", 16); sendcommandFile[16] = (byte)Convert.ToInt32("03", 16); sendcommandFile[17] = (byte)24; string pp2 = select.FILENAME.Substring(0, 15); byte[] array2 = Encoding.ASCII.GetBytes(pp2); for (int i = 0; i < array2.Length; i++) { //默认长度为15 sendcommandFile[18 + i] = array2[i]; } string pp = select.FILENAME.Substring(15, 18); byte[] array = new byte[pp.Length / 2]; for (int j = 0; j < pp.Length / 2; j++) { //默认长度为9 array[j] = Convert.ToByte(pp.Substring(2 * j, 2).ToString(), 16); } for (int i = 0; i < 9; i++) { sendcommandFile[33 + i] = array[i]; } sendcommandFile[42] = (byte)Convert.ToInt32("21", 16); sendcommandFile[43] = (byte)Convert.ToInt32("03", 16); sendcommandFile[44] = (byte)4; for (int i = 0; i < 4; i++) { sendcommandFile[45 + i] = select.PACKSTARTINDEX[i]; } sendcommandFile[49] = (byte)Convert.ToInt32("39", 16); sendcommandFile[50] = (byte)Convert.ToInt32("03", 16); sendcommandFile[51] = (byte)1; sendcommandFile[52] = (byte)select.Audio_reback_mode; sendcommandFile[53] = (byte)Convert.ToInt32("14", 16); sendcommandFile[54] = (byte)Convert.ToInt32("03", 16); sendcommandFile[55] = (byte)4; for (int i = 0; i < 4; i++) { sendcommandFile[56 + i] = (byte)(Convert.ToInt32(select.AUDIOREBACKSERVERIP.Split('.')[i])); } sendcommandFile[60] = (byte)Convert.ToInt32("15", 16); sendcommandFile[61] = (byte)Convert.ToInt32("03", 16); sendcommandFile[62] = (byte)2; string porttmp = select.AUDIOREBACKPORT.ToString("x").PadLeft(4, '0'); sendcommandFile[63] = (byte)Convert.ToInt32(porttmp.Substring(2, 2), 16); sendcommandFile[64] = (byte)Convert.ToInt32(porttmp.Substring(0, 2), 16); sendcommandFile = HexHelper.crc16(sendcommandFile, 12); IntPtr connIdFiletransfer = default(IntPtr); if (this.dataHelper.Clients.TryGetValue(select.SRVPHYSICALCODE, out connIdFiletransfer)) { byte[] bytes = sendcommandFile; string dadada = ""; for (int i = 0; i < bytes.Length; i++) { dadada += bytes[i].ToString("X2"); } this.netServer.Send(connIdFiletransfer, bytes, bytes.Length); //日志打印 20180305 log.Info("录音文件调取指令已发送"); } break; case Equipment.TTS: //文本转语音 log.Info("文本转语音指令进行组装发送阶段"); TTSC ttsc = (TTSC)SendObject.Extras; string tmp1 = ""; foreach (int item1 in ttsc.DeviceIdList) { tmp1 += " " + item1.ToString(); } log.Info("文本转语音指令设备ID" + tmp1); List <string> PhysicalList = dataHelper.DecId2Physical(ttsc.DeviceIdList); string tmp = ""; foreach (string item in PhysicalList) { tmp += " " + item; } log.Info("文本转语音指令物理码" + tmp); byte[] TextList = Encoding.Default.GetBytes(ttsc.TsCmd_Params); //字符串转ASCII foreach (var phycode in PhysicalList) { if (TextList.Length <= (255 - 6) * 5) //一个UDP包能发完 终端接收缓冲区为1024字节 实际最多一帧4段发完 { List <byte> SendCommandListTTS = new List <byte>(); SendCommandListTTS.Add(38); byte[] HeaderData = new byte[] { }; if (dataHelper.ClientHD == null) { log.Info("文本转语音指令数据头为空"); //终端未上报 建立连接 return; } if (!this.dataHelper.ClientHD.TryGetValue(phycode, out HeaderData)) { //终端未上报 建立连接 log.Info("文本转语音指令的物理码搜不到数据头,当前物理码:" + phycode.ToString()); continue; } for (int k = 0; k < 9; k++) { SendCommandListTTS.Add(HeaderData[1 + k]); } SendCommandListTTS.Add(HeaderData[16]); //协议版本号 int count = TextList.Length / 249 + 1; //段数 文本通过几段发送 switch (count) { case 1: //补充完整发送数据 for (int i = 0; i < 6 + 2 + TextList.Length + 1 + 6; i++) { SendCommandListTTS.Add(0); } byte[] sendcommand = SendCommandListTTS.ToArray(); string datalenth = (TextList.Length + 6 + 3).ToString("x").PadLeft(4, '0'); sendcommand[12] = (byte)Convert.ToInt32("10", 16); sendcommand[13] = (byte)Convert.ToInt32(datalenth.Substring(2, 2), 16); sendcommand[14] = (byte)Convert.ToInt32(datalenth.Substring(0, 2), 16); sendcommand[15] = (byte)Convert.ToInt32("44", 16); sendcommand[16] = (byte)Convert.ToInt32("03", 16); sendcommand[17] = (byte)(TextList.Length + 6); sendcommand[18] = (byte)0; sendcommand[19] = (byte)ttsc.TsCmd_PlayCount; sendcommand[20] = (byte)Convert.ToInt32(ttsc.FileID.Substring(0, 2), 16); sendcommand[21] = (byte)Convert.ToInt32(ttsc.FileID.Substring(2, 2), 16); sendcommand[22] = (byte)1; //分段序号 sendcommand[23] = (byte)1; //总段数 for (int l = 0; l < TextList.Length; l++) { sendcommand[24 + l] = TextList[l]; } sendcommand = HexHelper.crc16(sendcommand, 12); IntPtr connIdFile = default(IntPtr); if (this.dataHelper.Clients.TryGetValue(phycode, out connIdFile)) { byte[] bytes = sendcommand; this.netServer.Send(connIdFile, bytes, bytes.Length); //日志打印 20180305 log.Info("文本转语音指令已发送"); } break; case 2: for (int i = 0; i < TextList.Length + 24; i++) { SendCommandListTTS.Add(0); } byte[] sendcommandSection2 = SendCommandListTTS.ToArray(); string datalenthSection2 = (TextList.Length + 18).ToString("x").PadLeft(4, '0'); sendcommandSection2[12] = (byte)Convert.ToInt32("10", 16); sendcommandSection2[13] = (byte)Convert.ToInt32(datalenthSection2.Substring(2, 2), 16); sendcommandSection2[14] = (byte)Convert.ToInt32(datalenthSection2.Substring(0, 2), 16); #region 数据段1 sendcommandSection2[15] = (byte)Convert.ToInt32("44", 16); sendcommandSection2[16] = (byte)Convert.ToInt32("03", 16); sendcommandSection2[17] = (byte)255; sendcommandSection2[18] = (byte)0; sendcommandSection2[19] = (byte)ttsc.TsCmd_PlayCount; sendcommandSection2[20] = (byte)Convert.ToInt32(ttsc.FileID.Substring(0, 2), 16); sendcommandSection2[21] = (byte)Convert.ToInt32(ttsc.FileID.Substring(2, 2), 16); sendcommandSection2[22] = (byte)1; //分段序号 sendcommandSection2[23] = (byte)2; //总段数 for (int l = 0; l < 249; l++) { sendcommandSection2[24 + l] = TextList[l]; } #endregion #region 数据段2 sendcommandSection2[273] = (byte)Convert.ToInt32("44", 16); sendcommandSection2[274] = (byte)Convert.ToInt32("03", 16); sendcommandSection2[275] = (byte)(TextList.Length - 249 + 6); sendcommandSection2[276] = (byte)0; sendcommandSection2[277] = (byte)ttsc.TsCmd_PlayCount; sendcommandSection2[278] = (byte)Convert.ToInt32(ttsc.FileID.Substring(0, 2), 16); sendcommandSection2[279] = (byte)Convert.ToInt32(ttsc.FileID.Substring(2, 2), 16); sendcommandSection2[280] = (byte)2; //分段序号 sendcommandSection2[281] = (byte)2; //总段数 for (int l = 0; l < TextList.Length - 249; l++) { sendcommandSection2[282 + l] = TextList[249 + l]; } #endregion sendcommandSection2 = HexHelper.crc16(sendcommandSection2, 12); IntPtr connIdFileTTS2 = default(IntPtr); if (this.dataHelper.Clients.TryGetValue(phycode, out connIdFileTTS2)) { byte[] bytes = sendcommandSection2; this.netServer.Send(connIdFileTTS2, bytes, bytes.Length); //日志打印 20180305 log.Info("文本转语音指令已发送"); } break; case 3: for (int i = 0; i < TextList.Length + 33; i++) { SendCommandListTTS.Add(0); } byte[] sendcommandSection3 = SendCommandListTTS.ToArray(); string datalenthSection3 = (TextList.Length + 27).ToString("x").PadLeft(4, '0'); sendcommandSection3[12] = (byte)Convert.ToInt32("10", 16); sendcommandSection3[13] = (byte)Convert.ToInt32(datalenthSection3.Substring(2, 2), 16); sendcommandSection3[14] = (byte)Convert.ToInt32(datalenthSection3.Substring(0, 2), 16); #region 数据段1 sendcommandSection3[15] = (byte)Convert.ToInt32("44", 16); sendcommandSection3[16] = (byte)Convert.ToInt32("03", 16); sendcommandSection3[17] = (byte)255; sendcommandSection3[18] = (byte)0; sendcommandSection3[19] = (byte)ttsc.TsCmd_PlayCount; sendcommandSection3[20] = (byte)Convert.ToInt32(ttsc.FileID.Substring(0, 2), 16); sendcommandSection3[21] = (byte)Convert.ToInt32(ttsc.FileID.Substring(2, 2), 16); sendcommandSection3[22] = (byte)1; //分段序号 sendcommandSection3[23] = (byte)3; //总段数 for (int l = 0; l < 249; l++) { sendcommandSection3[24 + l] = TextList[l]; } #endregion #region 数据段2 sendcommandSection3[273] = (byte)Convert.ToInt32("44", 16); sendcommandSection3[274] = (byte)Convert.ToInt32("03", 16); sendcommandSection3[275] = (byte)255; sendcommandSection3[276] = (byte)0; sendcommandSection3[277] = (byte)ttsc.TsCmd_PlayCount; sendcommandSection3[278] = (byte)Convert.ToInt32(ttsc.FileID.Substring(0, 2), 16); sendcommandSection3[279] = (byte)Convert.ToInt32(ttsc.FileID.Substring(2, 2), 16); sendcommandSection3[280] = (byte)2; //分段序号 sendcommandSection3[281] = (byte)3; //总段数 for (int l = 0; l < 249; l++) { sendcommandSection3[282 + l] = TextList[249 + l]; } #endregion #region 数据段3 sendcommandSection3[531] = (byte)Convert.ToInt32("44", 16); sendcommandSection3[532] = (byte)Convert.ToInt32("03", 16); sendcommandSection3[533] = (byte)(TextList.Length - 249 * 2 + 6); sendcommandSection3[534] = (byte)0; sendcommandSection3[535] = (byte)ttsc.TsCmd_PlayCount; sendcommandSection3[536] = (byte)Convert.ToInt32(ttsc.FileID.Substring(0, 2), 16); sendcommandSection3[537] = (byte)Convert.ToInt32(ttsc.FileID.Substring(2, 2), 16); sendcommandSection3[538] = (byte)3; //分段序号 sendcommandSection3[539] = (byte)3; //总段数 for (int l = 0; l < TextList.Length - 249 * 2; l++) { sendcommandSection3[540 + l] = TextList[498 + l]; } #endregion sendcommandSection3 = HexHelper.crc16(sendcommandSection3, 12); IntPtr connIdFileTTS3 = default(IntPtr); if (this.dataHelper.Clients.TryGetValue(phycode, out connIdFileTTS3)) { byte[] bytes = sendcommandSection3; this.netServer.Send(connIdFileTTS3, bytes, bytes.Length); //日志打印 20180305 log.Info("文本转语音指令已发送"); } break; case 4: for (int i = 0; i < TextList.Length + 42; i++) { SendCommandListTTS.Add(0); } byte[] sendcommandSection4 = SendCommandListTTS.ToArray(); string datalenthSection4 = (TextList.Length + 36).ToString("x").PadLeft(4, '0'); sendcommandSection4[12] = (byte)Convert.ToInt32("10", 16); sendcommandSection4[13] = (byte)Convert.ToInt32(datalenthSection4.Substring(2, 2), 16); sendcommandSection4[14] = (byte)Convert.ToInt32(datalenthSection4.Substring(0, 2), 16); #region 数据段1 sendcommandSection4[15] = (byte)Convert.ToInt32("44", 16); sendcommandSection4[16] = (byte)Convert.ToInt32("03", 16); sendcommandSection4[17] = (byte)255; sendcommandSection4[18] = (byte)0; sendcommandSection4[19] = (byte)ttsc.TsCmd_PlayCount; sendcommandSection4[20] = (byte)Convert.ToInt32(ttsc.FileID.Substring(0, 2), 16); sendcommandSection4[21] = (byte)Convert.ToInt32(ttsc.FileID.Substring(2, 2), 16); sendcommandSection4[22] = (byte)1; //分段序号 sendcommandSection4[23] = (byte)4; //总段数 for (int l = 0; l < 249; l++) { sendcommandSection4[24 + l] = TextList[l]; } #endregion #region 数据段2 sendcommandSection4[273] = (byte)Convert.ToInt32("44", 16); sendcommandSection4[274] = (byte)Convert.ToInt32("03", 16); sendcommandSection4[275] = (byte)255; sendcommandSection4[276] = (byte)0; sendcommandSection4[277] = (byte)ttsc.TsCmd_PlayCount; sendcommandSection4[278] = (byte)Convert.ToInt32(ttsc.FileID.Substring(0, 2), 16); sendcommandSection4[279] = (byte)Convert.ToInt32(ttsc.FileID.Substring(2, 2), 16); sendcommandSection4[280] = (byte)2; //分段序号 sendcommandSection4[281] = (byte)4; //总段数 for (int l = 0; l < 249; l++) { sendcommandSection4[282 + l] = TextList[249 + l]; } #endregion #region 数据段3 sendcommandSection4[531] = (byte)Convert.ToInt32("44", 16); sendcommandSection4[532] = (byte)Convert.ToInt32("03", 16); sendcommandSection4[533] = (byte)255; sendcommandSection4[534] = (byte)0; sendcommandSection4[535] = (byte)ttsc.TsCmd_PlayCount; sendcommandSection4[536] = (byte)Convert.ToInt32(ttsc.FileID.Substring(0, 2), 16); sendcommandSection4[537] = (byte)Convert.ToInt32(ttsc.FileID.Substring(2, 2), 16); sendcommandSection4[538] = (byte)3; //分段序号 sendcommandSection4[539] = (byte)4; //总段数 for (int l = 0; l < 249; l++) { sendcommandSection4[540 + l] = TextList[498 + l]; } #endregion #region 数据段4 sendcommandSection4[789] = (byte)Convert.ToInt32("44", 16); sendcommandSection4[790] = (byte)Convert.ToInt32("03", 16); sendcommandSection4[791] = (byte)(TextList.Length - 249 * 3 + 6); sendcommandSection4[792] = (byte)0; sendcommandSection4[793] = (byte)ttsc.TsCmd_PlayCount; sendcommandSection4[794] = (byte)Convert.ToInt32(ttsc.FileID.Substring(0, 2), 16); sendcommandSection4[795] = (byte)Convert.ToInt32(ttsc.FileID.Substring(2, 2), 16); sendcommandSection4[796] = (byte)4; //分段序号 sendcommandSection4[797] = (byte)4; //总段数 for (int l = 0; l < TextList.Length - 249 * 3; l++) { sendcommandSection4[798 + l] = TextList[747 + l]; } #endregion sendcommandSection4 = HexHelper.crc16(sendcommandSection4, 12); IntPtr connIdFileTTS4 = default(IntPtr); if (this.dataHelper.Clients.TryGetValue(phycode, out connIdFileTTS4)) { byte[] bytes = sendcommandSection4; this.netServer.Send(connIdFileTTS4, bytes, bytes.Length); //日志打印 20180305 log.Info("文本转语音指令已发送"); } break; case 5: break; } } else { //需分包发送 目前暂无这么大的数据 } } break; } }