public void Create_ForInvokedWithCharacteristics_AddsDpg(
            DeskCharacteristicsCreator sut,
            IDeskCharacteristics characteristics,
            IDevice device,
            [Freeze] IDpg characteristic)
        {
            characteristics.WithCharacteristics(Arg.Any <DeskCharacteristicKey> ( ),
                                                Arg.Any <ICharacteristicBase> ( ))
            .Returns(characteristics);

            sut.Create(characteristics,
                       device);

            characteristics.Received( )
            .WithCharacteristics(DeskCharacteristicKey.Dpg,
                                 characteristic);
        }
        /// <inheritdoc />
        public void Create(
            IDeskCharacteristics characteristics,
            IDevice device)
        {
            Guard.ArgumentNotNull(device,
                                  nameof(device));
            Guard.ArgumentNotNull(characteristics,
                                  nameof(characteristics));

            _logger.Debug($"[{device.Id}] Creating desk characteristics {characteristics}");

            characteristics.WithCharacteristics(DeskCharacteristicKey.GenericAccess,
                                                _baseFactory.Create <IGenericAccess> (device))
            .WithCharacteristics(DeskCharacteristicKey.GenericAttribute,
                                 _baseFactory.Create <IGenericAttribute> (device))
            .WithCharacteristics(DeskCharacteristicKey.ReferenceInput,
                                 _baseFactory.Create <IReferenceInput> (device))
            .WithCharacteristics(DeskCharacteristicKey.ReferenceOutput,
                                 _baseFactory.Create <IReferenceOutput> (device))
            .WithCharacteristics(DeskCharacteristicKey.Dpg,
                                 _baseFactory.Create <IDpg> (device))
            .WithCharacteristics(DeskCharacteristicKey.Control,
                                 _baseFactory.Create <IControl> (device));
        }
Exemple #3
0
        public DeskConnector(
            [NotNull] ILogger logger,
            [NotNull] IScheduler scheduler,
            [NotNull] Func <ISubject <IEnumerable <byte> > > subjectFactory,
            [NotNull] ISubject <uint> subjectHeight,
            [NotNull] ISubject <int> subjectSpeed,
            [NotNull] ISubject <bool> subjectRefreshed,
            [NotNull] ISubject <HeightSpeedDetails> subjectHeightAndSpeed,
            [NotNull] IDevice device,
            [NotNull] IDeskCharacteristics deskCharacteristics,
            [NotNull] IDeskHeightAndSpeedFactory heightAndSpeedFactory,
            [NotNull] IDeskCommandExecutorFactory commandExecutorFactory,
            [NotNull] IDeskMoverFactory moverFactory,
            [NotNull] IDeskLockerFactory deskLockerFactory,
            [NotNull] IErrorManager errorManager)
        {
            Guard.ArgumentNotNull(logger,
                                  nameof(logger));
            Guard.ArgumentNotNull(scheduler,
                                  nameof(scheduler));
            Guard.ArgumentNotNull(subjectFactory,
                                  nameof(subjectFactory));
            Guard.ArgumentNotNull(subjectHeight,
                                  nameof(subjectHeight));
            Guard.ArgumentNotNull(subjectRefreshed,
                                  nameof(subjectRefreshed));
            Guard.ArgumentNotNull(subjectSpeed,
                                  nameof(subjectSpeed));
            Guard.ArgumentNotNull(subjectHeightAndSpeed,
                                  nameof(subjectHeightAndSpeed));
            Guard.ArgumentNotNull(device,
                                  nameof(device));
            Guard.ArgumentNotNull(deskCharacteristics,
                                  nameof(deskCharacteristics));
            Guard.ArgumentNotNull(heightAndSpeedFactory,
                                  nameof(heightAndSpeedFactory));
            Guard.ArgumentNotNull(commandExecutorFactory,
                                  nameof(commandExecutorFactory));
            Guard.ArgumentNotNull(moverFactory,
                                  nameof(moverFactory));
            Guard.ArgumentNotNull(deskLockerFactory,
                                  nameof(deskLockerFactory));
            Guard.ArgumentNotNull(errorManager,
                                  nameof(errorManager));        // todo testing

            _logger                 = logger;
            _scheduler              = scheduler;
            _subjectHeight          = subjectHeight;
            _subjectSpeed           = subjectSpeed;
            _subjectRefreshed       = subjectRefreshed;
            _subjectHeightAndSpeed  = subjectHeightAndSpeed;
            _device                 = device;
            _deskCharacteristics    = deskCharacteristics;
            _heightAndSpeedFactory  = heightAndSpeedFactory;
            _commandExecutorFactory = commandExecutorFactory;
            _moverFactory           = moverFactory;
            _deskLockerFactory      = deskLockerFactory;
            _errorManager           = errorManager;

            _device.GattServicesRefreshed
            .Throttle(TimeSpan.FromSeconds(1))
            .SubscribeOn(scheduler)
            .SubscribeAsync(OnGattServicesRefreshed);

            _deviceNameChanged = subjectFactory( );
        }