Example #1
0
        public IRControlService(IIRSlingerCsharp irService, IACDeviceService acDeviceService, IHostDeviceService hostDeviceService)
        {
            _irService = irService;

            _currentAcDevice = acDeviceService.GetCurrentDevice();
            _hostDevice      = hostDeviceService.GetCurrentDevice();
        }
Example #2
0
        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));
        }
Example #3
0
        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));
        }
Example #4
0
        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) { }
        }
Example #5
0
        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);
            }
        }
Example #6
0
        public IACDevice GetCurrentDevice()
        {
            if (_currentDevice != null)
            {
                return(_currentDevice);
            }

            _currentDevice = _acDeviceRepository.CurrentDevice;

            if (_currentDevice == null)
            {
                return(_currentDevice);
            }

            _currentDevice.OnChanged += _currentDevice_OnChanged;
            return(_currentDevice);
        }
Example #7
0
 public AcDeviceDto(IACDevice acDevice)
 {
     Id    = acDevice.Id;
     Model = acDevice.Model;
     Brand = acDevice.Brand;
 }
 public ACStateControlService(IIRControlService irControlService, IACDeviceService acDeviceService)
 {
     _irControlService = irControlService;
     _currentAcDevice  = acDeviceService.GetCurrentDevice();
 }
Example #9
0
 public ACSettingsService(IACDeviceService acDeviceService, ICodeRecordingService codeRecordingService)
 {
     _codeRecordingService = codeRecordingService;
     _currentAcDevice      = acDeviceService.GetCurrentDevice();
 }