// Normally I am not a fan of static functions, I did it here cuz Main doesn't have access to an instance of Program. // And honestly who cares what we're doin here in main anyways? the meat and potatoes are in the backend static void AttemptConnect(ILedService ledService, ILogger logger) { int retries = 5; while (retries > 0) { try { ledService.Connect(); break; } catch (Exception e) { logger.Warning($"Unable to connect to led device: {e.ToString()}"); retries--; // Prevent spamming; Thread.Sleep(500); } } if (retries == 0) { throw new Exception("Unable to connect to device, max retries reached"); } }
public SensorHub(SensorsDBContext sensorsDBContext, IOptions <RaspberryPiSettings> raspberryPiSettings, ISensorService sensorService, ILedService ledService) { context = sensorsDBContext; settings = raspberryPiSettings.Value; sensor = sensorService; led = ledService; }
public void Run(ILedService ledService) { _ledService = ledService; _timer = new Timer(Tick); GC.KeepAlive(_timer); _timer.Change(200, LedConstants.TICK_EVERY_MILISEC); }
public PiController(ILogger <PiController> logger, ILedService ledService) { _logger = logger; _ledService = ledService; }
public void Add(ILedService ledService) { _ledServices.Add(ledService); }
public DeviceEventHandler(IApiService api, ILedService surface) { this.api = api; this.surface = surface; surface.LoadDevices(Provider); }
public CorsairDeviceHandler(IApiService api, ILedService surface) : base(api, surface) { }
public LedController(ILedService ledService, IAuthenticationService authenticationService, IHubContext <LedConfigHub> ledConfigHub) { _ledService = ledService; _authenticationService = authenticationService; _ledConfigHub = ledConfigHub; }