From 006ee68fcb6f6e8c42c28127c9d7b3a76536242f Mon Sep 17 00:00:00 2001 From: wenjy Date: Fri, 8 Mar 2024 10:21:42 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E4=B8=BB=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=93=8D=E4=BD=9C=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DoSomething.cs | 1 - Main.Designer.cs | 193 +++++++++++++++++++++++++++++++---------------- Main.cs | 135 +++++++++++++++++---------------- 3 files changed, 195 insertions(+), 134 deletions(-) diff --git a/DoSomething.cs b/DoSomething.cs index 1178ebf..d371d47 100644 --- a/DoSomething.cs +++ b/DoSomething.cs @@ -403,7 +403,6 @@ namespace ZJ_BYD { Program.siemensS7Net.Write(M20.Address, ushort.Parse("2")); } - } catch (Exception ex) { diff --git a/Main.Designer.cs b/Main.Designer.cs index 7799f90..eb5433f 100644 --- a/Main.Designer.cs +++ b/Main.Designer.cs @@ -36,9 +36,16 @@ namespace ZJ_BYD this.sysLogo = new DevExpress.XtraEditors.PictureEdit(); this.lblLineName = new DevExpress.XtraEditors.LabelControl(); this.tablePanel1 = new DevExpress.Utils.Layout.TablePanel(); - this.sopPanelControl = new DevExpress.XtraEditors.PanelControl(); + this.splitContainerControl1 = new DevExpress.XtraEditors.SplitContainerControl(); + this.xtraTabControl1 = new DevExpress.XtraTab.XtraTabControl(); + this.xtraTabPage1 = new DevExpress.XtraTab.XtraTabPage(); + this.txtLog = new DevExpress.XtraEditors.MemoEdit(); this.stationpanel = new DevExpress.Utils.Layout.StackPanel(); this.panelControl3 = new DevExpress.XtraEditors.PanelControl(); + this.stackPanel5 = new DevExpress.Utils.Layout.StackPanel(); + this.txtSubCode = new DevExpress.XtraEditors.LabelControl(); + this.stackPanel4 = new DevExpress.Utils.Layout.StackPanel(); + this.txtProductCode = new DevExpress.XtraEditors.LabelControl(); this.stackPanel3 = new DevExpress.Utils.Layout.StackPanel(); this.machineTypeControl = new DevExpress.XtraEditors.LabelControl(); this.stackPanel2 = new DevExpress.Utils.Layout.StackPanel(); @@ -54,19 +61,27 @@ namespace ZJ_BYD this.Result = new DevExpress.XtraGrid.Columns.GridColumn(); this.labelControl1 = new DevExpress.XtraEditors.LabelControl(); this.lbldatetime = new DevExpress.XtraEditors.LabelControl(); - this.stackPanel4 = new DevExpress.Utils.Layout.StackPanel(); - this.txtProductCode = new DevExpress.XtraEditors.LabelControl(); - this.stackPanel5 = new DevExpress.Utils.Layout.StackPanel(); - this.txtSubCode = new DevExpress.XtraEditors.LabelControl(); ((System.ComponentModel.ISupportInitialize)(this.panelControl1)).BeginInit(); this.panelControl1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.sysLogo.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tablePanel1)).BeginInit(); this.tablePanel1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.sopPanelControl)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1.Panel1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1.Panel2)).BeginInit(); + this.splitContainerControl1.Panel2.SuspendLayout(); + this.splitContainerControl1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.xtraTabControl1)).BeginInit(); + this.xtraTabControl1.SuspendLayout(); + this.xtraTabPage1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.txtLog.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.stationpanel)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.panelControl3)).BeginInit(); this.panelControl3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.stackPanel5)).BeginInit(); + this.stackPanel5.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.stackPanel4)).BeginInit(); + this.stackPanel4.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.stackPanel3)).BeginInit(); this.stackPanel3.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.stackPanel2)).BeginInit(); @@ -75,10 +90,6 @@ namespace ZJ_BYD this.stackPanel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.gridTestInfo)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.gridView1)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.stackPanel4)).BeginInit(); - this.stackPanel4.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.stackPanel5)).BeginInit(); - this.stackPanel5.SuspendLayout(); this.SuspendLayout(); // // panelControl1 @@ -161,7 +172,7 @@ namespace ZJ_BYD this.tablePanel1.Columns.AddRange(new DevExpress.Utils.Layout.TablePanelColumn[] { new DevExpress.Utils.Layout.TablePanelColumn(DevExpress.Utils.Layout.TablePanelEntityStyle.Relative, 18.74F), new DevExpress.Utils.Layout.TablePanelColumn(DevExpress.Utils.Layout.TablePanelEntityStyle.Relative, 58.62F)}); - this.tablePanel1.Controls.Add(this.sopPanelControl); + this.tablePanel1.Controls.Add(this.splitContainerControl1); this.tablePanel1.Controls.Add(this.stationpanel); this.tablePanel1.Controls.Add(this.panelControl3); this.tablePanel1.Controls.Add(this.lbldatetime); @@ -175,15 +186,52 @@ namespace ZJ_BYD this.tablePanel1.Size = new System.Drawing.Size(1044, 973); this.tablePanel1.TabIndex = 5; // - // sopPanelControl + // splitContainerControl1 + // + this.tablePanel1.SetColumn(this.splitContainerControl1, 1); + this.splitContainerControl1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainerControl1.Horizontal = false; + this.splitContainerControl1.Location = new System.Drawing.Point(256, 53); + this.splitContainerControl1.Name = "splitContainerControl1"; + // + // splitContainerControl1.Panel1 + // + this.splitContainerControl1.Panel1.Text = "Panel1"; + // + // splitContainerControl1.Panel2 + // + this.splitContainerControl1.Panel2.Controls.Add(this.xtraTabControl1); + this.splitContainerControl1.Panel2.Text = "Panel2"; + this.tablePanel1.SetRow(this.splitContainerControl1, 1); + this.splitContainerControl1.Size = new System.Drawing.Size(785, 917); + this.splitContainerControl1.SplitterPosition = 763; + this.splitContainerControl1.TabIndex = 9; + // + // xtraTabControl1 + // + this.xtraTabControl1.Dock = System.Windows.Forms.DockStyle.Fill; + this.xtraTabControl1.Location = new System.Drawing.Point(0, 0); + this.xtraTabControl1.Name = "xtraTabControl1"; + this.xtraTabControl1.SelectedTabPage = this.xtraTabPage1; + this.xtraTabControl1.Size = new System.Drawing.Size(785, 144); + this.xtraTabControl1.TabIndex = 0; + this.xtraTabControl1.TabPages.AddRange(new DevExpress.XtraTab.XtraTabPage[] { + this.xtraTabPage1}); // - this.tablePanel1.SetColumn(this.sopPanelControl, 1); - this.sopPanelControl.Dock = System.Windows.Forms.DockStyle.Fill; - this.sopPanelControl.Location = new System.Drawing.Point(256, 53); - this.sopPanelControl.Name = "sopPanelControl"; - this.tablePanel1.SetRow(this.sopPanelControl, 1); - this.sopPanelControl.Size = new System.Drawing.Size(785, 917); - this.sopPanelControl.TabIndex = 9; + // xtraTabPage1 + // + this.xtraTabPage1.Controls.Add(this.txtLog); + this.xtraTabPage1.Name = "xtraTabPage1"; + this.xtraTabPage1.Size = new System.Drawing.Size(783, 118); + this.xtraTabPage1.Text = "操作记录"; + // + // txtLog + // + this.txtLog.Dock = System.Windows.Forms.DockStyle.Fill; + this.txtLog.Location = new System.Drawing.Point(0, 0); + this.txtLog.Name = "txtLog"; + this.txtLog.Size = new System.Drawing.Size(783, 118); + this.txtLog.TabIndex = 0; // // stationpanel // @@ -213,6 +261,46 @@ namespace ZJ_BYD this.panelControl3.Size = new System.Drawing.Size(305, 919); this.panelControl3.TabIndex = 6; // + // stackPanel5 + // + this.stackPanel5.Controls.Add(this.txtSubCode); + this.stackPanel5.Location = new System.Drawing.Point(3, 738); + this.stackPanel5.Name = "stackPanel5"; + this.stackPanel5.Size = new System.Drawing.Size(296, 51); + this.stackPanel5.TabIndex = 4; + // + // txtSubCode + // + this.txtSubCode.Appearance.Font = new System.Drawing.Font("Tahoma", 15F); + this.txtSubCode.Appearance.ForeColor = System.Drawing.Color.White; + this.txtSubCode.Appearance.Options.UseFont = true; + this.txtSubCode.Appearance.Options.UseForeColor = true; + this.txtSubCode.Location = new System.Drawing.Point(3, 13); + this.txtSubCode.Name = "txtSubCode"; + this.txtSubCode.Size = new System.Drawing.Size(100, 24); + this.txtSubCode.TabIndex = 0; + this.txtSubCode.Text = "组件条码:"; + // + // stackPanel4 + // + this.stackPanel4.Controls.Add(this.txtProductCode); + this.stackPanel4.Location = new System.Drawing.Point(3, 681); + this.stackPanel4.Name = "stackPanel4"; + this.stackPanel4.Size = new System.Drawing.Size(296, 51); + this.stackPanel4.TabIndex = 4; + // + // txtProductCode + // + this.txtProductCode.Appearance.Font = new System.Drawing.Font("Tahoma", 15F); + this.txtProductCode.Appearance.ForeColor = System.Drawing.Color.White; + this.txtProductCode.Appearance.Options.UseFont = true; + this.txtProductCode.Appearance.Options.UseForeColor = true; + this.txtProductCode.Location = new System.Drawing.Point(3, 13); + this.txtProductCode.Name = "txtProductCode"; + this.txtProductCode.Size = new System.Drawing.Size(80, 24); + this.txtProductCode.TabIndex = 0; + this.txtProductCode.Text = "主条码:"; + // // stackPanel3 // this.stackPanel3.Controls.Add(this.machineTypeControl); @@ -514,46 +602,6 @@ namespace ZJ_BYD this.lbldatetime.TabIndex = 4; this.lbldatetime.Text = "2022-03-16 00:00:00"; // - // stackPanel4 - // - this.stackPanel4.Controls.Add(this.txtProductCode); - this.stackPanel4.Location = new System.Drawing.Point(3, 681); - this.stackPanel4.Name = "stackPanel4"; - this.stackPanel4.Size = new System.Drawing.Size(296, 51); - this.stackPanel4.TabIndex = 4; - // - // txtProductCode - // - this.txtProductCode.Appearance.Font = new System.Drawing.Font("Tahoma", 15F); - this.txtProductCode.Appearance.ForeColor = System.Drawing.Color.White; - this.txtProductCode.Appearance.Options.UseFont = true; - this.txtProductCode.Appearance.Options.UseForeColor = true; - this.txtProductCode.Location = new System.Drawing.Point(3, 13); - this.txtProductCode.Name = "txtProductCode"; - this.txtProductCode.Size = new System.Drawing.Size(80, 24); - this.txtProductCode.TabIndex = 0; - this.txtProductCode.Text = "主条码:"; - // - // stackPanel5 - // - this.stackPanel5.Controls.Add(this.txtSubCode); - this.stackPanel5.Location = new System.Drawing.Point(3, 738); - this.stackPanel5.Name = "stackPanel5"; - this.stackPanel5.Size = new System.Drawing.Size(296, 51); - this.stackPanel5.TabIndex = 4; - // - // txtSubCode - // - this.txtSubCode.Appearance.Font = new System.Drawing.Font("Tahoma", 15F); - this.txtSubCode.Appearance.ForeColor = System.Drawing.Color.White; - this.txtSubCode.Appearance.Options.UseFont = true; - this.txtSubCode.Appearance.Options.UseForeColor = true; - this.txtSubCode.Location = new System.Drawing.Point(3, 13); - this.txtSubCode.Name = "txtSubCode"; - this.txtSubCode.Size = new System.Drawing.Size(100, 24); - this.txtSubCode.TabIndex = 0; - this.txtSubCode.Text = "组件条码:"; - // // Main // this.Appearance.BackColor = System.Drawing.Color.Transparent; @@ -577,10 +625,24 @@ namespace ZJ_BYD ((System.ComponentModel.ISupportInitialize)(this.tablePanel1)).EndInit(); this.tablePanel1.ResumeLayout(false); this.tablePanel1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.sopPanelControl)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1.Panel1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1.Panel2)).EndInit(); + this.splitContainerControl1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1)).EndInit(); + this.splitContainerControl1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.xtraTabControl1)).EndInit(); + this.xtraTabControl1.ResumeLayout(false); + this.xtraTabPage1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.txtLog.Properties)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.stationpanel)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.panelControl3)).EndInit(); this.panelControl3.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.stackPanel5)).EndInit(); + this.stackPanel5.ResumeLayout(false); + this.stackPanel5.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.stackPanel4)).EndInit(); + this.stackPanel4.ResumeLayout(false); + this.stackPanel4.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.stackPanel3)).EndInit(); this.stackPanel3.ResumeLayout(false); this.stackPanel3.PerformLayout(); @@ -590,12 +652,6 @@ namespace ZJ_BYD this.stackPanel1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.gridTestInfo)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.gridView1)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.stackPanel4)).EndInit(); - this.stackPanel4.ResumeLayout(false); - this.stackPanel4.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.stackPanel5)).EndInit(); - this.stackPanel5.ResumeLayout(false); - this.stackPanel5.PerformLayout(); this.ResumeLayout(false); } @@ -623,12 +679,15 @@ namespace ZJ_BYD private DevExpress.XtraEditors.SimpleButton btnSearchResult; private DevExpress.XtraEditors.SimpleButton btnPassRate; private DevExpress.XtraEditors.LabelControl lbldatetime; - private DevExpress.XtraEditors.PanelControl sopPanelControl; private DevExpress.Utils.Layout.StackPanel stackPanel3; private DevExpress.XtraEditors.LabelControl machineTypeControl; private DevExpress.Utils.Layout.StackPanel stackPanel5; private DevExpress.XtraEditors.LabelControl txtSubCode; private DevExpress.Utils.Layout.StackPanel stackPanel4; private DevExpress.XtraEditors.LabelControl txtProductCode; + private DevExpress.XtraEditors.SplitContainerControl splitContainerControl1; + private DevExpress.XtraTab.XtraTabControl xtraTabControl1; + private DevExpress.XtraTab.XtraTabPage xtraTabPage1; + private DevExpress.XtraEditors.MemoEdit txtLog; } } \ No newline at end of file diff --git a/Main.cs b/Main.cs index 37330b9..153b9f4 100644 --- a/Main.cs +++ b/Main.cs @@ -126,7 +126,7 @@ namespace ZJ_BYD pdfViewer.Show(); pdfViewer.LoadDocument(pdfFiles.First()); pdfViewer.Dock = System.Windows.Forms.DockStyle.Fill; - this.sopPanelControl.Controls.Add(pdfViewer); + this.splitContainerControl1.Panel1.Controls.Add(pdfViewer); return; } @@ -139,7 +139,7 @@ namespace ZJ_BYD } imageSlider.Refresh(); imageSlider.Dock = System.Windows.Forms.DockStyle.Fill; - this.sopPanelControl.Controls.Add(imageSlider); + this.splitContainerControl1.Panel1.Controls.Add(imageSlider); } @@ -227,31 +227,31 @@ namespace ZJ_BYD { try { - //var object_txt = xtraTabPage1.Controls; + var object_txt = xtraTabPage1.Controls; BeginInvoke(new Action(() => { - //foreach (var item in object_txt) - //{ - // if (stationCode == Program.ActiveStatinCode) - // { - // if (((MemoEdit)item).Name == Program.ActiveStatinCode + "X6") - // { - // //txtLog.Visible = false; - // ((MemoEdit)item).Visible = true; - // UpdateMemo((MemoEdit)item, newValue.ToString()); - // } - - // } - // else - // { - // var hide_memo_ID = ((MemoEdit)item).Name.Replace("X6", ""); - // if (hide_memo_ID == stationCode) - // { - // ((MemoEdit)item).Visible = false; - // UpdateMemo((MemoEdit)item, newValue.ToString()); - // } - // } - //} + foreach (var item in object_txt) + { + if (stationCode == Program.ActiveStatinCode) + { + if (((MemoEdit)item).Name == Program.ActiveStatinCode + "X6") + { + txtLog.Visible = false; + ((MemoEdit)item).Visible = true; + UpdateMemo((MemoEdit)item, newValue.ToString()); + } + + } + else + { + var hide_memo_ID = ((MemoEdit)item).Name.Replace("X6", ""); + if (hide_memo_ID == stationCode) + { + ((MemoEdit)item).Visible = false; + UpdateMemo((MemoEdit)item, newValue.ToString()); + } + } + } }) ); } @@ -276,21 +276,21 @@ namespace ZJ_BYD { try { - //if (!ExtendMethod.BoolPing(Program.PlcIpAddress)) - //{ - // SetPlcStatusLbl(lblplcstatus, "PLC通讯状态异常", Color.Red); - // LogHelper.WriteLog($"PLC的IP地址{Program.PlcIpAddress}无法PING通,请检查网络连接!"); - // overWrite = true; - // continue; - //} - //if (Program.siemensS7Net == null) - //{ - // LogHelper.WriteLog($"心跳监测时,Program.siemensS7Net为空,进行重连!"); - // SetPlcStatusLbl(lblplcstatus, "PLC通讯状态异常", Color.Red); - // overWrite = true; - // ConnectPLC(); - //} - + if (!ExtendMethod.BoolPing(Program.PlcIpAddress)) + { + //SetPlcStatusLbl(lblplcstatus, "PLC通讯状态异常", Color.Red); + LogHelper.WriteLog($"PLC的IP地址{Program.PlcIpAddress}无法PING通,请检查网络连接!"); + overWrite = true; + continue; + } + if (Program.siemensS7Net == null) + { + LogHelper.WriteLog($"心跳监测时,Program.siemensS7Net为空,进行重连!"); + //SetPlcStatusLbl(lblplcstatus, "PLC通讯状态异常", Color.Red); + overWrite = true; + ConnectPLC(); + } + if (heartPoints == null || heartPoints.Count <= 0) { LogHelper.WriteLog("心跳监测点位未配置!"); @@ -459,35 +459,38 @@ namespace ZJ_BYD private void DoSomething_LogChanged(object newValue, string stationCode) { - //var object_txt = xtraTabPage1.Controls; + var object_txt = xtraTabPage1.Controls; if (this.IsHandleCreated) { BeginInvoke(new Action(() => { + foreach (var item in object_txt) + { + if (stationCode == Program.ActiveStatinCode) + { + //if (((MemoEdit)item).Name == Program.ActiveStatinCode + "X6") + //{ + // txtLog.Visible = false; + // ((MemoEdit)item).Visible = true; + // UpdateMemo((MemoEdit)item, newValue.ToString()); + //} + + txtLog.Visible = false; + ((MemoEdit)item).Visible = true; + UpdateMemo((MemoEdit)item, newValue.ToString()); - //foreach (var item in object_txt) - //{ - // if (stationCode == Program.ActiveStatinCode) - // { - // if (((MemoEdit)item).Name == Program.ActiveStatinCode + "X6") - // { - // //txtLog.Visible = false; - // ((MemoEdit)item).Visible = true; - // UpdateMemo((MemoEdit)item, newValue.ToString()); - // } - - // } - // else - // { - // var hide_memo_ID = ((MemoEdit)item).Name.Replace("X6", ""); - // if (hide_memo_ID == stationCode) - // { - // ((MemoEdit)item).Visible = false; - // UpdateMemo((MemoEdit)item, newValue.ToString()); - // } - - // } - //} + } + else + { + var hide_memo_ID = ((MemoEdit)item).Name.Replace("X6", ""); + if (hide_memo_ID == stationCode) + { + ((MemoEdit)item).Visible = false; + UpdateMemo((MemoEdit)item, newValue.ToString()); + } + + } + } })); } } @@ -880,8 +883,8 @@ namespace ZJ_BYD BeginInvoke(new Action(() => { var memoCon = ((MemoEdit)control); - //memoEdit最多显示500行,每超过500就删除10行。 - if (memoCon.Lines.Count() > 500) + //memoEdit最多显示100行,每超过100就删除10行。 + if (memoCon.Lines.Count() > 100) { string[] strs = memoCon.Lines; ArrayList al = new ArrayList(strs);