Added NightAlert project for travel kit

This commit is contained in:
2021-06-10 14:39:06 -04:00
commit d38d9e3b7e
308 changed files with 35922 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NightScout
{
public class NightscoutAlerter
{
public INightscoutDataSource DataSource { get; set; }
public IAlerter Alerter { get; set; }
public DateTime LastDataUpdateReceived { get; set; }
public NightscoutAlerter(INightscoutDataSource dataSource, IAlerter alerter)
{
DataSource = dataSource;
Alerter = alerter;
SetupEvents();
}
private void SetupEvents()
{
DataSource.Connected += () => DataSource.Authorize();
DataSource.Alarm += (alarm) => Alerter.StartAlert();
DataSource.UrgentAlarm += (alarm) => Alerter.StartUrgentAlert();
DataSource.ClearAlarm += (alarm) => Alerter.StopAlerts();
DataSource.StaleDataAlarm += () => Alerter.StartStaleDataAlert();
//DataSource.DataUpdate += DataSource_DataUpdate;
}
void DataSource_DataUpdate(object obj)
{
Console.WriteLine(obj);
}
}
}