From 3a8b6926dd5530bc7e3ab1ec799466469e4aab56 Mon Sep 17 00:00:00 2001 From: xyy <544939200@qq.com> Date: Tue, 6 Jan 2026 21:51:23 +0800 Subject: [PATCH] --- .../外科辅料和患者防护罩激光抗性测试仪/ParameterSetting.cs | 2 +- .../外科辅料和患者防护罩激光抗性测试仪/PenetrationForm.cs | 38 +++++++++++-------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/外科辅料和患者防护罩激光抗性测试仪/外科辅料和患者防护罩激光抗性测试仪/ParameterSetting.cs b/外科辅料和患者防护罩激光抗性测试仪/外科辅料和患者防护罩激光抗性测试仪/ParameterSetting.cs index 5b1641a..763f694 100644 --- a/外科辅料和患者防护罩激光抗性测试仪/外科辅料和患者防护罩激光抗性测试仪/ParameterSetting.cs +++ b/外科辅料和患者防护罩激光抗性测试仪/外科辅料和患者防护罩激光抗性测试仪/ParameterSetting.cs @@ -251,7 +251,7 @@ namespace 外科辅料和患者防护罩激光抗性测试仪 { // 创建串口对象 serialPort = new SerialPort(); - serialPort.PortName = "COM3"; + serialPort.PortName = "COM2"; serialPort.BaudRate = 38400; serialPort.DataBits = 8; serialPort.Parity = Parity.None; diff --git a/外科辅料和患者防护罩激光抗性测试仪/外科辅料和患者防护罩激光抗性测试仪/PenetrationForm.cs b/外科辅料和患者防护罩激光抗性测试仪/外科辅料和患者防护罩激光抗性测试仪/PenetrationForm.cs index 9e6bf57..4b579ca 100644 --- a/外科辅料和患者防护罩激光抗性测试仪/外科辅料和患者防护罩激光抗性测试仪/PenetrationForm.cs +++ b/外科辅料和患者防护罩激光抗性测试仪/外科辅料和患者防护罩激光抗性测试仪/PenetrationForm.cs @@ -1,5 +1,6 @@ using BasicDemo; using Modbus.Device; +using NModbus.Device; using Sunny.UI; using System; using System.Collections.Generic; @@ -10,6 +11,7 @@ using System.Drawing; using System.Globalization; using System.IO.Ports; using System.Linq; +using System.Net; using System.Net.Sockets; using System.Text; using System.Threading; @@ -102,22 +104,26 @@ namespace 外科辅料和患者防护罩激光抗性测试仪 { return; } - string labelText = await Task.Factory.StartNew(() => - { - - if (this.InvokeRequired) - { - return (string)this.Invoke(new Func(() => uiLabel23.Text)); - } - else - { - return uiLabel23.Text; - } - }); - await Task.Run(() => - { - ma?.WriteToPLCForNew(labelText, 74, Function.DataType.浮点型, 3); - }); + //string labelText = await Task.Factory.StartNew(() => + //{ + + // if (this.InvokeRequired) + // { + // return (string)this.Invoke(new Func(() => uiLabel23.Text)); + // } + // else + // { + // return uiLabel23.Text; + // } + //}); + //await Task.Run(() => + //{ + + // ushort value = double.Parse(uiLabel23.Text); + //ma?.WriteToPLCForNew(labelText, 74, Function.DataType.浮点型, 3); + float value = float.Parse(uiLabel23.Text); + await _modbusMaster.WriteMultipleRegistersAsync(1, 74, c.SplitFloatToUShortArray((float)value)); + //}); } catch (Exception ex)