This commit is contained in:
@@ -251,7 +251,7 @@ namespace 外科辅料和患者防护罩激光抗性测试仪
|
|||||||
{
|
{
|
||||||
// 创建串口对象
|
// 创建串口对象
|
||||||
serialPort = new SerialPort();
|
serialPort = new SerialPort();
|
||||||
serialPort.PortName = "COM3";
|
serialPort.PortName = "COM2";
|
||||||
serialPort.BaudRate = 38400;
|
serialPort.BaudRate = 38400;
|
||||||
serialPort.DataBits = 8;
|
serialPort.DataBits = 8;
|
||||||
serialPort.Parity = Parity.None;
|
serialPort.Parity = Parity.None;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using BasicDemo;
|
using BasicDemo;
|
||||||
using Modbus.Device;
|
using Modbus.Device;
|
||||||
|
using NModbus.Device;
|
||||||
using Sunny.UI;
|
using Sunny.UI;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -10,6 +11,7 @@ using System.Drawing;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO.Ports;
|
using System.IO.Ports;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@@ -102,22 +104,26 @@ namespace 外科辅料和患者防护罩激光抗性测试仪
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
string labelText = await Task.Factory.StartNew(() =>
|
//string labelText = await Task.Factory.StartNew(() =>
|
||||||
{
|
//{
|
||||||
|
|
||||||
if (this.InvokeRequired)
|
// if (this.InvokeRequired)
|
||||||
{
|
// {
|
||||||
return (string)this.Invoke(new Func<string>(() => uiLabel23.Text));
|
// return (string)this.Invoke(new Func<string>(() => uiLabel23.Text));
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
return uiLabel23.Text;
|
// return uiLabel23.Text;
|
||||||
}
|
// }
|
||||||
});
|
//});
|
||||||
await Task.Run(() =>
|
//await Task.Run(() =>
|
||||||
{
|
//{
|
||||||
ma?.WriteToPLCForNew(labelText, 74, Function.DataType.浮点型, 3);
|
|
||||||
});
|
// 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)
|
catch (Exception ex)
|
||||||
|
|||||||
Reference in New Issue
Block a user