private void SetAlarm(AdsRuleSetting setting, double firedValue) { var counterKey = GetCounterKey(setting); var now = DateTimeProvider.Singleton.Time(); Func <string, PendingAlarm> addAlarmFunc = s => new PendingAlarm(now.Add(setting.Duration)); PendingAlarm alarm = _alarmThresholds.GetOrAdd(counterKey, addAlarmFunc); if (alarm.ThresholdTime <= now) { // sound the alarm string message = GetAlarmMessage(setting); setting.IsInFiredCondition = true; Log.To.Main.Add("ALARM - " + message); setting.AdsLastFired = new AdsRuleSetting.AdsRuleFiredDto { Fired = now, Value = firedValue }; _adsAlarmTrigger.Invoke(setting); // reset the alarm ResetAlarm(setting); // re-add the alarm; this counter measurement acts as new trigger _alarmThresholds.TryAdd(counterKey, addAlarmFunc(counterKey)); } }
private void ResetValidation(AdsRuleSetting setting, string key, PendingAlarm alarm) { // reset the alarm ResetAlarm(setting); // re-add the alarm; this counter measurement acts as new trigger _alarmThresholds.TryAdd(key, alarm); }
public void ForceResetTimer(DateTime utcTime) { _alarmThresholds[GetCounterKey(Settings)] = new PendingAlarm(utcTime.Add(Settings.Duration)); }