- // Create a new data snapshot
- _cur_analog_snapshot = shared_ptr<data::AnalogSnapshot>(
- new data::AnalogSnapshot(analog));
- _analog_data->push_snapshot(_cur_analog_snapshot);
+ sr_probe *const probe = (sr_probe*)p->data;
+ assert(probe);
+
+ // Try to get the snapshot of the probe
+ const map< const sr_probe*, shared_ptr<data::AnalogSnapshot> >::
+ iterator iter = _cur_analog_snapshots.find(probe);
+ if (iter != _cur_analog_snapshots.end())
+ snapshot = (*iter).second;
+ else
+ {
+ // If no snapshot was found, this means we havn't
+ // created one yet. i.e. this is the first packet
+ // in the sweep containing this snapshot.
+ sweep_beginning = true;
+
+ // Create a snapshot, keep it in the maps of probes
+ snapshot = shared_ptr<data::AnalogSnapshot>(
+ new data::AnalogSnapshot());
+ _cur_analog_snapshots[probe] = snapshot;
+
+ // Find the annalog data associated with the probe
+ shared_ptr<view::AnalogSignal> sig =
+ dynamic_pointer_cast<view::AnalogSignal>(
+ signal_from_probe(probe));
+ assert(sig);
+
+ shared_ptr<data::Analog> data(sig->analog_data());
+ assert(data);
+
+ // Push the snapshot into the analog data.
+ data->push_snapshot(snapshot);
+ }
+
+ assert(snapshot);
+
+ // Append the samples in the snapshot
+ snapshot->append_interleaved_samples(data++, sample_count,
+ probe_count);