From c6260156f85eb1bdb7e453ba14d151f9b372c91d Mon Sep 17 00:00:00 2001 From: gongxh Date: Mon, 27 Dec 2021 09:51:57 +0800 Subject: [PATCH] 1 --- CleanMachineHMI/CleanMachineHMI.csproj | 23 +------- .../Base/frmContaminationDTL.cs | 2 +- .../Base/frmContaminationType.cs | 2 +- .../FrmUserControl/frmMainDetail.cs | 2 +- .../FrmUserControl/frmPrinterMain.cs | 2 +- CleanMachineHMI/ListItem.cs | 15 +++++ CleanMachineHMI/Utils/PlcOperationHelper.cs | 56 +++++++++++++------ .../frmChild/frmAddContaminationDtl.cs | 2 +- .../frmChild/frmAddContaminationType.cs | 2 +- CleanMachineHMI/frmChild/frmAddUser.cs | 2 +- .../frmChild/frmEditContaminationDtl.cs | 2 +- .../frmChild/frmEditContaminationType.cs | 2 +- CleanMachineHMI/frmChild/frmEditUser.cs | 2 +- .../frmChild/frmSwitchRunDirection.cs | 2 +- CleanMachineHMI/frmIOMonitor_Old.cs | 2 +- LeadDataBaseUtility/App.config | 14 ----- .../LeadDataBaseUtility.csproj | 3 - 17 files changed, 68 insertions(+), 67 deletions(-) create mode 100644 CleanMachineHMI/ListItem.cs delete mode 100644 LeadDataBaseUtility/App.config diff --git a/CleanMachineHMI/CleanMachineHMI.csproj b/CleanMachineHMI/CleanMachineHMI.csproj index d73866d..4eb748d 100644 --- a/CleanMachineHMI/CleanMachineHMI.csproj +++ b/CleanMachineHMI/CleanMachineHMI.csproj @@ -120,24 +120,6 @@ ..\packages\Krypton.Toolkit.5.550.2108.1\lib\net45\Krypton.Toolkit.dll - - ..\packages\Microsoft.ReportingServices.ReportViewerControl.Winforms.140.1000.523\lib\net40\Microsoft.ReportViewer.Common.dll - - - ..\packages\Microsoft.ReportingServices.ReportViewerControl.Winforms.140.1000.523\lib\net40\Microsoft.ReportViewer.DataVisualization.dll - - - ..\packages\Microsoft.ReportingServices.ReportViewerControl.Winforms.140.1000.523\lib\net40\Microsoft.ReportViewer.Design.dll - - - ..\packages\Microsoft.ReportingServices.ReportViewerControl.Winforms.140.1000.523\lib\net40\Microsoft.ReportViewer.ProcessingObjectModel.dll - - - ..\packages\Microsoft.ReportingServices.ReportViewerControl.Winforms.140.1000.523\lib\net40\Microsoft.ReportViewer.WinForms.dll - - - ..\packages\Microsoft.SqlServer.Types.14.0.314.76\lib\net40\Microsoft.SqlServer.Types.dll - False ..\public\NModbus4.dll @@ -145,14 +127,10 @@ - - - - @@ -278,6 +256,7 @@ frmWarning.cs + diff --git a/CleanMachineHMI/FrmUserControl/Base/frmContaminationDTL.cs b/CleanMachineHMI/FrmUserControl/Base/frmContaminationDTL.cs index 1038cfa..8918d8e 100644 --- a/CleanMachineHMI/FrmUserControl/Base/frmContaminationDTL.cs +++ b/CleanMachineHMI/FrmUserControl/Base/frmContaminationDTL.cs @@ -11,7 +11,7 @@ using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; -using System.Web.UI.WebControls; + using System.Windows.Forms; namespace CleanMachineHMI.FrmUserControl diff --git a/CleanMachineHMI/FrmUserControl/Base/frmContaminationType.cs b/CleanMachineHMI/FrmUserControl/Base/frmContaminationType.cs index b0d5744..f4890be 100644 --- a/CleanMachineHMI/FrmUserControl/Base/frmContaminationType.cs +++ b/CleanMachineHMI/FrmUserControl/Base/frmContaminationType.cs @@ -11,7 +11,7 @@ using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; -using System.Web.UI.WebControls; + using System.Windows.Forms; namespace CleanMachineHMI.FrmUserControl diff --git a/CleanMachineHMI/FrmUserControl/frmMainDetail.cs b/CleanMachineHMI/FrmUserControl/frmMainDetail.cs index 734dc09..98e88eb 100644 --- a/CleanMachineHMI/FrmUserControl/frmMainDetail.cs +++ b/CleanMachineHMI/FrmUserControl/frmMainDetail.cs @@ -13,7 +13,7 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; -using System.Web.UI.WebControls; + using System.Windows.Forms; namespace CleanMachineHMI.FrmUserControl diff --git a/CleanMachineHMI/FrmUserControl/frmPrinterMain.cs b/CleanMachineHMI/FrmUserControl/frmPrinterMain.cs index 2a57c06..5e5af45 100644 --- a/CleanMachineHMI/FrmUserControl/frmPrinterMain.cs +++ b/CleanMachineHMI/FrmUserControl/frmPrinterMain.cs @@ -13,7 +13,7 @@ using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; -using System.Web.UI.WebControls; + using System.Windows.Forms; namespace CleanMachineHMI.FrmUserControl diff --git a/CleanMachineHMI/ListItem.cs b/CleanMachineHMI/ListItem.cs new file mode 100644 index 0000000..ebc55f5 --- /dev/null +++ b/CleanMachineHMI/ListItem.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CleanMachineHMI +{ + public class ListItem + { + public string Value { get; set; } + public string Text { get; set; } + + } +} diff --git a/CleanMachineHMI/Utils/PlcOperationHelper.cs b/CleanMachineHMI/Utils/PlcOperationHelper.cs index a08a01b..691ac4e 100644 --- a/CleanMachineHMI/Utils/PlcOperationHelper.cs +++ b/CleanMachineHMI/Utils/PlcOperationHelper.cs @@ -1,4 +1,6 @@ -using LeadDataBaseUtility; +#define USE_LOCAL_TCP_DEBUG //使用本地调式 + +using LeadDataBaseUtility; using Modbus.Device; using NX_LogUtility; using System; @@ -60,8 +62,15 @@ namespace CleanMachineHMI set { this._isConn = value; } } private static IModbusMaster master; +#if USE_LOCAL_TCP_DEBUG private static System.Net.Sockets.TcpClient port; - +#else + private static SerialPort port; +#endif + /// + /// 初始化PLC + /// + /// public bool PlcInit() { try @@ -72,8 +81,12 @@ namespace CleanMachineHMI StopBits stopbis = Convert.ToInt32(GlobalHelper.ParameterList.Select(" PARAMETER_CODE = 'StopBits'")[0]["PARAMETER_VALUE"]) == 0 ? StopBits.None : (Convert.ToInt32(GlobalHelper.ParameterList.Select(" PARAMETER_CODE = 'StopBits'")[0]["PARAMETER_VALUE"]) == 1 ? StopBits.One : StopBits.Two); Parity paritymsg = Convert.ToInt32(GlobalHelper.ParameterList.Select(" PARAMETER_CODE = 'ParityMsg'")[0]["PARAMETER_VALUE"]) == 0 ? Parity.None : (Convert.ToInt32(GlobalHelper.ParameterList.Select(" PARAMETER_CODE = 'ParityMsg'")[0]["PARAMETER_VALUE"]) == 1 ? Parity.Odd : Parity.Even); int modbusPattern = Convert.ToInt32(GlobalHelper.ParameterList.Select(" PARAMETER_CODE = 'ModbusPattern'")[0]["PARAMETER_VALUE"]); - // port = new SerialPort(portname, baudrate, paritymsg, databits, stopbis); +#if USE_LOCAL_TCP_DEBUG port = new System.Net.Sockets.TcpClient(); +#else + port = new SerialPort(portname, baudrate, paritymsg, databits, stopbis); +#endif + if (modbusPattern == 0) { master = ModbusSerialMaster.CreateRtu(port); @@ -82,9 +95,13 @@ namespace CleanMachineHMI { master = ModbusSerialMaster.CreateAscii(port); } +#if USE_LOCAL_TCP_DEBUG port.Connect("127.0.0.1", 5002); - // port.Open(); this._isConn = true; +#else + port.Open(); +#endif + return true; } catch (Exception ex) @@ -795,18 +812,25 @@ namespace CleanMachineHMI WritePlcItem("PlcHeartbeatWriteData", wcsToPlcHeartDataNew.ToString(), PlcItemTypeDesc.D); } - //if (DateTime.Now > HeartbeatTime.AddSeconds(5))//心跳超时 - //{ - // isConn = false; - // //报警处理。 - // frmMainNew.Show_Plc_Alarm("PLC heartbeat data is abnormal, PLC loses connection!"); - // if (ReConnNum % 5 == 0) - // { - // ClosePlcConn(); - // PlcInit(); - // } - // ReConnNum++; - //} + + +#if USE_LOCAL_TCP_DEBUG + +#else + + if (DateTime.Now > HeartbeatTime.AddSeconds(5))//心跳超时 + { + isConn = false; + //报警处理。 + frmMainNew.Show_Plc_Alarm("PLC heartbeat data is abnormal, PLC loses connection!"); + if (ReConnNum % 5 == 0) + { + ClosePlcConn(); + PlcInit(); + } + ReConnNum++; + } +#endif } catch { diff --git a/CleanMachineHMI/frmChild/frmAddContaminationDtl.cs b/CleanMachineHMI/frmChild/frmAddContaminationDtl.cs index 7e46a52..7d9a0ae 100644 --- a/CleanMachineHMI/frmChild/frmAddContaminationDtl.cs +++ b/CleanMachineHMI/frmChild/frmAddContaminationDtl.cs @@ -11,7 +11,7 @@ using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; -using System.Web.UI.WebControls; + using System.Windows.Forms; namespace CleanMachineHMI.frmChild diff --git a/CleanMachineHMI/frmChild/frmAddContaminationType.cs b/CleanMachineHMI/frmChild/frmAddContaminationType.cs index 7fcefe8..0e00aea 100644 --- a/CleanMachineHMI/frmChild/frmAddContaminationType.cs +++ b/CleanMachineHMI/frmChild/frmAddContaminationType.cs @@ -11,7 +11,7 @@ using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; -using System.Web.UI.WebControls; + using System.Windows.Forms; namespace CleanMachineHMI.frmChild diff --git a/CleanMachineHMI/frmChild/frmAddUser.cs b/CleanMachineHMI/frmChild/frmAddUser.cs index 134bca2..6e806b5 100644 --- a/CleanMachineHMI/frmChild/frmAddUser.cs +++ b/CleanMachineHMI/frmChild/frmAddUser.cs @@ -11,7 +11,7 @@ using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; -using System.Web.UI.WebControls; + using System.Windows.Forms; namespace CleanMachineHMI.frmChild diff --git a/CleanMachineHMI/frmChild/frmEditContaminationDtl.cs b/CleanMachineHMI/frmChild/frmEditContaminationDtl.cs index e13f716..fee758b 100644 --- a/CleanMachineHMI/frmChild/frmEditContaminationDtl.cs +++ b/CleanMachineHMI/frmChild/frmEditContaminationDtl.cs @@ -11,7 +11,7 @@ using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; -using System.Web.UI.WebControls; + using System.Windows.Forms; namespace CleanMachineHMI.frmChild diff --git a/CleanMachineHMI/frmChild/frmEditContaminationType.cs b/CleanMachineHMI/frmChild/frmEditContaminationType.cs index 4da6fea..de2de98 100644 --- a/CleanMachineHMI/frmChild/frmEditContaminationType.cs +++ b/CleanMachineHMI/frmChild/frmEditContaminationType.cs @@ -11,7 +11,7 @@ using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; -using System.Web.UI.WebControls; + using System.Windows.Forms; namespace CleanMachineHMI.frmChild diff --git a/CleanMachineHMI/frmChild/frmEditUser.cs b/CleanMachineHMI/frmChild/frmEditUser.cs index 7ace9e2..6a40f17 100644 --- a/CleanMachineHMI/frmChild/frmEditUser.cs +++ b/CleanMachineHMI/frmChild/frmEditUser.cs @@ -11,7 +11,7 @@ using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; -using System.Web.UI.WebControls; + using System.Windows.Forms; namespace CleanMachineHMI.frmChild diff --git a/CleanMachineHMI/frmChild/frmSwitchRunDirection.cs b/CleanMachineHMI/frmChild/frmSwitchRunDirection.cs index 1fb6c5e..95ac9b6 100644 --- a/CleanMachineHMI/frmChild/frmSwitchRunDirection.cs +++ b/CleanMachineHMI/frmChild/frmSwitchRunDirection.cs @@ -8,7 +8,7 @@ using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; -using System.Web.UI.WebControls; + using System.Windows.Forms; namespace CleanMachineHMI.frmChild diff --git a/CleanMachineHMI/frmIOMonitor_Old.cs b/CleanMachineHMI/frmIOMonitor_Old.cs index 5ee7a56..9904582 100644 --- a/CleanMachineHMI/frmIOMonitor_Old.cs +++ b/CleanMachineHMI/frmIOMonitor_Old.cs @@ -136,7 +136,7 @@ namespace CleanMachineHMI { } - Thread.Sleep(5); + Thread.Sleep(20); } } private void InitControl() diff --git a/LeadDataBaseUtility/App.config b/LeadDataBaseUtility/App.config deleted file mode 100644 index d5d0df3..0000000 --- a/LeadDataBaseUtility/App.config +++ /dev/null @@ -1,14 +0,0 @@ - - - - -
- - - - - - - - - \ No newline at end of file diff --git a/LeadDataBaseUtility/LeadDataBaseUtility.csproj b/LeadDataBaseUtility/LeadDataBaseUtility.csproj index f4335fa..ba90971 100644 --- a/LeadDataBaseUtility/LeadDataBaseUtility.csproj +++ b/LeadDataBaseUtility/LeadDataBaseUtility.csproj @@ -103,9 +103,6 @@ - - - {925057D8-7EE8-42ED-8AA0-628AF82F10B2}