+void Session::feed_in_analog(shared_ptr<Analog> analog)
+{
+ lock_guard<mutex> lock(data_mutex_);
+
+ const vector<shared_ptr<Channel>> channels = analog->channels();
+ const unsigned int channel_count = channels.size();
+ const size_t sample_count = analog->num_samples() / channel_count;
+ const float *data = analog->data_pointer();
+ bool sweep_beginning = false;
+
+ for (auto channel : channels)
+ {
+ shared_ptr<data::AnalogSnapshot> snapshot;
+
+ // Try to get the snapshot of the channel
+ const map< shared_ptr<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;
+
+ // Get sample limit.
+ uint64_t sample_limit;
+ try {
+ sample_limit = VariantBase::cast_dynamic<Variant<guint64>>(
+ device_->config_get(ConfigKey::LIMIT_SAMPLES)).get();
+ } catch (Error) {
+ sample_limit = 0;
+ }
+
+ // Create a snapshot, keep it in the maps of channels
+ snapshot = shared_ptr<data::AnalogSnapshot>(
+ new data::AnalogSnapshot(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);
+ }