Beispiel #1
0
        public void VcdTest()
        {
            if (System.IO.Directory.Exists(folder_path) == false)
            {
                System.IO.Directory.CreateDirectory(folder_path);
            }

            //digital VCD yest
            ExportDataStruct export_settings = new ExportDataStruct
            {
                FileName = folder_path + "digital_vcd_range",
                //DataExportMixedExportMode = DataExportMixedModeExportType.DigitalOnly,
                ExportChannelSelection = DataExportChannelSelection.AllChannels,
                //DigitalChannelsToExport = new int[] {},
                //AnalogChannelsToExport = new int[] {},

                SamplesRangeType = DataExportSampleRangeType.RangeTimes,
                StartingTime     = 0.001,
                EndingTime       = 0.002,

                DataExportType = DataExportType.ExportVcd,
                //CsvIncludeHeaders = CsvHeadersType.CsvIncludesHeaders,
                //CsvDelimiterType = CsvDelimiterType.CsvTab,
                //CsvOutputMode = CsvOutputMode.CsvOneColumnPerBit,
                //CsvTimestampType = CsvTimestampType.CsvTime,
                //CsvDisplayBase = CsvBase.CsvHexadecimal,
                //CsvDensity = CsvDensity.CsvTransition,

                //BinaryOutputMode = BinaryOutputMode.BinaryEverySample,
                //BinaryBitShifting = BinaryBitShifting.BinaryOriginalBitPositions,
                //BinaryOutputWordSize = BinaryOutputWordSize.Binary16Bit,

                //AnalogFormat = AnalogOutputFormat.ADC
            };


            client.SetActiveChannels(new int[] { 0, 1 }, new int[] { });
            client.SetCaptureSeconds(0.001);

            client.Capture();             //blocks until capture is complete, but processing is not complete.
            if (client.BlockUntillProcessingCompleteOrTimeout(new TimeSpan(0, 0, 5)) == false)
            {
                throw new Exception("processing took too long");
            }

            client.ExportData2(export_settings, true, false);
        }
Beispiel #2
0
        /// <summary>
        /// This replaced the hard to use and buggy EXPORT_DATA command.
        /// </summary>
        /// <param name="export_settings"></param>
        /// <param name="capture_contains_digital_channels"></param>
        /// <param name="capture_contains_analog_channels"></param>
        /// <returns></returns>
        public bool ExportData2(ExportDataStruct export_settings, bool capture_contains_digital_channels, bool capture_contains_analog_channels)
        {
            bool is_mixed_mode_capture = capture_contains_digital_channels && capture_contains_analog_channels;             //different export options happen in this case.

            if (is_mixed_mode_capture && export_settings.ExportChannelSelection == DataExportChannelSelection.AllChannels)
            {
                export_settings.DataExportMixedExportMode = DataExportMixedModeExportType.AnalogAndDigital;                 //this is not required to be explicitly set by the user.
            }
            List <string> command_parts = new List <string>();

            command_parts.Add(export_data2_cmd);

            command_parts.Add(export_settings.FileName);

            command_parts.Add(export_settings.ExportChannelSelection.GetDescription());

            if (export_settings.ExportChannelSelection == DataExportChannelSelection.SpecificChannels)
            {
                if (is_mixed_mode_capture)
                {
                    command_parts.Add(export_settings.DataExportMixedExportMode.GetDescription());
                }

                if (export_settings.DigitalChannelsToExport != null && export_settings.DigitalChannelsToExport.Any())
                {
                    command_parts.AddRange(export_settings.DigitalChannelsToExport.Select(x => new Channel {
                        Index = x, DataType = Channel.ChannelDataType.DigitalChannel
                    }.GetExportString()));
                }
                if (export_settings.AnalogChannelsToExport != null && export_settings.AnalogChannelsToExport.Any())
                {
                    command_parts.AddRange(export_settings.AnalogChannelsToExport.Select(x => new Channel {
                        Index = x, DataType = Channel.ChannelDataType.AnalogChannel
                    }.GetExportString()));
                }
            }

            //time options.
            command_parts.Add(export_settings.SamplesRangeType.GetDescription());

            if (export_settings.SamplesRangeType == DataExportSampleRangeType.RangeTimes)
            {
                command_parts.Add(export_settings.StartingTime.ToString());
                command_parts.Add(export_settings.EndingTime.ToString());
            }


            command_parts.Add(export_settings.DataExportType.GetDescription());
            //digital only CSV
            if (capture_contains_digital_channels && export_settings.DataExportType == DataExportType.ExportCsv && (!is_mixed_mode_capture || export_settings.DataExportMixedExportMode == DataExportMixedModeExportType.DigitalOnly))
            {
                command_parts.Add(export_settings.CsvIncludeHeaders.GetDescription());
                command_parts.Add(export_settings.CsvDelimiterType.GetDescription());
                command_parts.Add(export_settings.CsvTimestampType.GetDescription());
                command_parts.Add(export_settings.CsvOutputMode.GetDescription());
                if (export_settings.CsvOutputMode == CsvOutputMode.CsvSingleNumber)
                {
                    command_parts.Add(export_settings.CsvDisplayBase.GetDescription());
                }
                command_parts.Add(export_settings.CsvDensity.GetDescription());
            }

            //analog only CSV
            if (capture_contains_analog_channels && export_settings.DataExportType == DataExportType.ExportCsv && (!is_mixed_mode_capture || export_settings.DataExportMixedExportMode == DataExportMixedModeExportType.AnalogOnly))
            {
                command_parts.Add(export_settings.CsvIncludeHeaders.GetDescription());
                command_parts.Add(export_settings.CsvDelimiterType.GetDescription());
                command_parts.Add(export_settings.CsvDisplayBase.GetDescription());
                command_parts.Add(export_settings.AnalogFormat.GetDescription());
            }

            //mixed mode CSV
            if (export_settings.DataExportType == DataExportType.ExportCsv && is_mixed_mode_capture && export_settings.DataExportMixedExportMode == DataExportMixedModeExportType.AnalogAndDigital)
            {
                command_parts.Add(export_settings.CsvIncludeHeaders.GetDescription());
                command_parts.Add(export_settings.CsvDelimiterType.GetDescription());
                command_parts.Add(export_settings.CsvDisplayBase.GetDescription());
                command_parts.Add(export_settings.AnalogFormat.GetDescription());
            }

            //digital binary
            if (capture_contains_digital_channels && export_settings.DataExportType == DataExportType.ExportBinary && (!is_mixed_mode_capture || export_settings.DataExportMixedExportMode == DataExportMixedModeExportType.DigitalOnly))
            {
                command_parts.Add(export_settings.BinaryOutputMode.GetDescription());
                command_parts.Add(export_settings.BinaryBitShifting.GetDescription());
                command_parts.Add(export_settings.BinaryOutputWordSize.GetDescription());
            }

            //analog only binary
            if (capture_contains_analog_channels && export_settings.DataExportType == DataExportType.ExportBinary && (!is_mixed_mode_capture || export_settings.DataExportMixedExportMode == DataExportMixedModeExportType.AnalogOnly))
            {
                command_parts.Add(export_settings.AnalogFormat.GetDescription());
            }

            //VCD (always digital only)
            if (export_settings.DataExportType == DataExportType.ExportVcd)
            {
                //no settings
            }

            //Matlab digital:
            if (capture_contains_digital_channels && export_settings.DataExportType == DataExportType.ExportMatlab && (!is_mixed_mode_capture || export_settings.DataExportMixedExportMode == DataExportMixedModeExportType.DigitalOnly))
            {
                //no settings
            }

            //Matlab analog or mixed:
            if (capture_contains_analog_channels && export_settings.DataExportType == DataExportType.ExportMatlab && (!is_mixed_mode_capture || export_settings.DataExportMixedExportMode != DataExportMixedModeExportType.DigitalOnly))
            {
                command_parts.Add(export_settings.AnalogFormat.GetDescription());
            }


            string socket_command = String.Join(", ", command_parts);

            WriteString(socket_command);

            String response = "";

            GetResponse(ref response);

            return(true);
        }
