From f4a984f39604e3ffea0848dd8351703018c83297 Mon Sep 17 00:00:00 2001 From: SoulStar Date: Wed, 9 Apr 2025 11:21:28 +0800 Subject: [PATCH] =?UTF-8?q?fix=20-=20=E6=B7=BB=E5=8A=A0PLC=E6=9C=AA?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E6=8F=90=E7=A4=BA=EF=BC=8C=E7=90=86=E9=A1=BA?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=87=86=E5=A4=87=E5=BC=80=E5=B7=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 4 + HighWayIot.Plc/PlcHelper/WorkStationHelper.cs | 2 +- HighWayIot.Rfid/RfidDataAnalyse.cs | 2 +- .../Business/WorkStationBusiness.cs | 2 +- HighWayIot.Winform/Configuration.xml | 3 + .../MainForm/BaseForm.Designer.cs | 5 +- .../MainForm/LoginForm.Designer.cs | 2 +- HighWayIot.Winform/MainForm/LoginForm.cs | 2 +- .../RecipeConfigPage.Designer.cs | 88 +++++++++---------- .../RecipeConfigPages/RecipeConfigPage.cs | 22 +++-- HighWayIot.sln | 5 ++ 11 files changed, 81 insertions(+), 56 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..1a9e453 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +[*.{cs,vb}] + +# IDE0044: 添加只读修饰符 +dotnet_style_readonly_field = false diff --git a/HighWayIot.Plc/PlcHelper/WorkStationHelper.cs b/HighWayIot.Plc/PlcHelper/WorkStationHelper.cs index c35aa84..fbde2dd 100644 --- a/HighWayIot.Plc/PlcHelper/WorkStationHelper.cs +++ b/HighWayIot.Plc/PlcHelper/WorkStationHelper.cs @@ -22,7 +22,7 @@ namespace HighWayIot.Plc.PlcHelper int point = 0x600; //选择是哪个小车 - point += deviceNo * 32; + point += (deviceNo - 1) * 32; //选择是小车的哪个点位 point += rgvStationNo; diff --git a/HighWayIot.Rfid/RfidDataAnalyse.cs b/HighWayIot.Rfid/RfidDataAnalyse.cs index 86b1fea..8aaee00 100644 --- a/HighWayIot.Rfid/RfidDataAnalyse.cs +++ b/HighWayIot.Rfid/RfidDataAnalyse.cs @@ -28,7 +28,7 @@ namespace HighWayIot.Rfid } /// - /// 接受02H盘点数据 (默认EPC 12位) + /// 接受02H盘点数据 (默认EPC 4位) /// /// /// diff --git a/HighWayIot.Winform/Business/WorkStationBusiness.cs b/HighWayIot.Winform/Business/WorkStationBusiness.cs index fde7ec2..03e0ec9 100644 --- a/HighWayIot.Winform/Business/WorkStationBusiness.cs +++ b/HighWayIot.Winform/Business/WorkStationBusiness.cs @@ -75,7 +75,7 @@ namespace HighWayIot.Winform.Business public WorkStationBusiness() { _readerSetting = _readerService.GetReaderInfos(); - CreateAllRFIDClient(); + this.CreateAllRFIDClient(); _touchSocketTcpClient.GetMessageAction += ReciveRFIDSingal; timer = new Timer(new System.Threading.TimerCallback(SingalMonitor), null, 0, 2000); } diff --git a/HighWayIot.Winform/Configuration.xml b/HighWayIot.Winform/Configuration.xml index 6d41005..defd8f2 100644 --- a/HighWayIot.Winform/Configuration.xml +++ b/HighWayIot.Winform/Configuration.xml @@ -15,6 +15,9 @@ + + + \ No newline at end of file diff --git a/HighWayIot.Winform/MainForm/BaseForm.Designer.cs b/HighWayIot.Winform/MainForm/BaseForm.Designer.cs index 066c788..2834e37 100644 --- a/HighWayIot.Winform/MainForm/BaseForm.Designer.cs +++ b/HighWayIot.Winform/MainForm/BaseForm.Designer.cs @@ -249,6 +249,7 @@ namespace HighWayIot.Winform.MainForm this.DeviceParamManageToolStripMenuItem.Name = "DeviceParamManageToolStripMenuItem"; this.DeviceParamManageToolStripMenuItem.Size = new System.Drawing.Size(151, 22); this.DeviceParamManageToolStripMenuItem.Text = "设备参数配置"; + this.DeviceParamManageToolStripMenuItem.Click += new System.EventHandler(this.StripMenuItemClick); // // UserControlTabs // @@ -329,7 +330,7 @@ namespace HighWayIot.Winform.MainForm // LogInformationToolStrip // this.LogInformationToolStrip.Name = "LogInformationToolStrip"; - this.LogInformationToolStrip.Size = new System.Drawing.Size(1064, 17); + this.LogInformationToolStrip.Size = new System.Drawing.Size(1095, 17); this.LogInformationToolStrip.Spring = true; this.LogInformationToolStrip.Text = "message"; // @@ -370,7 +371,7 @@ namespace HighWayIot.Winform.MainForm this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "BaseForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "大连软控开炼机成型机数据管理系统"; + this.Text = "厦门正新轮胎实心胎上位机"; this.MainMenu.ResumeLayout(false); this.MainMenu.PerformLayout(); this.statusStrip1.ResumeLayout(false); diff --git a/HighWayIot.Winform/MainForm/LoginForm.Designer.cs b/HighWayIot.Winform/MainForm/LoginForm.Designer.cs index a5c90b4..20876d4 100644 --- a/HighWayIot.Winform/MainForm/LoginForm.Designer.cs +++ b/HighWayIot.Winform/MainForm/LoginForm.Designer.cs @@ -144,7 +144,7 @@ namespace HighWayIot.Winform.MainForm this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "LoginForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "大连软控开炼机成型机数据管理系统 - 登录界面"; + this.Text = "厦门正新轮胎实心胎上位机 - 登录界面"; this.Load += new System.EventHandler(this.LoginForm_Load); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); diff --git a/HighWayIot.Winform/MainForm/LoginForm.cs b/HighWayIot.Winform/MainForm/LoginForm.cs index 5ed2aab..d553edd 100644 --- a/HighWayIot.Winform/MainForm/LoginForm.cs +++ b/HighWayIot.Winform/MainForm/LoginForm.cs @@ -59,7 +59,7 @@ namespace HighWayIot.Winform.MainForm /// private void LoginForm_Load(object sender, EventArgs e) { - Login_Click(sender, e); + //Login_Click(sender, e); } } } diff --git a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.Designer.cs b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.Designer.cs index a4cee56..f37b706 100644 --- a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.Designer.cs @@ -111,6 +111,10 @@ namespace HighWayIot.Winform.UserControlPages this.Position2RadioButton = new System.Windows.Forms.RadioButton(); this.Position1RadioButton = new System.Windows.Forms.RadioButton(); this.groupbox5 = new System.Windows.Forms.GroupBox(); + this.PlcSpecNameLabel = new System.Windows.Forms.Label(); + this.label34 = new System.Windows.Forms.Label(); + this.PlcSpecNoLabel = new System.Windows.Forms.Label(); + this.label32 = new System.Windows.Forms.Label(); this.label30 = new System.Windows.Forms.Label(); this.label31 = new System.Windows.Forms.Label(); this.label29 = new System.Windows.Forms.Label(); @@ -150,10 +154,6 @@ namespace HighWayIot.Winform.UserControlPages this.UpdateWeightButton = new System.Windows.Forms.Button(); this.AddWeightButton = new System.Windows.Forms.Button(); this.DeleteWeightButton = new System.Windows.Forms.Button(); - this.PlcSpecNoLabel = new System.Windows.Forms.Label(); - this.label32 = new System.Windows.Forms.Label(); - this.PlcSpecNameLabel = new System.Windows.Forms.Label(); - this.label34 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.WeightDataGridView)).BeginInit(); this.ButtonPanel.SuspendLayout(); this.groupBox1.SuspendLayout(); @@ -1058,6 +1058,46 @@ namespace HighWayIot.Winform.UserControlPages this.groupbox5.TabStop = false; this.groupbox5.Text = "公共参数"; // + // PlcSpecNameLabel + // + this.PlcSpecNameLabel.AutoSize = true; + this.PlcSpecNameLabel.Font = new System.Drawing.Font("宋体", 9F); + this.PlcSpecNameLabel.Location = new System.Drawing.Point(477, 143); + this.PlcSpecNameLabel.Name = "PlcSpecNameLabel"; + this.PlcSpecNameLabel.Size = new System.Drawing.Size(23, 12); + this.PlcSpecNameLabel.TabIndex = 68; + this.PlcSpecNameLabel.Text = "N/A"; + // + // label34 + // + this.label34.AutoSize = true; + this.label34.Font = new System.Drawing.Font("宋体", 9F); + this.label34.Location = new System.Drawing.Point(397, 143); + this.label34.Name = "label34"; + this.label34.Size = new System.Drawing.Size(83, 12); + this.label34.TabIndex = 67; + this.label34.Text = "PLC规格名称:"; + // + // PlcSpecNoLabel + // + this.PlcSpecNoLabel.AutoSize = true; + this.PlcSpecNoLabel.Font = new System.Drawing.Font("宋体", 9F); + this.PlcSpecNoLabel.Location = new System.Drawing.Point(477, 121); + this.PlcSpecNoLabel.Name = "PlcSpecNoLabel"; + this.PlcSpecNoLabel.Size = new System.Drawing.Size(23, 12); + this.PlcSpecNoLabel.TabIndex = 66; + this.PlcSpecNoLabel.Text = "N/A"; + // + // label32 + // + this.label32.AutoSize = true; + this.label32.Font = new System.Drawing.Font("宋体", 9F); + this.label32.Location = new System.Drawing.Point(397, 121); + this.label32.Name = "label32"; + this.label32.Size = new System.Drawing.Size(71, 12); + this.label32.TabIndex = 65; + this.label32.Text = "PLC规格号:"; + // // label30 // this.label30.AutoSize = true; @@ -1444,46 +1484,6 @@ namespace HighWayIot.Winform.UserControlPages this.DeleteWeightButton.UseVisualStyleBackColor = true; this.DeleteWeightButton.Click += new System.EventHandler(this.DeleteWeightButton_Click); // - // PlcSpecNoLabel - // - this.PlcSpecNoLabel.AutoSize = true; - this.PlcSpecNoLabel.Font = new System.Drawing.Font("宋体", 9F); - this.PlcSpecNoLabel.Location = new System.Drawing.Point(477, 121); - this.PlcSpecNoLabel.Name = "PlcSpecNoLabel"; - this.PlcSpecNoLabel.Size = new System.Drawing.Size(23, 12); - this.PlcSpecNoLabel.TabIndex = 66; - this.PlcSpecNoLabel.Text = "N/A"; - // - // label32 - // - this.label32.AutoSize = true; - this.label32.Font = new System.Drawing.Font("宋体", 9F); - this.label32.Location = new System.Drawing.Point(397, 121); - this.label32.Name = "label32"; - this.label32.Size = new System.Drawing.Size(71, 12); - this.label32.TabIndex = 65; - this.label32.Text = "PLC规格号:"; - // - // PlcSpecNameLabel - // - this.PlcSpecNameLabel.AutoSize = true; - this.PlcSpecNameLabel.Font = new System.Drawing.Font("宋体", 9F); - this.PlcSpecNameLabel.Location = new System.Drawing.Point(477, 143); - this.PlcSpecNameLabel.Name = "PlcSpecNameLabel"; - this.PlcSpecNameLabel.Size = new System.Drawing.Size(23, 12); - this.PlcSpecNameLabel.TabIndex = 68; - this.PlcSpecNameLabel.Text = "N/A"; - // - // label34 - // - this.label34.AutoSize = true; - this.label34.Font = new System.Drawing.Font("宋体", 9F); - this.label34.Location = new System.Drawing.Point(397, 143); - this.label34.Name = "label34"; - this.label34.Size = new System.Drawing.Size(83, 12); - this.label34.TabIndex = 67; - this.label34.Text = "PLC规格名称:"; - // // RecipeConfigPage // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.cs b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.cs index a7c9d7a..a3b35dc 100644 --- a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.cs +++ b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.cs @@ -117,12 +117,14 @@ namespace HighWayIot.Winform.UserControlPages NowRecipeCode = RecipeDataGridView.Rows[0].Cells["RecipeCode"].Value.ToString(); InitPositionEntities(); + if(PlcConnect.IsConnect1 == true) + { + //读取SPEC编号 + PlcSpecNoLabel.Text = PlcConnect.ReadUInt321("D206").ToString(); - //读取SPEC编号 - PlcSpecNoLabel.Text = PlcConnect.ReadUInt321("D206").ToString(); - - //读取SPEC名称 - PlcSpecNameLabel.Text = PlcConnect.ReadString1("D290", 10).Trim(); + //读取SPEC名称 + PlcSpecNameLabel.Text = PlcConnect.ReadString1("D290", 10).Trim(); + } } #region 配方信息 @@ -1010,6 +1012,11 @@ namespace HighWayIot.Winform.UserControlPages { return; } + if (!PlcConnect.IsConnect1) + { + MessageBox.Show("PLC未连接"); + return; + } GetPublicParaValue(); GetPrivateParaValue(GetSelectIndex()); if (recipeParaHelper.UploadToPLC(zxRecipeParaEntity, zxRecipePositionParaEntity)) @@ -1035,6 +1042,11 @@ namespace HighWayIot.Winform.UserControlPages { return; } + if (!PlcConnect.IsConnect1) + { + MessageBox.Show("PLC未连接"); + return; + } zxRecipePositionParaEntity = recipeParaHelper.DownLoadFormPlc(ref zxRecipeParaEntity); SetPublicParaValue(zxRecipeParaEntity); SetPrivateParaValue(zxRecipePositionParaEntity.First(x => x.Position == GetSelectIndex())); diff --git a/HighWayIot.sln b/HighWayIot.sln index 0a3dcc8..26d3a92 100644 --- a/HighWayIot.sln +++ b/HighWayIot.sln @@ -19,6 +19,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HighWayIot.TouchSocket", "H EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HighWayIot.Rfid", "HighWayIot.Rfid\HighWayIot.Rfid.csproj", "{29813574-49C0-4979-A5A6-47EB7C4288A0}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A81E7321-F724-4581-BD1C-76916601470F}" + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU