using DevExpress.XtraBars.Alerter; using Mesnac.Action.ChemicalWeighing.Entity; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper { public class AlarmSaveHelper { /// /// 报警保存事件定义 /// public static event EventHandler OnAlarmSave; public static event EventHandler OnAlarmSaveExtend; public static object sender = null; public static object senderExtend = null; private static int WordLength = 16; //定义字长 static List _alarmBlockWordList; /// /// 保存报警信息 2023 /// public static void Save() { #region 读取PLC的报警数据 #region 保存报警数据 _alarmBlockWordList = Alarm.AlarmHelper.QueryAlarmLog(); if (_alarmBlockWordList == null) return; foreach (Entity.SimpleAlarmInfo sai in _alarmBlockWordList) { DataKeyValue plt_param = new DataKeyValue(sai.Alarm_Alias); if (plt_param.NowValue.ToInt() == 1) { //保存到数据库 //数据保存 // Entity.PmtAlarmInfo alarmInfo = Cache.CacheHelper.GetPmtAlarmInfoFromCache(sai.AlramPLC, sai.AlarmBlock, sai.Alarm_Alias); if (!Alarm.AlarmHelper.IsExist(sai.Alarm_ID)) { LR_Alarmlog alarmLogData = new LR_Alarmlog(); alarmLogData.Equip_Code = "01"; alarmLogData.Alarm_ID = sai.Alarm_ID; alarmLogData.Alarm_OccurTime = DateTime.Now.ToString(); alarmLogData.Alarm_ClearTime = String.Empty; alarmLogData.Alarm_Status = 1; alarmLogData.Alarm_GUID = Guid.NewGuid().ToString().ToUpper(); Alarm.AlarmHelper.InsertAlarmLogData(alarmLogData); } else { LR_Alarmlog alarmLog = new LR_Alarmlog(); alarmLog.Equip_Code = "01"; alarmLog.Alarm_ID = sai.Alarm_ID; alarmLog.Alarm_OccurTime = DateTime.Now.ToString(); alarmLog.Alarm_ClearTime = String.Empty; alarmLog.Alarm_Status = 0; Alarm.AlarmHelper.UpdateAlarmLogData(sai.Alarm_ID, DateTime.Now.ToString()); } } else { LR_Alarmlog alarmLog = new LR_Alarmlog(); alarmLog.Equip_Code = "01"; alarmLog.Alarm_ID = sai.Alarm_ID; alarmLog.Alarm_OccurTime = DateTime.Now.ToString(); alarmLog.Alarm_ClearTime = String.Empty; alarmLog.Alarm_Status = 0; Alarm.AlarmHelper.UpdateAlarmLogData(sai.Alarm_ID, DateTime.Now.ToString()); } } #region 触发事件 //if (OnAlarmSave != null && Global.PublicVar.Instance.isFlashFlag) //{ // OnAlarmSave(sender, System.EventArgs.Empty); //} //if (OnAlarmSaveExtend != null && Global.PublicVar.Instance.isFlashFlagExtend) //{ // OnAlarmSaveExtend(senderExtend, System.EventArgs.Empty); //} #endregion #endregion 保存报警数据 #endregion 保存报警数据 } } }