internal void ReCalcuateOverLimit(DateTime StartDate, DateTime EndDate) { IKPI_OverLimitConfigDal dataAccess = new KPI_OverLimitConfigDal(); try { //返回超限配置列表 List <OverLimitConfigEntity> faultConfigurations = dataAccess.GetOverLimitConfigs(); if (faultConfigurations == null) { m_Logger.Info("数据库不存在超限配置"); return; } //endDate = DateTime.Now; //endDate = endDate.AddSeconds(-1 * endDate.Second); //startDate = endDate.AddMinutes(-1 * AlarmInterval); //startDate = new DateTime(2013, 11, 28, 4, 30, 0); //endDate = new DateTime(2013, 11, 28, 4, 40, 0); List <TagValue> tagAttributeList; //faultConfigurations = faultConfigurations.Where(p => p.TagCode == @"\mjdc\DCS1\TE_31251F_PV").ToList<KPI_OverLimitConfig>(); foreach (OverLimitConfigEntity faultConfiguration in faultConfigurations) { //StopLastShiftAlarm(faultConfiguration);//停止上一班未结束的报警 if (UnitIsRunning(faultConfiguration.UnitID) == false) { continue; } tagAttributeList = RTDataAccess.GetHistoryDataList(faultConfiguration.TagCode, StartDate, EndDate); if (tagAttributeList == null) { m_Logger.InfoFormat("读取测点{0}{1}信息失败!", faultConfiguration.TagCode, faultConfiguration.TagDesc); continue; } tagAttributeList = tagAttributeList.OrderBy(p => p.TimeStamp).ToList <TagValue>(); //StopPreviousAlarm(faultConfiguration, tagAttributeList);//停止前一轮起报的报警 CalcAlarm(faultConfiguration, tagAttributeList);//计算报警 } } catch (Exception ex) { m_Logger.InfoFormat("PorcessExceedLimit安全指标超限报警计算错误,错误信息是:{0},调用栈信息是:{1}", ex.Message, ex.StackTrace); m_Logger.Error(ex); } }
private Double ExpCurrentValue(String expression) { try { if (String.IsNullOrEmpty(expression)) { return(Double.MinValue); } int pos = expression.LastIndexOf("'") - 1; if (pos <= 0) { return(double.MinValue); } String tagName = expression.Substring(1, pos); double tagValue = RTDataAccess.GetSnapshotValue(tagName); String Token = expression.Substring(pos + 2, 1); pos = expression.IndexOf(Token) + 1; String Val = expression.Substring(pos, expression.Length - pos); double targetValue = Convert.ToDouble(Val); return(tagValue - targetValue); } catch { return(double.MinValue); } }
private double GetTagValue(string tag, DateTime time) { return(RTDataAccess.GetArchiveValue(tag, time)); }