protected void InitializeHealthMonitor(int pi2GpioPinWithLed) { var pi2PortController = GpioController.GetDefault(); var ledPin = pi2PortController.OpenPin(pi2GpioPinWithLed); ledPin.SetDriveMode(GpioPinDriveMode.Output); HealthMonitor = new HealthMonitor(ledPin, Timer, HttpApiController); }
public Home(IHomeAutomationTimer timer, HealthMonitor healthMonitor, IWeatherStation weatherStation, IHttpRequestController httpApiController, INotificationHandler notificationHandler) { if (timer == null) throw new ArgumentNullException(nameof(timer)); if (httpApiController == null) throw new ArgumentNullException(nameof(httpApiController)); if (notificationHandler == null) throw new ArgumentNullException(nameof(notificationHandler)); Timer = timer; _healthMonitor = healthMonitor; WeatherStation = weatherStation; HttpApiController = httpApiController; NotificationHandler = notificationHandler; httpApiController.Handle(HttpMethod.Get, "configuration").Using(c => c.Response.Body = new JsonBody(GetConfigurationAsJSON())); httpApiController.Handle(HttpMethod.Get, "status").Using(HandleStatusRequest); httpApiController.Handle(HttpMethod.Get, "health").Using(c => c.Response.Body = new JsonBody(_healthMonitor.ApiGet())); }