- shared_ptr<view::Signal> signal;
- GVariant *gvar;
- uint64_t sample_rate = 0;
- unsigned int logic_probe_count = 0;
- unsigned int analog_probe_count = 0;
-
- // Detect what data types we will receive
- for (const GSList *l = sdi->probes; l; l = l->next) {
- const sr_probe *const probe = (const sr_probe *)l->data;
- if (!probe->enabled)
- continue;
-
- switch(probe->type) {
- case SR_PROBE_LOGIC:
- logic_probe_count++;
- break;
-
- case SR_PROBE_ANALOG:
- analog_probe_count++;
- break;
- }
- }
-
- // Read out the sample rate
- if(sdi->driver)
- {
- const int ret = sr_config_get(sdi->driver,
- SR_CONF_SAMPLERATE, &gvar, sdi);
- if (ret != SR_OK) {
- qDebug("Failed to get samplerate\n");
- return;
- }
-
- sample_rate = g_variant_get_uint64(gvar);
- g_variant_unref(gvar);
- }
-
- // Create data containers for the coming data snapshots
- {
- lock_guard<mutex> data_lock(_data_mutex);
-
- if (logic_probe_count != 0) {
- _logic_data.reset(new data::Logic(
- logic_probe_count, sample_rate));
- assert(_logic_data);
- }
-
- if (analog_probe_count != 0) {
- _analog_data.reset(new data::Analog(sample_rate));
- assert(_analog_data);
- }
- }
-
- // Make the logic probe list
- {
- lock_guard<mutex> lock(_signals_mutex);
-
- _signals.clear();
-
- for (const GSList *l = sdi->probes; l; l = l->next) {
- const sr_probe *const probe =
- (const sr_probe *)l->data;
- assert(probe);
- if (!probe->enabled)
- continue;
-
- switch(probe->type) {
- case SR_PROBE_LOGIC:
- signal = shared_ptr<view::Signal>(
- new view::LogicSignal(probe->name,
- _logic_data, probe->index));
- break;
-
- case SR_PROBE_ANALOG:
- signal = shared_ptr<view::Signal>(
- new view::AnalogSignal(probe->name,
- _analog_data, probe->index));
- break;
- }
-
- _signals.push_back(signal);
- }
-
- signals_changed();
- }