From e6e913bc8c19ce2c71b48f8a772fc3ef6d29b259 Mon Sep 17 00:00:00 2001 From: lxd <1004405501@qq.com> Date: Thu, 19 Dec 2024 14:49:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20BS-460-2\=20BA600-1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.config | 6 +- deviceAnalysis.cs | 244 +++++++++++++++++++++++++++++++++++++++++++--- mainForm.cs | 2 +- 3 files changed, 238 insertions(+), 14 deletions(-) diff --git a/app.config b/app.config index a117891..e2e7b12 100644 --- a/app.config +++ b/app.config @@ -27,6 +27,8 @@ + + @@ -81,7 +83,9 @@ - + + + diff --git a/deviceAnalysis.cs b/deviceAnalysis.cs index d2dff1c..d1250ba 100644 --- a/deviceAnalysis.cs +++ b/deviceAnalysis.cs @@ -589,7 +589,7 @@ namespace FlyDockTool if (i + 16 > resulteArray.Length) break; //string[] spArray = resulteArray[i + 1].Trim().Split(' '); - string sampleNo1 = resulteArray[3].Trim().Split(':')[1].Replace("ID", "").Trim(); + string sampleNo1 = resulteArray[2].Trim().Replace("0", " ").Trim(); //string testDate1 = jiexiDate(resulteArray[i + 1], resulteArray[i + 2]); string testDate1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); examResultMode erm = new examResultMode(); @@ -608,7 +608,7 @@ namespace FlyDockTool erm1.sampleNo = sampleNo1; erm1.testDate = testDate1; erm1.chanelNo = "URO";//项目代号 - erm1.itemValue = resulteArray[i + 5].Replace("URO", "").Trim();//项目结果 + erm1.itemValue = resulteArray[i + 5].Replace("URO", "").Trim().Split(' ')[0].Trim();//项目结果 erm1.itemUnit = ""; ermList.Add(erm1); @@ -618,7 +618,7 @@ namespace FlyDockTool erm2.sampleNo = sampleNo1; erm2.testDate = testDate1; erm2.chanelNo = "BIL";//项目代号 - erm2.itemValue = resulteArray[i + 6].Replace("BIL", "").Trim().Trim();//项目结果 + erm2.itemValue = resulteArray[i + 6].Replace("BIL", "").Trim().Trim().Split(' ')[0].Trim();//项目结果 erm2.itemUnit = ""; ermList.Add(erm2); @@ -628,7 +628,7 @@ namespace FlyDockTool erm3.sampleNo = sampleNo1; erm3.testDate = testDate1; erm3.chanelNo = "KET";//项目代号 - erm3.itemValue = resulteArray[i + 7].Replace("KET", "").Trim();//项目结果 + erm3.itemValue = resulteArray[i + 7].Replace("KET", "").Trim().Split(' ')[0].Trim();//项目结果 erm3.itemUnit = ""; ermList.Add(erm3); @@ -649,7 +649,7 @@ namespace FlyDockTool erm5.sampleNo = sampleNo1; erm5.testDate = testDate1; erm5.chanelNo = "PRO";//项目代号 - erm5.itemValue = resulteArray[i + 9].Replace("PRO", "").Trim();//项目结果 + erm5.itemValue = resulteArray[i + 9].Replace("PRO", "").Trim().Split(' ')[0].Trim();//项目结果 erm5.itemUnit = ""; ermList.Add(erm5); @@ -660,7 +660,7 @@ namespace FlyDockTool erm6.sampleNo = sampleNo1; erm6.testDate = testDate1; erm6.chanelNo = "NIT";//项目代号 - erm6.itemValue = resulteArray[i + 10].Replace("NIT", "").Trim();//项目结果 + erm6.itemValue = resulteArray[i + 10].Replace("NIT", "").Trim().Split(' ')[0].Trim();//项目结果 erm6.itemUnit = ""; ermList.Add(erm6); @@ -670,7 +670,7 @@ namespace FlyDockTool erm10.sampleNo = sampleNo1; erm10.testDate = testDate1; erm10.chanelNo = "LEU";//项目代号 - erm10.itemValue = resulteArray[i + 11].Replace("LEU", "").Trim();//项目结果 + erm10.itemValue = resulteArray[i + 11].Replace("LEU", "").Trim().Split(' ')[0].Trim();//项目结果 erm10.itemUnit = ""; ermList.Add(erm10); @@ -681,7 +681,7 @@ namespace FlyDockTool erm7.sampleNo = sampleNo1; erm7.testDate = testDate1; erm7.chanelNo = "GLU";//项目代号 - erm7.itemValue = resulteArray[i + 12].Replace("GLU", "").Trim();//项目结果 + erm7.itemValue = resulteArray[i + 12].Replace("GLU", "").Trim().Split(' ')[0].Trim();//项目结果 erm7.itemUnit = ""; ermList.Add(erm7); @@ -691,7 +691,7 @@ namespace FlyDockTool erm8.sampleNo = sampleNo1; erm8.testDate = testDate1; erm8.chanelNo = "SG";//项目代号 - erm8.itemValue = resulteArray[i + 13].Replace("SG", "").Trim();//项目结果 + erm8.itemValue = resulteArray[i + 13].Replace("SG", "").Trim().Split(' ')[0].Trim();//项目结果 erm8.itemUnit = ""; ermList.Add(erm8); @@ -701,7 +701,7 @@ namespace FlyDockTool erm9.sampleNo = sampleNo1; erm9.testDate = testDate1; erm9.chanelNo = "PH";//项目代号 - erm9.itemValue = resulteArray[i + 14].Replace("PH", "").Trim();//项目结果 + erm9.itemValue = resulteArray[i + 14].Replace("PH", "").Trim().Split(' ')[0].Trim();//项目结果 erm9.itemUnit = ""; ermList.Add(erm9); @@ -2299,7 +2299,186 @@ namespace FlyDockTool dataOutPutShow("数据提交失败:" + jsonStr, null); } + if (apiOptions.CurrentDevice == "BS-460-2")//生化BS-460 + { + string MachineCode = apiOptions.MachineCode; + string MachineID = apiOptions.MachineID; + List ermList = new List(); + string[] itemArray = new string[16] { "Glu-G", "T-Bil-V", "D-Bil-V", "ALT", "AST", "ALP", "γ-GT", "TG", "LDL-C", "HDL-C", "TC", "CREA-S", "UREA", "AST/ALT", "IBIL-V", "UA" };// + string[] itemArrayC = new string[16] { "葡萄糖", "总胆红素", "直接胆红素", "丙氨酸氨基转移酶", "天门冬氨酸氨基转移酶", "碱性磷酸酶", "γ-谷氨酰转移酶", "甘油三酯", "低密度脂蛋白胆固醇", "高密度脂蛋白胆固醇", "总胆固醇", "肌酐", "尿素", "AST/ALT", "IBIL-V", "尿酸" };// + deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", ""); + //string[] valArray = deviceDataStr.Split(','); + string[] valArray = deviceDataStr.Split('|'); + string sampleNo1 = valArray[54];//样本号 + for (int i = 0; i < itemArrayC.Length; i++) + { + string testDate1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + examResultMode erm1 = new examResultMode(); + erm1.machineCode = MachineCode; + erm1.machineID = MachineID; + erm1.sampleNo = sampleNo1; + erm1.testDate = testDate1; + erm1.chanelNo = itemArray[i];//项目代号 + // MessageBox.Show(deviceDataStr+"\r\n\r\n :"+ggg[5]); + string itemStr = itemArrayC[i] + "|"; + int index1 = deviceDataStr.IndexOf(itemStr); + string valueS = jiexiVal(index1, itemStr, deviceDataStr); + double roundedValue = Math.Round(double.Parse(valueS), 2); + erm1.itemValue = roundedValue.ToString();//项目结果 + erm1.itemUnit = ""; + ermList.Add(erm1); + + } + //将结果提交到LIS系统 + baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList); + string jsonStr = JsonConvert.SerializeObject(ermList); + if (bmm1.code == 200) + dataOutPutShow("数据提交成功:" + jsonStr, null); + else + dataOutPutShow("数据提交失败:" + jsonStr, null); + } + if (apiOptions.CurrentDevice == "BA600-1")//尿常规 GeniusBA600 + { + string MachineCode = apiOptions.MachineCode; + string MachineID = apiOptions.MachineID; + List ermList = new List(); + string[] resulteArray = deviceDataStr.Split('\n'); + // File.WriteAllText("BT-200.TXT", deviceDataStr); + for (int i = 0; i < resulteArray.Length; i += 16) + { + //这里需要判断一下数据是否超过了 当前数据的长度 + ermList.Clear(); + if (i + 16 > resulteArray.Length) + break; + //string[] spArray = resulteArray[i + 1].Trim().Split(' '); + string sampleNo1 = resulteArray[2].Trim().Replace("0", " ").Trim(); + //string testDate1 = jiexiDate(resulteArray[i + 1], resulteArray[i + 2]); + string testDate1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + examResultMode erm = new examResultMode(); + erm.machineCode = MachineCode; + erm.machineID = MachineID; + erm.sampleNo = sampleNo1; + erm.testDate = testDate1; + erm.chanelNo = "VC";//项目代号 + erm.itemValue = resulteArray[i + 4].Replace("VC", "").Trim().Split(' ')[0].Trim();//项目结果 + erm.itemUnit = ""; + ermList.Add(erm); + + examResultMode erm1 = new examResultMode(); + erm1.machineCode = MachineCode; + erm1.machineID = MachineID; + erm1.sampleNo = sampleNo1; + erm1.testDate = testDate1; + erm1.chanelNo = "URO";//项目代号 + erm1.itemValue = resulteArray[i + 5].Replace("URO", "").Trim().Split(' ')[0].Trim();//项目结果 + erm1.itemUnit = ""; + ermList.Add(erm1); + + examResultMode erm2 = new examResultMode(); + erm2.machineCode = MachineCode; + erm2.machineID = MachineID; + erm2.sampleNo = sampleNo1; + erm2.testDate = testDate1; + erm2.chanelNo = "BIL";//项目代号 + erm2.itemValue = resulteArray[i + 6].Replace("BIL", "").Trim().Trim().Split(' ')[0].Trim();//项目结果 + erm2.itemUnit = ""; + ermList.Add(erm2); + + examResultMode erm3 = new examResultMode(); + erm3.machineCode = MachineCode; + erm3.machineID = MachineID; + erm3.sampleNo = sampleNo1; + erm3.testDate = testDate1; + erm3.chanelNo = "KET";//项目代号 + erm3.itemValue = resulteArray[i + 7].Replace("KET", "").Trim().Split(' ')[0].Trim();//项目结果 + erm3.itemUnit = ""; + ermList.Add(erm3); + + examResultMode erm4 = new examResultMode(); + erm4.machineCode = MachineCode; + erm4.machineID = MachineID; + erm4.sampleNo = sampleNo1; + erm4.testDate = testDate1; + erm4.chanelNo = "BLD";//项目代号 + erm4.itemValue = resulteArray[i + 8].Replace("BLD", "").Trim().Split(' ')[0].Trim();//项目结果 + erm4.itemUnit = "Cell/uL"; + ermList.Add(erm4); + + + examResultMode erm5 = new examResultMode(); + erm5.machineCode = MachineCode; + erm5.machineID = MachineID; + erm5.sampleNo = sampleNo1; + erm5.testDate = testDate1; + erm5.chanelNo = "PRO";//项目代号 + erm5.itemValue = resulteArray[i + 9].Replace("PRO", "").Trim().Split(' ')[0].Trim();//项目结果 + erm5.itemUnit = ""; + ermList.Add(erm5); + + + examResultMode erm6 = new examResultMode(); + erm6.machineCode = MachineCode; + erm6.machineID = MachineID; + erm6.sampleNo = sampleNo1; + erm6.testDate = testDate1; + erm6.chanelNo = "NIT";//项目代号 + erm6.itemValue = resulteArray[i + 10].Replace("NIT", "").Trim().Split(' ')[0].Trim();//项目结果 + erm6.itemUnit = ""; + ermList.Add(erm6); + + examResultMode erm10 = new examResultMode(); + erm10.machineCode = MachineCode; + erm10.machineID = MachineID; + erm10.sampleNo = sampleNo1; + erm10.testDate = testDate1; + erm10.chanelNo = "LEU";//项目代号 + erm10.itemValue = resulteArray[i + 11].Replace("LEU", "").Trim().Split(' ')[0].Trim();//项目结果 + erm10.itemUnit = ""; + ermList.Add(erm10); + + + examResultMode erm7 = new examResultMode(); + erm7.machineCode = MachineCode; + erm7.machineID = MachineID; + erm7.sampleNo = sampleNo1; + erm7.testDate = testDate1; + erm7.chanelNo = "GLU";//项目代号 + erm7.itemValue = resulteArray[i + 12].Replace("GLU", "").Trim().Split(' ')[0].Trim();//项目结果 + erm7.itemUnit = ""; + ermList.Add(erm7); + + examResultMode erm8 = new examResultMode(); + erm8.machineCode = MachineCode; + erm8.machineID = MachineID; + erm8.sampleNo = sampleNo1; + erm8.testDate = testDate1; + erm8.chanelNo = "SG";//项目代号 + erm8.itemValue = resulteArray[i + 13].Replace("SG", "").Trim().Split(' ')[0].Trim();//项目结果 + erm8.itemUnit = ""; + ermList.Add(erm8); + + examResultMode erm9 = new examResultMode(); + erm9.machineCode = MachineCode; + erm9.machineID = MachineID; + erm9.sampleNo = sampleNo1; + erm9.testDate = testDate1; + erm9.chanelNo = "PH";//项目代号 + erm9.itemValue = resulteArray[i + 14].Replace("PH", "").Trim().Split(' ')[0].Trim();//项目结果 + erm9.itemUnit = ""; + ermList.Add(erm9); + + + //将结果提交到LIS系统 + baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList); + string jsonStr = JsonConvert.SerializeObject(ermList); + if (bmm1.code == 200) + dataOutPutShow("数据提交成功:" + jsonStr, null); + else + dataOutPutShow("数据提交失败:" + jsonStr, null); + } + + } return rerultJson; } @@ -2590,6 +2769,12 @@ namespace FlyDockTool SerialPortOption.CreateInstance().dataOutPutShow += new EventHandler(onReData); SerialPortOption.CreateInstance().StartDataReadThread();//开启数据接收 } + if (apiOptions.CurrentDevice == "BA600-1")//尿常规 GeniusBA600 + { + SerialPortOption.CreateInstance().IniserialPortOption();//初始化串口 + SerialPortOption.CreateInstance().dataOutPutShow += new EventHandler(onReData); + SerialPortOption.CreateInstance().StartDataReadThread();//开启数据接收 + } if (apiOptions.CurrentDevice == "BA600MY")//煤窑中心卫生院的尿常规 GeniusBA600 { SerialPortOption.CreateInstance().IniserialPortOption();//初始化串口 @@ -2851,7 +3036,24 @@ namespace FlyDockTool } _tcpResult.Change(0, 10);//开始tcp数据接收,10毫秒频率 } - if (apiOptions.CurrentDevice == "BS-460-1")//迈瑞生化BS-430 + if (apiOptions.CurrentDevice == "BS-460-1")//迈瑞生化BS-460 + { + // 设置IP地址和端口号 + string tcp_ip = ConfigurationManager.AppSettings[apiOptions.CurrentDevice].Split(',')[3]; + string tcp_port = ConfigurationManager.AppSettings[apiOptions.CurrentDevice].Split(',')[4]; + // IPAddress ipAddress = IPAddress.Parse(tcp_ip); + IPAddress ipAddress = IPAddress.Any; + // 创建一个监听Socket + if (listener == null) + { + //listener = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp); + listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + listener.Bind(new IPEndPoint(IPAddress.Any, int.Parse(tcp_port))); + listener.Listen(10000); + } + _tcpResult.Change(0, 10);//开始tcp数据接收,10毫秒频率 + } + if (apiOptions.CurrentDevice == "BS-460-2")//迈瑞生化BS-460 { // 设置IP地址和端口号 string tcp_ip = ConfigurationManager.AppSettings[apiOptions.CurrentDevice].Split(',')[3]; @@ -2903,6 +3105,8 @@ namespace FlyDockTool _tResult.Change(10000, 10000);// 数据处理:延迟5秒开始 5秒计时 if (apiOptions.CurrentDevice == "BA600")//尿常规 GeniusBA600 _tResult.Change(5000, 5000);// 数据处理:延迟5秒开始 5秒计时 + if (apiOptions.CurrentDevice == "BA600-1")//尿常规 GeniusBA600 + _tResult.Change(5000, 5000);// 数据处理:延迟5秒开始 5秒计时 if (apiOptions.CurrentDevice == "MC-600")//血常规MAC-600 _tResult.Change(5000, 5000);// 数据处理:延迟5秒开始 5秒计时 if (apiOptions.CurrentDevice == "CS-1300B")//迪瑞全自动生化分析仪 CS-1300B @@ -3004,7 +3208,7 @@ namespace FlyDockTool if (apiOptions.CurrentDevice == "BS-460")//生化BS-460 { //File.WriteAllText("deviceDataLog.txt", deviceDataStr, Encoding.GetEncoding("GB18030")); - if (tempData.Contains("OBX|17|"))//OBX|22| 为结束符 说明字符串完整了 + if (tempData.Contains("OBX|17|"))//OBX|22| 为结束符 说明字符串完整了 OBX|17| { deviceAnalysisOption(tempData); tempData = string.Empty;//执行完以后 将临时积累数据清空 以便接收下一个样本数据 @@ -3021,6 +3225,13 @@ namespace FlyDockTool // } // _tResult.Change(10000, 10000);// 数据处理:延迟5秒开始 5秒计时 } + if (apiOptions.CurrentDevice == "BS-460-2")//生化BS-460 + { + + deviceAnalysisOption(tempData); + tempData = string.Empty;//执行完以后 将临时积累数据清空 以便接收下一个样本数据 + + } } /// @@ -3250,6 +3461,10 @@ namespace FlyDockTool { SerialPortOption.CreateInstance().StopDataReadThread();//开启数据接收 } + if (apiOptions.CurrentDevice == "BA600-1")//尿常规 GeniusBA600 + { + SerialPortOption.CreateInstance().StopDataReadThread();//开启数据接收 + } if (apiOptions.CurrentDevice == "BA600MY")//煤窑中心卫生院的尿常规 GeniusBA600 { SerialPortOption.CreateInstance().StopDataReadThread();//开启数据接收 @@ -3364,6 +3579,11 @@ namespace FlyDockTool _tcpResult.Change(-1, 10);//停止tcp数据接收 clientSocket.Close(); } + if (apiOptions.CurrentDevice == "BS-460-2")//生化BS-460 + { + _tcpResult.Change(-1, 10);//停止tcp数据接收 + clientSocket.Close(); + } } ///// diff --git a/mainForm.cs b/mainForm.cs index 58a2178..c0dcf1d 100644 --- a/mainForm.cs +++ b/mainForm.cs @@ -33,7 +33,7 @@ namespace FlyDockTool apiOptions.MachineID = ConfigurationManager.AppSettings[CurrentDevice].Split(',')[2]; lb_currentDeviceInfo.Text = CurrentDevice; //////测试代码 测试完毕后注释调一下两行代码 - //string resultDataStr = File.ReadAllText(@"C:\Users\10044\Desktop\BS-460.txt", Encoding.GetEncoding("GB18030")); + //string resultDataStr = File.ReadAllText(@"D:\工作\接受数据工具 list\BA600.txt", Encoding.GetEncoding("GB18030")); //deviceAnalysis.CreateInstance().deviceAnalysisOption(resultDataStr); btn_start_or_stop_Click(null,null);//启动数据接收