| 866 | } |
| 867 | |
| 868 | void 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; |
nothing calls this directly
no test coverage detected