通信组可编辑
This commit is contained in:
+20
-14
@@ -53,10 +53,10 @@
|
||||
this.panelExt1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panelExt1.LeftGap = 0;
|
||||
this.panelExt1.Location = new System.Drawing.Point(0, 0);
|
||||
this.panelExt1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
||||
this.panelExt1.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||
this.panelExt1.Name = "panelExt1";
|
||||
this.panelExt1.RightGap = 0;
|
||||
//this.panelExt1.Size = new System.Drawing.Size(600, 480);
|
||||
this.panelExt1.Size = new System.Drawing.Size(990, 509);
|
||||
this.panelExt1.TabIndex = 0;
|
||||
this.panelExt1.TopGap = 0;
|
||||
//
|
||||
@@ -86,9 +86,11 @@
|
||||
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
|
||||
this.groupTable.DefaultCellStyle = dataGridViewCellStyle2;
|
||||
this.groupTable.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.groupTable.EnableHeadersVisualStyles = false;
|
||||
this.groupTable.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(21)))), ((int)(((byte)(77)))), ((int)(((byte)(147)))));
|
||||
this.groupTable.Location = new System.Drawing.Point(19, 55);
|
||||
this.groupTable.Location = new System.Drawing.Point(0, 39);
|
||||
this.groupTable.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.groupTable.Name = "groupTable";
|
||||
this.groupTable.ReadOnly = true;
|
||||
this.groupTable.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
|
||||
@@ -105,7 +107,7 @@
|
||||
this.groupTable.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
|
||||
this.groupTable.RowTemplate.Height = 40;
|
||||
this.groupTable.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||
this.groupTable.Size = new System.Drawing.Size(800, 580);
|
||||
this.groupTable.Size = new System.Drawing.Size(990, 470);
|
||||
this.groupTable.TabIndex = 15;
|
||||
//
|
||||
// topPanel
|
||||
@@ -115,8 +117,9 @@
|
||||
this.topPanel.Controls.Add(this.lblTitle);
|
||||
this.topPanel.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.topPanel.Location = new System.Drawing.Point(0, 0);
|
||||
this.topPanel.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.topPanel.Name = "topPanel";
|
||||
this.topPanel.Size = new System.Drawing.Size(1237, 49);
|
||||
this.topPanel.Size = new System.Drawing.Size(990, 39);
|
||||
this.topPanel.TabIndex = 0;
|
||||
this.topPanel.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Panel_MouseDown);
|
||||
this.topPanel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Panel_MouseMove);
|
||||
@@ -127,9 +130,10 @@
|
||||
this.BtnAdd.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.BtnAdd.Font = new System.Drawing.Font("微软雅黑", 11.5F);
|
||||
this.BtnAdd.ForeColor = System.Drawing.Color.White;
|
||||
this.BtnAdd.Location = new System.Drawing.Point(996, 7);
|
||||
this.BtnAdd.Location = new System.Drawing.Point(797, 6);
|
||||
this.BtnAdd.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.BtnAdd.Name = "BtnAdd";
|
||||
this.BtnAdd.Size = new System.Drawing.Size(105, 36);
|
||||
this.BtnAdd.Size = new System.Drawing.Size(84, 29);
|
||||
this.BtnAdd.TabIndex = 49;
|
||||
this.BtnAdd.Text = "添加通信组";
|
||||
this.BtnAdd.UseVisualStyleBackColor = false;
|
||||
@@ -143,9 +147,10 @@
|
||||
this.btn_Close.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btn_Close.Font = new System.Drawing.Font("微软雅黑", 15.5F);
|
||||
this.btn_Close.ForeColor = System.Drawing.Color.White;
|
||||
this.btn_Close.Location = new System.Drawing.Point(1189, 7);
|
||||
this.btn_Close.Location = new System.Drawing.Point(951, 6);
|
||||
this.btn_Close.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btn_Close.Name = "btn_Close";
|
||||
this.btn_Close.Size = new System.Drawing.Size(32, 32);
|
||||
this.btn_Close.Size = new System.Drawing.Size(26, 26);
|
||||
this.btn_Close.TabIndex = 1;
|
||||
this.btn_Close.Text = "X";
|
||||
this.btn_Close.UseVisualStyleBackColor = true;
|
||||
@@ -155,23 +160,24 @@
|
||||
//
|
||||
this.lblTitle.AutoSize = true;
|
||||
this.lblTitle.ForeColor = System.Drawing.Color.White;
|
||||
this.lblTitle.Location = new System.Drawing.Point(15, 18);
|
||||
this.lblTitle.Location = new System.Drawing.Point(12, 14);
|
||||
this.lblTitle.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.lblTitle.Name = "lblTitle";
|
||||
this.lblTitle.Size = new System.Drawing.Size(112, 27);
|
||||
this.lblTitle.Size = new System.Drawing.Size(90, 21);
|
||||
this.lblTitle.TabIndex = 0;
|
||||
this.lblTitle.Text = "通信组配置";
|
||||
//
|
||||
// CommunicationEditForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(120F, 120F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(14)))), ((int)(((byte)(23)))), ((int)(((byte)(38)))));
|
||||
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.ClientSize = new System.Drawing.Size(1237, 636);
|
||||
this.ClientSize = new System.Drawing.Size(990, 509);
|
||||
this.Controls.Add(this.panelExt1);
|
||||
this.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
this.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
||||
this.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||
this.Name = "CommunicationEditForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "FrmGroupConfig";
|
||||
|
||||
@@ -56,6 +56,7 @@ namespace LargeSquareOne
|
||||
ReadOnly = true,
|
||||
DataPropertyName = "PlcNum",
|
||||
DefaultCellStyle = new DataGridViewCellStyle(){Alignment=DataGridViewContentAlignment.MiddleCenter},
|
||||
Frozen = true
|
||||
},
|
||||
new DataGridViewTextBoxColumn
|
||||
{
|
||||
@@ -64,6 +65,7 @@ namespace LargeSquareOne
|
||||
Width = 120,
|
||||
DataPropertyName = "GroupName",
|
||||
DefaultCellStyle = new DataGridViewCellStyle(){Alignment=DataGridViewContentAlignment.MiddleCenter},
|
||||
Frozen = true
|
||||
},
|
||||
new DataGridViewTextBoxColumn
|
||||
{
|
||||
@@ -72,6 +74,7 @@ namespace LargeSquareOne
|
||||
Width = 150,
|
||||
DataPropertyName = "Start",
|
||||
DefaultCellStyle = new DataGridViewCellStyle(){Alignment=DataGridViewContentAlignment.MiddleCenter},
|
||||
Frozen = true
|
||||
},
|
||||
new DataGridViewTextBoxColumn
|
||||
{
|
||||
@@ -435,12 +438,13 @@ namespace LargeSquareOne
|
||||
).ToList();
|
||||
|
||||
|
||||
// 允许同一个PLC内有多个相同的组名 by clm 20260804
|
||||
// 3. 只在同一个PLC内检查地址是否冲突
|
||||
if (groupsInSamePLC.Any(g => g.GroupName.Equals(config.GroupName, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
ShowError($"在PLC {config.PlcNum} 中,组名 {config.GroupName} 已被使用");
|
||||
return false;
|
||||
}
|
||||
//if (groupsInSamePLC.Any(g => g.GroupName.Equals(config.GroupName, StringComparison.OrdinalIgnoreCase)))
|
||||
//{
|
||||
// ShowError($"在PLC {config.PlcNum} 中,组名 {config.GroupName} 已被使用");
|
||||
// return false;
|
||||
//}
|
||||
//Console.WriteLine("\n筛选后的配置:");
|
||||
//foreach (var g in groupsInSamePLC)
|
||||
//{
|
||||
@@ -464,18 +468,19 @@ namespace LargeSquareOne
|
||||
return false;
|
||||
}
|
||||
|
||||
// 取消该检查 by clm 20260804
|
||||
// 检查地址范围冲突
|
||||
foreach (var other in groupsInSamePLC)
|
||||
{
|
||||
int otherStart = int.Parse(other.Start.Substring(1));
|
||||
int otherEnd = otherStart + other.Length - 1;
|
||||
//foreach (var other in groupsInSamePLC)
|
||||
//{
|
||||
// int otherStart = int.Parse(other.Start.Substring(1));
|
||||
// int otherEnd = otherStart + other.Length - 1;
|
||||
|
||||
if (!(endAddress < otherStart || startAddress > otherEnd))
|
||||
{
|
||||
ShowError($"地址范围与组 \"{other.GroupName}\" 冲突");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// if (!(endAddress < otherStart || startAddress > otherEnd))
|
||||
// {
|
||||
// ShowError($"地址范围与组 \"{other.GroupName}\" 冲突");
|
||||
// return false;
|
||||
// }
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -505,7 +510,7 @@ namespace LargeSquareOne
|
||||
}
|
||||
|
||||
// 检查地址范围(根据实际需求调整范围)
|
||||
if (addressNum < 0 || addressNum > 9999)
|
||||
if (addressNum < 0 || addressNum > 30000)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user