Added NightAlert project for travel kit
This commit is contained in:
39
NightScout/NightscoutAlerter.cs
Normal file
39
NightScout/NightscoutAlerter.cs
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user