diff --git a/RfidWeb/Frm/UserAlarmShow.Designer.cs b/RfidWeb/Frm/UserAlarmShow.Designer.cs index cd199e9..a342243 100644 --- a/RfidWeb/Frm/UserAlarmShow.Designer.cs +++ b/RfidWeb/Frm/UserAlarmShow.Designer.cs @@ -28,19 +28,23 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.panel1 = new System.Windows.Forms.Panel(); - this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); - this.dataGridView1 = new System.Windows.Forms.DataGridView(); - this.al = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Msg = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.dataGridView2 = new System.Windows.Forms.DataGridView(); this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.al = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Msg = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.panel1 = new System.Windows.Forms.Panel(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.hslLanternSimple1 = new HslControls.HslLanternSimple(); this.tableLayoutPanel1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.panel1.SuspendLayout(); + this.groupBox1.SuspendLayout(); this.SuspendLayout(); // // tableLayoutPanel1 @@ -58,21 +62,37 @@ this.tableLayoutPanel1.Size = new System.Drawing.Size(910, 276); this.tableLayoutPanel1.TabIndex = 0; // - // panel1 + // dataGridView2 // - this.panel1.Dock = System.Windows.Forms.DockStyle.Top; - this.panel1.Location = new System.Drawing.Point(0, 0); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(910, 320); - this.panel1.TabIndex = 1; + this.dataGridView2.AllowUserToAddRows = false; + this.dataGridView2.AllowUserToDeleteRows = false; + this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.dataGridViewTextBoxColumn1, + this.dataGridViewTextBoxColumn2}); + this.dataGridView2.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridView2.Location = new System.Drawing.Point(458, 3); + this.dataGridView2.Name = "dataGridView2"; + this.dataGridView2.ReadOnly = true; + this.dataGridView2.RowTemplate.Height = 23; + this.dataGridView2.Size = new System.Drawing.Size(449, 270); + this.dataGridView2.TabIndex = 1; + // + // dataGridViewTextBoxColumn1 // - // flowLayoutPanel1 + this.dataGridViewTextBoxColumn1.DataPropertyName = "AlartTime"; + this.dataGridViewTextBoxColumn1.HeaderText = "警告时间"; + this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1"; + this.dataGridViewTextBoxColumn1.ReadOnly = true; + this.dataGridViewTextBoxColumn1.Width = 150; // - this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 320); - this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - this.flowLayoutPanel1.Size = new System.Drawing.Size(910, 339); - this.flowLayoutPanel1.TabIndex = 2; + // dataGridViewTextBoxColumn2 + // + this.dataGridViewTextBoxColumn2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.dataGridViewTextBoxColumn2.DataPropertyName = "Msg"; + this.dataGridViewTextBoxColumn2.HeaderText = "警告内容"; + this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2"; + this.dataGridViewTextBoxColumn2.ReadOnly = true; // // dataGridView1 // @@ -86,12 +106,12 @@ this.dataGridView1.Location = new System.Drawing.Point(3, 3); this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.ReadOnly = true; - dataGridViewCellStyle1.BackColor = System.Drawing.Color.Red; - dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle1.ForeColor = System.Drawing.Color.White; - dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.Red; - dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle1; + dataGridViewCellStyle6.BackColor = System.Drawing.Color.Red; + dataGridViewCellStyle6.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle6.ForeColor = System.Drawing.Color.White; + dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.Red; + dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle6; this.dataGridView1.RowTemplate.Height = 23; this.dataGridView1.Size = new System.Drawing.Size(449, 270); this.dataGridView1.TabIndex = 0; @@ -112,50 +132,64 @@ this.Msg.Name = "Msg"; this.Msg.ReadOnly = true; // - // dataGridView2 - // - this.dataGridView2.AllowUserToAddRows = false; - this.dataGridView2.AllowUserToDeleteRows = false; - this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { - this.dataGridViewTextBoxColumn1, - this.dataGridViewTextBoxColumn2}); - this.dataGridView2.Dock = System.Windows.Forms.DockStyle.Fill; - this.dataGridView2.Location = new System.Drawing.Point(458, 3); - this.dataGridView2.Name = "dataGridView2"; - this.dataGridView2.ReadOnly = true; - this.dataGridView2.RowTemplate.Height = 23; - this.dataGridView2.Size = new System.Drawing.Size(449, 270); - this.dataGridView2.TabIndex = 1; - // - // dataGridViewTextBoxColumn1 - // - this.dataGridViewTextBoxColumn1.DataPropertyName = "AlartTime"; - this.dataGridViewTextBoxColumn1.HeaderText = "警告时间"; - this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1"; - this.dataGridViewTextBoxColumn1.ReadOnly = true; - this.dataGridViewTextBoxColumn1.Width = 150; + // panel1 // - // dataGridViewTextBoxColumn2 + this.panel1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.panel1.Controls.Add(this.groupBox1); + this.panel1.Dock = System.Windows.Forms.DockStyle.Top; + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(910, 330); + this.panel1.TabIndex = 1; // - this.dataGridViewTextBoxColumn2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.dataGridViewTextBoxColumn2.DataPropertyName = "Msg"; - this.dataGridViewTextBoxColumn2.HeaderText = "警告内容"; - this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2"; - this.dataGridViewTextBoxColumn2.ReadOnly = true; + // groupBox2 + // + this.groupBox2.BackgroundImage = global::RfidWeb.Properties.Resources.Snipaste_2024_11_14_10_33_44; + this.groupBox2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBox2.Location = new System.Drawing.Point(0, 330); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(910, 329); + this.groupBox2.TabIndex = 2; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "料盘侧(收料2)"; + // + // groupBox1 + // + this.groupBox1.BackgroundImage = global::RfidWeb.Properties.Resources.Snipaste_2024_11_14_10_28_21; + this.groupBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.groupBox1.Controls.Add(this.hslLanternSimple1); + this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBox1.Location = new System.Drawing.Point(0, 0); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(910, 330); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "卷料侧(收料1)"; + // + // hslLanternSimple1 + // + this.hslLanternSimple1.LanternBackground = System.Drawing.Color.DarkViolet; + this.hslLanternSimple1.Location = new System.Drawing.Point(44, 215); + this.hslLanternSimple1.Name = "hslLanternSimple1"; + this.hslLanternSimple1.Size = new System.Drawing.Size(15, 14); + this.hslLanternSimple1.TabIndex = 0; + this.hslLanternSimple1.Text = "hslLanternSimple1"; // // UserAlarmShow // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.flowLayoutPanel1); + this.Controls.Add(this.groupBox2); this.Controls.Add(this.panel1); this.Controls.Add(this.tableLayoutPanel1); this.Name = "UserAlarmShow"; this.Size = new System.Drawing.Size(910, 935); this.tableLayoutPanel1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.panel1.ResumeLayout(false); + this.groupBox1.ResumeLayout(false); this.ResumeLayout(false); } @@ -163,13 +197,15 @@ #endregion private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; - private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; private System.Windows.Forms.DataGridView dataGridView1; private System.Windows.Forms.DataGridViewTextBoxColumn al; private System.Windows.Forms.DataGridViewTextBoxColumn Msg; private System.Windows.Forms.DataGridView dataGridView2; private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1; private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn2; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.GroupBox groupBox1; + private HslControls.HslLanternSimple hslLanternSimple1; } } diff --git a/RfidWeb/Frm/UserAlarmShow.cs b/RfidWeb/Frm/UserAlarmShow.cs index cec9bd1..40c421d 100644 --- a/RfidWeb/Frm/UserAlarmShow.cs +++ b/RfidWeb/Frm/UserAlarmShow.cs @@ -62,167 +62,6 @@ namespace RfidWeb.Frm } - public class HimAlarmManager - { - private HmiChAlarm hmiChAlarm = new HmiChAlarm(); - private HmiCqAlarm hmiCq = new HmiCqAlarm(); - - EsStop esStop=new EsStop(); - - AlarmDataService alarmDataService = new AlarmDataService(); - - - public Dictionary GetList() - { - - List list = alarmDataService.GetList(); - ICache cache = Cache.Default; - Dictionary dictionary = cache[CacheKeyManager.AramlList] as Dictionary - ?? new Dictionary(); - var a = hmiChAlarm.GetPlcDb(); - var dicCha = list.Where(x => x.PlcAb == "A" && x.Address == "CH_alarm" - && !string.IsNullOrEmpty(x.Msg)) - .ToDictionary(x => x.No, x => x.Msg); - for (int i = 0; i < 31; i++) - { - var obj = a.GetValue("A" + i); - if (obj != null) - { - if (dicCha.TryGetValue(i, out var value)) - { - if (Convert.ToBoolean(obj)) - { - if (!dictionary.ContainsKey(value)) - { - dictionary[value] = DateTime.Now; - } - } - else - { - dictionary.Remove(value); - } - } - - - } - } - - - - var dicChb = list.Where(x => x.PlcAb == "B" && x.Address == "CH_alarm" - && !string.IsNullOrEmpty(x.Msg)) - .ToDictionary(x => x.No, x => x.Msg); - - for (int i = 0; i < 31; i++) - { - var obj = a.GetValue("B" + i); - if (obj != null) - { - if (dicChb.TryGetValue(i, out var value)) - { - if (Convert.ToBoolean(obj)) - { - if (!dictionary.ContainsKey(value)) - { - dictionary[value] = DateTime.Now; - } - } - else - { - dictionary.Remove(value); - } - } - - - } - } - - a = hmiCq.GetPlcDb(); - - var dicCqA = list.Where(x => x.PlcAb == "A" && x.Address == "CQ_alarm" - && !string.IsNullOrEmpty(x.Msg)) - .ToDictionary(x => x.No, x => x.Msg); - - for (int i = 0; i < 31; i++) - { - var obj = a.GetValue("A" + i); - if (obj != null) - { - if (dicCqA.TryGetValue(i, out var value)) - { - if (Convert.ToBoolean(obj)) - { - if (!dictionary.ContainsKey(value)) - { - dictionary[value] = DateTime.Now; - } - } - else - { - dictionary.Remove(value); - } - } - - - } - } - - var dicCqB = list.Where(x => x.PlcAb == "B" && x.Address == "CQ_alarm" - && !string.IsNullOrEmpty(x.Msg)) - .ToDictionary(x => x.No, x => x.Msg); - - for (int i = 0; i < 31; i++) - { - var obj = a.GetValue("B" + i); - if (obj != null) - { - if (dicCqB.TryGetValue(i, out var value)) - { - if (Convert.ToBoolean(obj)) - { - if (!dictionary.ContainsKey(value)) - { - dictionary[value] = DateTime.Now; - } - } - else - { - dictionary.Remove(value); - } - } - - - } - } - - var listEs= list.Where(x => x.PlcAb == "" && x.Address == "estop_temporary_storage" - && !string.IsNullOrEmpty(x.Msg)) - .ToDictionary(x => x.No, x => x.Msg); - - var bools = esStop.GetDb(); - for (int i = 0; i < 31; i++) - { - var obj = bools[i]; - if (listEs.TryGetValue(i, out var value)) - { - if (Convert.ToBoolean(obj)) - { - if (!dictionary.ContainsKey(value)) - { - dictionary[value] = DateTime.Now; - } - } - else - { - dictionary.Remove(value); - } - } - } - - cache.Set(CacheKeyManager.AramlList, dictionary, TimeSpan.FromMinutes(10)); - return dictionary; - } - - } + } } diff --git a/RfidWeb/Frm/UserAlarmShow.resx b/RfidWeb/Frm/UserAlarmShow.resx index 4788679..5bd3155 100644 --- a/RfidWeb/Frm/UserAlarmShow.resx +++ b/RfidWeb/Frm/UserAlarmShow.resx @@ -123,6 +123,12 @@ True + + True + + + True + True diff --git a/RfidWeb/Properties/Resources.Designer.cs b/RfidWeb/Properties/Resources.Designer.cs index e501e61..1048da4 100644 --- a/RfidWeb/Properties/Resources.Designer.cs +++ b/RfidWeb/Properties/Resources.Designer.cs @@ -100,6 +100,26 @@ namespace RfidWeb.Properties { } } + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap Snipaste_2024_11_14_10_28_21 { + get { + object obj = ResourceManager.GetObject("Snipaste_2024-11-14_10-28-21", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap Snipaste_2024_11_14_10_33_44 { + get { + object obj = ResourceManager.GetObject("Snipaste_2024-11-14_10-33-44", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// 查找 System.Drawing.Bitmap 类型的本地化资源。 /// diff --git a/RfidWeb/Properties/Resources.resx b/RfidWeb/Properties/Resources.resx index a9adf0d..f4dd235 100644 --- a/RfidWeb/Properties/Resources.resx +++ b/RfidWeb/Properties/Resources.resx @@ -121,9 +121,27 @@ ..\Resources\海威图标在上.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\左箭头.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\消音开.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Snipaste_2024-11-14_10-28-21.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\照明关.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\右箭头.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\脱机.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\2024-11-12_170754_114.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\frmMain.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -134,22 +152,10 @@ ..\Resources\frmBei.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\脱机.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\左箭头.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\消音开.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\照明关.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\log.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\2024-11-12_170754_114.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Snipaste_2024-11-14_10-33-44.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/RfidWeb/Resources/Snipaste_2024-11-14_10-28-21.png b/RfidWeb/Resources/Snipaste_2024-11-14_10-28-21.png new file mode 100644 index 0000000..a081f32 Binary files /dev/null and b/RfidWeb/Resources/Snipaste_2024-11-14_10-28-21.png differ diff --git a/RfidWeb/Resources/Snipaste_2024-11-14_10-33-44.png b/RfidWeb/Resources/Snipaste_2024-11-14_10-33-44.png new file mode 100644 index 0000000..d976a98 Binary files /dev/null and b/RfidWeb/Resources/Snipaste_2024-11-14_10-33-44.png differ diff --git a/RfidWeb/RfidWeb.csproj b/RfidWeb/RfidWeb.csproj index bbd2baa..427cd65 100644 --- a/RfidWeb/RfidWeb.csproj +++ b/RfidWeb/RfidWeb.csproj @@ -192,8 +192,9 @@ - - + + + FormLogin.cs @@ -278,6 +279,8 @@ + + diff --git a/RfidWeb/Tool/HimAlarmManager.cs b/RfidWeb/Tool/HimAlarmManager.cs index 8ed15ce..0dd5738 100644 --- a/RfidWeb/Tool/HimAlarmManager.cs +++ b/RfidWeb/Tool/HimAlarmManager.cs @@ -1,7 +1,196 @@ -namespace RfidWeb +using System; +using System.Collections.Generic; +using System.Linq; +using DB.Entity; +using DB.Service; +using NewLife.Caching; +using NewLife.Reflection; +using Tool.Model; + +namespace RfidWeb { - public class HimAlarmManager - { - - } + public class HimAlarmManager + { + private HmiChAlarm hmiChAlarm = new HmiChAlarm(); + private HmiCqAlarm hmiCq = new HmiCqAlarm(); + EsStop esStop=new EsStop(); + AlarmDataService alarmDataService = new AlarmDataService(); + + private readonly int Max = 31; + private readonly TimeSpan timeOut = TimeSpan.FromSeconds(5); + + private Dictionary GetDic(List list, string plcAb, string address) + { + var dicCha = list.Where(x => x.PlcAb == plcAb && x.Address == address + && !string.IsNullOrEmpty(x.Msg)) + .ToDictionary(x => x.No, x => x.Msg); + + return dicCha; + } + + private void SetCH_alarm(Dictionary dictionary,List list) + { + var a = hmiChAlarm.GetPlcDb(); + + cache.Set(CacheKeyManager.CH_alarm, a,timeOut); + var dicCha = GetDic(list, "A", "CH_alarm"); + + for (int i = 0; i < Max; i++) + { + var obj = a.GetValue("A" + i); + if (obj != null) + { + if (dicCha.TryGetValue(i, out var value)) + { + if (Convert.ToBoolean(obj)) + { + if (!dictionary.ContainsKey(value)) + { + dictionary[value] = DateTime.Now; + } + } + else + { + dictionary.Remove(value); + } + } + + + } + } + + + + var dicChb = GetDic(list, "B", "CH_alarm"); + + for (int i = 0; i < Max; i++) + { + var obj = a.GetValue("B" + i); + if (obj != null) + { + if (dicChb.TryGetValue(i, out var value)) + { + if (Convert.ToBoolean(obj)) + { + if (!dictionary.ContainsKey(value)) + { + dictionary[value] = DateTime.Now; + } + } + else + { + dictionary.Remove(value); + } + } + + + } + } + } + + + private void SetCQ_alarm(Dictionary dictionary,List list) + { + var a = hmiCq.GetPlcDb(); + cache.Set(CacheKeyManager.CQ_alarm, a,timeOut); + var dicCqA = GetDic(list, "A", "CQ_alarm"); + + + for (int i = 0; i < Max; i++) + { + var obj = a.GetValue("A" + i); + if (obj != null) + { + if (dicCqA.TryGetValue(i, out var value)) + { + if (Convert.ToBoolean(obj)) + { + if (!dictionary.ContainsKey(value)) + { + dictionary[value] = DateTime.Now; + } + } + else + { + dictionary.Remove(value); + } + } + + + } + } + + var dicCqB =GetDic(list, "B", "CQ_alarm"); + + for (int i = 0; i < Max; i++) + { + var obj = a.GetValue("B" + i); + if (obj != null) + { + if (dicCqB.TryGetValue(i, out var value)) + { + if (Convert.ToBoolean(obj)) + { + if (!dictionary.ContainsKey(value)) + { + dictionary[value] = DateTime.Now; + } + } + else + { + dictionary.Remove(value); + } + } + + + } + } + } + + + private void SetEsStop(Dictionary dictionary,List list) + { + + var listEs= GetDic(list, "", "estop_temporary_storage"); + var bools = esStop.GetDb(); + + //全局的异常 + cache.Set(CacheKeyManager.estop_temporary_storage, bools,timeOut); + + for (int i = 0; i < Max; i++) + { + var obj = bools[i]; + if (!listEs.TryGetValue(i, out var value)) continue; + if (Convert.ToBoolean(obj)) + { + if (!dictionary.ContainsKey(value)) + { + dictionary[value] = DateTime.Now; + } + } + else + { + dictionary.Remove(value); + } + } + + } + + ICache cache = Cache.Default; + public Dictionary GetList() + { + + Dictionary dictionary = cache[CacheKeyManager.AramlList] as Dictionary + ?? new Dictionary(); + + List list = alarmDataService.GetList(); + SetCH_alarm(dictionary,list); + SetCQ_alarm(dictionary,list); + SetEsStop(dictionary,list); + + cache.Set(CacheKeyManager.AramlList, dictionary, TimeSpan.FromMinutes(10)); + return dictionary; + } + + } } \ No newline at end of file diff --git a/Tool/GridViewData.cs b/Tool/GridViewData.cs index de3ac41..5294348 100644 --- a/Tool/GridViewData.cs +++ b/Tool/GridViewData.cs @@ -8,8 +8,6 @@ namespace Tool { public class GridViewData { - - public string AlartTime { get; set; } public string Msg { get; set; } } diff --git a/Tool/Model/HmiChModel.cs b/Tool/Model/HmiChModel.cs index feb61ff..f0c2b14 100644 --- a/Tool/Model/HmiChModel.cs +++ b/Tool/Model/HmiChModel.cs @@ -1,11 +1,7 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; - -using HslCommunication; using NewLife.Caching; using NewLife.Reflection; @@ -17,61 +13,4 @@ namespace Tool.Model { } } - - - public class HmiCqModel : BoolModelFactory - { - public HmiCqModel() : base("HMI_button_CQ_ON[0]", "HMI_button_CQ_ON[1]") - { - } - } - - public class HmiLpModel : BoolModelFactory - { - public HmiLpModel() : base("HMI_button_LP_ON[0]", "HMI_button_LP_ON[1]") - { - } - } - - public class HmiChAlarm : BoolModelFactory - { - public HmiChAlarm() : base("CH_alarm_A", "CH_alarm_B") - { - } - } - - public class HmiCqAlarm : BoolModelFactory - { - public HmiCqAlarm() : base("CQ_alarm_A", "CQ_alarm_B") - { - } - } - - - public class EsStop - { - - public List GetDb() - { - bool[] bitArray = new bool[32]; - var readUInt32 = PlcConnect.Instance.ReadUInt32("estop_temporary_storage"); - var bo = readUInt32.IsSuccess; - var context = readUInt32.Content; - if (bo) - { - - for (int i = 0; i < 31; i++) - { - bitArray[i] = context.GetBoolByIndex(i); - } - - } - - return bitArray.ToList(); - - } - } - - - } diff --git a/Tool/Model/HmiPoint.cs b/Tool/Model/HmiPoint.cs index 03186cc..b712cc0 100644 --- a/Tool/Model/HmiPoint.cs +++ b/Tool/Model/HmiPoint.cs @@ -68,5 +68,11 @@ namespace Tool.Model public static readonly string AramlList = "AramlList"; public static readonly string AramlDataList = "AramlDataList"; + + public static readonly string CH_alarm = "CH_alarm"; + public static readonly string CQ_alarm = "CQ_alarm"; + public static readonly string estop_temporary_storage = "estop_temporary_storage"; + + } } diff --git a/Tool/Tool.csproj b/Tool/Tool.csproj index 38794d3..d911a3a 100644 --- a/Tool/Tool.csproj +++ b/Tool/Tool.csproj @@ -67,9 +67,13 @@ - + + + + +