Beispiel #3
0
        //create input struct
        public void ExportData(ExportDataStruct export_data_struct)
        {
            //channels
            const String all_channels_option     = ", ALL_CHANNELS";
            const String digital_channels_option = ", DIGITAL_CHANNELS";
            const String analog_channels_option  = ", ANALOG_CHANNELS";

            //time span
            const String all_time_option  = ", ALL_TIME";
            const String time_span_option = ", TIME_SPAN";

            const String csv_option            = ", CSV";
            const String headers_option        = ", HEADERS";
            const String no_headers_option     = ", NO_HEADERS";
            const String tab_option            = ", TAB";
            const String comma_option          = ", COMMA";
            const String sample_number_option  = ", SAMPLE_NUMBER";
            const String time_stamp_option     = ", TIME_STAMP";
            const String combined_option       = ", COMBINED";
            const String separate_option       = ", SEPARATE";
            const String row_per_change_option = ", ROW_PER_CHANGE";
            const String row_per_sample_option = ", ROW_PER_SAMPLE";
            const String dec_option            = ", DEC";
            const String hex_option            = ", HEX";
            const String bin_option            = ", BIN";
            const String ascii_option          = ", ASCII";

            const String binary_option      = ", BINARY";
            const String each_sample_option = ", EACH_SAMPLE";
            const String on_change_option   = ", ON_CHANGE";

            const String voltage_option = ", VOLTAGE";
            const String raw_adc_option = ", ADC";
            const String vcd_option     = ", VCD";
            const String matlab_option  = ", MATLAB";


            String export_command = export_data_cmd;

            export_command += ", " + export_data_struct.FileName;

            if (export_data_struct.ExportChannelSelection == DataExportChannelSelection.AllChannels)
            {
                export_command += all_channels_option;
            }
            else
            {
                if (export_data_struct.DigitalChannelsToExport.Length > 0)
                {
                    export_command += digital_channels_option;
                    foreach (int channel in export_data_struct.DigitalChannelsToExport)
                    {
                        export_command += ", " + channel.ToString();
                    }
                }

                if (export_data_struct.AnalogChannelsToExport.Length > 0)
                {
                    export_command += analog_channels_option;
                    foreach (int channel in export_data_struct.AnalogChannelsToExport)
                    {
                        export_command += ", " + channel.ToString();
                    }
                }
            }

            if ((export_data_struct.ExportChannelSelection == DataExportChannelSelection.AllChannels) || (export_data_struct.AnalogChannelsToExport != null && export_data_struct.AnalogChannelsToExport.Length > 0))
            {
                if (export_data_struct.AnalogFormat == AnalogOutputFormat.Voltage)
                {
                    export_command += voltage_option;
                }
                else if (export_data_struct.AnalogFormat == AnalogOutputFormat.ADC)
                {
                    export_command += raw_adc_option;
                }
            }

            if (export_data_struct.SamplesRangeType == DataExportSampleRangeType.RangeAll)
            {
                export_command += all_time_option;
            }
            else if (export_data_struct.SamplesRangeType == DataExportSampleRangeType.RangeTimes)
            {
                export_command += time_span_option;
                export_command += ", " + export_data_struct.StartingTime;
                export_command += ", " + export_data_struct.EndingTime;
            }

            if (export_data_struct.DataExportType == DataExportType.ExportCsv)
            {
                export_command += csv_option;

                if (export_data_struct.CsvIncludeHeaders == CsvHeadersType.CsvIncludesHeaders)
                {
                    export_command += headers_option;
                }
                else if (export_data_struct.CsvIncludeHeaders == CsvHeadersType.CsvNoHeaders)
                {
                    export_command += no_headers_option;
                }

                if (export_data_struct.CsvDelimiterType == CsvDelimiterType.CsvTab)
                {
                    export_command += tab_option;
                }
                else if (export_data_struct.CsvDelimiterType == CsvDelimiterType.CsvComma)
                {
                    export_command += comma_option;
                }

                if (export_data_struct.CsvTimestampType == CsvTimestampType.CsvSample)
                {
                    export_command += sample_number_option;
                }
                else if (export_data_struct.CsvTimestampType == CsvTimestampType.CsvTime)
                {
                    export_command += time_stamp_option;
                }

                if (export_data_struct.CsvOutputMode == CsvOutputMode.CsvSingleNumber)
                {
                    export_command += combined_option;
                }
                else if (export_data_struct.CsvOutputMode == CsvOutputMode.CsvOneColumnPerBit)
                {
                    export_command += separate_option;
                }

                if (export_data_struct.CsvDensity == CsvDensity.CsvTransition)
                {
                    export_command += row_per_change_option;
                }
                else if (export_data_struct.CsvDensity == CsvDensity.CsvComplete)
                {
                    export_command += row_per_sample_option;
                }

                if (export_data_struct.CsvDisplayBase == CsvBase.CsvDecimal)
                {
                    export_command += dec_option;
                }
                else if (export_data_struct.CsvDisplayBase == CsvBase.CsvHexadecimal)
                {
                    export_command += hex_option;
                }
                else if (export_data_struct.CsvDisplayBase == CsvBase.CsvBinary)
                {
                    export_command += bin_option;
                }
                else if (export_data_struct.CsvDisplayBase == CsvBase.CsvAscii)
                {
                    export_command += ascii_option;
                }
            }
            else if (export_data_struct.DataExportType == DataExportType.ExportBinary)
            {
                export_command += binary_option;

                if (export_data_struct.BinaryOutputMode == BinaryOutputMode.BinaryEverySample)
                {
                    export_command += each_sample_option;
                }
                else if (export_data_struct.BinaryOutputMode == BinaryOutputMode.BinaryEveryChange)
                {
                    export_command += on_change_option;
                }

                if (export_data_struct.BinaryOutputWordSize == BinaryOutputWordSize.Binary8Bit)
                {
                    export_command += ", 8";
                }
                else if (export_data_struct.BinaryOutputWordSize == BinaryOutputWordSize.Binary16Bit)
                {
                    export_command += ", 16";
                }
                else if (export_data_struct.BinaryOutputWordSize == BinaryOutputWordSize.Binary32Bit)
                {
                    export_command += ", 32";
                }
                else if (export_data_struct.BinaryOutputWordSize == BinaryOutputWordSize.Binary64Bit)
                {
                    export_command += ", 64";
                }
            }
            else if (export_data_struct.DataExportType == DataExportType.ExportVcd)
            {
                export_command += vcd_option;
            }
            else if (export_data_struct.DataExportType == DataExportType.ExportMatlab)
            {
                export_command += matlab_option;
            }


            WriteString(export_command);

            String response = "";

            GetResponse(ref response);
        }
        public void VcdTest()
        {
            if( System.IO.Directory.Exists( folder_path ) == false )
                System.IO.Directory.CreateDirectory( folder_path );

            //digital VCD yest
            ExportDataStruct export_settings = new ExportDataStruct
            {
                FileName = folder_path + "digital_vcd_range",
                //DataExportMixedExportMode = DataExportMixedModeExportType.DigitalOnly,
                ExportChannelSelection = DataExportChannelSelection.AllChannels,
                //DigitalChannelsToExport = new int[] {},
                //AnalogChannelsToExport = new int[] {},

                SamplesRangeType = DataExportSampleRangeType.RangeTimes,
                StartingTime = 0.001,
                EndingTime = 0.002,

                DataExportType = DataExportType.ExportVcd,
                //CsvIncludeHeaders = CsvHeadersType.CsvIncludesHeaders,
                //CsvDelimiterType = CsvDelimiterType.CsvTab,
                //CsvOutputMode = CsvOutputMode.CsvOneColumnPerBit,
                //CsvTimestampType = CsvTimestampType.CsvTime,
                //CsvDisplayBase = CsvBase.CsvHexadecimal,
                //CsvDensity = CsvDensity.CsvTransition,

                //BinaryOutputMode = BinaryOutputMode.BinaryEverySample,
                //BinaryBitShifting = BinaryBitShifting.BinaryOriginalBitPositions,
                //BinaryOutputWordSize = BinaryOutputWordSize.Binary16Bit,

                //AnalogFormat = AnalogOutputFormat.ADC
            };

            client.SetActiveChannels( new int[] { 0, 1 }, new int[] { } );
            client.SetCaptureSeconds( 0.001 );

            client.Capture(); //blocks until capture is complete, but processing is not complete.
            if( client.BlockUntillProcessingCompleteOrTimeout( new TimeSpan( 0, 0, 5 ) ) == false )
                throw new Exception( "processing took too long" );

            client.ExportData2( export_settings, true, false );
        }
        public void TriggerOffsetTest()
        {
            //connect the signal generator to channel 0 of Logic8/Pro8/Pro16. (do not use Logic4, the original Logic, or Logic16)
            //set signal generator to 1 hz square wave and start.

            if( System.IO.Directory.Exists( folder_path ) == false )
                System.IO.Directory.CreateDirectory( folder_path );

            //digital only CSV all time
            ExportDataStruct export_settings = new ExportDataStruct
            {
                FileName = folder_path + "trigger_digital_csv_alltime",
                //DataExportMixedExportMode = DataExportMixedModeExportType.DigitalOnly,
                ExportChannelSelection = DataExportChannelSelection.AllChannels,
                //DigitalChannelsToExport = new int[] {},
                //AnalogChannelsToExport = new int[] {},

                SamplesRangeType = DataExportSampleRangeType.RangeAll,
                StartingTime = -0.005, //-5mS
                EndingTime = 0.005, //+5mS

                DataExportType = DataExportType.ExportCsv,
                CsvIncludeHeaders = CsvHeadersType.CsvIncludesHeaders,
                CsvDelimiterType = CsvDelimiterType.CsvComma,
                CsvOutputMode = CsvOutputMode.CsvOneColumnPerBit,
                CsvTimestampType = CsvTimestampType.CsvTime,
                //CsvDisplayBase = CsvBase.CsvHexadecimal,
                CsvDensity = CsvDensity.CsvTransition,

                //BinaryOutputMode = BinaryOutputMode.BinaryEverySample,
                //BinaryBitShifting = BinaryBitShifting.BinaryOriginalBitPositions,
                //BinaryOutputWordSize = BinaryOutputWordSize.Binary16Bit,

                //AnalogFormat = AnalogOutputFormat.ADC
            };

            client.SetActiveChannels( new int[] { 0 }, new int[] { } );
            client.SetCapturePretriggerBufferSize( 1000000 ); //1M pre-trigger buffer. that's 10ms at 100 MSPS.
            client.SetCaptureSeconds( 0.01 ); //10ms, prob go to 30 ms
            client.SetSampleRate( new SampleRate { DigitalSampleRate = 100000000, AnalogSampleRate = 0 } );

            client.Capture(); //blocks until capture is complete, but processing is not complete.
            if( client.BlockUntillProcessingCompleteOrTimeout( new TimeSpan( 0, 0, 5 ) ) == false )
                throw new Exception( "processing took too long" );

            client.ExportData2( export_settings, true, false );

            //digital only CSV time range
            export_settings.FileName = folder_path + "trigger_digital_csv_timerange";
            export_settings.SamplesRangeType = DataExportSampleRangeType.RangeTimes;
            client.Capture(); //blocks until capture is complete, but processing is not complete.
            if( client.BlockUntillProcessingCompleteOrTimeout( new TimeSpan( 0, 0, 5 ) ) == false )
                throw new Exception( "processing took too long" );

            client.ExportData2( export_settings, true, false );

            //digital only CSV time range with sample numbers

            export_settings.FileName = folder_path + "trigger_digital_csv_timerange_samples";
            export_settings.SamplesRangeType = DataExportSampleRangeType.RangeTimes;
            export_settings.CsvTimestampType = CsvTimestampType.CsvSample;
            client.Capture(); //blocks until capture is complete, but processing is not complete.
            if( client.BlockUntillProcessingCompleteOrTimeout( new TimeSpan( 0, 0, 5 ) ) == false )
                throw new Exception( "processing took too long" );

            client.ExportData2( export_settings, true, false );

            //digital only binary all time
            export_settings = new ExportDataStruct
            {
                FileName = folder_path + "trigger_digital_binary_alltime",
                //DataExportMixedExportMode = DataExportMixedModeExportType.DigitalOnly,
                ExportChannelSelection = DataExportChannelSelection.AllChannels,
                //DigitalChannelsToExport = new int[] {},
                //AnalogChannelsToExport = new int[] {},

                SamplesRangeType = DataExportSampleRangeType.RangeAll,
                StartingTime = -0.005, //-5mS
                EndingTime = 0.005, //+5mS

                //DataExportType = DataExportType.ExportCsv,
                //CsvIncludeHeaders = CsvHeadersType.CsvIncludesHeaders,
                //CsvDelimiterType = CsvDelimiterType.CsvTab,
                //CsvOutputMode = CsvOutputMode.CsvOneColumnPerBit,
                //CsvTimestampType = CsvTimestampType.CsvTime,
                //CsvDisplayBase = CsvBase.CsvHexadecimal,
                //CsvDensity = CsvDensity.CsvTransition,

                BinaryOutputMode = BinaryOutputMode.BinaryEverySample,
                BinaryBitShifting = BinaryBitShifting.BinaryOriginalBitPositions,
                BinaryOutputWordSize = BinaryOutputWordSize.Binary16Bit,

                //AnalogFormat = AnalogOutputFormat.ADC
            };

            client.Capture(); //blocks until capture is complete, but processing is not complete.
            if( client.BlockUntillProcessingCompleteOrTimeout( new TimeSpan( 0, 0, 5 ) ) == false )
                throw new Exception( "processing took too long" );

            client.ExportData2( export_settings, true, false );

            //digital only binary time_rage
            export_settings.FileName = folder_path + "trigger_digital_binary_timerange";
            export_settings.SamplesRangeType = DataExportSampleRangeType.RangeTimes;

            client.Capture(); //blocks until capture is complete, but processing is not complete.
            if( client.BlockUntillProcessingCompleteOrTimeout( new TimeSpan( 0, 0, 5 ) ) == false )
                throw new Exception( "processing took too long" );

            client.ExportData2( export_settings, true, false );

            //digital only binary all time with sample numbers
            export_settings.FileName = folder_path + "trigger_digital_binary_alltime_with_sample_number";
            export_settings.SamplesRangeType = DataExportSampleRangeType.RangeAll;
            export_settings.BinaryOutputMode = BinaryOutputMode.BinaryEveryChange;

            client.Capture(); //blocks until capture is complete, but processing is not complete.
            if( client.BlockUntillProcessingCompleteOrTimeout( new TimeSpan( 0, 0, 5 ) ) == false )
                throw new Exception( "processing took too long" );

            client.ExportData2( export_settings, true, false );

            //digital only binary time range with sample numbers
            export_settings.FileName = folder_path + "trigger_digital_binary_range_with_sample_number";
            export_settings.SamplesRangeType = DataExportSampleRangeType.RangeTimes;

            client.Capture(); //blocks until capture is complete, but processing is not complete.
            if( client.BlockUntillProcessingCompleteOrTimeout( new TimeSpan( 0, 0, 5 ) ) == false )
                throw new Exception( "processing took too long" );

            client.ExportData2( export_settings, true, false );

            //digital only VCD all time
            export_settings.FileName = folder_path + "trigger_digital_vcd_alltime";
            export_settings.DataExportType = DataExportType.ExportVcd;
            export_settings.SamplesRangeType = DataExportSampleRangeType.RangeAll;

            client.Capture(); //blocks until capture is complete, but processing is not complete.
            if( client.BlockUntillProcessingCompleteOrTimeout( new TimeSpan( 0, 0, 5 ) ) == false )
                throw new Exception( "processing took too long" );

            client.ExportData2( export_settings, true, false );

            //digital only VCD time range
            export_settings.FileName = folder_path + "trigger_digital_vcd_range";
            export_settings.SamplesRangeType = DataExportSampleRangeType.RangeTimes;

            client.Capture(); //blocks until capture is complete, but processing is not complete.
            if( client.BlockUntillProcessingCompleteOrTimeout( new TimeSpan( 0, 0, 5 ) ) == false )
                throw new Exception( "processing took too long" );

            client.ExportData2( export_settings, true, false );

            //digital only Matlab all time
            export_settings.FileName = folder_path + "trigger_digital_matlab_alltime";
            export_settings.DataExportType = DataExportType.ExportMatlab;
            export_settings.SamplesRangeType = DataExportSampleRangeType.RangeAll;

            client.Capture(); //blocks until capture is complete, but processing is not complete.
            if( client.BlockUntillProcessingCompleteOrTimeout( new TimeSpan( 0, 0, 5 ) ) == false )
                throw new Exception( "processing took too long" );

            client.ExportData2( export_settings, true, false );

            //digital only Matlab time range
            export_settings.FileName = folder_path + "trigger_digital_matlab_range";
            export_settings.DataExportType = DataExportType.ExportMatlab;
            export_settings.SamplesRangeType = DataExportSampleRangeType.RangeTimes;

            client.Capture(); //blocks until capture is complete, but processing is not complete.
            if( client.BlockUntillProcessingCompleteOrTimeout( new TimeSpan( 0, 0, 5 ) ) == false )
                throw new Exception( "processing took too long" );

            client.ExportData2( export_settings, true, false );

            //Mix mode full mix CSV all time
            export_settings = new ExportDataStruct
            {
                FileName = folder_path + "trigger_mix_both_csv_alltime",
                //DataExportMixedExportMode = DataExportMixedModeExportType.DigitalOnly,
                ExportChannelSelection = DataExportChannelSelection.AllChannels,
                //DigitalChannelsToExport = new int[] {},
                //AnalogChannelsToExport = new int[] {},

                SamplesRangeType = DataExportSampleRangeType.RangeAll,
                StartingTime = -0.005, //-5mS
                EndingTime = 0.005, //+5mS

                DataExportType = DataExportType.ExportCsv,
                CsvIncludeHeaders = CsvHeadersType.CsvIncludesHeaders,
                CsvDelimiterType = CsvDelimiterType.CsvComma,
                CsvOutputMode = CsvOutputMode.CsvOneColumnPerBit,
                CsvTimestampType = CsvTimestampType.CsvTime,
                CsvDisplayBase = CsvBase.CsvHexadecimal,
                CsvDensity = CsvDensity.CsvTransition,

                //BinaryOutputMode = BinaryOutputMode.BinaryEverySample,
                //BinaryBitShifting = BinaryBitShifting.BinaryOriginalBitPositions,
                //BinaryOutputWordSize = BinaryOutputWordSize.Binary16Bit,

                AnalogFormat = AnalogOutputFormat.Voltage
            };

            client.SetActiveChannels( new int[] { 0 }, new int[] { 0 } );
            client.SetCapturePretriggerBufferSize( 5000000 ); //5M pre-trigger buffer. that's 10ms at 500 MSPS.
            client.SetCaptureSeconds( 0.01 ); //10ms, prob go to 30 ms
            client.SetSampleRate( new SampleRate { DigitalSampleRate = 500000000, AnalogSampleRate = 125000 } );

            client.Capture(); //blocks until capture is complete, but processing is not complete.
            if( client.BlockUntillProcessingCompleteOrTimeout( new TimeSpan( 0, 0, 35 ) ) == false )
                throw new Exception( "processing took too long" );

            client.ExportData2( export_settings, true, true );

            //mix mode both matlab time range
            export_settings.FileName = folder_path + "trigger_mixed_both_matlab_range";
            export_settings.DataExportType = DataExportType.ExportMatlab;
            export_settings.SamplesRangeType = DataExportSampleRangeType.RangeTimes;
            client.Capture(); //blocks until capture is complete, but processing is not complete.
            if( client.BlockUntillProcessingCompleteOrTimeout( new TimeSpan( 0, 0, 35 ) ) == false )
                throw new Exception( "processing took too long" );

            client.ExportData2( export_settings, true, true );

            //mix mode digital only csv range
            export_settings.FileName = folder_path + "trigger_mixed_digital_only_csv_range";
            export_settings.SamplesRangeType = DataExportSampleRangeType.RangeTimes;
            export_settings.DataExportType = DataExportType.ExportCsv;
            export_settings.ExportChannelSelection = DataExportChannelSelection.SpecificChannels;
            export_settings.DataExportMixedExportMode = DataExportMixedModeExportType.DigitalOnly;
            export_settings.DigitalChannelsToExport = new int[] { 0 };

            client.Capture(); //blocks until capture is complete, but processing is not complete.
            if( client.BlockUntillProcessingCompleteOrTimeout( new TimeSpan( 0, 0, 35 ) ) == false )
                throw new Exception( "processing took too long" );

            client.ExportData2( export_settings, true, true );
        }
        public void CsvMixedModeTest()
        {
            if( System.IO.Directory.Exists( folder_path ) == false )
                System.IO.Directory.CreateDirectory( folder_path );

            //mixed everything csv
            ExportDataStruct export_settings = new ExportDataStruct
            {
                FileName = folder_path + "mixed_tsv_everything",
                DataExportMixedExportMode = DataExportMixedModeExportType.AnalogAndDigital,
                ExportChannelSelection = DataExportChannelSelection.AllChannels,
                //DigitalChannelsToExport = new int[] {},
                //AnalogChannelsToExport = new int[] {},

                SamplesRangeType = DataExportSampleRangeType.RangeAll,
                //StartingTime = 0.0,
                //EndingTime = 0.001,

                DataExportType = DataExportType.ExportCsv,
                CsvIncludeHeaders = CsvHeadersType.CsvIncludesHeaders,
                CsvDelimiterType = CsvDelimiterType.CsvTab,
                //CsvOutputMode = CsvOutputMode.CsvOneColumnPerBit,
                //CsvTimestampType = CsvTimestampType.CsvTime,
                CsvDisplayBase = CsvBase.CsvHexadecimal,
                //CsvDensity = CsvDensity.CsvTransition,

                //BinaryOutputMode = BinaryOutputMode.BinaryEverySample,
                //BinaryBitShifting = BinaryBitShifting.BinaryOriginalBitPositions,
                //BinaryOutputWordSize = BinaryOutputWordSize.Binary16Bit,

                AnalogFormat = AnalogOutputFormat.Voltage
            };

            client.SetActiveChannels( new int[] { 0, 1 }, new int[] { 0, 1 } );
            client.SetCaptureSeconds( 0.001 );

            client.Capture(); //blocks until capture is complete, but processing is not complete.
            if( client.BlockUntillProcessingCompleteOrTimeout( new TimeSpan( 0, 0, 15 ) ) == false )
                throw new Exception( "processing took too long" );

            client.ExportData2( export_settings, true, true );

            //mixed, selective channels and time
            export_settings = new ExportDataStruct
            {
                FileName = folder_path + "mixed_csv_both_somechannels_sometime",
                DataExportMixedExportMode = DataExportMixedModeExportType.AnalogAndDigital,
                ExportChannelSelection = DataExportChannelSelection.SpecificChannels,
                DigitalChannelsToExport = new int[] { 1 },
                AnalogChannelsToExport = new int[] { 1 },

                SamplesRangeType = DataExportSampleRangeType.RangeTimes,
                StartingTime = 0.001,
                EndingTime = 0.002,

                DataExportType = DataExportType.ExportCsv,
                CsvIncludeHeaders = CsvHeadersType.CsvIncludesHeaders,
                CsvDelimiterType = CsvDelimiterType.CsvComma,
                //CsvOutputMode = CsvOutputMode.CsvSingleNumber,
                //CsvTimestampType = CsvTimestampType.CsvSample,
                CsvDisplayBase = CsvBase.CsvHexadecimal,
                //CsvDensity = CsvDensity.CsvComplete,

                //BinaryOutputMode = BinaryOutputMode.BinaryEverySample,
                //BinaryBitShifting = BinaryBitShifting.BinaryOriginalBitPositions,
                //BinaryOutputWordSize = BinaryOutputWordSize.Binary16Bit,

                AnalogFormat = AnalogOutputFormat.ADC
            };

            client.SetActiveChannels( new int[] { 0, 1, 2 }, new int[] { 0, 1, 2 } );
            client.SetCaptureSeconds( 0.003 );

            client.Capture(); //blocks until capture is complete, but processing is not complete.
            if( client.BlockUntillProcessingCompleteOrTimeout( new TimeSpan( 0, 0, 35 ) ) == false )
                throw new Exception( "processing took too long" );

            client.ExportData2( export_settings, true, true );

            //mixed as digital only:
            export_settings = new ExportDataStruct
            {
                FileName = folder_path + "mixed_csv_as_digital_all",
                DataExportMixedExportMode = DataExportMixedModeExportType.DigitalOnly,
                ExportChannelSelection = DataExportChannelSelection.SpecificChannels,
                DigitalChannelsToExport = new int[] { 0, 1, 2 },
                //AnalogChannelsToExport = new int[] { 1 },

                SamplesRangeType = DataExportSampleRangeType.RangeAll,
                //StartingTime = 0.001,
                //EndingTime = 0.002,

                DataExportType = DataExportType.ExportCsv,
                CsvIncludeHeaders = CsvHeadersType.CsvIncludesHeaders,
                CsvDelimiterType = CsvDelimiterType.CsvComma,
                CsvOutputMode = CsvOutputMode.CsvOneColumnPerBit,
                CsvTimestampType = CsvTimestampType.CsvSample,
                //CsvDisplayBase = CsvBase.CsvHexadecimal,
                CsvDensity = CsvDensity.CsvTransition,

                //BinaryOutputMode = BinaryOutputMode.BinaryEverySample,
                //BinaryBitShifting = BinaryBitShifting.BinaryOriginalBitPositions,
                //BinaryOutputWordSize = BinaryOutputWordSize.Binary16Bit,

                //AnalogFormat = AnalogOutputFormat.Voltage
            };

            client.SetActiveChannels( new int[] { 0, 1, 2 }, new int[] { 0, 1 } );
            client.SetCaptureSeconds( 0.003 );

            client.Capture(); //blocks until capture is complete, but processing is not complete.
            if( client.BlockUntillProcessingCompleteOrTimeout( new TimeSpan( 0, 0, 35 ) ) == false )
                throw new Exception( "processing took too long" );

            client.ExportData2( export_settings, true, true );

            //mixed as anaog only:
            export_settings = new ExportDataStruct
            {
                FileName = folder_path + "mixed_csv_as_analog_all",
                DataExportMixedExportMode = DataExportMixedModeExportType.AnalogOnly,
                ExportChannelSelection = DataExportChannelSelection.SpecificChannels,
                //DigitalChannelsToExport = new int[] { 1 },
                AnalogChannelsToExport = new int[] { 0 },

                SamplesRangeType = DataExportSampleRangeType.RangeAll,
                //StartingTime = 0.001,
                //EndingTime = 0.002,

                DataExportType = DataExportType.ExportCsv,
                CsvIncludeHeaders = CsvHeadersType.CsvIncludesHeaders,
                CsvDelimiterType = CsvDelimiterType.CsvComma,
                //CsvOutputMode = CsvOutputMode.CsvOneColumnPerBit,
                //CsvTimestampType = CsvTimestampType.CsvSample,
                CsvDisplayBase = CsvBase.CsvHexadecimal,
                //CsvDensity = CsvDensity.CsvTransition,

                //BinaryOutputMode = BinaryOutputMode.BinaryEverySample,
                //BinaryBitShifting = BinaryBitShifting.BinaryOriginalBitPositions,
                //BinaryOutputWordSize = BinaryOutputWordSize.Binary16Bit,

                AnalogFormat = AnalogOutputFormat.Voltage
            };

            client.SetActiveChannels( new int[] { 0, 1, 2 }, new int[] { 0, 1, 2 } );
            client.SetCaptureSeconds( 0.003 );

            client.Capture(); //blocks until capture is complete, but processing is not complete.
            if( client.BlockUntillProcessingCompleteOrTimeout( new TimeSpan( 0, 0, 35 ) ) == false )
                throw new Exception( "processing took too long" );

            client.ExportData2( export_settings, true, true );
        }
        public void CsvDitialTestSet()
        {
            if( System.IO.Directory.Exists( folder_path ) == false )
                System.IO.Directory.CreateDirectory( folder_path );

            //commented members of ExportDataStruct are not required, and can be set to any value or not intialized at all.

            //digital only tests.

            //Export Digital data
            //CSV
            //(really tab seperated, not comma, but same main export mode)
            //All time, all channels.
            ExportDataStruct export_settings = new ExportDataStruct
            {
                FileName = folder_path + "digital_tsv_allchannels_alltime",
                //DataExportMixedExportMode = DataExportMixedModeExportType.DigitalOnly,
                ExportChannelSelection = DataExportChannelSelection.AllChannels,
                //DigitalChannelsToExport = new int[] {},
                //AnalogChannelsToExport = new int[] {},

                SamplesRangeType = DataExportSampleRangeType.RangeAll,
                //StartingTime = 0.0,
                //EndingTime = 0.001,

                DataExportType = DataExportType.ExportCsv,
                CsvIncludeHeaders = CsvHeadersType.CsvIncludesHeaders,
                CsvDelimiterType = CsvDelimiterType.CsvTab,
                CsvOutputMode = CsvOutputMode.CsvOneColumnPerBit,
                CsvTimestampType = CsvTimestampType.CsvTime,
                //CsvDisplayBase = CsvBase.CsvHexadecimal,
                CsvDensity = CsvDensity.CsvTransition,

                //BinaryOutputMode = BinaryOutputMode.BinaryEverySample,
                //BinaryBitShifting = BinaryBitShifting.BinaryOriginalBitPositions,
                //BinaryOutputWordSize = BinaryOutputWordSize.Binary16Bit,

                //AnalogFormat = AnalogOutputFormat.ADC
            };

            client.SetActiveChannels( new int[] { 0, 1 }, new int[] { } );
            client.SetCaptureSeconds( 0.001 );

            client.Capture(); //blocks until capture is complete, but processing is not complete.
            if( client.BlockUntillProcessingCompleteOrTimeout( new TimeSpan( 0, 0, 5 ) ) == false )
                throw new Exception( "processing took too long" );

            client.ExportData2( export_settings, true, false );

            export_settings = new ExportDataStruct
            {
                FileName = folder_path + "digital_csv_somechannels_sometime",
                //DataExportMixedExportMode = DataExportMixedModeExportType.DigitalOnly,
                ExportChannelSelection = DataExportChannelSelection.SpecificChannels,
                DigitalChannelsToExport = new int[] {2},
                //AnalogChannelsToExport = new int[] {},

                SamplesRangeType = DataExportSampleRangeType.RangeTimes,
                StartingTime = 0.001,
                EndingTime = 0.002,

                DataExportType = DataExportType.ExportCsv,
                CsvIncludeHeaders = CsvHeadersType.CsvNoHeaders,
                CsvDelimiterType = CsvDelimiterType.CsvComma,
                CsvOutputMode = CsvOutputMode.CsvSingleNumber,
                CsvTimestampType = CsvTimestampType.CsvSample,
                CsvDisplayBase = CsvBase.CsvHexadecimal,
                CsvDensity = CsvDensity.CsvComplete,

                //BinaryOutputMode = BinaryOutputMode.BinaryEverySample,
                //BinaryBitShifting = BinaryBitShifting.BinaryOriginalBitPositions,
                //BinaryOutputWordSize = BinaryOutputWordSize.Binary16Bit,

                //AnalogFormat = AnalogOutputFormat.ADC
            };

            client.SetActiveChannels( new int[] { 0, 1, 2, 3 }, new int[] { } );
            client.SetCaptureSeconds( 0.003 );

            client.Capture(); //blocks until capture is complete, but processing is not complete.
            if( client.BlockUntillProcessingCompleteOrTimeout( new TimeSpan( 0, 0, 5 ) ) == false )
                throw new Exception( "processing took too long" );

            client.ExportData2( export_settings, true, false );
        }
