- // Create a new data snapshot
- _cur_analog_snapshot = shared_ptr<data::AnalogSnapshot>(
- new data::AnalogSnapshot(analog));
- _analog_data->push_snapshot(_cur_analog_snapshot);
+ shared_ptr<data::AnalogSnapshot> snapshot;
+
+ sr_channel *const channel = (sr_channel*)p->data;
+ assert(channel);
+
+ // Try to get the snapshot of the channel
+ const map< const sr_channel*, shared_ptr<data::AnalogSnapshot> >::
+ iterator iter = _cur_analog_snapshots.find(channel);
+ 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 channels
+ snapshot = shared_ptr<data::AnalogSnapshot>(
+ new data::AnalogSnapshot(_dev_inst->get_sample_limit()));
+ _cur_analog_snapshots[channel] = snapshot;
+
+ // Find the annalog data associated with the channel
+ shared_ptr<view::AnalogSignal> sig =
+ dynamic_pointer_cast<view::AnalogSignal>(
+ signal_from_channel(channel));
+ 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,
+ channel_count);