接入设备:BS-460

This commit is contained in:
lishuang 2024-12-13 09:47:28 +08:00
parent ce1b462e94
commit 3b1028ab96
5 changed files with 190 additions and 87 deletions

View File

@ -14,7 +14,7 @@ namespace FlyDockTool
//测试11111 都是对的收到大大大
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new mainForm()); ;//gitceshi
Application.Run(new mainForm()); ;//gitceshi88
}
}
}

View File

@ -37,8 +37,8 @@
<add key="BA600MY" value="User-2024H-II,H-II,86,COM1,19200,NONE,8,1,Unicode" />
<!--优利特血常规URIT-5180-->
<add key="URIT-5180" value="User-2024H-II,URIT-5180,87,127.0.0.1,6688,GB18030" />
<!--BS-430-->
<add key="BS-430" value="User-2024H-II,BS-430,91,127.0.0.1,6688,GB18030" />
<!--迈瑞BS-430-->
<add key="BS-430" value="User-2024H-II,BS-430,91,192.168.1.15,6688,GB18030" />
<!--尿常规 URIT-1600 -->
<add key="URIT-1600" value="User-2024H-II,URIT-1600,86,COM1,19200,NONE,8,1,Unicode" />
<!--HTSH-4000全自动生化分析仪 读access数据库-->
@ -59,6 +59,8 @@
<add key="DF55-2" value="PC-202106061449,DF55-2,121,127.0.0.1,5600,GB18030" />
<add key="MA-4210" value="wstwsy-PC,MA-4210,90,COM1,9600,NONE,8,1" />
<!--迈瑞BS-460-->
<add key="BS-460" value="User-2024H-II,BS-460,91,127.0.0.1,6688,GB18030" />
<add key="CurrentDevice" value="BC-5130" />
</appSettings>

View File

@ -1641,78 +1641,79 @@ namespace FlyDockTool
}
}
if (apiOptions.CurrentDevice == "BC-5130")//BC-5130
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
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<examResultMode> ermList = new List<examResultMode>();
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<examImageParaModel> eipmList = new List<examImageParaModel>();
int[] array1 = strCount("^Base64^", deviceDataStr);
string keyStr = "||||||F";//结束符
List<string> 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<examImageParaModel> eipmList = new List<examImageParaModel>();
int[] array1 = strCount("^Base64^", deviceDataStr);
string keyStr = "||||||F";//结束符
List<string> 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<examResultMode> ermList = new List<examResultMode>();
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;
}
/// <summary>
/// 从结果字符串中截取 结果
/// </summary>
/// <param name="itemStr"></param>
/// <param name="deviceDataStr"></param>
/// <returns></returns>
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;
}
/// <summary>
/// 从结果字符串中截取 结果
/// </summary>
@ -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毫秒频率
}
}
/// <summary>
@ -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秒计时
}
}
/// <summary>
@ -2895,7 +2986,11 @@ namespace FlyDockTool
SerialPortOption.CreateInstance().StopDataReadThread();//开启数据接收
}
if (apiOptions.CurrentDevice == "BS-460")//生化BS-460
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
}
///// <summary>

3
mainForm.Designer.cs generated
View File

@ -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);

View File

@ -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)
{
}
}
}