diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/WarnTable.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/WarnTable.cs new file mode 100644 index 0000000..f15bfcd --- /dev/null +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FreeDb/WarnTable.cs @@ -0,0 +1,31 @@ +using FreeSql.DataAnnotations; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Mesnac.Action.ChemicalWeighing.FreeDb +{ + + [Table(Name = "WarnTable")] + public class WarnTable + { + /// + /// 主键 + /// + [Column(IsPrimary = true, IsIdentity = true)] + public int Id { get; set; } + + public int AlarmId { get; set; } + + public string CnInfo { get; set; } + public string OtherInfo { get; set; } + public DateTime CreateTime { get; set; } + public DateTime UpdateTime { get; set; } + public int Num { get; set; } + + public int Status { get; set; } + } +} diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/MainDetailControl/MainDetailControlAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/MainDetailControl/MainDetailControlAction.cs index 9b665a7..28d6edb 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/MainDetailControl/MainDetailControlAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/MainDetailControl/MainDetailControlAction.cs @@ -30,6 +30,9 @@ using Mesnac.Action.ChemicalWeighing.InterfaceDocking.DockingEntity; using Mesnac.Core.Service; using Mesnac.Basic; using Mesnac.Action.ChemicalWeighing.Util; +using DevExpress.XtraRichEdit.Import.Doc; +using System.Threading.Tasks; +using DevExpress.Utils.Filtering.Internal; namespace Mesnac.Action.ChemicalWeighing.MainDetailControl { @@ -277,7 +280,7 @@ namespace Mesnac.Action.ChemicalWeighing.MainDetailControl conCurrentCache.Clear(); } } - + int bao = 0; /// /// Plc读数线程池,定时器退出删除 /// @@ -510,7 +513,27 @@ namespace Mesnac.Action.ChemicalWeighing.MainDetailControl ThreadPool.QueueUserWorkItem(new WaitCallback(NewThread)); - AlarmControl(); + + if (bao > 2) + { + bao = 0; + try + { + ThreadPool.QueueUserWorkItem((ty) => + { + AlarmControl(); + }); + + } + catch (Exception) + { + bao = 0; + + } + + } + bao += 1; + //现有报警刷新 var db2110 = new Db2110Help(); @@ -881,35 +904,92 @@ namespace Mesnac.Action.ChemicalWeighing.MainDetailControl b3 = DB2103.bytes; b7 = DB2107.bytes; - StringBuilder sb = new StringBuilder(); + List list = new List(); + StringBuilder sb = new StringBuilder(); + //string nowtime = DateTime.Now.ToString(); //报警点位遍历 foreach (DataRow rows in AllAlarmTable.Rows) { + int Alarm_ID = Convert.ToInt32(rows["Alarm_ID"]); + string otherInfo = rows["Alarm_Other_Info"].ToString(); + string cnInfo = rows["Alarm_Cn_Info"].ToString(); + + WarnTable warnTable = new WarnTable(); + warnTable.CnInfo = cnInfo; + warnTable.AlarmId = Alarm_ID; + warnTable.OtherInfo = otherInfo; + warnTable.CreateTime = DateTime.Now; + warnTable.UpdateTime = DateTime.Now; + + if ((int)rows["Alarm_Block"] == 2102 && b2[(int)rows["Alarm_Word"]].GetBit((int)rows["Alarm_bit"]) == true) { sb.Append(rows["Alarm_Other_Info"].ToString()); sb.Append(" "); sb.Append(rows["Alarm_Cn_Info"].ToString()); sb.Append(@" \ "); + warnTable.Status = 1; + } + else + { + warnTable.Status = 0; } - else if ((int)rows["Alarm_Block"] == 2107 && b7[(int)rows["Alarm_Word"]].GetBit((int)rows["Alarm_bit"]) == true) + + + + if ((int)rows["Alarm_Block"] == 2107 && b7[(int)rows["Alarm_Word"]].GetBit((int)rows["Alarm_bit"]) == true) { sb.Append(rows["Alarm_Other_Info"].ToString()); sb.Append(" "); sb.Append(rows["Alarm_Cn_Info"].ToString()); sb.Append(@" \ "); + + warnTable.Status = 1; + + + } + else + { + warnTable.Status = 0; + } - else if ((int)rows["Alarm_Block"] == 2103 && b3[(int)rows["Alarm_Word"]].GetBit((int)rows["Alarm_bit"]) == true) + + if ((int)rows["Alarm_Block"] == 2103 && b3[(int)rows["Alarm_Word"]].GetBit((int)rows["Alarm_bit"]) == true) { sb.Append(rows["Alarm_Other_Info"].ToString()); sb.Append(" "); sb.Append(rows["Alarm_Cn_Info"].ToString()); sb.Append(@" \ "); + + warnTable.Status = 1; + + } + else + { + warnTable.Status = 0; + } + + list.Add(warnTable); + } + + + + var Sql = FreeDb.FreeSqlUnit.Instance; + long cou = Sql.Queryable().Count(); + if (cou > 50000) + { + Sql.Delete().Where(x => x.CreateTime < DateTime.Now).ExecuteAffrows(); } + //只记录等于1的 + var ls=list.Where(x=>x.Status==1); + Sql.Insert(ls).ExecuteInserted(); + + + string str = sb.ToString(); if (string.IsNullOrWhiteSpace(str)) { @@ -928,6 +1008,9 @@ namespace Mesnac.Action.ChemicalWeighing.MainDetailControl } } + + + #endregion #region 图像数据读取、控件赋值 diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj index 7a99195..7a87fbc 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj @@ -286,6 +286,7 @@ + diff --git a/Main/MCEdit/Data/MCProject/nodeDataSource.xml b/Main/MCEdit/Data/MCProject/nodeDataSource.xml index de0e88a..224ba3d 100644 --- a/Main/MCEdit/Data/MCProject/nodeDataSource.xml +++ b/Main/MCEdit/Data/MCProject/nodeDataSource.xml @@ -1,3 +1,3 @@ - + \ No newline at end of file