Beispiel #8
0
        public void TriggerOffsetTest()
        {
            //connect the signal generator to channel 0 of Logic8/Pro8/Pro16. (do not use Logic4, the original Logic, or Logic16)
            //set signal generator to 1 hz square wave and start.



            if (System.IO.Directory.Exists(folder_path) == false)
            {
                System.IO.Directory.CreateDirectory(folder_path);
            }

            //digital only CSV all time
            ExportDataStruct export_settings = new ExportDataStruct
            {
                FileName = folder_path + "trigger_digital_csv_alltime",
                //DataExportMixedExportMode = DataExportMixedModeExportType.DigitalOnly,
                ExportChannelSelection = DataExportChannelSelection.AllChannels,
                //DigitalChannelsToExport = new int[] {},
                //AnalogChannelsToExport = new int[] {},

                SamplesRangeType = DataExportSampleRangeType.RangeAll,
                StartingTime     = -0.005,          //-5mS
                EndingTime       = 0.005,           //+5mS

                DataExportType    = DataExportType.ExportCsv,
                CsvIncludeHeaders = CsvHeadersType.CsvIncludesHeaders,
                CsvDelimiterType  = CsvDelimiterType.CsvComma,
                CsvOutputMode     = CsvOutputMode.CsvOneColumnPerBit,
                CsvTimestampType  = CsvTimestampType.CsvTime,
                //CsvDisplayBase = CsvBase.CsvHexadecimal,
                CsvDensity = CsvDensity.CsvTransition,

                //BinaryOutputMode = BinaryOutputMode.BinaryEverySample,
                //BinaryBitShifting = BinaryBitShifting.BinaryOriginalBitPositions,
                //BinaryOutputWordSize = BinaryOutputWordSize.Binary16Bit,

                //AnalogFormat = AnalogOutputFormat.ADC
            };


            client.SetActiveChannels(new int[] { 0 }, new int[] { });
            client.SetCapturePretriggerBufferSize(1000000); //1M pre-trigger buffer. that's 10ms at 100 MSPS.
            client.SetCaptureSeconds(0.01);                 //10ms, prob go to 30 ms
            client.SetSampleRate(new SampleRate {
                DigitalSampleRate = 100000000, AnalogSampleRate = 0
            });


            client.Capture();             //blocks until capture is complete, but processing is not complete.
            if (client.BlockUntillProcessingCompleteOrTimeout(new TimeSpan(0, 0, 5)) == false)
            {
                throw new Exception("processing took too long");
            }

            client.ExportData2(export_settings, true, false);


            //digital only CSV time range
            export_settings.FileName         = folder_path + "trigger_digital_csv_timerange";
            export_settings.SamplesRangeType = DataExportSampleRangeType.RangeTimes;
            client.Capture();             //blocks until capture is complete, but processing is not complete.
            if (client.BlockUntillProcessingCompleteOrTimeout(new TimeSpan(0, 0, 5)) == false)
            {
                throw new Exception("processing took too long");
            }

            client.ExportData2(export_settings, true, false);

            //digital only CSV time range with sample numbers

            export_settings.FileName         = folder_path + "trigger_digital_csv_timerange_samples";
            export_settings.SamplesRangeType = DataExportSampleRangeType.RangeTimes;
            export_settings.CsvTimestampType = CsvTimestampType.CsvSample;
            client.Capture();             //blocks until capture is complete, but processing is not complete.
            if (client.BlockUntillProcessingCompleteOrTimeout(new TimeSpan(0, 0, 5)) == false)
            {
                throw new Exception("processing took too long");
            }

            client.ExportData2(export_settings, true, false);

            //digital only binary all time
            export_settings = new ExportDataStruct
            {
                FileName = folder_path + "trigger_digital_binary_alltime",
                //DataExportMixedExportMode = DataExportMixedModeExportType.DigitalOnly,
                ExportChannelSelection = DataExportChannelSelection.AllChannels,
                //DigitalChannelsToExport = new int[] {},
                //AnalogChannelsToExport = new int[] {},

                SamplesRangeType = DataExportSampleRangeType.RangeAll,
                StartingTime     = -0.005,          //-5mS
                EndingTime       = 0.005,           //+5mS

                //DataExportType = DataExportType.ExportCsv,
                //CsvIncludeHeaders = CsvHeadersType.CsvIncludesHeaders,
                //CsvDelimiterType = CsvDelimiterType.CsvTab,
                //CsvOutputMode = CsvOutputMode.CsvOneColumnPerBit,
                //CsvTimestampType = CsvTimestampType.CsvTime,
                //CsvDisplayBase = CsvBase.CsvHexadecimal,
                //CsvDensity = CsvDensity.CsvTransition,

                BinaryOutputMode     = BinaryOutputMode.BinaryEverySample,
                BinaryBitShifting    = BinaryBitShifting.BinaryOriginalBitPositions,
                BinaryOutputWordSize = BinaryOutputWordSize.Binary16Bit,

                //AnalogFormat = AnalogOutputFormat.ADC
            };

            client.Capture();             //blocks until capture is complete, but processing is not complete.
            if (client.BlockUntillProcessingCompleteOrTimeout(new TimeSpan(0, 0, 5)) == false)
            {
                throw new Exception("processing took too long");
            }

            client.ExportData2(export_settings, true, false);

            //digital only binary time_rage
            export_settings.FileName         = folder_path + "trigger_digital_binary_timerange";
            export_settings.SamplesRangeType = DataExportSampleRangeType.RangeTimes;

            client.Capture();             //blocks until capture is complete, but processing is not complete.
            if (client.BlockUntillProcessingCompleteOrTimeout(new TimeSpan(0, 0, 5)) == false)
            {
                throw new Exception("processing took too long");
            }

            client.ExportData2(export_settings, true, false);

            //digital only binary all time with sample numbers
            export_settings.FileName         = folder_path + "trigger_digital_binary_alltime_with_sample_number";
            export_settings.SamplesRangeType = DataExportSampleRangeType.RangeAll;
            export_settings.BinaryOutputMode = BinaryOutputMode.BinaryEveryChange;

            client.Capture();             //blocks until capture is complete, but processing is not complete.
            if (client.BlockUntillProcessingCompleteOrTimeout(new TimeSpan(0, 0, 5)) == false)
            {
                throw new Exception("processing took too long");
            }

            client.ExportData2(export_settings, true, false);

            //digital only binary time range with sample numbers
            export_settings.FileName         = folder_path + "trigger_digital_binary_range_with_sample_number";
            export_settings.SamplesRangeType = DataExportSampleRangeType.RangeTimes;

            client.Capture();             //blocks until capture is complete, but processing is not complete.
            if (client.BlockUntillProcessingCompleteOrTimeout(new TimeSpan(0, 0, 5)) == false)
            {
                throw new Exception("processing took too long");
            }

            client.ExportData2(export_settings, true, false);

            //digital only VCD all time
            export_settings.FileName         = folder_path + "trigger_digital_vcd_alltime";
            export_settings.DataExportType   = DataExportType.ExportVcd;
            export_settings.SamplesRangeType = DataExportSampleRangeType.RangeAll;

            client.Capture();             //blocks until capture is complete, but processing is not complete.
            if (client.BlockUntillProcessingCompleteOrTimeout(new TimeSpan(0, 0, 5)) == false)
            {
                throw new Exception("processing took too long");
            }

            client.ExportData2(export_settings, true, false);

            //digital only VCD time range
            export_settings.FileName         = folder_path + "trigger_digital_vcd_range";
            export_settings.SamplesRangeType = DataExportSampleRangeType.RangeTimes;

            client.Capture();             //blocks until capture is complete, but processing is not complete.
            if (client.BlockUntillProcessingCompleteOrTimeout(new TimeSpan(0, 0, 5)) == false)
            {
                throw new Exception("processing took too long");
            }

            client.ExportData2(export_settings, true, false);

            //digital only Matlab all time
            export_settings.FileName         = folder_path + "trigger_digital_matlab_alltime";
            export_settings.DataExportType   = DataExportType.ExportMatlab;
            export_settings.SamplesRangeType = DataExportSampleRangeType.RangeAll;

            client.Capture();             //blocks until capture is complete, but processing is not complete.
            if (client.BlockUntillProcessingCompleteOrTimeout(new TimeSpan(0, 0, 5)) == false)
            {
                throw new Exception("processing took too long");
            }

            client.ExportData2(export_settings, true, false);

            //digital only Matlab time range
            export_settings.FileName         = folder_path + "trigger_digital_matlab_range";
            export_settings.DataExportType   = DataExportType.ExportMatlab;
            export_settings.SamplesRangeType = DataExportSampleRangeType.RangeTimes;

            client.Capture();             //blocks until capture is complete, but processing is not complete.
            if (client.BlockUntillProcessingCompleteOrTimeout(new TimeSpan(0, 0, 5)) == false)
            {
                throw new Exception("processing took too long");
            }

            client.ExportData2(export_settings, true, false);



            //Mix mode full mix CSV all time
            export_settings = new ExportDataStruct
            {
                FileName = folder_path + "trigger_mix_both_csv_alltime",
                //DataExportMixedExportMode = DataExportMixedModeExportType.DigitalOnly,
                ExportChannelSelection = DataExportChannelSelection.AllChannels,
                //DigitalChannelsToExport = new int[] {},
                //AnalogChannelsToExport = new int[] {},

                SamplesRangeType = DataExportSampleRangeType.RangeAll,
                StartingTime     = -0.005,          //-5mS
                EndingTime       = 0.005,           //+5mS

                DataExportType    = DataExportType.ExportCsv,
                CsvIncludeHeaders = CsvHeadersType.CsvIncludesHeaders,
                CsvDelimiterType  = CsvDelimiterType.CsvComma,
                CsvOutputMode     = CsvOutputMode.CsvOneColumnPerBit,
                CsvTimestampType  = CsvTimestampType.CsvTime,
                CsvDisplayBase    = CsvBase.CsvHexadecimal,
                CsvDensity        = CsvDensity.CsvTransition,

                //BinaryOutputMode = BinaryOutputMode.BinaryEverySample,
                //BinaryBitShifting = BinaryBitShifting.BinaryOriginalBitPositions,
                //BinaryOutputWordSize = BinaryOutputWordSize.Binary16Bit,

                AnalogFormat = AnalogOutputFormat.Voltage
            };

            client.SetActiveChannels(new int[] { 0 }, new int[] { 0 });
            client.SetCapturePretriggerBufferSize(5000000); //5M pre-trigger buffer. that's 10ms at 500 MSPS.
            client.SetCaptureSeconds(0.01);                 //10ms, prob go to 30 ms
            client.SetSampleRate(new SampleRate {
                DigitalSampleRate = 500000000, AnalogSampleRate = 125000
            });

            client.Capture();             //blocks until capture is complete, but processing is not complete.
            if (client.BlockUntillProcessingCompleteOrTimeout(new TimeSpan(0, 0, 35)) == false)
            {
                throw new Exception("processing took too long");
            }

            client.ExportData2(export_settings, true, true);



            //mix mode both matlab time range
            export_settings.FileName         = folder_path + "trigger_mixed_both_matlab_range";
            export_settings.DataExportType   = DataExportType.ExportMatlab;
            export_settings.SamplesRangeType = DataExportSampleRangeType.RangeTimes;
            client.Capture();             //blocks until capture is complete, but processing is not complete.
            if (client.BlockUntillProcessingCompleteOrTimeout(new TimeSpan(0, 0, 35)) == false)
            {
                throw new Exception("processing took too long");
            }

            client.ExportData2(export_settings, true, true);

            //mix mode digital only csv range
            export_settings.FileName                  = folder_path + "trigger_mixed_digital_only_csv_range";
            export_settings.SamplesRangeType          = DataExportSampleRangeType.RangeTimes;
            export_settings.DataExportType            = DataExportType.ExportCsv;
            export_settings.ExportChannelSelection    = DataExportChannelSelection.SpecificChannels;
            export_settings.DataExportMixedExportMode = DataExportMixedModeExportType.DigitalOnly;
            export_settings.DigitalChannelsToExport   = new int[] { 0 };

            client.Capture();             //blocks until capture is complete, but processing is not complete.
            if (client.BlockUntillProcessingCompleteOrTimeout(new TimeSpan(0, 0, 35)) == false)
            {
                throw new Exception("processing took too long");
            }

            client.ExportData2(export_settings, true, true);
        }
