Exemple #1
0
 /// <summary>
 ///     Get instance of signal generator
 /// </summary>
 /// <returns>Instance of signal generator</returns>
 public Smb100A GetConnectionSignalGenerator()
 {
     try
     {
         return(Smb100A ?? (Smb100A =
                                new Smb100A(Device.Default.IP_ADDR_SIGNAL_GEN, Device.Default.PORT_SIGNAL_GEN)));
     }
     catch (Exception exception)
     {
         throw new Smb100AException("Failed to connect to the signal generator: \n" + exception.Message);
     }
 }
        /// <summary>
        ///     Realization task for output data from signal generator
        /// </summary>
        /// <param name="token">Cancel token</param>
        private void ThreadMethodSignalGenerator(CancellationToken token)
        {
            var signalGenerator = new Smb100A(
                Core.Properties.Device.Default.IP_ADDR_SIGNAL_GEN,
                Core.Properties.Device.Default.PORT_SIGNAL_GEN);

            while (true)
            {
                try
                {
                    token.ThrowIfCancellationRequested();

                    OutputFrequency = signalGenerator.GetFreqMhz() * _frequencyRatio[FrequencySelector];

                    OutputPow = Math.Round(PowSelector == Smb100A.Pow.Dbm
                        ? signalGenerator.GetPowdBm()
                        : signalGenerator.GetPowdBm() + _powRatio[PowSelector], 2);


                    OutputPulseWidth     = signalGenerator.GetPulseWidth() * _pulseWidthRatio[PulseWidthSelector];
                    OutputPulsePeriod    = signalGenerator.GetPulsePeriod() * _pulsePeriodRatio[PulsePeriodSelector];
                    OutputPulseDeviation =
                        signalGenerator.GetFreqDeviation() * _pulseDeviationRatio[DeviationSelector];
                    OutputPulseDelay      = signalGenerator.GetPulseDelay() * _pulseDelayRatio[PulseDelaySelector];
                    OutputRfState         = SignalGenerator.GetRfOutputState();
                    OutputModulationState = SignalGenerator.GetModulationState();

                    GetDataSignalGeneratorComplete?.Invoke();
                    Thread.Sleep(300);
                    GC.Collect();
                }
                catch (OperationCanceledException e)
                {
                    throw new Exception("Task is stopped");
                }
                catch (Exception exception)
                {
                    throw new Exception("Error of work with signal generator: " + exception.Message);
                }
            }
        }
 public void CreateInstanceSignalGenerator()
 {
     SignalGenerator = new Smb100A(Device.Default.IP_ADDR_SIGNAL_GEN, Device.Default.PORT_SIGNAL_GEN);
 }