public IRControlService(IIRSlingerCsharp irService, IACDeviceService acDeviceService, IHostDeviceService hostDeviceService) { _irService = irService; _currentAcDevice = acDeviceService.GetCurrentDevice(); _hostDevice = hostDeviceService.GetCurrentDevice(); }
public AcDeviceDto SetCurrentDevice(int id) { var newDevice = _acDeviceRepository.Find(x => x.Id.Equals(id)).SingleOrDefault(); _acDeviceRepository.CurrentDevice = newDevice ?? throw new ItemNotFoundException($"AcDevice with id {id} not found!"); if (_currentDevice != null) { _currentDevice.OnChanged -= _currentDevice_OnChanged; } _currentDevice = newDevice; return(new AcDeviceDto(_currentDevice)); }
private int AddDevice(IACDevice device) { if (device == null) { throw new ArgumentNullException(nameof(device)); } var currentDevices = _acDeviceRepository.Find(x => x.Id.Equals(device.Id) || x.Model.Equals(device.Model) && x.Brand.Equals(device.Brand)); if (currentDevices.Any()) { throw new ItemAlreadyExistsException(); } return(_acDeviceRepository.Add(device)); }
public ACScheduleService(IACScheduleRepository scheduleRepository, IACStateControlService stateControlService, IACDeviceService acDeviceService, ILogger <ACScheduleService> logger) { _acStateControlService = stateControlService; _logger = logger; _scheduleRepository = scheduleRepository; _currentAcDevice = acDeviceService.GetCurrentDevice(); try { if (_isFirstInstance) { RegisterAllSchedulesFromRepository(); } _isFirstInstance = false; } catch (CurrentACDeviceNotSetException) { } }
public CodeRecordingService(IACDeviceService acDeviceService, IHostDeviceService hostDeviceService, ILogger <CodeRecordingService> logger) { _logger = logger; _currentAcDevice = acDeviceService.GetCurrentDevice(); var currentRaspberryPiDevice = hostDeviceService.GetCurrentDevice(); try { _inputPin = Pi.Gpio.Pins.Single(x => x.HeaderPinNumber == currentRaspberryPiDevice.BoardInPin); _inputPin.PinMode = GpioPinDriveMode.Input; } catch (Exception e) { _logger.LogError(e.Message); _logger.LogError(e.InnerException.InnerException.Message); } }
public IACDevice GetCurrentDevice() { if (_currentDevice != null) { return(_currentDevice); } _currentDevice = _acDeviceRepository.CurrentDevice; if (_currentDevice == null) { return(_currentDevice); } _currentDevice.OnChanged += _currentDevice_OnChanged; return(_currentDevice); }
public AcDeviceDto(IACDevice acDevice) { Id = acDevice.Id; Model = acDevice.Model; Brand = acDevice.Brand; }
public ACStateControlService(IIRControlService irControlService, IACDeviceService acDeviceService) { _irControlService = irControlService; _currentAcDevice = acDeviceService.GetCurrentDevice(); }
public ACSettingsService(IACDeviceService acDeviceService, ICodeRecordingService codeRecordingService) { _codeRecordingService = codeRecordingService; _currentAcDevice = acDeviceService.GetCurrentDevice(); }