From 8c0bd3c1598c1b1cc39e03cc64f7fb5f9c6643d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Tue, 16 Apr 2024 13:46:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProductionSystem/Forms/HomeFormInfo.cs | 4 ++++ ProductionSystem/Untils/PWMDeviceHelper.cs | 6 +++--- ProductionSystem/Untils/PWMHelper.cs | 24 +++++++++++++++++++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/ProductionSystem/Forms/HomeFormInfo.cs b/ProductionSystem/Forms/HomeFormInfo.cs index c1319db..bc4d739 100644 --- a/ProductionSystem/Forms/HomeFormInfo.cs +++ b/ProductionSystem/Forms/HomeFormInfo.cs @@ -636,6 +636,10 @@ namespace ProductionSystem.Forms middleIsCanRound = false; Thread.Sleep(Program.ReadPlcRate); + + PWMHelper.Open(); + PWMHelper.Cloud(); + //自动模式 如果是手动模式就是false if (D1004) { diff --git a/ProductionSystem/Untils/PWMDeviceHelper.cs b/ProductionSystem/Untils/PWMDeviceHelper.cs index ac28750..dbf4421 100644 --- a/ProductionSystem/Untils/PWMDeviceHelper.cs +++ b/ProductionSystem/Untils/PWMDeviceHelper.cs @@ -39,8 +39,8 @@ namespace ProductionSystem.Untils _data = new List(); _serialPort = new SerialPort { - PortName = Program.PortName, - BaudRate = Program.BaudRate, + PortName = "COM5", + BaudRate = 9600, Parity = (Parity)Program.Parity, DataBits = Program.DataBits, StopBits = (StopBits)Program.StopBits @@ -138,7 +138,7 @@ namespace ProductionSystem.Untils } } - private (bool isok, string msg) writeData(string sendString) + public (bool isok, string msg) writeData(string sendString) { try { diff --git a/ProductionSystem/Untils/PWMHelper.cs b/ProductionSystem/Untils/PWMHelper.cs index e0a04d3..1aa685d 100644 --- a/ProductionSystem/Untils/PWMHelper.cs +++ b/ProductionSystem/Untils/PWMHelper.cs @@ -1,4 +1,5 @@ -using ProductionSystem_Model.ViewModel.Response.Para; +using DevExpress.Data.Helpers; +using ProductionSystem_Model.ViewModel.Response.Para; namespace ProductionSystem.Untils { @@ -15,6 +16,27 @@ namespace ProductionSystem.Untils { return PWMDeviceHelper.Instance.Run(paraCategory, speed, pointKeyValue); } + + + + public static void Open() + { + string a = + "01 10 00 00 00 0D 1A 00 78 00 00 00 64 01 CC 00 14 00 0A 00 0A 00 32 03 E8 01 90 00 32 00 01 00 01 62 55"; + PWMDeviceHelper.Instance.writeData(a); + + a = "01 06 00 0D 00 01 D9 C9"; + PWMDeviceHelper.Instance.writeData(a); + } + + public static void Cloud() + { + string a = + "01 06 00 0D 00 00 18 09"; + PWMDeviceHelper.Instance.writeData(a); + + + } }