MCPcopy Index your code
hub / github.com/DreamSourceLab/DSView / export_exec

Method export_exec

DSView/pv/storesession.cpp:868–1221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

866}
867
868void StoreSession::export_exec(data::Snapshot *snapshot)
869{
870 assert(snapshot);
871
872 //set export all data flag
873 AppConfig &app = AppConfig::Instance();
874 int origin_flag = app.appOptions.originalData ? 1 : 0;
875
876 data::LogicSnapshot *logic_snapshot = NULL;
877 data::AnalogSnapshot *analog_snapshot = NULL;
878 data::DsoSnapshot *dso_snapshot = NULL;
879 int channel_type;
880
881 if ((logic_snapshot = dynamic_cast<data::LogicSnapshot*>(snapshot))) {
882 channel_type = SR_CHANNEL_LOGIC;
883 } else if ((dso_snapshot = dynamic_cast<data::DsoSnapshot*>(snapshot))) {
884 channel_type = SR_CHANNEL_DSO;
885 } else if ((analog_snapshot = dynamic_cast<data::AnalogSnapshot*>(snapshot))) {
886 channel_type = SR_CHANNEL_ANALOG;
887 } else {
888 _has_error = true;
889 _error = L_S(STR_PAGE_DLG, S_ID(IDS_MSG_STORESESS_EXPORTPROC_ERROR1), "data type don't support.");
890 return;
891 }
892
893 GHashTable *params = g_hash_table_new(g_str_hash, g_str_equal);
894 GVariant* filenameGVariant = g_variant_new_bytestring(_file_name.toUtf8().data());
895 g_hash_table_insert(params, (char*)"filename", filenameGVariant);
896 GVariant* typeGVariant = g_variant_new_int16(channel_type);
897 g_hash_table_insert(params, (char*)"type", typeGVariant);
898
899 struct sr_output output;
900 output.module = (sr_output_module*) _outModule;
901 output.sdi = _session->get_device()->inst();
902 output.param = NULL;
903 output.start_sample_index = 0;
904
905 if (channel_type == SR_CHANNEL_LOGIC){
906 output.start_sample_index = _start_index;
907 }
908
909 if(_outModule->init){
910 if(_outModule->init(&output, params) != SR_OK){
911 dsv_err("Failed to init export module.");
912 return;
913 }
914 }
915
916 QFile file(_file_name);
917 file.open(QIODevice::WriteOnly | QIODevice::Text);
918 QTextStream out(&file);
919 encoding::set_utf8(out);
920 //out.setGenerateByteOrderMark(true); // UTF-8 without BOM
921
922 // Meta
923 GString *data_out;
924 struct sr_datafeed_packet p;
925 struct sr_datafeed_meta meta;

Callers

nothing calls this directly

Calls 15

set_utf8Function · 0.85
instMethod · 0.80
get_deviceMethod · 0.80
new_configMethod · 0.80
cur_snap_samplerateMethod · 0.80
get_sample_countMethod · 0.80
get_config_byteMethod · 0.80
get_configMethod · 0.80
free_configMethod · 0.80
get_block_bufMethod · 0.80
sizeMethod · 0.80
get_channel_numMethod · 0.80

Tested by

no test coverage detected