Esempio n. 1
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.ExportAllChannels == true)
            {
                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.ExportAllChannels || (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);
        }
        //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.ExportAllChannels == true)
                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.ExportAllChannels || (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);
        }