Ejemplo n.º 1
0
        /// <summary>
        /// Set the sample rate
        /// </summary>
        /// <param name="targetRate"></param>
        /// <param name="smartInterleave">Automatically pause scanning if necessary to adjust the sample rate, then resume scanning</param>
        public async Task SetSamplingRateAsync(SweepSampleRate targetRate, bool smartInterleave = true)
        {
            if (!Connected)
                throw new LidaRxStateException("This instance is not yet connected to the Sweep scanner.");

            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 AdjustSampleRateCommand(targetRate);
            await SimpleCommandTxRxAsync(cmd);

            if (cmd.Status == AdjustSampleRateResult.Success)
            {
                this.Info.SampleRate = targetRate;
            }
            else
            {
                throw new SweepProtocolErrorException($"Adjust sample rate command failed with status {cmd.Status}", null);
            }

            if (restartScanning)
            {
                await StartScanAsync();
            }

            _semaphoreConfigurationChanges.Release();
        }
Ejemplo n.º 2
0
 public AdjustSampleRateCommand(SweepSampleRate targetSampleRate)
 {
     this.TargetSamplingRate = targetSampleRate;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Set the sample rate
 /// </summary>
 /// <param name="targetRate"></param>
 /// <param name="smartInterleave">Automatically pause scanning if necessary to adjust the sample rate, then resume scanning</param>
 public void SetSamplingRate(SweepSampleRate targetRate, bool smartInterleave = true)
 {
     SetSamplingRateAsync(targetRate, smartInterleave).Wait();
 }