コード例 #1
0
        protected override void Calculate(OverLimitConfigEntity overLimitConfig, List<TagValue> tagAttributeList)
        {
            if (!string.IsNullOrEmpty(overLimitConfig.FourthLimitingTag)) {
                H4(overLimitConfig, tagAttributeList);
            }
            if (!string.IsNullOrEmpty(overLimitConfig.ThirdLimitingTag)) {
                H3(overLimitConfig, tagAttributeList);
            }
            if (!string.IsNullOrEmpty(overLimitConfig.SecondLimitingTag)) {
                H2(overLimitConfig, tagAttributeList);
            }
            if (!string.IsNullOrEmpty(overLimitConfig.FirstLimitingTag)) {
                H1(overLimitConfig, tagAttributeList);
            }

            if (!string.IsNullOrEmpty(overLimitConfig.LowLimit1Tag)) {
                L1(overLimitConfig, tagAttributeList);
            }
            if (!string.IsNullOrEmpty(overLimitConfig.LowLimit2Tag)) {
                L2(overLimitConfig, tagAttributeList);
            }
            if (!string.IsNullOrEmpty(overLimitConfig.LowLimit3Tag)) {
                L3(overLimitConfig, tagAttributeList);
            }
        }
コード例 #2
0
 private void H4(OverLimitConfigEntity overLimitConfig, List<TagValue> tagAttributeList, double high4)
 {
     double maxValue = tagAttributeList.Max(p => Convert.ToDouble(p.TagStringValue));
     foreach (TagValue item in tagAttributeList) {
         if (item.TagDoubleValue > high4) {
             AddOrUpdateOverLimitRecordToDB(overLimitConfig, 4, item.TimeStamp, high4, maxValue);
         }
         else {
             UpdateExistOverLimitRecordToDB(overLimitConfig, 4, item.TimeStamp);
         }
     }
 }
コード例 #3
0
        protected override void Calculate(OverLimitConfigEntity overLimitConfig, List<TagValue> tagAttributeList)
        {
            OverLimitConfigParameter parameter = InitOverLimitParameter(overLimitConfig);

            if (parameter.High4 != double.MaxValue) H4(overLimitConfig, tagAttributeList, parameter.High4);
            if (parameter.High3 != double.MaxValue) H3(overLimitConfig, tagAttributeList, parameter.High3, parameter.High4);
            if (parameter.High2 != double.MaxValue) H2(overLimitConfig, tagAttributeList, parameter.High2, parameter.High3);
            if (parameter.High1 != double.MaxValue) H1(overLimitConfig, tagAttributeList, parameter.High1, parameter.High2);

            if (parameter.Low1 != double.MinValue) L1(overLimitConfig, tagAttributeList, parameter.Low2, parameter.Low1);
            if (parameter.Low2 != double.MinValue) L2(overLimitConfig, tagAttributeList, parameter.Low3, parameter.Low2);
            if (parameter.Low3 != double.MinValue) L3(overLimitConfig, tagAttributeList, parameter.Low3);
        }
コード例 #4
0
        private OverLimitConfigParameter InitOverLimitParameter(OverLimitConfigEntity faultConfiguration)
        {
            OverLimitConfigParameter parameter = new OverLimitConfigParameter();

            if (faultConfiguration.LowLimit1Value != null) parameter.Low1 = Convert.ToDouble(faultConfiguration.LowLimit1Value.Value);//低1限值
            if (faultConfiguration.LowLimit2Value != null) parameter.Low2 = Convert.ToDouble(faultConfiguration.LowLimit2Value.Value);//低2限值
            if (faultConfiguration.LowLimit3Value != null) parameter.Low3 = Convert.ToDouble(faultConfiguration.LowLimit3Value.Value);//低3限值

            if (faultConfiguration.FirstLimitingValue != null) parameter.High1 = Convert.ToDouble(faultConfiguration.FirstLimitingValue.Value);//高1限值
            if (faultConfiguration.SecondLimitingValue != null) parameter.High2 = Convert.ToDouble(faultConfiguration.SecondLimitingValue.Value);//高2限值
            if (faultConfiguration.ThirdLimitingValue != null) parameter.High3 = Convert.ToDouble(faultConfiguration.ThirdLimitingValue.Value);//高3限值
            if (faultConfiguration.FourthLimitingValue != null) parameter.High4 = Convert.ToDouble(faultConfiguration.FourthLimitingValue.Value);//高4限值

            return parameter;
        }
コード例 #5
0
        public void InitCalculate(RTInterface mdataAccess, OverLimitConfigEntity overLimitConfig, DateTime startDate, DateTime endDate)
        {
            m_DataAccess = mdataAccess;

            if (CheckUnitIsRunning(overLimitConfig.UnitID) == false) return;

            List<TagValue> tagAttributeList = RTDataAccess.GetHistoryDataList(overLimitConfig.TagCode, startDate, endDate);
            if (tagAttributeList == null || tagAttributeList.Count <= 0)
            {
                m_Logger.InfoFormat("读取测点{0}{1}信息失败!", overLimitConfig.TagCode, overLimitConfig.TagDesc);
                return;
            }
            tagAttributeList = tagAttributeList.OrderBy(p => p.TimeStamp).ToList<TagValue>();

            Calculate(overLimitConfig, tagAttributeList);
        }