Beispiel #9
0
        public void CsvDitialTestSet()
        {
            if (System.IO.Directory.Exists(folder_path) == false)
            {
                System.IO.Directory.CreateDirectory(folder_path);
            }

            //commented members of ExportDataStruct are not required, and can be set to any value or not intialized at all.

            //digital only tests.

            //Export Digital data
            //CSV
            //(really tab seperated, not comma, but same main export mode)
            //All time, all channels.
            ExportDataStruct export_settings = new ExportDataStruct
            {
                FileName = folder_path + "digital_tsv_allchannels_alltime",
                //DataExportMixedExportMode = DataExportMixedModeExportType.DigitalOnly,
                ExportChannelSelection = DataExportChannelSelection.AllChannels,
                //DigitalChannelsToExport = new int[] {},
                //AnalogChannelsToExport = new int[] {},

                SamplesRangeType = DataExportSampleRangeType.RangeAll,
                //StartingTime = 0.0,
                //EndingTime = 0.001,

                DataExportType    = DataExportType.ExportCsv,
                CsvIncludeHeaders = CsvHeadersType.CsvIncludesHeaders,
                CsvDelimiterType  = CsvDelimiterType.CsvTab,
                CsvOutputMode     = CsvOutputMode.CsvOneColumnPerBit,
                CsvTimestampType  = CsvTimestampType.CsvTime,
                //CsvDisplayBase = CsvBase.CsvHexadecimal,
                CsvDensity = CsvDensity.CsvTransition,

                //BinaryOutputMode = BinaryOutputMode.BinaryEverySample,
                //BinaryBitShifting = BinaryBitShifting.BinaryOriginalBitPositions,
                //BinaryOutputWordSize = BinaryOutputWordSize.Binary16Bit,

                //AnalogFormat = AnalogOutputFormat.ADC
            };


            client.SetActiveChannels(new int[] { 0, 1 }, new int[] { });
            client.SetCaptureSeconds(0.001);

            client.Capture();             //blocks until capture is complete, but processing is not complete.
            if (client.BlockUntillProcessingCompleteOrTimeout(new TimeSpan(0, 0, 5)) == false)
            {
                throw new Exception("processing took too long");
            }

            client.ExportData2(export_settings, true, false);

            export_settings = new ExportDataStruct
            {
                FileName = folder_path + "digital_csv_somechannels_sometime",
                //DataExportMixedExportMode = DataExportMixedModeExportType.DigitalOnly,
                ExportChannelSelection  = DataExportChannelSelection.SpecificChannels,
                DigitalChannelsToExport = new int[] { 2 },
                //AnalogChannelsToExport = new int[] {},

                SamplesRangeType = DataExportSampleRangeType.RangeTimes,
                StartingTime     = 0.001,
                EndingTime       = 0.002,

                DataExportType    = DataExportType.ExportCsv,
                CsvIncludeHeaders = CsvHeadersType.CsvNoHeaders,
                CsvDelimiterType  = CsvDelimiterType.CsvComma,
                CsvOutputMode     = CsvOutputMode.CsvSingleNumber,
                CsvTimestampType  = CsvTimestampType.CsvSample,
                CsvDisplayBase    = CsvBase.CsvHexadecimal,
                CsvDensity        = CsvDensity.CsvComplete,

                //BinaryOutputMode = BinaryOutputMode.BinaryEverySample,
                //BinaryBitShifting = BinaryBitShifting.BinaryOriginalBitPositions,
                //BinaryOutputWordSize = BinaryOutputWordSize.Binary16Bit,

                //AnalogFormat = AnalogOutputFormat.ADC
            };

            client.SetActiveChannels(new int[] { 0, 1, 2, 3 }, new int[] { });
            client.SetCaptureSeconds(0.003);

            client.Capture();             //blocks until capture is complete, but processing is not complete.
            if (client.BlockUntillProcessingCompleteOrTimeout(new TimeSpan(0, 0, 5)) == false)
            {
                throw new Exception("processing took too long");
            }

            client.ExportData2(export_settings, true, false);
        }
