private void UserControl_Loaded(object sender, RoutedEventArgs e) { if (Tag != null) { Cmd[] cmd = (Tag as Eqlogic).cmds; // Cmd commande = cmd.GetCmd("enable"); Binding tmpBinding = new Binding() { Converter = new AlarmToImageConverter() }; tmpBinding.Source = cmd.GetCmd("enable").state; AlarmStatus.SetBinding(Image.SourceProperty, tmpBinding); Binding tmp2Binding = new Binding() { Converter = new StatusToImageConverter() }; tmp2Binding.Source = cmd.GetCmd("immediatState").state; ImmediatStatus.SetBinding(Image.SourceProperty, tmp2Binding); Binding tmp3Binding = new Binding() { Converter = new StatusToImageConverter() }; tmp3Binding.Source = cmd.GetCmd("state").state; StatutStatus.SetBinding(Image.SourceProperty, tmp3Binding); } }
public GetAlarmItemsResult GetAlarmItems(AlarmStatus status, MongodbAdminConfigurationItem admin, int pageSize, int pageIndex) { try { var databases = admin.MongodbAdminDatabaseConfigurationItems.Values.Select(b => b.DatabasePrefix).Distinct().ToList(); var tables = admin.MongodbAdminDatabaseConfigurationItems.Values.SelectMany(b => b.MongodbAdminTableConfigurationItems).Select(c => c.Value.TableName).Distinct().ToList(); GetAlarmItemsResult r = new GetAlarmItemsResult(); var dbContextFactory = LocalServiceLocator.GetService<IDbContextFactory>(); using (var context = dbContextFactory.CreateContext<AlarmDbContext>()) { var q = context.AlarmItems.Where(_ => _.AlarmStatusId == (int)status); if (!databases.Contains("*")) q = q.Where(_ => databases.Contains(_.AlarmDatabaseName)); if (!tables.Contains("*")) q = q.Where(_ => tables.Contains(_.AlarmTableName)); r.Count = q.Count(); r.Data = q.OrderByDescending(_ => _.OpenTime) .Skip(pageIndex * pageSize).Take(pageSize).ToList(); return r; } } catch (Exception ex) { ex.Handle("GetAlarmItems"); throw; } }
public static FakeAlarm GetAlarm(AlarmStatus status = default(AlarmStatus), Guid id = default(Guid)) { var alarm = Substitute.For<FakeAlarm>(); alarm.Id = id == default(Guid) ? Guid.NewGuid() : id; alarm.Status = status; return alarm; }
public GetAlarmItemsResult GetAlarmItems(AlarmStatus status, MongodbAdminConfigurationItem admin, int pageSize, int pageIndex) { try { var databases = admin.MongodbAdminDatabaseConfigurationItems.Values.Select(b => b.DatabasePrefix).Distinct().ToList(); var tables = admin.MongodbAdminDatabaseConfigurationItems.Values.SelectMany(b => b.MongodbAdminTableConfigurationItems).Select(c => c.Value.TableName).Distinct().ToList(); GetAlarmItemsResult r = new GetAlarmItemsResult(); var dbContextFactory = LocalServiceLocator.GetService <IDbContextFactory>(); using (var context = dbContextFactory.CreateContext <AlarmDbContext>()) { var q = context.AlarmItems.Where(_ => _.AlarmStatusId == (int)status); if (!databases.Contains("*")) { q = q.Where(_ => databases.Contains(_.AlarmDatabaseName)); } if (!tables.Contains("*")) { q = q.Where(_ => tables.Contains(_.AlarmTableName)); } r.Count = q.Count(); r.Data = q.OrderByDescending(_ => _.OpenTime) .Skip(pageIndex * pageSize).Take(pageSize).ToList(); return(r); } } catch (Exception ex) { ex.Handle("GetAlarmItems"); throw; } }
/// <summary> /// Set alarm clock for Band. /// </summary> /// <param name="status"></param> /// <param name="alarmSlot"></param> /// <param name="alarmDays"></param> /// <param name="hour"></param> /// <param name="minute"></param> /// <returns></returns> public async Task <bool> SetAlarmClock(AlarmStatus status, int alarmSlot, List <AlarmDays> alarmDays, int hour, int minute) { GattCharacteristic notificationCharacteristic = await Gatt.GetCharacteristicByServiceUuid(MIBAND3_SERVICE, CONFIGURATION_CHARACTERISTIC); int maxAlarmSlots = 5; int days = 0; if (alarmSlot >= maxAlarmSlots) { Debug.WriteLine("Only 5 slots for alarms available. Saving to 0 slot."); alarmSlot = 0; } if (alarmDays.Count == 0) { Debug.WriteLine("alarmDays is empty. Setting alarm once."); days = 128; } else { foreach (var day in alarmDays) { days += (int)day; } } Debug.WriteLine($"Setting alarm clock at {hour}:{minute} to slot {alarmSlot}"); byte[] setAlarmCmd = new byte[] { 0x2, (byte)(status + alarmSlot), (byte)hour, (byte)minute, (byte)days }; return(await notificationCharacteristic.WriteValueAsync(setAlarmCmd.AsBuffer()) == GattCommunicationStatus.Success); }
public static void AlarmStart(object o) { if (!Annunciators.Contains(o)) { Annunciators.Add(o); lock (Key) { if (!Alarm) { Alarm = true; Task.Run(() => { while (App.Live && Alarm) { using (var sound = new SoundPlayer(Properties.Resources.alarm)) { sound.PlaySync(); } } }); Task.Run(() => AlarmStatus?.Invoke(true)); } } } }
public static FakeAlarm GetAlarm(AlarmStatus status = default(AlarmStatus), Guid id = default(Guid)) { var alarm = Substitute.For <FakeAlarm>(); alarm.Id = id == default(Guid) ? Guid.NewGuid() : id; alarm.Status = status; return(alarm); }
private void HandleAlarmTelemetry(AlarmUpdated alarmTelemetry) { if (alarmStatus != alarmTelemetry.Status) { alarmStatus = alarmTelemetry.Status; UpdateCurrentStatus(); } }
/// <summary> /// Constructor for the struct /// </summary> /// <param name="Display">display string</param> /// <param name="status">status from enum</param> /// <param name="time">DateTime</param> public Alarm(string Display, AlarmStatus status, DateTime time, AlarmTone alarmTone, uint snoozeLength) : this() { DateTime = time; DisplayString = Display; AlarmStatus = status; SnoozeLength = snoozeLength; AlarmTone = alarmTone; }
private void TestIsWorthShowing(AlarmStatus status, bool isFresh, bool expectSuccess) { dateTimeProvider.Now.Returns(SAMPLE_DATETIME); alarm.SetTime(isFresh ? SAMPLE_DATETIME : SAMPLE_DATETIME.AddMinutes(-(SAMPLE_FRESHNESS + 1))); alarm.Status = status; Assert.AreEqual(expectSuccess, this.condition.Match(alarm)); }
/// <summary> /// Fires a change of the alarm status. /// </summary> /// <param name="severity">New alarm severity</param> /// <param name="status">New alarm status</param> public void TriggerAlarm(AlarmSeverity severity, AlarmStatus status) { if (CurrentAlarmSeverity != severity) { CurrentAlarmSeverity = severity; AlarmStatus = status; } }
/// <summary> /// 重置 /// </summary> public void Reset() { mAlarmStatus = AlarmStatus.Unknown; mLastAlarmLevel = AlarmLevel.Unknown; mCurrentAlarmLevel = AlarmLevel.Unknown; mReadyAlarmNum = 0; mIsRecord = false; mIsTimeout = false; }
public ShowItem(Item item, AlarmStatus alarmStatus) { this.item = item; this.Dock = DockStyle.None; InitializeComponent(); populateItem(item); setAlarm(alarmStatus); checkCriteria(item.ID); }
public ShowItemWithDelete(Item item, AlarmStatus alarmStatus, SettingsPanel settingPanel) { this.item = item; this.settingPanel = settingPanel; this.Dock = DockStyle.None; InitializeComponent(); populateItem(item); setAlarm(alarmStatus); checkCriteria(item.ID); }
public void WriteToVoiceFile(ClimateData[] climateDataObjecsToFile, AlarmStatus alarmData) { FileStream fstream = new FileStream(VoiceFile, FileMode.Truncate); string fileContent = ClimateStatusCheck(climateDataObjecsToFile, alarmData); byte[] info = new UTF8Encoding(true).GetBytes(fileContent); fstream.Write(info, 0, fileContent.Length); fstream.Dispose(); }
protected override void Start() { base.Start(); curHealth = maxHealth; AlarmStatus = transform.GetChild(0).gameObject; myAnimator = gameObject.GetComponent <Animator>(); alarmStatusScript = alarmStatus.GetComponent <AlarmStatus>(); gun = shootPointLeft; //Left is the default state of the gun }
private void setAlarm(AlarmStatus alarmStatus) { if (alarmStatus == AlarmStatus.Warning) { alarmPictureBox.Visible = true; //alarmPictureBox.Image = Properties.Resources.Bullet_RedFlashing; } else if (alarmStatus == AlarmStatus.Danger) { alarmPictureBox.Visible = true; alarmPictureBox.Image = Properties.Resources.Bullet_RedFlashing; } }
/// <summary> /// Handles user response to alarm /// </summary> /// <param name="s">AlarmStatus determined by user selection</param> /// <param name="index">index of alarm to be quieted</param> public void QuietAlarm(AlarmStatus s, int index) { switch (s) { case AlarmStatus.Stopped: model.QuietAlarm(index, false); break; case AlarmStatus.Snoozed: model.QuietAlarm(index, true); break; } observer(AppState.LISTENING, -1); }
private void SetAlarmStatusColor() { if (Acknowledged) { if (Active) { AlarmStausColor = AlarmStatus.BlueAcknowledgedActive; } } else { AlarmStausColor = Active ? AlarmStatus.RedUnAcknowledgedActive : AlarmStatus.GreenUnAcknowledgedInActive; } }
public static async Task <bool> UpdateAlarmState(string key, AlarmStatus alarmStatus, string msg) { //Get authentication of not bool isSuccess = false; if (!IsConnected) { await Connect(); } client = new HttpClient(); client.BaseAddress = new Uri(TelitUrl); var getThingsRequest = new { auth = new { sessionId = SessionRef }, things = new { command = "alarm.publish", @params = new { thingKey = key, key = "on", state = alarmStatus, msg = msg } } }; HttpResponseMessage responseMessage = await client.PostAsJsonAsync(TelitUrl, getThingsRequest); if (responseMessage.IsSuccessStatusCode) { var status = responseMessage.Content.ReadAsAsync <Alarm.RootObject>().Result; if (status != null && status.things != null && status.things.success) { isSuccess = status.things.success; } else { isSuccess = status.things.success; } } return(isSuccess); }
internal void SetStatus(AlarmStatus status) { if (status == Status) { return; } switch (status) { case AlarmStatus.Canceled: if (!CanBeCanceled) { throw new InvalidStateException(); } break; case AlarmStatus.Completed: if (!CanBeCompleted) { throw new InvalidStateException(); } break; case AlarmStatus.Ringing: if (!CanBeRinging) { throw new InvalidStateException(); } break; case AlarmStatus.Set: if (!CanBeSet) { throw new InvalidStateException(); } break; case AlarmStatus.Missed: if (!CanBeMissed) { throw new InvalidStateException(); } break; default: throw new InvalidProgramException("Unknown state: " + Status); } Status = status; }
public static string GetStatus() { WebRequest req = System.Net.WebRequest.Create(baseAddress + "Status"); HttpWebResponse resp = req.GetResponse() as HttpWebResponse; System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream()); String json; using (var reader = new StreamReader(resp.GetResponseStream(), Encoding.UTF8)) { json = reader.ReadToEnd(); } AlarmStatus status = JsonConvert.DeserializeObject <AlarmStatus>(json); return("Arm: " + status.Armed + " alm: " + status.InAlarm); }
public static void AlarmStop(object o = null) { if (o != null) { Annunciators = Annunciators.Where(a => a != o).ToList(); if (Annunciators.Count > 0) { return; } } else { Annunciators = new List <object>(); } Alarm = false; Task.Run(() => AlarmStatus?.Invoke(false)); }
private async Task CreateSensorAlarm(Sensor sensor, AlarmStatus alarmStatus, bool singleton = false) { if (singleton) { var existingAlarm = await _sensorAlarmRepository.GetBySensorBoxIdAndSensorTypeAndStatusAsync(sensor.BoxId, sensor.Type, alarmStatus); if (existingAlarm != null) { return; } } var sensorAlarm = new SensorAlarm { SensorBoxId = sensor.BoxId, SensorType = sensor.Type, Status = alarmStatus }; await _sensorAlarmRepository.InsertAsync(sensorAlarm); }
private IEnumerator ChangeVolume(int startValue, int endValue, AlarmStatus alarmStatus) { float time = 0; if (alarmStatus == AlarmStatus.On) { _tune.Play(); } while (time < 1) { float volumeValue = Mathf.Lerp(startValue, endValue, time / 1); time += Time.deltaTime; _tune.volume = volumeValue; yield return(null); } if (alarmStatus == AlarmStatus.Off) { _tune.Stop(); } }
public void setCurrentAlarmStatus() { if (curve.Evaluate(problemPercentage()) * 100 < 25) { alarmStatus = AlarmStatus.Critical; } else if (curve.Evaluate(problemPercentage()) * 100 < 50) { alarmStatus = AlarmStatus.Caution; } else if (curve.Evaluate(problemPercentage()) * 100 >= 75) { alarmStatus = AlarmStatus.Safe; } image.color = colors[(int)alarmStatus]; lightingImage.color = new Color(colors[(int)alarmStatus].r, colors[(int)alarmStatus].g, colors[(int)alarmStatus].b, lightingImage.color.a); float x = Mathf.Abs(lightSize * Mathf.Sin(Time.timeSinceLevelLoad * lightSpeed) + startingScalex); //float y = lightSize * Mathf.Sin(Time.timeSinceLevelLoad); float y = Mathf.Abs(lightSize * Mathf.Sin(Time.timeSinceLevelLoad * lightSpeed) + startingScaley); lightingImage.rectTransform.localScale = new Vector3(x, y); }
private static string ClimateStatusCheck(ClimateData[] climateDataObjecsToFile, AlarmStatus alarmData) { string fileContent = ""; fileContent += "Velkommen " + alarmData.Name; fileContent += Environment.NewLine; fileContent += Environment.NewLine; fileContent += "klokken er.! " + DateTime.Now.ToString("HH:mm"); fileContent += Environment.NewLine; fileContent += "Utfører system sjekk !."; for (int i = 0; i < climateDataObjecsToFile.Length; i++) { if (climateDataObjecsToFile[i].Temperature > 22 && climateDataObjecsToFile[i].Temperature > 0) { fileContent += climateDataObjecsToFile[i].Location; fileContent += " "; fileContent += " " + climateDataObjecsToFile[i].Temperature + " grader!. for varmt!"; fileContent += Environment.NewLine; } else if (climateDataObjecsToFile[i].Temperature < 18 && climateDataObjecsToFile[i].Temperature > 0) { fileContent += climateDataObjecsToFile[i].Location; fileContent += " "; fileContent += " " + climateDataObjecsToFile[i].Temperature + " grader!. for kaldt!"; fileContent += Environment.NewLine; } else if (climateDataObjecsToFile[i].Humidity > 55 && climateDataObjecsToFile[i].Humidity > 0) { fileContent += climateDataObjecsToFile[i].Location; fileContent += " "; fileContent += " " + " Foktighetsnivå høy!" + climateDataObjecsToFile[i].Humidity; fileContent += Environment.NewLine; } else if (climateDataObjecsToFile[i].Humidity < 35 && climateDataObjecsToFile[i].Humidity > 0) { fileContent += climateDataObjecsToFile[i].Location; fileContent += " "; fileContent += " " + " Foktighetsnivå lav!" + climateDataObjecsToFile[i].Humidity; fileContent += Environment.NewLine; } else { fileContent += climateDataObjecsToFile[i].Location; fileContent += " OK. "; } } return(fileContent); }
public async Task <IActionResult> FilterAlarm([FromBody] AlarmRequest alarmRequest) { var snmpReciverList = await this.alarmRepo.GetFilteredSNMPReceiverHistory(AlarmStatus.GetStatusCode(alarmRequest.StatusCode), alarmRequest.FromDate, alarmRequest.ToDate, alarmRequest.MaxAlarmID); var siteList = await this.siteRepo.GetSiteListFiltered(int.Parse(alarmRequest.Filter), alarmRequest.SiteName); int priority = alarmRequest.Priority.Equals("All", StringComparison.InvariantCultureIgnoreCase) ? 0 : int.Parse(alarmRequest.Priority); return(Ok(await SNMPHistoryMapping.DoMapping(siteList, snmpReciverList, priority, alarmRequest.PageIndex, alarmRequest.PageSize, alarmRequest.Trap, alarmRequest.SortField, alarmRequest.SortDirection))); }
private void AlarmPanelStatusChanged(AlarmStatus stat) { _log.Debug("AlarmPanelStatusChanged" + stat); byte num = 0; switch (stat) { case AlarmStatus.UnArmed: num = 6; break; case AlarmStatus.Armed: num = 7; break; case AlarmStatus.Alarm: num = 9; break; } send_StateRequest(num); }
/// <summary> /// 历史回放模式 /// </summary> //public bool HistoryMode { get; set; } bool RefreshState(NEWTRACK gps, string fieldName = null, bool noWeb = false) { if (gps == null) { return(false); } CarStatus.RefreshStatus(gps.STATUS, gps.STOPTIME); //车辆状态 OnPropertyChanged(nameof(CarStatus), true); AlarmStatus.RefreshAlarmStatus(gps.ALARM); OnPropertyChanged(nameof(AlarmStatus), true); if (gps.IsRealTime || _isCopy || (!gps.IsRealTime && !_isCopy)) { //在线或者历史回放状态刷新 if (!_isCopy && (CarStatus.offline == true || !gps.IsRealTime)) { //车辆下线 CarState = CarState.OffLine; } else { //在线状态下 if (AlarmStatus.HasAlarm) { //报警状态 CarState = CarState.Alarm; if (!_isCopy) { OnHaveNewAlarm(AlarmType.Normal); //新的报警 } } else if (gps.LOCATE != 1) //不定位 { CarState = CarState.NoGps; } else if (gps.SPEED >= 3) //行驶中 { CarState = CarState.Run; } else { //速度小于3km/h 认定为停车(可去除部分漂移) CarState = CarState.Stop; } } } else { //不在线状态判断 CarState = CarState.OffLine; } if (noWeb) { return(true); } if (!gps.IsRealTime) { return(true); } if (CarStatus.blindarea_status) { return(true); } if (!NEWTRACK.IsWebPosition) { return(true); } if (!IsInView) { return(true); } if (!GPSTool.CheckLaLo(gps.LATITUDE, gps.LONGITUDE)) { return(true); } GeoLatLng geo = GPSTool.wgs84togcj02(gps.LONGITUDE, gps.LATITUDE); geo.longitude = Math.Round(geo.longitude, 6); geo.latitude = Math.Round(geo.latitude, 6); Common_liby.InvokeMethodOnMainThread(() => { HtmlPage.Window.Invoke("GetWebPosition", geo.longitude, geo.latitude, MAC); }); return(false); }
public async Task <SensorAlarm> GetBySensorBoxIdAndSensorTypeAndStatusAsync(string sensorBoxId, SensorType sensorType, AlarmStatus status) { var table = _client.GetTableClient(_tableName); await table.CreateIfNotExistsAsync(); var sensorTypeString = sensorType.ToString("G"); var alarmStatusString = status.ToString("G"); var entityPages = table.QueryAsync <TableEntity>($"{nameof(TableEntity.PartitionKey)} eq '{sensorBoxId}' and {nameof(SensorAlarm.SensorType)} eq '{sensorTypeString}' and {nameof(SensorAlarm.Status)} eq '{alarmStatusString}'"); return((await entityPages.AsPages().FirstOrDefaultAsync())?.Values.Select(SensorAlarmMapper.Map).FirstOrDefault()); }
/// <summary> /// 单个告警处理 /// </summary> private void SubProcessSeletionAlarm(SelectionAlarmType alarmType, Selection select) { AlarmConfigData alarmSet; AlarmInfo info; float temperature; switch (alarmType) { case SelectionAlarmType.MaxTemp: alarmSet = select.mAlarmConfig.mMaxTempConfig; temperature = select.mTemperatureData.mMaxTemperature; info = select.mAlarmInfo.mMaxTempAlarmInfo; break; case SelectionAlarmType.MinTemp: alarmSet = select.mAlarmConfig.mMinTempConfig; temperature = select.mTemperatureData.mMinTemperature; info = select.mAlarmInfo.mMinTempAlarmInfo; break; case SelectionAlarmType.AvgTemp: alarmSet = select.mAlarmConfig.mAvgTempConfig; temperature = select.mTemperatureData.mAvgTemperature; info = select.mAlarmInfo.mAvgTempAlarmInfo; break; default: return; } AlarmStatus lastStatus = info.mAlarmStatus; info.mLastAlarmLevel = info.mCurrentAlarmLevel; CalcAlarmInfo(alarmSet, temperature, info); ProcessAlarmReadyEnd(alarmSet, temperature, info); if (info.mAlarmStatus == AlarmStatus.AlarmStart) { info.mAlarmStatus = AlarmStatus.Alarming; // 添加告警 string selectionData = select.Serialize(); string temperatureInfo = JsonUtils.ObjectToJson(select.mTemperatureData); // 阈值设置序列化 string condition = string.Format("{0},{1},{2}", alarmSet.mGeneralThreshold, alarmSet.mSeriousThreshold, alarmSet.mCriticalThreshold); List <Selection> list = new List <Selection>() { select }; // 记录告警开始时间 info.mBeginTime = DateTime.Now; info.mIsTimeout = false; // 告警入库 OnAddAlarmInfo?.Invoke( (int)AlarmMode.Selection, (int)alarmType, (int)alarmSet.mAlarmReason, (int)info.mCurrentAlarmLevel, condition, temperature, select.mSelectionId, select.mSelectionName, selectionData, temperatureInfo, mMaxTemperature, mMinTemperature, list, info); } else if (info.mAlarmStatus == AlarmStatus.AlarmEnd) { info.mAlarmStatus = AlarmStatus.Unknown; // 结束告警 string selectionData = select.Serialize(); OnUpdateAlarmInfo?.Invoke( (int)AlarmMode.Selection, (int)alarmType, select.mSelectionId, selectionData, info); // 取消超时 info.mIsTimeout = true; } else if (info.mAlarmStatus == AlarmStatus.AlarmingChanged) { // 结束上一次告警 string selectionData = select.Serialize(); OnUpdateAlarmInfo?.Invoke( (int)AlarmMode.Selection, (int)alarmType, select.mSelectionId, selectionData, info); string temperatureInfo = JsonUtils.ObjectToJson(select.mTemperatureData); List <Selection> list = new List <Selection>() { select }; // 阈值设置序列化 string condition = string.Format("{0},{1},{2}", alarmSet.mGeneralThreshold, alarmSet.mSeriousThreshold, alarmSet.mCriticalThreshold); // 记录告警开始时间 info.mBeginTime = DateTime.Now; info.mIsTimeout = false; info.mAlarmStatus = AlarmStatus.Alarming; OnAddAlarmInfo?.Invoke( (int)AlarmMode.Selection, (int)alarmType, (int)alarmSet.mAlarmReason, (int)info.mCurrentAlarmLevel, condition, temperature, select.mSelectionId, select.mSelectionName, selectionData, temperatureInfo, mMaxTemperature, mMinTemperature, list, info); } else if (((info.mAlarmStatus == AlarmStatus.Alarming) || (info.mAlarmStatus == AlarmStatus.AlarmingReadyChanged)) && (info.mIsTimeout == false)) { DateTime time = DateTime.Now; if ((time - info.mBeginTime).TotalMinutes >= mTimeout) { string selectionData = select.Serialize(); OnAlarmTimeout?.Invoke( (int)AlarmMode.Selection, (int)alarmType, select.mSelectionId, selectionData, info); info.mIsTimeout = true; } } }
/// <summary> /// 单个告警处理 /// </summary> private void SubProcessGroupAlarm( GroupAlarmType alarmType, SelectionGroup group) { AlarmConfigData alarmSet; AlarmInfo info; float temperature; switch (alarmType) { case GroupAlarmType.MaxTemperature: alarmSet = group.mAlarmConfig.mMaxTempConfig; temperature = group.mTemperatureData.mMaxTemperature; info = group.mAlarmInfo.mMaxTempAlarm; break; case GroupAlarmType.MaxTempRise: alarmSet = group.mAlarmConfig.mMaxTempeRiseConfig; temperature = group.mTemperatureData.mTemperatureRise; info = group.mAlarmInfo.mMaxTempRiseAlarmInfo; break; case GroupAlarmType.MaxTempDif: alarmSet = group.mAlarmConfig.mMaxTempDifConfig; temperature = group.mTemperatureData.mTemperatureDif; info = group.mAlarmInfo.mMaxTempDifAlarmInfo; break; case GroupAlarmType.RelativeTempDif: alarmSet = group.mAlarmConfig.mRelativeTempDifConfig; temperature = group.mTemperatureData.mRelTemperatureDif; info = group.mAlarmInfo.mRelativeTempDifAlarmInfo; break; default: return; } AlarmStatus lastStatus = info.mAlarmStatus; info.mLastAlarmLevel = info.mCurrentAlarmLevel; if ((alarmType == GroupAlarmType.MaxTemperature) || (alarmType == GroupAlarmType.RelativeTempDif)) { CalcAlarmInfo(alarmSet, temperature, info); } else { SpecialCalAlarmInfo(alarmSet, temperature, info); // 特殊处理组选区温升/温差 } if (alarmType == GroupAlarmType.MaxTemperature) { ProcessAlarmReadyEnd(alarmSet, temperature, info); } if (info.mAlarmStatus == AlarmStatus.AlarmStart) { info.mAlarmStatus = AlarmStatus.Alarming; // 添加告警 string groupData = group.Serialize(); string temperatureInfo = JsonUtils.ObjectToJson(group.mTemperatureData); // 阈值设置序列化 string condition = string.Format("{0},{1},{2}", alarmSet.mGeneralThreshold, alarmSet.mSeriousThreshold, alarmSet.mCriticalThreshold); // 记录告警开始时间 info.mBeginTime = DateTime.Now; info.mIsTimeout = false; // 告警入库 OnAddAlarmInfo?.Invoke( (int)AlarmMode.GroupSelection, (int)alarmType, (int)alarmSet.mAlarmReason, (int)info.mCurrentAlarmLevel, condition, temperature, group.mId, group.mGroupName, groupData, temperatureInfo, mMaxTemperature, mMinTemperature, group.mSelections, info); } else if (info.mAlarmStatus == AlarmStatus.AlarmEnd) { info.mAlarmStatus = AlarmStatus.Unknown; // 结束告警 string selectionData = group.Serialize(); OnUpdateAlarmInfo?.Invoke( (int)AlarmMode.GroupSelection, (int)alarmType, group.mId, selectionData, info); // 取消超时 info.mIsTimeout = true; } else if (info.mAlarmStatus == AlarmStatus.AlarmingChanged) { // 结束上一次告警 string selectionData = group.Serialize(); OnUpdateAlarmInfo?.Invoke( (int)AlarmMode.GroupSelection, (int)alarmType, group.mId, selectionData, info); string temperatureInfo = JsonUtils.ObjectToJson(group.mTemperatureData); // 阈值设置序列化 string condition = string.Format("{0},{1},{2}", alarmSet.mGeneralThreshold, alarmSet.mSeriousThreshold, alarmSet.mCriticalThreshold); // 记录告警开始时间 info.mBeginTime = DateTime.Now; info.mIsTimeout = false; info.mAlarmStatus = AlarmStatus.Alarming; OnAddAlarmInfo?.Invoke( (int)AlarmMode.GroupSelection, (int)alarmType, (int)alarmSet.mAlarmReason, (int)info.mCurrentAlarmLevel, condition, temperature, group.mId, group.mGroupName, selectionData, temperatureInfo, mMaxTemperature, mMinTemperature, group.mSelections, info); } else if ((info.mAlarmStatus == AlarmStatus.Alarming || info.mAlarmStatus == AlarmStatus.AlarmingReadyChanged) && (info.mIsTimeout == false)) { DateTime time = DateTime.Now; if ((time - info.mBeginTime).TotalMinutes >= mTimeout) { string selectionData = group.Serialize(); OnAlarmTimeout?.Invoke( (int)AlarmMode.GroupSelection, (int)alarmType, group.mId, selectionData, info); info.mIsTimeout = true; } } }