private List <RemoteAudioCode> ListRemoteAudioCode() { List <RemoteAudioCode> list = new List <RemoteAudioCode>(); for (int i = 0; i < dgvRemote.Rows.Count; i++) { if (dgvRemote.Rows[i].Cells["isAccept"].Value.ToString() == "否") { continue; } var DestMac = dgvRemote.Rows[i].Cells["MAC"].Value.ToString(); if (list.Any(l => l.DestMac == DestMac)) { continue; } var code = new RemoteAudioCode() { Guid = this.Guid, SrcMac = Setting.authorizationInfo.MachineCode, SrctetName = this.ucTextBoxEx1.Text, DestStetName = dgvRemote.Rows[i].Cells["StetName"].Value.ToString(), DestMac = dgvRemote.Rows[i].Cells["MAC"].Value.ToString() }; list.Add(code); } return(list); }
/// <summary> /// 接收数据 /// </summary> /// <param name="message"></param> public void HandleMessage(RemoteAudioCode message) { if (this.IsDisposed || this.Disposing) { return; } if (message.Guid != this.Guid) { return; } this.Invoke(new MethodInvoker(() => { var rows = this.DgvTable.Select("MAC='" + Setting.authorizationInfo.MachineCode + "'"); foreach (DataRow row in rows) { var stetName = row["StetName"] + ""; var stethoscopeArr = StethoscopeManager.StethoscopeList.Where(s => s.Name == stetName); if (!stethoscopeArr.Any()) { throw new Exception("目前没有检测到听诊器,请检测设备设置!"); } var stethoscope = stethoscopeArr.First(); if (!stethoscope.IsConnected) { Mediator.ShowMsg(string.Format("听诊器 {0} 尚未连接", stethoscope.Name)); return; } else { stethoscope.AudioOutputStream.Write(message.AudioData, 0, message.AudioData.Length); } } })); IsReceived = true; //var MSG = "TotalBytes:" + stethoscope.TotalBytesWritten + "PerBytes:" + stethoscope.BytesWrittenPerSecond; //Mediator.ShowMsg("处理音频消息:" + message.AudioData.Length+"\r\n"+MSG); }