Beispiel #10
0
        public void CsvMixedModeTest()
        {
            if (System.IO.Directory.Exists(folder_path) == false)
            {
                System.IO.Directory.CreateDirectory(folder_path);
            }

            //mixed everything csv
            ExportDataStruct export_settings = new ExportDataStruct
            {
                FileName = folder_path + "mixed_tsv_everything",
                DataExportMixedExportMode = DataExportMixedModeExportType.AnalogAndDigital,
                ExportChannelSelection    = DataExportChannelSelection.AllChannels,
                //DigitalChannelsToExport = new int[] {},
                //AnalogChannelsToExport = new int[] {},

                SamplesRangeType = DataExportSampleRangeType.RangeAll,
                //StartingTime = 0.0,
                //EndingTime = 0.001,

                DataExportType    = DataExportType.ExportCsv,
                CsvIncludeHeaders = CsvHeadersType.CsvIncludesHeaders,
                CsvDelimiterType  = CsvDelimiterType.CsvTab,
                //CsvOutputMode = CsvOutputMode.CsvOneColumnPerBit,
                //CsvTimestampType = CsvTimestampType.CsvTime,
                CsvDisplayBase = CsvBase.CsvHexadecimal,
                //CsvDensity = CsvDensity.CsvTransition,

                //BinaryOutputMode = BinaryOutputMode.BinaryEverySample,
                //BinaryBitShifting = BinaryBitShifting.BinaryOriginalBitPositions,
                //BinaryOutputWordSize = BinaryOutputWordSize.Binary16Bit,

                AnalogFormat = AnalogOutputFormat.Voltage
            };


            client.SetActiveChannels(new int[] { 0, 1 }, new int[] { 0, 1 });
            client.SetCaptureSeconds(0.001);

            client.Capture();             //blocks until capture is complete, but processing is not complete.
            if (client.BlockUntillProcessingCompleteOrTimeout(new TimeSpan(0, 0, 15)) == false)
            {
                throw new Exception("processing took too long");
            }

            client.ExportData2(export_settings, true, true);

            //mixed, selective channels and time
            export_settings = new ExportDataStruct
            {
                FileName = folder_path + "mixed_csv_both_somechannels_sometime",
                DataExportMixedExportMode = DataExportMixedModeExportType.AnalogAndDigital,
                ExportChannelSelection    = DataExportChannelSelection.SpecificChannels,
                DigitalChannelsToExport   = new int[] { 1 },
                AnalogChannelsToExport    = new int[] { 1 },

                SamplesRangeType = DataExportSampleRangeType.RangeTimes,
                StartingTime     = 0.001,
                EndingTime       = 0.002,

                DataExportType    = DataExportType.ExportCsv,
                CsvIncludeHeaders = CsvHeadersType.CsvIncludesHeaders,
                CsvDelimiterType  = CsvDelimiterType.CsvComma,
                //CsvOutputMode = CsvOutputMode.CsvSingleNumber,
                //CsvTimestampType = CsvTimestampType.CsvSample,
                CsvDisplayBase = CsvBase.CsvHexadecimal,
                //CsvDensity = CsvDensity.CsvComplete,

                //BinaryOutputMode = BinaryOutputMode.BinaryEverySample,
                //BinaryBitShifting = BinaryBitShifting.BinaryOriginalBitPositions,
                //BinaryOutputWordSize = BinaryOutputWordSize.Binary16Bit,

                AnalogFormat = AnalogOutputFormat.ADC
            };

            client.SetActiveChannels(new int[] { 0, 1, 2 }, new int[] { 0, 1, 2 });
            client.SetCaptureSeconds(0.003);

            client.Capture();             //blocks until capture is complete, but processing is not complete.
            if (client.BlockUntillProcessingCompleteOrTimeout(new TimeSpan(0, 0, 35)) == false)
            {
                throw new Exception("processing took too long");
            }

            client.ExportData2(export_settings, true, true);

            //mixed as digital only:
            export_settings = new ExportDataStruct
            {
                FileName = folder_path + "mixed_csv_as_digital_all",
                DataExportMixedExportMode = DataExportMixedModeExportType.DigitalOnly,
                ExportChannelSelection    = DataExportChannelSelection.SpecificChannels,
                DigitalChannelsToExport   = new int[] { 0, 1, 2 },
                //AnalogChannelsToExport = new int[] { 1 },

                SamplesRangeType = DataExportSampleRangeType.RangeAll,
                //StartingTime = 0.001,
                //EndingTime = 0.002,

                DataExportType    = DataExportType.ExportCsv,
                CsvIncludeHeaders = CsvHeadersType.CsvIncludesHeaders,
                CsvDelimiterType  = CsvDelimiterType.CsvComma,
                CsvOutputMode     = CsvOutputMode.CsvOneColumnPerBit,
                CsvTimestampType  = CsvTimestampType.CsvSample,
                //CsvDisplayBase = CsvBase.CsvHexadecimal,
                CsvDensity = CsvDensity.CsvTransition,

                //BinaryOutputMode = BinaryOutputMode.BinaryEverySample,
                //BinaryBitShifting = BinaryBitShifting.BinaryOriginalBitPositions,
                //BinaryOutputWordSize = BinaryOutputWordSize.Binary16Bit,

                //AnalogFormat = AnalogOutputFormat.Voltage
            };

            client.SetActiveChannels(new int[] { 0, 1, 2 }, new int[] { 0, 1 });
            client.SetCaptureSeconds(0.003);

            client.Capture();             //blocks until capture is complete, but processing is not complete.
            if (client.BlockUntillProcessingCompleteOrTimeout(new TimeSpan(0, 0, 35)) == false)
            {
                throw new Exception("processing took too long");
            }

            client.ExportData2(export_settings, true, true);


            //mixed as anaog only:
            export_settings = new ExportDataStruct
            {
                FileName = folder_path + "mixed_csv_as_analog_all",
                DataExportMixedExportMode = DataExportMixedModeExportType.AnalogOnly,
                ExportChannelSelection    = DataExportChannelSelection.SpecificChannels,
                //DigitalChannelsToExport = new int[] { 1 },
                AnalogChannelsToExport = new int[] { 0 },

                SamplesRangeType = DataExportSampleRangeType.RangeAll,
                //StartingTime = 0.001,
                //EndingTime = 0.002,

                DataExportType    = DataExportType.ExportCsv,
                CsvIncludeHeaders = CsvHeadersType.CsvIncludesHeaders,
                CsvDelimiterType  = CsvDelimiterType.CsvComma,
                //CsvOutputMode = CsvOutputMode.CsvOneColumnPerBit,
                //CsvTimestampType = CsvTimestampType.CsvSample,
                CsvDisplayBase = CsvBase.CsvHexadecimal,
                //CsvDensity = CsvDensity.CsvTransition,

                //BinaryOutputMode = BinaryOutputMode.BinaryEverySample,
                //BinaryBitShifting = BinaryBitShifting.BinaryOriginalBitPositions,
                //BinaryOutputWordSize = BinaryOutputWordSize.Binary16Bit,

                AnalogFormat = AnalogOutputFormat.Voltage
            };

            client.SetActiveChannels(new int[] { 0, 1, 2 }, new int[] { 0, 1, 2 });
            client.SetCaptureSeconds(0.003);

            client.Capture();             //blocks until capture is complete, but processing is not complete.
            if (client.BlockUntillProcessingCompleteOrTimeout(new TimeSpan(0, 0, 35)) == false)
            {
                throw new Exception("processing took too long");
            }

            client.ExportData2(export_settings, true, true);
        }