예제 #1
0
 public DiagnoseAlarmLevel?GetAlarmLevelByCode(DiagnoseModelBase model, DiagnoseEntity entity)
 {
     ////当为严重报警时
     if (Code == model.SeriousAlarmCode)
     {
         return(entity.SeriousAlarmLevel);
     }
     else if (Code == model.LightAlarmCode)
     {
         return(entity.LightAlarmLevel);
     }
     else
     {
         return(DiagnoseAlarmLevel.None);
     }
 }
예제 #2
0
        public static DiagnoseModelBase GetDiagnoseModelByType(DiagnoseModelType modelType)
        {
            DiagnoseModelBase diagnoseModel = null;

            switch (modelType)
            {
            case DiagnoseModelType.load_I_Ij:
                diagnoseModel = new Load_I_IjDiagnose();
                break;

            case DiagnoseModelType.load_I_Ir:
                diagnoseModel = new Load_I_IrDiagnose();
                break;

            case DiagnoseModelType.load_ID_Ij:
                diagnoseModel = new Load_ID_IjDiagnose();
                break;

            case DiagnoseModelType.load_ID_Ir:
                diagnoseModel = new Load_ID_IrDiagnose();
                break;

            case DiagnoseModelType.Iunbal:
                diagnoseModel = new IunbalDiagnose();
                break;

            case DiagnoseModelType.Aging:
                diagnoseModel = new AgingDiagnose();
                break;

            case DiagnoseModelType.PF:
                diagnoseModel = new PFDiagnose();
                break;

            case DiagnoseModelType.SDE_Trip:
                diagnoseModel = new SDE_TripDiagnose();
                break;

            case DiagnoseModelType.Sys_THDi:
                diagnoseModel = new Sys_THDiDiagnose();
                break;

            case DiagnoseModelType.Temp_delta:
                diagnoseModel = new Temp_deltaDiagnose();
                break;

            case DiagnoseModelType.THDi:
                diagnoseModel = new THDiDiagnose();
                break;

            case DiagnoseModelType.THDu:
                diagnoseModel = new THDuDiagnose();
                break;

            case DiagnoseModelType.Uhigh:
                diagnoseModel = new UhighDiagnose();
                break;

            case DiagnoseModelType.Ulow:
                diagnoseModel = new UlowDiagnose();
                break;

            case DiagnoseModelType.Uunbal:
                diagnoseModel = new UunbalDiagnose();
                break;

            case DiagnoseModelType.COSy:
                diagnoseModel = new COSyDiagnose();
                break;

            case DiagnoseModelType.F:
                diagnoseModel = new FDiagnose();
                break;
            }

            return(diagnoseModel);
        }
예제 #3
0
        private List <Alarm> CalculateDiagnoseData(IEnumerable <DiagnoseResult> diagnoseDataList, DiagnoseEntity diagnoseEntity, Alarm lastAlarm, ref DiagnoseResult firstNormalDataPoint, ref DateTime?abnormalTime)
        {
            // Get the attributes of the diagnose model
            DiagnoseModelBase diagnoseModel = DiagnoseModelFactory.GetDiagnoseModelByType(diagnoseEntity.DiagnoseModel);

            var   currentAlarmCode  = string.Empty;
            var   currentAlarmLevel = DiagnoseAlarmLevel.None;
            long? currentAlarmId    = diagnoseEntity.AlarmId;
            float?thresholdValue    = null;

            bool isNormalWithDeadArea = false;

            string currentHealthCode = string.Empty;

            var lastAlarmCode     = lastAlarm == null ? "" : lastAlarm.Code;
            var lastAlarmLevel    = lastAlarm == null ? (int)DiagnoseAlarmLevel.None : lastAlarm.Level;
            var lastAbnormalValue = lastAlarm == null ? 0 : string.IsNullOrEmpty(lastAlarm.ActualValue) ? 0 : double.Parse(lastAlarm.ActualValue);
            var maintenanceState  = this.alarmRepository.GetDeviceMaintenanceState(diagnoseEntity.DeviceId);
            var uom = diagnoseModel.GetUomsFromModel(diagnoseEntity.DiagnoseModel).FirstOrDefault();

            List <Alarm> newAlarms = new List <Alarm>();

            foreach (var diagnoseData in diagnoseDataList)
            {
                currentAlarmCode  = diagnoseData.Code ?? string.Empty;
                currentHealthCode = diagnoseData.Code ?? string.Empty;

                currentAlarmLevel    = diagnoseData.GetAlarmLevelByCode(diagnoseModel, diagnoseEntity).Value;
                isNormalWithDeadArea = diagnoseModel.JudgeValueWithDeadArea(diagnoseEntity.LowLimit, diagnoseEntity.HighLimit, diagnoseEntity.DeadArea, diagnoseData.Value, lastAbnormalValue, lastAlarmCode, currentAlarmCode);

                ////报警级别降低时,需要加入死区的判断,判断是否真的降低
                if ((int)currentAlarmLevel < lastAlarmLevel)
                {
                    if (isNormalWithDeadArea)
                    {
                        if (firstNormalDataPoint == null)
                        {
                            firstNormalDataPoint = new DiagnoseResult()
                            {
                                Code         = diagnoseData.Code,
                                Value        = diagnoseData.Value,
                                LocalTime    = diagnoseData.LocalTime,
                                Time         = diagnoseData.Time,
                                DiagnosticId = diagnoseData.DiagnosticId,
                                State        = diagnoseData.State
                            };
                        }
                        newAlarms.Clear();
                        //this.alarmRepository.ResetAlarm(diagnoseEntity.Id, diagnoseData.Value.ToString(), diagnoseData.LocalTime, "智能诊断自动恢复");  ////重置上一次的报警
                    }
                }

                ////报警级别真的发生变化,而且不为空(正常时),需要记录报警
                ////1. LowLevel->HighLevel, create anew HighLevel alarm 2. After Reset HighLevel, create a new Lowlevel alarm
                if (isNormalWithDeadArea)
                {
                    if (!string.IsNullOrEmpty(currentAlarmCode))
                    {
                        thresholdValue = diagnoseModel.GetThresholdValue(diagnoseEntity.HighLimit, diagnoseEntity.LowLimit, currentAlarmCode, diagnoseData.Value);
                        newAlarms.Add(new Alarm()
                        {
                            HierarchyId             = diagnoseEntity.DeviceId,
                            DeviceParameterUniqueId = diagnoseEntity.Id,
                            Code             = currentAlarmCode,
                            ActualValue      = diagnoseData.Value.ToString(),
                            ThresholdValue   = thresholdValue.HasValue ? thresholdValue.Value.ToString() : null,
                            AlarmTime        = diagnoseData.LocalTime,
                            Level            = (int)currentAlarmLevel,
                            Description      = diagnoseEntity.Name + "异常",
                            Uom              = uom,
                            AlarmType        = AlarmType.PopDiagnose,
                            MaintenanceState = maintenanceState,
                        });
                    }
                }
                else
                {
                    currentAlarmCode = lastAlarmCode;
                }

                abnormalTime  = CalculateNewAbnormTime(abnormalTime, diagnoseData);
                lastAlarmCode = currentAlarmCode;
            }
            return(newAlarms);
        }