From 73320cb736b3a0a9de073119f889d09db339078a Mon Sep 17 00:00:00 2001 From: nodyang Date: Fri, 25 Aug 2023 10:20:48 +0800 Subject: [PATCH] merge --- .../ElectronicMachinery.cs | 20 +- .../ElectronicMachinery_2.cs | 14 +- .../ValveStateControl/ValveStateControl.cs | 20 +- .../FinishBatch/SaveHelper/AlarmSaveHelper.cs | 26 +- .../Mesnac.Action.ChemicalWeighing.csproj | 3 + Main/MCRun/Program.cs | 24 +- Mesnac.DoUtils/DoControl.cs | 336 +++++++++--------- 7 files changed, 216 insertions(+), 227 deletions(-) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ElectronicMachinery/ElectronicMachinery.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ElectronicMachinery/ElectronicMachinery.cs index a11b181..2fc29de 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ElectronicMachinery/ElectronicMachinery.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ElectronicMachinery/ElectronicMachinery.cs @@ -26,9 +26,9 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMach public ElectronicMachinery() { InitializeComponent(); - DoControl AlarmLight = DoControl.Instance; - DoControl.Instance.ComOn(); - DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.On); + // DoControl AlarmLight = DoControl.Instance; + // DoControl.Instance.ComOn(); + // DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.On); StateMonitor(); } @@ -249,8 +249,8 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMach private void AlarmReset_Click(object sender, EventArgs e) { SetDataValue("_Alarm", 0); - DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.On); - DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Red, DoUtils.enumInfo.DOOnOff.Off); + // DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.On); + // DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Red, DoUtils.enumInfo.DOOnOff.Off); } /// @@ -281,8 +281,8 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMach private void Alarm_Click(object sender, EventArgs e) { SetDataValue("_Alarm", 1); - DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Red, DoUtils.enumInfo.DOOnOff.On); - DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.Off); + // DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Red, DoUtils.enumInfo.DOOnOff.On); + // DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.Off); } /// @@ -292,9 +292,9 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMach /// private void ElectronicMachinery_FormClosing(object sender, FormClosingEventArgs e) { - DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.Off); - DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Red, DoUtils.enumInfo.DOOnOff.Off); - DoControl.Instance.ComOff(); + // DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.Off); + // DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Red, DoUtils.enumInfo.DOOnOff.Off); + // DoControl.Instance.ComOff(); } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ElectronicMachinery/ElectronicMachinery_2.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ElectronicMachinery/ElectronicMachinery_2.cs index 5c472db..df6728c 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ElectronicMachinery/ElectronicMachinery_2.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ElectronicMachinery/ElectronicMachinery_2.cs @@ -23,9 +23,9 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMach public ElectronicMachinery_2() { InitializeComponent(); - DoControl AlarmLight = DoControl.Instance; - DoControl.Instance.ComOn(); - DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.On); + // DoControl AlarmLight = DoControl.Instance; + // DoControl.Instance.ComOn(); + // DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.On); StateMonitor(); } @@ -129,15 +129,15 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMach private void Alarm_Click(object sender, EventArgs e) { SetDataValue("_Alarm", 1); - DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Red, DoUtils.enumInfo.DOOnOff.On); - DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.Off); + // DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Red, DoUtils.enumInfo.DOOnOff.On); + // DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.Off); } private void AlarmReset_Click(object sender, EventArgs e) { SetDataValue("_Alarm", 0); - DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.On); - DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Red, DoUtils.enumInfo.DOOnOff.Off); + // DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.On); + // DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Red, DoUtils.enumInfo.DOOnOff.Off); } /// diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ValveStateControl/ValveStateControl.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ValveStateControl/ValveStateControl.cs index 710232c..426aad1 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ValveStateControl/ValveStateControl.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ValveStateControl/ValveStateControl.cs @@ -25,9 +25,9 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ValveStateCont public ValveStateControl() { InitializeComponent(); - DoControl AlarmLight = DoControl.Instance; - DoControl.Instance.ComOn(); - DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.On); + // DoControl AlarmLight = DoControl.Instance; + // DoControl.Instance.ComOn(); + // DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.On); StateMonitor(); } @@ -199,8 +199,8 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ValveStateCont private void Alarm_Click(object sender, EventArgs e) { SetDataValue("_Alarm", 1); - DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Red, DoUtils.enumInfo.DOOnOff.On); - DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.Off); + // DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Red, DoUtils.enumInfo.DOOnOff.On); + // DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.Off); } /// @@ -211,8 +211,8 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ValveStateCont private void AlarmSet_Click(object sender, EventArgs e) { SetDataValue("_Alarm", 0); - DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.On); - DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Red, DoUtils.enumInfo.DOOnOff.Off); + // DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.On); + // DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Red, DoUtils.enumInfo.DOOnOff.Off); } /// @@ -232,9 +232,9 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ValveStateCont /// private void ValveStateControl_FormClosing(object sender, FormClosingEventArgs e) { - DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.Off); - DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Red, DoUtils.enumInfo.DOOnOff.Off); - DoControl.Instance.ComOff(); + // DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.Off); + // DoControl.Instance.DOControl(DoUtils.enumInfo.DOName.Red, DoUtils.enumInfo.DOOnOff.Off); + // DoControl.Instance.ComOff(); } private IDictionary dmNameValue = new Dictionary() diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/SaveHelper/AlarmSaveHelper.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/SaveHelper/AlarmSaveHelper.cs index 5d93bf8..68577a1 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/SaveHelper/AlarmSaveHelper.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/SaveHelper/AlarmSaveHelper.cs @@ -28,7 +28,7 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper private PlcBusiness plcBusiness = PlcBusiness.Instance; - private DoControl doControl = DoControl.Instance; + // private DoControl doControl = DoControl.Instance; private static readonly Lazy lazy = new Lazy(() => new AlarmSaveHelper()); @@ -239,18 +239,18 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper /// 是否报警 private void AlarmLight(bool flag) { - if(flag) - { - //打开报警灯:FIRST 关闭绿灯 SECOND 打开红灯 - doControl.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.Off); - doControl.DOControl(DoUtils.enumInfo.DOName.Red, DoUtils.enumInfo.DOOnOff.On); - } - else - { - // 关闭报警灯:FIRST 打开红灯 SECOND 关闭绿灯 - doControl.DOControl(DoUtils.enumInfo.DOName.Red, DoUtils.enumInfo.DOOnOff.Off); - doControl.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.On); - } + // if(flag) + // { + // //打开报警灯:FIRST 关闭绿灯 SECOND 打开红灯 + // doControl.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.Off); + // doControl.DOControl(DoUtils.enumInfo.DOName.Red, DoUtils.enumInfo.DOOnOff.On); + // } + // else + // { + // // 关闭报警灯:FIRST 打开红灯 SECOND 关闭绿灯 + // doControl.DOControl(DoUtils.enumInfo.DOName.Red, DoUtils.enumInfo.DOOnOff.Off); + // doControl.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.On); + // } } } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj index 8368aa9..c20e8d6 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj @@ -153,6 +153,9 @@ False ..\..\..\PlugInPlatform\Mesnac.PlugIn.dll + + ..\..\Microsoft.Office.Interop.Excel.dll + diff --git a/Main/MCRun/Program.cs b/Main/MCRun/Program.cs index 485f929..bb62845 100644 --- a/Main/MCRun/Program.cs +++ b/Main/MCRun/Program.cs @@ -28,7 +28,7 @@ namespace MCRun static void Main(string[] args) { - Timer timer = new Timer(); + if (Mesnac.Basic.ProcessHelper.HaveRunningInstance()) { @@ -117,7 +117,7 @@ namespace MCRun doc.Load(instance); var nodes = doc.ChildNodes[1].ChildNodes[0].ChildNodes[0].ChildNodes[4].ChildNodes[0]; var ip = nodes.Attributes["value"].Value; - //初始化HslCommunication 11.0.6.0 + //初始化HslCommunication 11.0.6.0 PlcBusiness.Instance.InitPlcConnect(PlcType.SiemensPlc,ip, 102); } catch (Exception exception) @@ -125,15 +125,10 @@ namespace MCRun ICSharpCode.Core.LoggingService.Debug("HSLPlc读取失败"); } //初始化连接报警器 - DoControl.Instance.ComOn(); + // DoControl.Instance.ComOn(); - // 设置触发间隔时间(以毫秒为单位) - timer.Interval = 1500; // 1000 毫秒 = 1 秒 -// 绑定 Tick 事件处理程序 - timer.Tick += new EventHandler(new Program().Timer_Tick); -// 启动 Timer - timer.Start(); + } @@ -192,15 +187,6 @@ namespace MCRun Application.ExitThread(); Application.Exit(); } - - - private void Timer_Tick(object sender, EventArgs e) - { - // 定时触发的操作 - Task.Run(() => { - - // FinishBatchService.Instance.Start(); - }); - } + } } diff --git a/Mesnac.DoUtils/DoControl.cs b/Mesnac.DoUtils/DoControl.cs index d261e13..58d5ea8 100644 --- a/Mesnac.DoUtils/DoControl.cs +++ b/Mesnac.DoUtils/DoControl.cs @@ -1,168 +1,168 @@ -using Mesnac.DoUtils.enumInfo; -using System; -using System.Collections.Generic; -using System.IO.Ports; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Xml.Linq; - -namespace Mesnac.DoUtils -{ - /// - /// 报警灯控制类 - /// - public sealed class DoControl - { - public SerialPort serialPort = new SerialPort("COM5"); - private static readonly Lazy lazy = new Lazy(() => new DoControl()); - public static DoControl Instance => lazy.Value; - public bool AlarmState { get; private set; } = false; - private DoControl() - { - serialPort.BaudRate = 115200; - serialPort.DataBits = 8; - serialPort.StopBits = StopBits.One; - serialPort.Parity = Parity.None; - } - - /// - /// 串口启动 - /// - public void ComOn() - { - try - { - if (!serialPort.IsOpen) - { - serialPort.Open(); - ICSharpCode.Core.LoggingService.Debug($"打开报警器串口成功,串口:{serialPort.PortName};波特率:{serialPort.BaudRate}"); - } - }catch (Exception ex) - { - ICSharpCode.Core.LoggingService.Error($"报警器串口打开异常,串口:{serialPort.PortName};波特率:{serialPort.BaudRate};异常信息:{ex.Message}"); - } - } - /// - /// 串口关闭 - /// - public void ComOff() - { - if (serialPort.IsOpen) - { - serialPort.Close(); - } - } - - /// - /// DO1设备启动(红灯) - /// - public void redLightOn() - { - DOControl(DOName.Red, DOOnOff.On); - } - - /// - /// DO2设备启动(绿灯) - /// - public void greenLightOn() - { - DOControl(DOName.Green, DOOnOff.On); - } - - /// - /// DO3设备启动(蜂鸣器) - /// - public void buzzerOn() - { - DOControl(DOName.Buzzer, DOOnOff.On); - } - - /// - /// DO1设备关闭(红灯) - /// - public void redLightOff() - { - DOControl(DOName.Red, DOOnOff.Off); - } - - /// - /// DO2设备关闭(绿灯) - /// - public void greenLightOff() - { - DOControl(DOName.Green, DOOnOff.Off); - } - - /// - /// DO3设备关闭(蜂鸣器) - /// - public void buzzerOff() - { - DOControl(DOName.Buzzer, DOOnOff.On); - } - - /// - /// 重置串口和DO状态 - /// - public void Reset() - { - SetOff(); - ComOff(); - } - - /// - /// 重置DO状态 - /// - public void SetOff() - { - foreach (DOName dOName in Enum.GetValues(typeof(DOName))) - { - DOControl(dOName, DOOnOff.Off); - } - } - - /// - /// DO启停控制 - /// 如果收到红灯亮的信号,AlarmState会变为True; 收到红灯灭的信号,AlarmState设置为false - /// - /// DegitalOut接口名称 - /// 启停状态 - public void DOControl(DOName dOName, DOOnOff dOOnOff) - { - if(dOName.Equals(DOName.Red) && dOOnOff.Equals(DOOnOff.On)) - { - AlarmState = true; - } - if(dOName.Equals(DOName.Red) && dOOnOff.Equals(DOOnOff.Off)) - { - AlarmState = false; - } - if (serialPort.IsOpen) - { - serialPort.Write(new byte[] { 0xE3, 0x01, 0x09, (byte)dOName, (byte)dOOnOff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, 12); - } - else - { - ComOn(); - serialPort.Write(new byte[] { 0xE3, 0x01, 0x09, (byte)dOName, (byte)dOOnOff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, 12); - } - } - - /// - /// 文本框传输数据控制COM5串口 - /// - public void DOTestSend(string str) - { - //ComOn(); - string[] strArray = str.Split(' '); - byte[] bytes = new byte[strArray.Length]; - for (int i = 0; i < bytes.Length; i++) - { - bytes[i] = Convert.ToByte(strArray[i], 16); - } - serialPort.Write(bytes, 0, bytes.Length); - } - } -} \ No newline at end of file +// using Mesnac.DoUtils.enumInfo; +// using System; +// using System.Collections.Generic; +// using System.IO.Ports; +// using System.Linq; +// using System.Text; +// using System.Threading; +// using System.Threading.Tasks; +// using System.Xml.Linq; +// +// namespace Mesnac.DoUtils +// { +// /// +// /// 报警灯控制类 +// /// +// public sealed class DoControl +// { +// public SerialPort serialPort = new SerialPort("COM5"); +// private static readonly Lazy lazy = new Lazy(() => new DoControl()); +// public static DoControl Instance => lazy.Value; +// public bool AlarmState { get; private set; } = false; +// private DoControl() +// { +// serialPort.BaudRate = 115200; +// serialPort.DataBits = 8; +// serialPort.StopBits = StopBits.One; +// serialPort.Parity = Parity.None; +// } +// +// /// +// /// 串口启动 +// /// +// public void ComOn() +// { +// try +// { +// if (!serialPort.IsOpen) +// { +// serialPort.Open(); +// ICSharpCode.Core.LoggingService.Debug($"打开报警器串口成功,串口:{serialPort.PortName};波特率:{serialPort.BaudRate}"); +// } +// }catch (Exception ex) +// { +// ICSharpCode.Core.LoggingService.Error($"报警器串口打开异常,串口:{serialPort.PortName};波特率:{serialPort.BaudRate};异常信息:{ex.Message}"); +// } +// } +// /// +// /// 串口关闭 +// /// +// public void ComOff() +// { +// if (serialPort.IsOpen) +// { +// serialPort.Close(); +// } +// } +// +// /// +// /// DO1设备启动(红灯) +// /// +// public void redLightOn() +// { +// DOControl(DOName.Red, DOOnOff.On); +// } +// +// /// +// /// DO2设备启动(绿灯) +// /// +// public void greenLightOn() +// { +// DOControl(DOName.Green, DOOnOff.On); +// } +// +// /// +// /// DO3设备启动(蜂鸣器) +// /// +// public void buzzerOn() +// { +// DOControl(DOName.Buzzer, DOOnOff.On); +// } +// +// /// +// /// DO1设备关闭(红灯) +// /// +// public void redLightOff() +// { +// DOControl(DOName.Red, DOOnOff.Off); +// } +// +// /// +// /// DO2设备关闭(绿灯) +// /// +// public void greenLightOff() +// { +// DOControl(DOName.Green, DOOnOff.Off); +// } +// +// /// +// /// DO3设备关闭(蜂鸣器) +// /// +// public void buzzerOff() +// { +// DOControl(DOName.Buzzer, DOOnOff.On); +// } +// +// /// +// /// 重置串口和DO状态 +// /// +// public void Reset() +// { +// SetOff(); +// ComOff(); +// } +// +// /// +// /// 重置DO状态 +// /// +// public void SetOff() +// { +// foreach (DOName dOName in Enum.GetValues(typeof(DOName))) +// { +// DOControl(dOName, DOOnOff.Off); +// } +// } +// +// /// +// /// DO启停控制 +// /// 如果收到红灯亮的信号,AlarmState会变为True; 收到红灯灭的信号,AlarmState设置为false +// /// +// /// DegitalOut接口名称 +// /// 启停状态 +// public void DOControl(DOName dOName, DOOnOff dOOnOff) +// { +// if(dOName.Equals(DOName.Red) && dOOnOff.Equals(DOOnOff.On)) +// { +// AlarmState = true; +// } +// if(dOName.Equals(DOName.Red) && dOOnOff.Equals(DOOnOff.Off)) +// { +// AlarmState = false; +// } +// if (serialPort.IsOpen) +// { +// serialPort.Write(new byte[] { 0xE3, 0x01, 0x09, (byte)dOName, (byte)dOOnOff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, 12); +// } +// else +// { +// ComOn(); +// serialPort.Write(new byte[] { 0xE3, 0x01, 0x09, (byte)dOName, (byte)dOOnOff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, 12); +// } +// } +// +// /// +// /// 文本框传输数据控制COM5串口 +// /// +// public void DOTestSend(string str) +// { +// //ComOn(); +// string[] strArray = str.Split(' '); +// byte[] bytes = new byte[strArray.Length]; +// for (int i = 0; i < bytes.Length; i++) +// { +// bytes[i] = Convert.ToByte(strArray[i], 16); +// } +// serialPort.Write(bytes, 0, bytes.Length); +// } +// } +// } \ No newline at end of file