コード例 #6
0
        private void H3(OverLimitConfigEntity overLimitConfig, List<TagValue> tagAttributeList)
        {
            double maxValue = tagAttributeList.Max(p => Convert.ToDouble(p.TagStringValue));
            foreach (TagValue item in tagAttributeList) {
                double High3 = GetTagValue(overLimitConfig.ThirdLimitingTag, item.TimeStamp);
                double High4 = double.MaxValue;
                if (string.IsNullOrEmpty(overLimitConfig.FourthLimitingTag)) {
                    High4 = GetTagValue(overLimitConfig.FourthLimitingTag, item.TimeStamp);
                }

                if ((item.TagDoubleValue > High3) && (item.TagDoubleValue <= High4)) {
                    AddOrUpdateOverLimitRecordToDB(overLimitConfig, 3, item.TimeStamp, High3, maxValue);
                }
                else {
                    UpdateExistOverLimitRecordToDB(overLimitConfig, 3, item.TimeStamp);
                }
            }
        }
コード例 #7
0
        private void H1(OverLimitConfigEntity overLimitConfig, List<TagValue> tagAttributeList)
        {
            double maxValue = tagAttributeList.Max(p => Convert.ToDouble(p.TagStringValue));
            foreach (TagValue item in tagAttributeList) {
                double High1 = GetTagValue(overLimitConfig.FirstLimitingTag, item.TimeStamp);
                double High2 = double.MaxValue;
                if (!string.IsNullOrEmpty(overLimitConfig.SecondLimitingTag)) {
                    High2 = GetTagValue(overLimitConfig.SecondLimitingTag, item.TimeStamp);
                }

                if ((item.TagDoubleValue > High1) && (item.TagDoubleValue <= High2)) {
                    AddOrUpdateOverLimitRecordToDB(overLimitConfig, 1, item.TimeStamp, High1, maxValue);
                }
                else {
                    UpdateExistOverLimitRecordToDB(overLimitConfig, 1, item.TimeStamp);
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// 启动报警,向KPI_OverLimitRecord表中添加数据
        /// </summary>
        /// <param name="faultConfiguration">报警配置信息</param>
        /// <param name="alarmType">报警类型 1=超高限,2=超高高限,3=超更高</param>
        /// <param name="alarmTime">开始报警时间</param>
        /// <param name="maxValue">超标极值</param>
        /// <param name="standardValue">标准值</param>
        protected void AddOrUpdateOverLimitRecordToDB(OverLimitConfigEntity faultConfiguration, int alarmType,
            DateTime alarmTime, double standardValue, double maxValue)
        {
            try
            {
                KPI_OverLimitRecordEntity entity = new KPI_OverLimitRecordEntity();
                entity.AlarmID = Guid.NewGuid() + "";
                entity.UnitID = faultConfiguration.UnitID;
                entity.TagID = faultConfiguration.TagName;
                entity.AlarmType = alarmType;
                entity.AlarmStartTime = alarmTime;
                entity.StandardValue = Convert.ToDecimal(standardValue);
                entity.Offset = Convert.ToDecimal(maxValue - standardValue);
                entity.Duration = 0;
                entity.AlarmValue = Convert.ToDecimal(maxValue);
                String Period = "";
                String Shift = "";
                GetShiftAndPeriod(faultConfiguration.UnitID, out Shift, out Period, alarmTime);
                entity.Shift = Shift;
                entity.Period = Period;

                using (KPI_OverLimitRecordDal DataAccess = new KPI_OverLimitRecordDal())
                {
                    if (DataAccess.ExistsOverLimitRecord(entity))
                    {
                        DataAccess.UpdateAlarmMaxValue(entity);
                        return;
                    }
                    DataAccess.AddOverLimitRecord(entity);
                }
            }
            catch (Exception ex)
            {
                m_Logger.InfoFormat("AddOrUpdateOverLimitRecordToDB安全指标超限报警计算错误,错误信息是:{0},调用栈信息是:{1}",
                    ex.Message, ex.StackTrace);
                m_Logger.Error(ex.Message, ex);
            }
        }
コード例 #9
0
        private void L2(OverLimitConfigEntity overLimitConfig, List<TagValue> tagAttributeList)
        {
            double minValue = tagAttributeList.Min(p => Convert.ToDouble(p.TagStringValue));
            foreach (TagValue item in tagAttributeList) {
                double low2 = GetTagValue(overLimitConfig.LowLimit2Tag, item.TimeStamp);
                double low3 = double.MinValue;
                if (!string.IsNullOrEmpty(overLimitConfig.LowLimit3Tag)) {
                    low3 = GetTagValue(overLimitConfig.LowLimit3Tag, item.TimeStamp);
                }

                if ((item.TagDoubleValue < low2) && (item.TagDoubleValue >= low3)) {
                    AddOrUpdateOverLimitRecordToDB(overLimitConfig, -2, item.TimeStamp, low2, minValue);
                }
                else {
                    UpdateExistOverLimitRecordToDB(overLimitConfig, -2, item.TimeStamp);
                }
            }
        }
コード例 #10
0
 /// <summary>
 /// 超高三限
 /// </summary>
 /// <param name="faultConfiguration"></param>
 /// <param name="tagAttributeList"></param>
 /// <param name="standardValue"></param>
 private void H3(OverLimitConfigEntity faultConfiguration, List<TagValue> tagAttributeList, double standardValue)
 {
     double maxValue = tagAttributeList.Max(p => Convert.ToDouble(p.TagStringValue));
     foreach (TagValue item in tagAttributeList) {
         if (item.TagDoubleValue > standardValue) {
             StartAlarm(faultConfiguration, 3, item.TimeStamp, standardValue, maxValue);
         }
         else {
             StopAlarm(faultConfiguration, 3, item.TimeStamp);
         }
     }
 }
コード例 #11
0
        /// <summary>
        /// 停止前一轮起报的报警
        /// </summary>
        private void StopPreviousAlarm(OverLimitConfigEntity faultConfiguration, List<TagValue> tagAttributeList)
        {
            double high1, high2, high3, high4;
            double low1, low2, low3;
            double FirstItemValue;
            high1 = double.MaxValue;
            high2 = double.MaxValue;
            high3 = double.MaxValue;
            high4 = double.MaxValue;
            low1 = double.MinValue;
            low2 = double.MinValue;
            low3 = double.MinValue;

            if (tagAttributeList.Count <= 0) return;
            if (faultConfiguration.LowLimit1Value != null) low1 = Convert.ToDouble(faultConfiguration.LowLimit1Value.Value);//低1限值
            if (faultConfiguration.LowLimit2Value != null) low2 = Convert.ToDouble(faultConfiguration.LowLimit2Value.Value);//低2限值
            if (faultConfiguration.LowLimit3Value != null) low3 = Convert.ToDouble(faultConfiguration.LowLimit3Value.Value);//低3限值

            if (faultConfiguration.FirstLimitingValue != null) high1 = Convert.ToDouble(faultConfiguration.FirstLimitingValue.Value);//高1限值
            if (faultConfiguration.SecondLimitingValue != null) high2 = Convert.ToDouble(faultConfiguration.SecondLimitingValue.Value);//高2限值
            if (faultConfiguration.ThirdLimitingValue != null) high3 = Convert.ToDouble(faultConfiguration.ThirdLimitingValue.Value);//高3限值
            if (faultConfiguration.FourthLimitingValue != null) high4 = Convert.ToDouble(faultConfiguration.FourthLimitingValue.Value);//高4限值
            FirstItemValue = tagAttributeList.First().TagDoubleValue;

            //停高4
            if ((FirstItemValue <= high4) && (high4 != double.MaxValue)) {
                StopAlarm(faultConfiguration, 4, tagAttributeList.First().TimeStamp);
            }

            //停高3
            if ((FirstItemValue <= high3) && (high3 != double.MaxValue)) {
                StopAlarm(faultConfiguration, 3, tagAttributeList.First().TimeStamp);
            }

            //停高2
            if ((FirstItemValue <= high2) && (high2 != double.MaxValue)) {
                StopAlarm(faultConfiguration, 2, tagAttributeList.First().TimeStamp);
            }

            //停高1
            if ((FirstItemValue <= high1) && (high1 != double.MaxValue)) {
                StopAlarm(faultConfiguration, 1, tagAttributeList.First().TimeStamp);
            }

            //停低1
            if ((FirstItemValue >= low1) && (low1 != double.MinValue)) {
                StopAlarm(faultConfiguration, -1, tagAttributeList.First().TimeStamp);
            }

            //停低2
            if ((FirstItemValue >= low2) && (low2 != double.MinValue)) {
                StopAlarm(faultConfiguration, -2, tagAttributeList.First().TimeStamp);
            }

            //停低3
            if ((FirstItemValue >= low3) && (low3 != double.MinValue)) {
                StopAlarm(faultConfiguration, -3, tagAttributeList.First().TimeStamp);
            }
        }
コード例 #12
0
 private void L3(OverLimitConfigEntity overLimitConfig, List<TagValue> tagAttributeList,
     double standardValue)
 {
     double minValue = tagAttributeList.Min(p => Convert.ToDouble(p.TagStringValue));
     foreach (TagValue item in tagAttributeList) {
         if (item.TagDoubleValue <= standardValue) {
             AddOrUpdateOverLimitRecordToDB(overLimitConfig, -3, item.TimeStamp, standardValue, minValue);
         }
         else {
             UpdateExistOverLimitRecordToDB(overLimitConfig, -3, item.TimeStamp);
         }
     }
 }
コード例 #13
0
 private void L3(OverLimitConfigEntity overLimitConfig, List<TagValue> tagAttributeList)
 {
     double minValue = tagAttributeList.Min(p => Convert.ToDouble(p.TagStringValue));
     foreach (TagValue item in tagAttributeList) {
         double low3 = GetTagValue(overLimitConfig.LowLimit3Tag, item.TimeStamp);
         if (item.TagDoubleValue <= low3) {
             AddOrUpdateOverLimitRecordToDB(overLimitConfig, -3, item.TimeStamp, low3, minValue);
         }
         else {
             UpdateExistOverLimitRecordToDB(overLimitConfig, -3, item.TimeStamp);
         }
     }
 }
コード例 #14
0
 protected abstract void Calculate(OverLimitConfigEntity overLimitConfig, List<TagValue> tagAttributeList);
コード例 #15
0
        private IDbDataParameter[] GetParameters(OverLimitConfigEntity OverLimitConfig)
        {
            IDbDataParameter[] parames = new SqlParameter[] {
                new SqlParameter(param_TagName,SqlDbType.VarChar,50),
                new SqlParameter(param_FirstLimitingValue,SqlDbType.Decimal),
                new SqlParameter(param_SecondLimitingValue,SqlDbType.Decimal),
                new SqlParameter(param_ThirdLimitingValue,SqlDbType.Decimal),
                new SqlParameter(param_FourthLimitingValue,SqlDbType.Decimal),
                new SqlParameter(param_LowLimit1Value,SqlDbType.Decimal),
                new SqlParameter(param_LowLimit2Value,SqlDbType.Decimal),
                new SqlParameter(param_LowLimit3Value,SqlDbType.Decimal),
                new SqlParameter(param_Comment,SqlDbType.VarChar,255),
                new SqlParameter(param_OverLimitConfigID,SqlDbType.VarChar),

                new SqlParameter(param_FirstLimitingTag,SqlDbType.VarChar,50),
                new SqlParameter(param_SecondLimitingTag,SqlDbType.VarChar,50),
                new SqlParameter(param_ThirdLimitingTag,SqlDbType.VarChar,50),
                new SqlParameter(param_FourthLimitingTag,SqlDbType.VarChar,50),
                new SqlParameter(param_LowLimit1Tag,SqlDbType.VarChar,50),
                new SqlParameter(param_LowLimit2Tag,SqlDbType.VarChar,50),
                new SqlParameter(param_LowLimit3Tag,SqlDbType.VarChar,50),
                new SqlParameter(param_OverLimitComputeType,SqlDbType.Int)
            };

            parames[0].Value = OverLimitConfig.TagName;
            parames[1].Value = OverLimitConfig.FirstLimitingValue;
            parames[2].Value = OverLimitConfig.SecondLimitingValue;
            parames[3].Value = OverLimitConfig.ThirdLimitingValue;
            parames[4].Value = OverLimitConfig.FourthLimitingValue;
            parames[5].Value = OverLimitConfig.LowLimit1Value;
            parames[6].Value = OverLimitConfig.LowLimit2Value;
            parames[7].Value = OverLimitConfig.LowLimit3Value;
            parames[8].Value = OverLimitConfig.Comment;
            parames[9].Value = OverLimitConfig.OverLimitConfigID;

            parames[10].Value = OverLimitConfig.FirstLimitingTag;
            parames[11].Value = OverLimitConfig.SecondLimitingTag;
            parames[12].Value = OverLimitConfig.ThirdLimitingTag;
            parames[13].Value = OverLimitConfig.FourthLimitingTag;
            parames[14].Value = OverLimitConfig.LowLimit1Tag;
            parames[15].Value = OverLimitConfig.LowLimit2Tag;
            parames[16].Value = OverLimitConfig.LowLimit3Tag;
            parames[17].Value = OverLimitConfig.OverLimitComputeType;
            return parames;
        }
コード例 #16
0
 public bool SavOverLimitConfigs(OverLimitConfigEntity OverLimitConfig)
 {
     if (HasOverLimitConfigs(OverLimitConfig.TagCode)) {
         return Update(OverLimitConfig);
     }
     else {
         return Insert(OverLimitConfig);
     }
 }
コード例 #17
0
        private void H2(OverLimitConfigEntity faultConfiguration, List<TagValue> tagAttributeList,
			double lowValue, double hightValue)
        {
            double maxValue = tagAttributeList.Max(p => Convert.ToDouble(p.TagStringValue));
            foreach (TagValue item in tagAttributeList) {
                if ((item.TagDoubleValue > lowValue) && (item.TagDoubleValue <= hightValue)) {
                    StartAlarm(faultConfiguration, 2, item.TimeStamp, lowValue, maxValue);
                }
                else {
                    StopAlarm(faultConfiguration, 2, item.TimeStamp);
                }
            }
        }
コード例 #18
0
 private void L1(OverLimitConfigEntity overLimitConfig, List<TagValue> tagAttributeList,
     double lowValue, double hightValue)
 {
     double minValue = tagAttributeList.Min(p => Convert.ToDouble(p.TagStringValue));
     foreach (TagValue item in tagAttributeList) {
         if ((item.TagDoubleValue < hightValue) && (item.TagDoubleValue >= lowValue)) {
             AddOrUpdateOverLimitRecordToDB(overLimitConfig, -1, item.TimeStamp, hightValue, minValue);
         }
         else {
             UpdateExistOverLimitRecordToDB(overLimitConfig, -1, item.TimeStamp);
         }
     }
 }
コード例 #19
0
        /// <summary>
        /// 启动报警,向KPI_OverLimitRecord表中添加数据
        /// </summary>
        /// <param name="faultConfiguration">报警配置信息</param>
        /// <param name="alarmType">报警类型 1=超高限,2=超高高限,3=超更高</param>
        /// <param name="alarmTime">开始报警时间</param>
        /// <param name="maxValue">超标极值</param>
        /// <param name="standardValue">标准值</param>
        private void StartAlarm(OverLimitConfigEntity faultConfiguration, int alarmType,
			DateTime alarmTime, double standardValue, double maxValue)
        {
            //Console.WriteLine(String.Format("测点{0}的报警类型是:{1}报警值是:{2}", faultConfiguration.TagDesc, alarmType, maxValue));
            try {
                KPI_OverLimitRecordEntity entity = new KPI_OverLimitRecordEntity();
                entity.AlarmID = Guid.NewGuid() + "";
                entity.UnitID = faultConfiguration.UnitID;
                entity.TagID = faultConfiguration.TagName;
                entity.AlarmType = alarmType;
                entity.AlarmStartTime = alarmTime;
                entity.StandardValue = Convert.ToDecimal(standardValue);
                entity.Offset = Convert.ToDecimal(maxValue - standardValue);
                entity.Duration = 0;
                entity.AlarmValue = Convert.ToDecimal(maxValue);
                String Period = "";
                String Shift = "";
                GetShiftAndPeriod(faultConfiguration.UnitID, out Shift, out Period);
                entity.Shift = Shift;
                entity.Period = Period;
                using (KPI_OverLimitRecordDal DataAccess = new KPI_OverLimitRecordDal()) {
                    if (DataAccess.ExistsOverLimitRecord(entity)) return;
                    DataAccess.AddOverLimitRecord(entity);
                }
            }
            catch (Exception ex) {
                LogUtil.LogMessage(string.Format("安全指标超限报警计算错误,错误信息是:{0},调用栈信息是:{1}",
                    ex.Message, ex.StackTrace));
            }
        }
コード例 #20
0
        public bool Update(OverLimitConfigEntity overLimitConfig)
        {
            try {
                int result = DBAccess.GetRelation().ExecuteNonQuery(sql_UpdateInfo,
                    GetParameters(overLimitConfig));
                if (result == 0) {
                    return false;
                }
            }
            catch (Exception ex) {
                throw ex;
            }

            return true;
        }
コード例 #21
0
 /// <summary>
 /// 解除报警,更新KPI_OverLimitRecord表中数据
 /// </summary>
 /// <param name="faultConfiguration">报警配置信息</param>
 /// <param name="alarmType">报警类型 1=超高限,2=超高高限,3=超更高;</param>
 /// <param name="alarmTime">解除报警时间</param>
 private void StopAlarm(OverLimitConfigEntity faultConfiguration, int alarmType, DateTime alarmTime)
 {
     try {
         KPI_OverLimitRecordEntity entity = new KPI_OverLimitRecordEntity();
         entity.TagID = faultConfiguration.TagName;
         entity.AlarmStartTime = alarmTime;
         entity.AlarmType = alarmType;
         using (KPI_OverLimitRecordDal DataAccess = new KPI_OverLimitRecordDal()) {
             DataAccess.UpdateOverLimitRecord(entity);
         }
     }
     catch (Exception ex) {
         LogUtil.LogMessage(string.Format("安全指标超限报警计算错误,错误信息是:{0},调用栈信息是:{1}",
             ex.Message, ex.StackTrace));
     }
 }
コード例 #22
0
        public OverLimitConfigEntity GetOverLimitConfig(string overLimitConfigID)
        {
            OverLimitConfigEntity overLimitConfig = null;
            SqlParameter parame = new SqlParameter(param_OverLimitConfigID, SqlDbType.VarChar);
            parame.Value = overLimitConfigID;
            using (IDataReader dataReader = DBAccess.GetRelation().ExecuteReader(CommandType.Text, sql_SearchOverLimitConfigByID, parame)) {
                while (dataReader.Read()) {
                    overLimitConfig = new OverLimitConfigEntity {
                        OverLimitConfigID = dataReader["OverLimitConfigID"].ToString(),
                        TagName = dataReader["TagName"] == DBNull.Value ? string.Empty : dataReader["TagName"].ToString(),
                        RealDesc = dataReader["RealDesc"] == DBNull.Value ? string.Empty : dataReader["RealDesc"].ToString(),
                        FirstLimitingValue = dataReader["FirstLimitingValue"] == DBNull.Value ? null : (decimal?)dataReader["FirstLimitingValue"],
                        SecondLimitingValue = dataReader["SecondLimitingValue"] == DBNull.Value ? null : (decimal?)dataReader["SecondLimitingValue"],
                        ThirdLimitingValue = dataReader["ThirdLimitingValue"] == DBNull.Value ? null : (decimal?)dataReader["ThirdLimitingValue"],
                        FourthLimitingValue = dataReader["FourthLimitingValue"] == DBNull.Value ? null : (decimal?)dataReader["FourthLimitingValue"],
                        LowLimit1Value = dataReader["LowLimit1Value"] == DBNull.Value ? null : (decimal?)dataReader["LowLimit1Value"],
                        LowLimit2Value = dataReader["LowLimit2Value"] == DBNull.Value ? null : (decimal?)dataReader["LowLimit2Value"],
                        LowLimit3Value = dataReader["LowLimit3Value"] == DBNull.Value ? null : (decimal?)dataReader["LowLimit3Value"],

                        Comment = dataReader["Comment"] == DBNull.Value ? string.Empty : dataReader["Comment"].ToString(),
                    };
                }
            }

            return overLimitConfig;
        }
コード例 #23
0
 /// <summary>
 /// 交接时关闭上一班报警
 /// </summary>
 /// <param name="faultConfiguration"></param>
 private void StopLastShiftAlarm(OverLimitConfigEntity faultConfiguration)
 {
     KPI_UnitEntity Entity = KPI_UnitDal.GetEntity(faultConfiguration.UnitID);
     if (Entity == null) return;
     String strWorkID = Entity.WorkID;
     String strStartTime = "";
     String strEndTime = "";
     String Shift = "";
     String Period = "";
     String strCurrentMinute = DateTime.Now.ToString("yyyy-MM-dd HH:mm:00");
     KPI_WorkDal.GetShiftAndPeriod(strWorkID, strCurrentMinute,
         ref Shift, ref Period, ref strStartTime, ref strEndTime);
     DateTime ShiftStartTime = Convert.ToDateTime(strStartTime);
     DateTime CurrentTime = DateTime.Now;
     TimeSpan Span = CurrentTime - ShiftStartTime;
     double TotalMinutes = Span.TotalMinutes;
     if (TotalMinutes <= 10) {
         try {
             using (KPI_OverLimitRecordDal DataAccess = new KPI_OverLimitRecordDal()) {
                 KPI_OverLimitRecordEntity entity = new KPI_OverLimitRecordEntity();
                 for (int i = 1; i < 4; i++) {
                     entity.TagID = faultConfiguration.TagName;
                     entity.AlarmStartTime = ShiftStartTime;
                     entity.AlarmType = i;
                     DataAccess.UpdateOverLimitRecord(entity);
                 }
             }
         }
         catch (Exception ex) {
             LogUtil.LogMessage(string.Format("安全指标超限报警计算错误,错误信息是:{0},调用栈信息是:{1}",
                 ex.Message, ex.StackTrace));
         }
     }
 }
コード例 #24
0
 /// <summary>
 /// 解除报警,更新KPI_OverLimitRecord表中数据
 /// </summary>
 /// <param name="faultConfiguration">报警配置信息</param>
 /// <param name="alarmType">报警类型 1=超高限,2=超高高限,3=超更高;</param>
 /// <param name="alarmTime">解除报警时间</param>
 protected void UpdateExistOverLimitRecordToDB(OverLimitConfigEntity faultConfiguration, int alarmType, DateTime alarmTime)
 {
     try
     {
         KPI_OverLimitRecordEntity entity = new KPI_OverLimitRecordEntity();
         entity.TagID = faultConfiguration.TagName;
         entity.AlarmEndTime = alarmTime;
         entity.AlarmType = alarmType;
         using (KPI_OverLimitRecordDal DataAccess = new KPI_OverLimitRecordDal())
         {
             DataAccess.UpdateOverLimitRecord(entity);
         }
     }
     catch (Exception ex)
     {
         m_Logger.InfoFormat("UpdateExistOverLimitRecordToDB安全指标超限报警计算错误,错误信息是:{0},调用栈信息是:{1}",
             ex.Message, ex.StackTrace);
         m_Logger.Error(ex.Message, ex);
     }
 }
コード例 #25
0
        private OverLimitConfigEntity GetFixedParaConfigEntity(string tagName)
        {
            decimal? firstLimiting = null, secondLimiting = null,
                thirdLimiting = null, FourthLimiting = null,
                lowLimit1Value = null, lowLimit2Value = null, lowLimit3Value = null;
            if (!string.IsNullOrWhiteSpace(txtLowLimit1Value.Text)) {
                lowLimit1Value = Convert.ToDecimal(txtLowLimit1Value.Text);
            }
            if (!string.IsNullOrWhiteSpace(txtLowLimit2Value.Text)) {
                lowLimit2Value = Convert.ToDecimal(txtLowLimit2Value.Text);
            }
            if (!string.IsNullOrWhiteSpace(txtLowLimit3Value.Text)) {
                lowLimit3Value = Convert.ToDecimal(txtLowLimit3Value.Text);
            }

            if (!string.IsNullOrWhiteSpace(txtFirstLimiting.Text)) {
                firstLimiting = Convert.ToDecimal(txtFirstLimiting.Text);
            }
            if (!string.IsNullOrWhiteSpace(txtSecondLimiting.Text)) {
                secondLimiting = Convert.ToDecimal(txtSecondLimiting.Text);
            }
            if (!string.IsNullOrWhiteSpace(txtThirdLimiting.Text)) {
                thirdLimiting = Convert.ToDecimal(txtThirdLimiting.Text);
            }
            if (!string.IsNullOrWhiteSpace(txtFourthLimiting.Text)) {
                FourthLimiting = Convert.ToDecimal(txtFourthLimiting.Text);
            }

            string comment = txtComment.Text;

            OverLimitConfigEntity overLimitConfig = new OverLimitConfigEntity {
                TagName = tagName,
                FirstLimitingValue = firstLimiting,
                SecondLimitingValue = secondLimiting,
                ThirdLimitingValue = thirdLimiting,
                FourthLimitingValue = FourthLimiting,
                LowLimit1Value = lowLimit1Value,
                LowLimit2Value = lowLimit2Value,
                LowLimit3Value = lowLimit3Value,
                Comment = comment,
                EnumOverLimitComputeType = OverLimitComputeTypeEnum.FixedPara,
                OverLimitComputeType = 0,

                FirstLimitingTag = "",
                SecondLimitingTag = "",
                ThirdLimitingTag = "",
                FourthLimitingTag = "",
                LowLimit1Tag = "",
                LowLimit2Tag = "",
                LowLimit3Tag = "",
            };
            return overLimitConfig;
        }
コード例 #26
0
        private OverLimitConfigEntity InitRealTimeTypeConfigEntity(string tagName, out string errorInfo)
        {
            errorInfo = null;
            decimal? firstLimiting = null, secondLimiting = null,
               thirdLimiting = null, FourthLimiting = null,
               lowLimit1Value = null, lowLimit2Value = null, lowLimit3Value = null;

            string lowLimit1Tag = null;
            string lowLimit2Tag = null;
            string lowLimit3Tag = null;
            string firstLimitingTag = null;
            string secondLimitingTag = null;
            string thirdLimitingTag = null;
            string fourthLimitingTag = null;

            ///string baseInfo = "在PI中没有找到对应{0}测点";
            if (!string.IsNullOrWhiteSpace(txtLowLimit1Value.Text)) {
                lowLimit1Tag = txtLowLimit1Value.Text.Trim();
                //if (!RTDataAccess.ExistPoint(lowLimit1Tag))
                //{
                //    errorInfo = string.Format(baseInfo, "低一");
                //    return null;
                //}
            }

            if (!string.IsNullOrWhiteSpace(txtLowLimit2Value.Text)) {
                lowLimit2Tag = txtLowLimit2Value.Text.Trim();
                //if (!RTDataAccess.ExistPoint(lowLimit2Tag))
                //{
                //    errorInfo = string.Format(baseInfo, "低二");
                //    return null;
                //}
            }

            if (!string.IsNullOrWhiteSpace(txtLowLimit3Value.Text)) {
                lowLimit3Tag = txtLowLimit3Value.Text.Trim();
                //if (!RTDataAccess.ExistPoint(lowLimit3Tag))
                //{
                //    errorInfo = string.Format(baseInfo, "低三");
                //    return null;
                //}
            }

            if (!string.IsNullOrWhiteSpace(txtFirstLimiting.Text)) {
                firstLimitingTag = txtFirstLimiting.Text.Trim();
                //if (!RTDataAccess.ExistPoint(firstLimitingTag))
                //{
                //    errorInfo = string.Format(baseInfo, "高一");
                //    return null;
                //}
            }

            if (!string.IsNullOrWhiteSpace(txtSecondLimiting.Text)) {
                secondLimitingTag = txtSecondLimiting.Text.Trim();
                //if (!RTDataAccess.ExistPoint(secondLimitingTag))
                //{
                //    errorInfo = string.Format(baseInfo, "高二");
                //    return null;
                //}
            }

            if (!string.IsNullOrWhiteSpace(txtThirdLimiting.Text)) {
                thirdLimitingTag = txtThirdLimiting.Text.Trim();
                //if (!RTDataAccess.ExistPoint(thirdLimitingTag))
                //{
                //    errorInfo = string.Format(baseInfo, "高三");
                //    return null;
                //}
            }

            if (!string.IsNullOrWhiteSpace(txtFourthLimiting.Text)) {
                fourthLimitingTag = txtFourthLimiting.Text.Trim();
                //if (!RTDataAccess.ExistPoint(fourthLimitingTag))
                //{
                //    errorInfo = string.Format(baseInfo, "高四");
                //    return null;
                //}
            }

            string comment = txtComment.Text;
            OverLimitConfigEntity overLimitConfig = new OverLimitConfigEntity {
                TagName = tagName,
                FirstLimitingValue = firstLimiting,
                SecondLimitingValue = secondLimiting,
                ThirdLimitingValue = thirdLimiting,
                FourthLimitingValue = FourthLimiting,
                LowLimit1Value = lowLimit1Value,
                LowLimit2Value = lowLimit2Value,
                LowLimit3Value = lowLimit3Value,

                FirstLimitingTag = firstLimitingTag,
                SecondLimitingTag = secondLimitingTag,
                ThirdLimitingTag = thirdLimitingTag,
                FourthLimitingTag = fourthLimitingTag,
                LowLimit1Tag = lowLimit1Tag,
                LowLimit2Tag = lowLimit2Tag,
                LowLimit3Tag = lowLimit3Tag,

                Comment = comment,
                EnumOverLimitComputeType = OverLimitComputeTypeEnum.Realtime,
                OverLimitComputeType = 1
            };
            return overLimitConfig;
        }
コード例 #27
0
        private void CalcAlarm(OverLimitConfigEntity faultConfiguration, List<TagValue> tagAttributeList)
        {
            double high1, high2, high3, high4;
            double low1, low2, low3;
            high1 = double.MaxValue;
            high2 = double.MaxValue;
            high3 = double.MaxValue;
            high4 = double.MaxValue;
            low1 = double.MinValue;
            low2 = double.MinValue;
            low3 = double.MinValue;

            if (tagAttributeList.Count <= 0) return;
            if (faultConfiguration.LowLimit1Value != null) low1 = Convert.ToDouble(faultConfiguration.LowLimit1Value.Value);//低1限值
            if (faultConfiguration.LowLimit2Value != null) low2 = Convert.ToDouble(faultConfiguration.LowLimit2Value.Value);//低2限值
            if (faultConfiguration.LowLimit3Value != null) low3 = Convert.ToDouble(faultConfiguration.LowLimit3Value.Value);//低3限值

            if (faultConfiguration.FirstLimitingValue != null) high1 = Convert.ToDouble(faultConfiguration.FirstLimitingValue.Value);//高1限值
            if (faultConfiguration.SecondLimitingValue != null) high2 = Convert.ToDouble(faultConfiguration.SecondLimitingValue.Value);//高2限值
            if (faultConfiguration.ThirdLimitingValue != null) high3 = Convert.ToDouble(faultConfiguration.ThirdLimitingValue.Value);//高3限值
            if (faultConfiguration.FourthLimitingValue != null) high4 = Convert.ToDouble(faultConfiguration.FourthLimitingValue.Value);//高4限值

            if (high4 != double.MaxValue) H4(faultConfiguration, tagAttributeList, high4);
            if (high3 != double.MaxValue) H3(faultConfiguration, tagAttributeList, high3, high4);
            if (high2 != double.MaxValue) H2(faultConfiguration, tagAttributeList, high2, high3);
            if (high1 != double.MaxValue) H1(faultConfiguration, tagAttributeList, high1, high2);
            if (low1 != double.MinValue) L1(faultConfiguration, tagAttributeList, low2, low1);
            if (low2 != double.MinValue) L2(faultConfiguration, tagAttributeList, low3, low2);
            if (low3 != double.MinValue) L3(faultConfiguration, tagAttributeList, low3);

            //tagAttributeList = tagAttributeList.OrderBy(p => p.TimeStamp).ToList<TagValue>();
            //超高4
            /*var q = (from p in tagAttributeList where p.TagDoubleValue > high4 select p);
            if (q.Count() > 0) {
                H4(faultConfiguration, tagAttributeList, high4);
            }
            //超高3
            q = (from p in tagAttributeList where p.TagDoubleValue > high3 && p.TagDoubleValue <= high4 select p);
            if (q.Count() > 0) {
                H3(faultConfiguration, tagAttributeList, high3, high4);
            }

            //超高2
            q = (from p in tagAttributeList where p.TagDoubleValue > high2 && p.TagDoubleValue <= high3 select p);
            if (q.Count() > 0) {
                H2(faultConfiguration, tagAttributeList, high2, high3);
            }

            //超高1
            q = (from p in tagAttributeList where p.TagDoubleValue > high1 && p.TagDoubleValue <= high2 select p);
            if (q.Count() > 0) {
                H1(faultConfiguration, tagAttributeList, high1, high2);
            }

            //超低1
            q = (from p in tagAttributeList where p.TagDoubleValue >= low2 && p.TagDoubleValue < low1 select p);
            if (q.Count() > 0) {
                L1(faultConfiguration, tagAttributeList, low2, low1);
            }

            //超低2
            q = (from p in tagAttributeList where p.TagDoubleValue >= low3 && p.TagDoubleValue < low2 select p);
            if (q.Count() > 0) {
                L2(faultConfiguration, tagAttributeList, low3, low2);
            }

            //超低3
            q = (from p in tagAttributeList where p.TagDoubleValue < low3 select p);
            if (q.Count() > 0) {
                L3(faultConfiguration, tagAttributeList, low3);
            }*/
        }