From 3b1028ab96aa9b7188e0353b2c1e864aa91386b6 Mon Sep 17 00:00:00 2001
From: lishuang <43914504@qq.com>
Date: Fri, 13 Dec 2024 09:47:28 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=85=A5=E8=AE=BE=E5=A4=87=EF=BC=9ABS?=
=?UTF-8?q?-460?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Program.cs | 2 +-
app.config | 6 +-
deviceAnalysis.cs | 255 +++++++++++++++++++++++++++++--------------
mainForm.Designer.cs | 3 +-
mainForm.cs | 11 +-
5 files changed, 190 insertions(+), 87 deletions(-)
diff --git a/Program.cs b/Program.cs
index e5e2143..ced15e7 100644
--- a/Program.cs
+++ b/Program.cs
@@ -14,7 +14,7 @@ namespace FlyDockTool
//测试11111 都是对的收到大大大
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new mainForm()); ;//gitceshi
+ Application.Run(new mainForm()); ;//gitceshi88
}
}
}
diff --git a/app.config b/app.config
index d9f2b23..4c9f413 100644
--- a/app.config
+++ b/app.config
@@ -37,8 +37,8 @@
-
-
+
+
@@ -59,6 +59,8 @@
+
+
diff --git a/deviceAnalysis.cs b/deviceAnalysis.cs
index 4b7c3d3..68619c0 100644
--- a/deviceAnalysis.cs
+++ b/deviceAnalysis.cs
@@ -1641,78 +1641,79 @@ namespace FlyDockTool
}
}
-
if (apiOptions.CurrentDevice == "BC-5130")//BC-5130
{
-
- string MachineCode = apiOptions.MachineCode;
- string MachineID = apiOptions.MachineID;
- List ermList = new List();
- string[] itemArray = new string[26] { "WBC", "NEU%", "LYM%", "MON%", "EOS%", "BAS%", "NEU#", "LYM#", "MON#", "EOS#", "BAS#", "RBC", "HGB", "HCT", "MCV", "MCH", "MCHC", "RDW-SD", "PLT", "MPV", "PDW", "PCT", "RDW-CV", "PLCC", "PLCR" , "Lymphocytosis" };
- //string[] resulteArray = deviceDataStr.Split('\n');
- deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", "");
- string sampleNo1 = string.Empty;//样本号
- for (int i = 0; i < itemArray.Length; i++)
+ try
{
- string itemStr = string.Empty;
- if (itemArray[i] == "*LIC#" || itemArray[i] == "*LIC%" || itemArray[i] == "PCT" || itemArray[i] == "PLCC" || itemArray[i] == "PLCR" || itemArray[i] == "Lymphocytosis")
- itemStr = itemArray[i] + "^99MRC||";
+ string MachineCode = apiOptions.MachineCode;
+ string MachineID = apiOptions.MachineID;
+ List ermList = new List();
+ string[] itemArray = new string[26] { "WBC", "NEU%", "LYM%", "MON%", "EOS%", "BAS%", "NEU#", "LYM#", "MON#", "EOS#", "BAS#", "RBC", "HGB", "HCT", "MCV", "MCH", "MCHC", "RDW-SD", "PLT", "MPV", "PDW", "PCT", "RDW-CV", "PLCC", "PLCR", "Lymphocytosis" };
+ //string[] resulteArray = deviceDataStr.Split('\n');
+ deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", "");
+ string sampleNo1 = string.Empty;//样本号
+ for (int i = 0; i < itemArray.Length; i++)
+ {
+ string itemStr = string.Empty;
+ if (itemArray[i] == "*LIC#" || itemArray[i] == "*LIC%" || itemArray[i] == "PCT" || itemArray[i] == "PLCC" || itemArray[i] == "PLCR" || itemArray[i] == "Lymphocytosis")
+ itemStr = itemArray[i] + "^99MRC||";
+ else
+ itemStr = itemArray[i] + "^LN||";
+
+ string val1 = deviceDataStr.Substring(deviceDataStr.IndexOf("OBR"), 30);
+ sampleNo1 = val1.Split('|')[3];
+ 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]; //项目代号
+ if (itemArray[i] != "Lymphocytosis")
+ erm1.itemValue = jiexiVal(deviceDataStr.IndexOf(itemStr), itemStr, deviceDataStr).ToString();//项目结果
+ else
+ erm1.itemValue = jiexiItemValue11(itemStr, deviceDataStr);
+ erm1.itemUnit = "";
+ ermList.Add(erm1);
+ }
+ string jsonStr12 = JsonConvert.SerializeObject(ermList);
+ //把血常规的图也传上去
+ List eipmList = new List();
+ int[] array1 = strCount("^Base64^", deviceDataStr);
+ string keyStr = "||||||F";//结束符
+ List imgBase64StrList = jiexiBase64(array1, keyStr, deviceDataStr);//解析出数据中的图片base64
+ //int[] array2 = strCount("||||||F||||||", deviceDataStr);
+ for (int i = 0; i < imgBase64StrList.Count; i++)
+ {
+ string base64Str = imgBase64StrList[i];
+ examImageParaModel EIPM1 = new examImageParaModel();
+ EIPM1.machineCode = MachineCode;
+ EIPM1.machineID = MachineID;
+ EIPM1.testDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+ EIPM1.sampleNo = sampleNo1;
+ EIPM1.img = "data:image/jpeg;base64," + base64Str;
+ eipmList.Add(EIPM1);
+ }
+
+
+ //将结果提交到LIS系统
+ baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
+ string jsonStr = JsonConvert.SerializeObject(ermList);
+ if (eipmList.Count > 0)
+ {
+ baseMsgModel bmm2 = apiOptions.CreateInstance().uploadExamImage(eipmList);//传图像List
+ //if (bmm2.code == 200)
+ // dataOutPutShow("图像提交成功:" + jsonStr, null);
+ //else
+ // dataOutPutShow("图像提交失败:" + jsonStr, null);
+ }
+
+ if (bmm1.code == 200)
+ dataOutPutShow("数据和图像提交成功:" + jsonStr, null);
else
- itemStr = itemArray[i] + "^LN||";
-
- string val1 = deviceDataStr.Substring(deviceDataStr.IndexOf("OBR"),30);
- sampleNo1 = val1.Split('|')[3];
- 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]; //项目代号
- if (itemArray[i] != "Lymphocytosis")
- erm1.itemValue = jiexiVal(deviceDataStr.IndexOf(itemStr), itemStr, deviceDataStr).ToString();//项目结果
- else
- erm1.itemValue = jiexiItemValue(itemStr, deviceDataStr);
- erm1.itemUnit = "";
- ermList.Add(erm1);
+ dataOutPutShow("数据和图像提交失败:" + jsonStr, null);
}
- string jsonStr12 = JsonConvert.SerializeObject(ermList);
- //把血常规的图也传上去
- List eipmList = new List();
- int[] array1 = strCount("^Base64^", deviceDataStr);
- string keyStr = "||||||F";//结束符
- List imgBase64StrList = jiexiBase64(array1, keyStr, deviceDataStr);//解析出数据中的图片base64
- //int[] array2 = strCount("||||||F||||||", deviceDataStr);
- for (int i = 0; i < imgBase64StrList.Count; i++)
- {
- string base64Str = imgBase64StrList[i];
- examImageParaModel EIPM1 = new examImageParaModel();
- EIPM1.machineCode = MachineCode;
- EIPM1.machineID = MachineID;
- EIPM1.testDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- EIPM1.sampleNo = sampleNo1;
- EIPM1.img = "data:image/jpeg;base64," + base64Str;
- eipmList.Add(EIPM1);
- }
-
-
- //将结果提交到LIS系统
- baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
- string jsonStr = JsonConvert.SerializeObject(ermList);
- if (eipmList.Count > 0)
- {
- baseMsgModel bmm2 = apiOptions.CreateInstance().uploadExamImage(eipmList);//传图像List
- //if (bmm2.code == 200)
- // dataOutPutShow("图像提交成功:" + jsonStr, null);
- //else
- // dataOutPutShow("图像提交失败:" + jsonStr, null);
- }
-
- if (bmm1.code == 200)
- dataOutPutShow("数据和图像提交成功:" + jsonStr, null);
- else
- dataOutPutShow("数据和图像提交失败:" + jsonStr, null);
-
+ catch(Exception ex) { /*MessageBox.Show(ex.ToString()); */}
}
if (apiOptions.CurrentDevice == "SD1")//斯玛特SD1
{
@@ -1836,8 +1837,6 @@ namespace FlyDockTool
dataOutPutShow("数据和图像提交失败:" + jsonStr, null);
}
-
-
if (apiOptions.CurrentDevice == "MA-4210")//华晟源尿常规型号:H-II
{
string MachineCode = apiOptions.MachineCode;
@@ -1984,8 +1983,48 @@ namespace FlyDockTool
}
}
+ if (apiOptions.CurrentDevice == "BS-460")//生化BS-460
+ {
+ string MachineCode = apiOptions.MachineCode;
+ string MachineID = apiOptions.MachineID;
+ List ermList = new List();
+ string[] itemArray = new string[18] { "Glu-G", "T-Bil-V", "D-Bil-V", "ALT", "AST", "ALP", "γ-GT", "TG", "LDL-C", "HDL-C","TC","CREA-S","UREA","ALB_II","TP_II","AST/ALT","IBIL-V" , "UA" };
+ string[] itemArrayC = new string[18] { "葡萄糖", "总胆红素", "直接胆红素", "丙氨酸氨基转移酶", "天门冬氨酸氨基转移酶", "碱性磷酸酶", "γ-谷氨酰转移酶", "甘油三酯", "低密度脂蛋白胆固醇", "高密度脂蛋白胆固醇", "总胆固醇", "肌酐(肌氨酸氧化酶法)", "尿素", "白蛋白", "总蛋白(双缩脲法)", "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);
+
+ }
return rerultJson;
}
@@ -2003,13 +2042,37 @@ namespace FlyDockTool
string jiexiItemValue(string itemStr, string deviceDataStr)
{
string ItemValueStr = "";
- string Str1 = deviceDataStr.Substring(deviceDataStr.IndexOf(itemStr) + itemStr.Length, 30);
- int firstIndex = Str1.IndexOf('|');
- ItemValueStr= Str1.Substring(0, firstIndex);
+ try
+ {
+
+ string Str1 = deviceDataStr.Substring(deviceDataStr.IndexOf(itemStr) + itemStr.Length, 30);
+ int firstIndex = Str1.IndexOf('|');
+ ItemValueStr = Str1.Substring(0, firstIndex);
+
+ }catch (Exception ex) { MessageBox.Show(itemStr + "," + deviceDataStr); }
return ItemValueStr;
}
+ ///
+ /// 从结果字符串中截取 结果
+ ///
+ ///
+ ///
+ ///
+ string jiexiItemValue11(string itemStr, string deviceDataStr)
+ {
+ string ItemValueStr = "";
+ try
+ {
+ string Str1 = deviceDataStr.Substring(deviceDataStr.IndexOf(itemStr) + itemStr.Length, 6);
+ int firstIndex = Str1.IndexOf('|');
+ ItemValueStr = Str1.Substring(0, firstIndex);
+
+ }
+ catch (Exception ex) { /*MessageBox.Show(itemStr + "," + deviceDataStr);*/ }
+ return ItemValueStr;
+ }
///
/// 从结果字符串中截取 结果
///
@@ -2300,18 +2363,19 @@ namespace FlyDockTool
// 设置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;
+ // IPAddress ipAddress = IPAddress.Parse(tcp_ip);
+ IPAddress ipAddress = IPAddress.Any;
// 创建一个监听Socket
if (listener == null)
{
- listener = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
- listener.Bind(new IPEndPoint(ipAddress, int.Parse(tcp_port)));
+ //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 == "DF55-1")//帝迈血常规DF55
+ if (apiOptions.CurrentDevice == "DF55-1")//帝迈血常规DF55
{
// 设置IP地址和端口号
string tcp_ip = ConfigurationManager.AppSettings[apiOptions.CurrentDevice].Split(',')[3];
@@ -2369,8 +2433,6 @@ namespace FlyDockTool
}
_tcpResult.Change(0, 10);//开始tcp数据接收,10毫秒频率
}
-
-
if (apiOptions.CurrentDevice == "U500")//尿常规U500
{
SerialPortOption.CreateInstance().IniserialPortOption();//初始化串口
@@ -2459,6 +2521,24 @@ namespace FlyDockTool
SerialPortOption.CreateInstance().StartDataReadThread();//开启数据接收
}
+ if (apiOptions.CurrentDevice == "BS-460")//迈瑞生化BS-430
+ {
+ // 设置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毫秒频率
+ }
+
}
///
@@ -2575,6 +2655,17 @@ namespace FlyDockTool
}
if (apiOptions.CurrentDevice == "MA-4210")//MA-4210
_tResult.Change(5000, 5000);// 数据处理:延迟5秒开始 5秒计时
+
+ if (apiOptions.CurrentDevice == "BS-460")//生化BS-460
+ {
+ //File.WriteAllText("deviceDataLog.txt", deviceDataStr, Encoding.GetEncoding("GB18030"));
+ if (tempData.Contains("OBX|17|"))//OBX|22| 为结束符 说明字符串完整了
+ {
+ deviceAnalysisOption(tempData);
+ tempData = string.Empty;//执行完以后 将临时积累数据清空 以便接收下一个样本数据
+ }
+ // _tResult.Change(10000, 10000);// 数据处理:延迟5秒开始 5秒计时
+ }
}
///
@@ -2895,7 +2986,11 @@ namespace FlyDockTool
SerialPortOption.CreateInstance().StopDataReadThread();//开启数据接收
}
-
+ if (apiOptions.CurrentDevice == "BS-460")//生化BS-460
+ {
+ _tcpResult.Change(-1, 10);//停止tcp数据接收
+ clientSocket.Close();
+ }
}
/////
diff --git a/mainForm.Designer.cs b/mainForm.Designer.cs
index 19f8659..0bc32b9 100644
--- a/mainForm.Designer.cs
+++ b/mainForm.Designer.cs
@@ -62,6 +62,7 @@
this.groupBox2.TabIndex = 1;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "操作";
+ this.groupBox2.Enter += new System.EventHandler(this.groupBox2_Enter);
//
// button1
//
@@ -188,7 +189,7 @@
this.MinimizeBox = false;
this.Name = "mainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "福乐云软硬件数据对接工具V1.1(2024121214)";
+ this.Text = "福乐云软硬件数据对接工具V1.1(2024121301)";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.mainForm_FormClosing);
this.Load += new System.EventHandler(this.Form1_Load);
this.groupBox2.ResumeLayout(false);
diff --git a/mainForm.cs b/mainForm.cs
index 2092d94..5df2b12 100644
--- a/mainForm.cs
+++ b/mainForm.cs
@@ -32,11 +32,11 @@ namespace FlyDockTool
lb_currentDeviceInfo.Text = CurrentDevice;
btn_start_or_stop_Click(null,null);//启动数据接收
- ////测试代码 测试完毕后注释调一下两行代码
- //string resultDataStr = File.ReadAllText(@"C:\Users\Administrator\Desktop\察哈尔右翼中旗\黄羊城\尿常规MA-4210\尿常规MA-4210.txt", Encoding.GetEncoding("GB18030"));
+ ////测试代码 测试完毕后注释调一下两行代码
+ //string resultDataStr = File.ReadAllText(@"C:\Users\Administrator\Desktop\察哈尔右翼中旗\宏盘卫生院\血常规BC-5130\血常规BC-5130.txt", Encoding.GetEncoding("UTF-8"));
//deviceAnalysis.CreateInstance().deviceAnalysisOption(resultDataStr);
-
+
}
private void btn_start_or_stop_Click(object sender, EventArgs e)
@@ -143,5 +143,10 @@ namespace FlyDockTool
MessageBox.Show("未查到设备编号,请先在配置文件中配置MacAddress和MachineCode");
}
+
+ private void groupBox2_Enter(object sender, EventArgs e)
+ {
+
+ }
}
}