コード例 #1
0
        private AlarmRecordInfo getAlarmRecord(AlarmRuleInfo alarmRuleInfo, DjLiquidInfo liquidInfo)
        {
            if (null != alarmRuleInfo)
            {
                float     curValue  = float.Parse(liquidInfo.LIQUIDDATA);
                IDevice   deviceDal = SensorHub.DALFactory.Device.Create();
                IDjLiquid liquidDal = SensorHub.DALFactory.DjLiquid.Create();

                AlarmRecordInfo alarmRecordInfo = new AlarmRecordInfo();
                alarmRecordInfo.ACTIVE           = true;
                alarmRecordInfo.DEVICE_CODE      = liquidInfo.DEVID;
                alarmRecordInfo.DEVICE_ID        = alarmRuleInfo.DeviceId;
                alarmRecordInfo.DEVICE_TYPE_NAME = deviceDal.getDevTypeByCode(liquidInfo.DEVID);
                alarmRecordInfo.ITEMNAME         = "液位值";
                alarmRecordInfo.ITEMVALUE        = curValue.ToString();
                alarmRecordInfo.MESSAGE_STATUS   = 0;
                alarmRecordInfo.MESSAGE          = (int)LiquidAlarmEnum.OVER_THRESH + "";

                alarmRecordInfo.RECORDCODE = "";
                alarmRecordInfo.RECORDDATE = System.DateTime.Now;

                if (alarmRuleInfo.HighValue != null && curValue > alarmRuleInfo.HighValue)
                {
                    alarmRecordInfo.MESSAGE = (int)LiquidAlarmEnum.OVER_THRESH + "";
                    return(alarmRecordInfo);
                }

                if (alarmRuleInfo.Saltation != null)
                {
                    float lastData = liquidDal.getLastData(liquidInfo);
                    if (-1 != lastData && Math.Abs(curValue - lastData) > alarmRuleInfo.Saltation)
                    {
                        alarmRecordInfo.MESSAGE = "液位突变";
                        //   return alarmRecordInfo;
                        return(null);
                    }
                }
            }
            return(null);
        }