Exemple #1
0
      // 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");
          }
      }
Exemple #2
0
 public SensorHub(SensorsDBContext sensorsDBContext, IOptions <RaspberryPiSettings> raspberryPiSettings, ISensorService sensorService, ILedService ledService)
 {
     context  = sensorsDBContext;
     settings = raspberryPiSettings.Value;
     sensor   = sensorService;
     led      = ledService;
 }
Exemple #3
0
 public void Run(ILedService ledService)
 {
     _ledService = ledService;
     _timer = new Timer(Tick);
     GC.KeepAlive(_timer);
     _timer.Change(200, LedConstants.TICK_EVERY_MILISEC);
 }
Exemple #4
0
 public void Run(ILedService ledService)
 {
     _ledService = ledService;
     _timer      = new Timer(Tick);
     GC.KeepAlive(_timer);
     _timer.Change(200, LedConstants.TICK_EVERY_MILISEC);
 }
Exemple #5
0
 public PiController(ILogger <PiController> logger, ILedService ledService)
 {
     _logger     = logger;
     _ledService = ledService;
 }
Exemple #6
0
 public void Add(ILedService ledService)
 {
     _ledServices.Add(ledService);
 }
Exemple #7
0
 public DeviceEventHandler(IApiService api, ILedService surface)
 {
     this.api     = api;
     this.surface = surface;
     surface.LoadDevices(Provider);
 }
Exemple #8
0
 public CorsairDeviceHandler(IApiService api, ILedService surface) : base(api, surface)
 {
 }
Exemple #9
0
 public LedController(ILedService ledService, IAuthenticationService authenticationService, IHubContext <LedConfigHub> ledConfigHub)
 {
     _ledService            = ledService;
     _authenticationService = authenticationService;
     _ledConfigHub          = ledConfigHub;
 }
Exemple #10
0
 public void Add(ILedService ledService)
 {
     _ledServices.Add(ledService);
 }