Пример #1
0
        /// <summary>
        /// Set sweep the motor speed
        /// </summary>
        /// <param name="targetSpeed"></param>
        /// <param name="smartInterleave">Automatically pause scanning if necessary to adjust the speed, then resume scanning</param>
        public async Task SetMotorSpeedAsync(SweepMotorSpeed targetSpeed, bool smartInterleave = true)
        {
            if (!Connected)
                throw new LidaRxStateException("This instance is not yet connected to the Sweep scanner.");

            if (this.Info.MotorSpeed == targetSpeed)
                return;

            bool restartScanning = _isScanning;

            if(_isScanning && !smartInterleave)
                throw new InvalidOperationException("Cannot change device configuration while scan is running");

            await _semaphoreConfigurationChanges.WaitAsync();

            if (_isScanning)
            {
                await StopScanAsync();

                // give sweep some time to recover
                await Task.Delay(250);
            }

            var cmd = new AdjustMotorSpeedCommand(targetSpeed);
            await SimpleCommandTxRxAsync(cmd);

            if (cmd.Status == AdjustMotorSpeedResult.Success)
            {
                await WaitForStabilizedMotorSpeedAsync(TimeSpan.FromSeconds(30));
                this.Info.MotorSpeed = targetSpeed;
            }
            else
            {
                throw new SweepProtocolErrorException($"Adjust motor speed command failed with status {cmd.Status}", null);
            }

            if (restartScanning)
            {
                await StartScanAsync();
            }

            _semaphoreConfigurationChanges.Release();
        }
Пример #2
0
 public AdjustMotorSpeedCommand(SweepMotorSpeed targetSpeed)
 {
     this.TargetSpeed = targetSpeed;
 }
Пример #3
0
 /// <summary>
 /// Set sweep the motor speed
 /// </summary>
 /// <param name="targetSpeed"></param>
 /// <param name="smartInterleave">Automatically pause scanning if necessary to adjust the speed, then resume scanning</param>
 public void SetMotorSpeed(SweepMotorSpeed targetSpeed, bool smartInterleave = true)
 {
     SetMotorSpeedAsync(targetSpeed, smartInterleave).Wait();
 }