예제 #1
0
        /// <summary>
        /// Get the currently available sample rates for the selected performance options
        /// </summary>
        /// <returns>Array of sample rate combinations available</returns>
        public List <SampleRate> GetAvailableSampleRates()
        {
            WriteString(get_all_sample_rates_cmd);
            String response = "";

            GetResponse(ref response);

            List <SampleRate> sample_rates = new List <SampleRate>();

            String[] new_line  = { "\n" };
            String[] responses = response.Split(new_line, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < responses.Length - 1; i++)
            {
                String[] split_sample_rate = responses[i].Split(',');
                if (split_sample_rate.Length != 2)
                {
                    sample_rates.Clear();
                    return(sample_rates);
                }

                SampleRate new_sample_rate = new SampleRate();
                new_sample_rate.DigitalSampleRate = Convert.ToInt32(split_sample_rate[0].Trim());
                new_sample_rate.AnalogSampleRate  = Convert.ToInt32(split_sample_rate[1].Trim());
                sample_rates.Add(new_sample_rate);
            }

            return(sample_rates);
        }
        public void SetCaptureSettings( CaptureSettings settings )
        {
            Client.SetActiveChannels( settings.ActiveDigitalChannels.ToArray(), settings.ActiveAnalogChannels.ToArray() );

            var all_sample_rates = GetAllSampleRates();

            SampleRate target_sample_rate = new SampleRate() { DigitalSampleRate = settings.DigitalSampleRateHz, AnalogSampleRate = settings.AnalogSampleRateHz };
            var found_sample_rate_pair = all_sample_rates.FirstOrDefault( x => x.Value.Any( y => y == target_sample_rate ) );
            if( found_sample_rate_pair.Equals( default( KeyValuePair<PerformanceOption, List<SampleRate>> ) ) )
                throw new Exception( "sample rate not possible" );

            PerformanceOption perfomance_option = found_sample_rate_pair.Key;
            Client.SetPerformanceOption( perfomance_option );
            Client.SetSampleRate( target_sample_rate );

            Client.SetCaptureSeconds( settings.CaptureDurationS );

            //trigger configure.
            List<Trigger> trigger_settings = new List<Trigger>();

            settings.ActiveDigitalChannels.Sort(); // lowest to largest.
            foreach( int channel in settings.ActiveDigitalChannels )
            {
                Trigger channel_trigger_setting = Trigger.None;
                if( settings.TriggerSettings.ContainsKey( channel ) )
                    channel_trigger_setting = settings.TriggerSettings[ channel ];

                trigger_settings.Add( channel_trigger_setting );

            }

            Client.SetTrigger( trigger_settings.ToArray(), settings.TriggerMinTimeS, settings.TriggerMaxTimeS );

            //TODO: voltage level
        }
예제 #3
0
        /// <summary>
        /// Set the sample rate for capture
        /// </summary>
        /// <param name="sample_rate">Sample rate to set</param>
        public void SetSampleRate(SampleRate sample_rate)
        {
            String export_command = set_sample_rate_cmd + ", ";

            export_command += sample_rate.DigitalSampleRate.ToString();
            export_command += ", " + sample_rate.AnalogSampleRate.ToString();

            WriteString(export_command);

            String response = "";

            GetResponse(ref response);
        }