]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * This file is part of the PulseView project. | |
3 | * | |
4 | * Copyright (C) 2012-14 Joel Holdsworth <joel@airwebreathe.org.uk> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, see <http://www.gnu.org/licenses/>. | |
18 | */ | |
19 | ||
20 | #include <QDebug> | |
21 | #include <QFileInfo> | |
22 | ||
23 | #include <cassert> | |
24 | #include <memory> | |
25 | #include <mutex> | |
26 | #include <stdexcept> | |
27 | ||
28 | #include <sys/stat.h> | |
29 | ||
30 | #include "devicemanager.hpp" | |
31 | #include "mainwindow.hpp" | |
32 | #include "session.hpp" | |
33 | ||
34 | #include "data/analog.hpp" | |
35 | #include "data/analogsegment.hpp" | |
36 | #include "data/decode/decoder.hpp" | |
37 | #include "data/logic.hpp" | |
38 | #include "data/logicsegment.hpp" | |
39 | #include "data/signalbase.hpp" | |
40 | ||
41 | #include "devices/hardwaredevice.hpp" | |
42 | #include "devices/inputfile.hpp" | |
43 | #include "devices/sessionfile.hpp" | |
44 | ||
45 | #include "toolbars/mainbar.hpp" | |
46 | ||
47 | #include "views/trace/analogsignal.hpp" | |
48 | #include "views/trace/decodetrace.hpp" | |
49 | #include "views/trace/logicsignal.hpp" | |
50 | #include "views/trace/signal.hpp" | |
51 | #include "views/trace/view.hpp" | |
52 | ||
53 | #include <libsigrokcxx/libsigrokcxx.hpp> | |
54 | ||
55 | #ifdef ENABLE_DECODE | |
56 | #include <libsigrokdecode/libsigrokdecode.h> | |
57 | #include "data/decodesignal.hpp" | |
58 | #endif | |
59 | ||
60 | using std::bad_alloc; | |
61 | using std::dynamic_pointer_cast; | |
62 | using std::find_if; | |
63 | using std::function; | |
64 | using std::lock_guard; | |
65 | using std::list; | |
66 | using std::make_pair; | |
67 | using std::make_shared; | |
68 | using std::map; | |
69 | using std::max; | |
70 | using std::move; | |
71 | using std::mutex; | |
72 | using std::pair; | |
73 | using std::recursive_mutex; | |
74 | using std::runtime_error; | |
75 | using std::shared_ptr; | |
76 | using std::string; | |
77 | using std::unique_ptr; | |
78 | using std::unordered_set; | |
79 | using std::vector; | |
80 | ||
81 | using sigrok::Analog; | |
82 | using sigrok::Channel; | |
83 | using sigrok::ConfigKey; | |
84 | using sigrok::DatafeedCallbackFunction; | |
85 | using sigrok::Error; | |
86 | using sigrok::InputFormat; | |
87 | using sigrok::Logic; | |
88 | using sigrok::Meta; | |
89 | using sigrok::Packet; | |
90 | using sigrok::Session; | |
91 | ||
92 | using Glib::VariantBase; | |
93 | ||
94 | namespace pv { | |
95 | ||
96 | shared_ptr<sigrok::Context> Session::sr_context; | |
97 | ||
98 | Session::Session(DeviceManager &device_manager, QString name) : | |
99 | device_manager_(device_manager), | |
100 | default_name_(name), | |
101 | name_(name), | |
102 | capture_state_(Stopped), | |
103 | cur_samplerate_(0), | |
104 | data_saved_(true) | |
105 | { | |
106 | } | |
107 | ||
108 | Session::~Session() | |
109 | { | |
110 | // Stop and join to the thread | |
111 | stop_capture(); | |
112 | } | |
113 | ||
114 | DeviceManager& Session::device_manager() | |
115 | { | |
116 | return device_manager_; | |
117 | } | |
118 | ||
119 | const DeviceManager& Session::device_manager() const | |
120 | { | |
121 | return device_manager_; | |
122 | } | |
123 | ||
124 | shared_ptr<sigrok::Session> Session::session() const | |
125 | { | |
126 | if (!device_) | |
127 | return shared_ptr<sigrok::Session>(); | |
128 | return device_->session(); | |
129 | } | |
130 | ||
131 | shared_ptr<devices::Device> Session::device() const | |
132 | { | |
133 | return device_; | |
134 | } | |
135 | ||
136 | QString Session::name() const | |
137 | { | |
138 | return name_; | |
139 | } | |
140 | ||
141 | void Session::set_name(QString name) | |
142 | { | |
143 | if (default_name_.isEmpty()) | |
144 | default_name_ = name; | |
145 | ||
146 | name_ = name; | |
147 | ||
148 | name_changed(); | |
149 | } | |
150 | ||
151 | const list< shared_ptr<views::ViewBase> > Session::views() const | |
152 | { | |
153 | return views_; | |
154 | } | |
155 | ||
156 | shared_ptr<views::ViewBase> Session::main_view() const | |
157 | { | |
158 | return main_view_; | |
159 | } | |
160 | ||
161 | void Session::set_main_bar(shared_ptr<pv::toolbars::MainBar> main_bar) | |
162 | { | |
163 | main_bar_ = main_bar; | |
164 | } | |
165 | ||
166 | shared_ptr<pv::toolbars::MainBar> Session::main_bar() const | |
167 | { | |
168 | return main_bar_; | |
169 | } | |
170 | ||
171 | bool Session::data_saved() const | |
172 | { | |
173 | return data_saved_; | |
174 | } | |
175 | ||
176 | void Session::save_settings(QSettings &settings) const | |
177 | { | |
178 | map<string, string> dev_info; | |
179 | list<string> key_list; | |
180 | int decode_signals = 0, views = 0; | |
181 | ||
182 | if (device_) { | |
183 | shared_ptr<devices::HardwareDevice> hw_device = | |
184 | dynamic_pointer_cast< devices::HardwareDevice >(device_); | |
185 | ||
186 | if (hw_device) { | |
187 | settings.setValue("device_type", "hardware"); | |
188 | settings.beginGroup("device"); | |
189 | ||
190 | key_list.emplace_back("vendor"); | |
191 | key_list.emplace_back("model"); | |
192 | key_list.emplace_back("version"); | |
193 | key_list.emplace_back("serial_num"); | |
194 | key_list.emplace_back("connection_id"); | |
195 | ||
196 | dev_info = device_manager_.get_device_info(device_); | |
197 | ||
198 | for (string key : key_list) { | |
199 | if (dev_info.count(key)) | |
200 | settings.setValue(QString::fromUtf8(key.c_str()), | |
201 | QString::fromUtf8(dev_info.at(key).c_str())); | |
202 | else | |
203 | settings.remove(QString::fromUtf8(key.c_str())); | |
204 | } | |
205 | ||
206 | settings.endGroup(); | |
207 | } | |
208 | ||
209 | shared_ptr<devices::SessionFile> sessionfile_device = | |
210 | dynamic_pointer_cast< devices::SessionFile >(device_); | |
211 | ||
212 | if (sessionfile_device) { | |
213 | settings.setValue("device_type", "sessionfile"); | |
214 | settings.beginGroup("device"); | |
215 | settings.setValue("filename", QString::fromStdString( | |
216 | sessionfile_device->full_name())); | |
217 | settings.endGroup(); | |
218 | } | |
219 | ||
220 | // Save channels and decoders | |
221 | for (shared_ptr<data::SignalBase> base : signalbases_) { | |
222 | #ifdef ENABLE_DECODE | |
223 | if (base->is_decode_signal()) { | |
224 | settings.beginGroup("decode_signal" + QString::number(decode_signals++)); | |
225 | base->save_settings(settings); | |
226 | settings.endGroup(); | |
227 | } else | |
228 | #endif | |
229 | { | |
230 | settings.beginGroup(base->internal_name()); | |
231 | base->save_settings(settings); | |
232 | settings.endGroup(); | |
233 | } | |
234 | } | |
235 | ||
236 | settings.setValue("decode_signals", decode_signals); | |
237 | ||
238 | // Save view states and their signal settings | |
239 | // Note: main_view must be saved as view0 | |
240 | settings.beginGroup("view" + QString::number(views++)); | |
241 | main_view_->save_settings(settings); | |
242 | settings.endGroup(); | |
243 | ||
244 | for (shared_ptr<views::ViewBase> view : views_) { | |
245 | if (view != main_view_) { | |
246 | settings.beginGroup("view" + QString::number(views++)); | |
247 | view->save_settings(settings); | |
248 | settings.endGroup(); | |
249 | } | |
250 | } | |
251 | ||
252 | settings.setValue("views", views); | |
253 | } | |
254 | } | |
255 | ||
256 | void Session::restore_settings(QSettings &settings) | |
257 | { | |
258 | shared_ptr<devices::Device> device; | |
259 | ||
260 | QString device_type = settings.value("device_type").toString(); | |
261 | ||
262 | if (device_type == "hardware") { | |
263 | map<string, string> dev_info; | |
264 | list<string> key_list; | |
265 | ||
266 | // Re-select last used device if possible but only if it's not demo | |
267 | settings.beginGroup("device"); | |
268 | key_list.emplace_back("vendor"); | |
269 | key_list.emplace_back("model"); | |
270 | key_list.emplace_back("version"); | |
271 | key_list.emplace_back("serial_num"); | |
272 | key_list.emplace_back("connection_id"); | |
273 | ||
274 | for (string key : key_list) { | |
275 | const QString k = QString::fromStdString(key); | |
276 | if (!settings.contains(k)) | |
277 | continue; | |
278 | ||
279 | const string value = settings.value(k).toString().toStdString(); | |
280 | if (!value.empty()) | |
281 | dev_info.insert(make_pair(key, value)); | |
282 | } | |
283 | ||
284 | if (dev_info.count("model") > 0) | |
285 | device = device_manager_.find_device_from_info(dev_info); | |
286 | ||
287 | if (device) | |
288 | set_device(device); | |
289 | ||
290 | settings.endGroup(); | |
291 | } | |
292 | ||
293 | if (device_type == "sessionfile") { | |
294 | settings.beginGroup("device"); | |
295 | QString filename = settings.value("filename").toString(); | |
296 | settings.endGroup(); | |
297 | ||
298 | if (QFileInfo(filename).isReadable()) { | |
299 | device = make_shared<devices::SessionFile>(device_manager_.context(), | |
300 | filename.toStdString()); | |
301 | set_device(device); | |
302 | ||
303 | start_capture([](QString infoMessage) { | |
304 | // TODO Emulate noquote() | |
305 | qDebug() << "Session error:" << infoMessage; }); | |
306 | ||
307 | set_name(QFileInfo(filename).fileName()); | |
308 | } | |
309 | } | |
310 | ||
311 | if (device) { | |
312 | // Restore channels | |
313 | for (shared_ptr<data::SignalBase> base : signalbases_) { | |
314 | settings.beginGroup(base->internal_name()); | |
315 | base->restore_settings(settings); | |
316 | settings.endGroup(); | |
317 | } | |
318 | ||
319 | // Restore decoders | |
320 | #ifdef ENABLE_DECODE | |
321 | int decode_signals = settings.value("decode_signals").toInt(); | |
322 | ||
323 | for (int i = 0; i < decode_signals; i++) { | |
324 | settings.beginGroup("decode_signal" + QString::number(i)); | |
325 | shared_ptr<data::DecodeSignal> signal = add_decode_signal(); | |
326 | signal->restore_settings(settings); | |
327 | settings.endGroup(); | |
328 | } | |
329 | #endif | |
330 | ||
331 | // Restore views | |
332 | int views = settings.value("views").toInt(); | |
333 | ||
334 | for (int i = 0; i < views; i++) { | |
335 | settings.beginGroup("view" + QString::number(i)); | |
336 | ||
337 | if (i > 0) { | |
338 | views::ViewType type = (views::ViewType)settings.value("type").toInt(); | |
339 | add_view(name_, type, this); | |
340 | views_.back()->restore_settings(settings); | |
341 | } else | |
342 | main_view_->restore_settings(settings); | |
343 | ||
344 | settings.endGroup(); | |
345 | } | |
346 | } | |
347 | } | |
348 | ||
349 | void Session::select_device(shared_ptr<devices::Device> device) | |
350 | { | |
351 | try { | |
352 | if (device) | |
353 | set_device(device); | |
354 | else | |
355 | set_default_device(); | |
356 | } catch (const QString &e) { | |
357 | MainWindow::show_session_error(tr("Failed to select device"), e); | |
358 | } | |
359 | } | |
360 | ||
361 | void Session::set_device(shared_ptr<devices::Device> device) | |
362 | { | |
363 | assert(device); | |
364 | ||
365 | // Ensure we are not capturing before setting the device | |
366 | stop_capture(); | |
367 | ||
368 | if (device_) | |
369 | device_->close(); | |
370 | ||
371 | device_.reset(); | |
372 | ||
373 | // Revert name back to default name (e.g. "Session 1") as the data is gone | |
374 | name_ = default_name_; | |
375 | name_changed(); | |
376 | ||
377 | // Remove all stored data | |
378 | for (shared_ptr<views::ViewBase> view : views_) { | |
379 | view->clear_signals(); | |
380 | #ifdef ENABLE_DECODE | |
381 | view->clear_decode_signals(); | |
382 | #endif | |
383 | } | |
384 | for (const shared_ptr<data::SignalData> d : all_signal_data_) | |
385 | d->clear(); | |
386 | all_signal_data_.clear(); | |
387 | signalbases_.clear(); | |
388 | cur_logic_segment_.reset(); | |
389 | ||
390 | for (auto entry : cur_analog_segments_) { | |
391 | shared_ptr<sigrok::Channel>(entry.first).reset(); | |
392 | shared_ptr<data::AnalogSegment>(entry.second).reset(); | |
393 | } | |
394 | ||
395 | logic_data_.reset(); | |
396 | ||
397 | signals_changed(); | |
398 | ||
399 | device_ = move(device); | |
400 | ||
401 | try { | |
402 | device_->open(); | |
403 | } catch (const QString &e) { | |
404 | device_.reset(); | |
405 | MainWindow::show_session_error(tr("Failed to open device"), e); | |
406 | } | |
407 | ||
408 | if (device_) { | |
409 | device_->session()->add_datafeed_callback([=] | |
410 | (shared_ptr<sigrok::Device> device, shared_ptr<Packet> packet) { | |
411 | data_feed_in(device, packet); | |
412 | }); | |
413 | ||
414 | update_signals(); | |
415 | } | |
416 | ||
417 | device_changed(); | |
418 | } | |
419 | ||
420 | void Session::set_default_device() | |
421 | { | |
422 | const list< shared_ptr<devices::HardwareDevice> > &devices = | |
423 | device_manager_.devices(); | |
424 | ||
425 | if (devices.empty()) | |
426 | return; | |
427 | ||
428 | // Try and find the demo device and select that by default | |
429 | const auto iter = find_if(devices.begin(), devices.end(), | |
430 | [] (const shared_ptr<devices::HardwareDevice> &d) { | |
431 | return d->hardware_device()->driver()->name() == "demo"; }); | |
432 | set_device((iter == devices.end()) ? devices.front() : *iter); | |
433 | } | |
434 | ||
435 | /** | |
436 | * Convert generic options to data types that are specific to InputFormat. | |
437 | * | |
438 | * @param[in] user_spec Vector of tokenized words, string format. | |
439 | * @param[in] fmt_opts Input format's options, result of InputFormat::options(). | |
440 | * | |
441 | * @return Map of options suitable for InputFormat::create_input(). | |
442 | */ | |
443 | map<string, Glib::VariantBase> | |
444 | Session::input_format_options(vector<string> user_spec, | |
445 | map<string, shared_ptr<Option>> fmt_opts) | |
446 | { | |
447 | map<string, Glib::VariantBase> result; | |
448 | ||
449 | for (auto entry : user_spec) { | |
450 | /* | |
451 | * Split key=value specs. Accept entries without separator | |
452 | * (for simplified boolean specifications). | |
453 | */ | |
454 | string key, val; | |
455 | size_t pos = entry.find("="); | |
456 | if (pos == std::string::npos) { | |
457 | key = entry; | |
458 | val = ""; | |
459 | } else { | |
460 | key = entry.substr(0, pos); | |
461 | val = entry.substr(pos + 1); | |
462 | } | |
463 | ||
464 | /* | |
465 | * Skip user specifications that are not a member of the | |
466 | * format's set of supported options. Have the text input | |
467 | * spec converted to the required input format specific | |
468 | * data type. | |
469 | */ | |
470 | auto found = fmt_opts.find(key); | |
471 | if (found == fmt_opts.end()) | |
472 | continue; | |
473 | shared_ptr<Option> opt = found->second; | |
474 | result[key] = opt->parse_string(val); | |
475 | } | |
476 | ||
477 | return result; | |
478 | } | |
479 | ||
480 | void Session::load_init_file(const string &file_name, const string &format) | |
481 | { | |
482 | shared_ptr<InputFormat> input_format; | |
483 | map<string, Glib::VariantBase> input_opts; | |
484 | ||
485 | if (!format.empty()) { | |
486 | const map<string, shared_ptr<InputFormat> > formats = | |
487 | device_manager_.context()->input_formats(); | |
488 | auto user_opts = pv::util::split_string(format, ":"); | |
489 | string user_name = user_opts.front(); | |
490 | user_opts.erase(user_opts.begin()); | |
491 | const auto iter = find_if(formats.begin(), formats.end(), | |
492 | [&](const pair<string, shared_ptr<InputFormat> > f) { | |
493 | return f.first == user_name; }); | |
494 | if (iter == formats.end()) { | |
495 | MainWindow::show_session_error(tr("Error"), | |
496 | tr("Unexpected input format: %s").arg(QString::fromStdString(format))); | |
497 | return; | |
498 | } | |
499 | input_format = (*iter).second; | |
500 | input_opts = input_format_options(user_opts, | |
501 | input_format->options()); | |
502 | } | |
503 | ||
504 | load_file(QString::fromStdString(file_name), input_format, input_opts); | |
505 | } | |
506 | ||
507 | void Session::load_file(QString file_name, | |
508 | shared_ptr<sigrok::InputFormat> format, | |
509 | const map<string, Glib::VariantBase> &options) | |
510 | { | |
511 | const QString errorMessage( | |
512 | QString("Failed to load file %1").arg(file_name)); | |
513 | ||
514 | // In the absence of a caller's format spec, try to auto detect. | |
515 | // Assume "sigrok session file" upon lookup miss. | |
516 | if (!format) | |
517 | format = device_manager_.context()->input_format_match(file_name.toStdString()); | |
518 | try { | |
519 | if (format) | |
520 | set_device(shared_ptr<devices::Device>( | |
521 | new devices::InputFile( | |
522 | device_manager_.context(), | |
523 | file_name.toStdString(), | |
524 | format, options))); | |
525 | else | |
526 | set_device(shared_ptr<devices::Device>( | |
527 | new devices::SessionFile( | |
528 | device_manager_.context(), | |
529 | file_name.toStdString()))); | |
530 | } catch (Error& e) { | |
531 | MainWindow::show_session_error(tr("Failed to load ") + file_name, e.what()); | |
532 | set_default_device(); | |
533 | main_bar_->update_device_list(); | |
534 | return; | |
535 | } | |
536 | ||
537 | main_bar_->update_device_list(); | |
538 | ||
539 | start_capture([&, errorMessage](QString infoMessage) { | |
540 | MainWindow::show_session_error(errorMessage, infoMessage); }); | |
541 | ||
542 | set_name(QFileInfo(file_name).fileName()); | |
543 | } | |
544 | ||
545 | Session::capture_state Session::get_capture_state() const | |
546 | { | |
547 | lock_guard<mutex> lock(sampling_mutex_); | |
548 | return capture_state_; | |
549 | } | |
550 | ||
551 | void Session::start_capture(function<void (const QString)> error_handler) | |
552 | { | |
553 | if (!device_) { | |
554 | error_handler(tr("No active device set, can't start acquisition.")); | |
555 | return; | |
556 | } | |
557 | ||
558 | stop_capture(); | |
559 | ||
560 | // Check that at least one channel is enabled | |
561 | const shared_ptr<sigrok::Device> sr_dev = device_->device(); | |
562 | if (sr_dev) { | |
563 | const auto channels = sr_dev->channels(); | |
564 | if (!any_of(channels.begin(), channels.end(), | |
565 | [](shared_ptr<Channel> channel) { | |
566 | return channel->enabled(); })) { | |
567 | error_handler(tr("No channels enabled.")); | |
568 | return; | |
569 | } | |
570 | } | |
571 | ||
572 | // Clear signal data | |
573 | for (const shared_ptr<data::SignalData> d : all_signal_data_) | |
574 | d->clear(); | |
575 | ||
576 | trigger_list_.clear(); | |
577 | ||
578 | // Revert name back to default name (e.g. "Session 1") for real devices | |
579 | // as the (possibly saved) data is gone. File devices keep their name. | |
580 | shared_ptr<devices::HardwareDevice> hw_device = | |
581 | dynamic_pointer_cast< devices::HardwareDevice >(device_); | |
582 | ||
583 | if (hw_device) { | |
584 | name_ = default_name_; | |
585 | name_changed(); | |
586 | } | |
587 | ||
588 | // Begin the session | |
589 | sampling_thread_ = std::thread( | |
590 | &Session::sample_thread_proc, this, error_handler); | |
591 | } | |
592 | ||
593 | void Session::stop_capture() | |
594 | { | |
595 | if (get_capture_state() != Stopped) | |
596 | device_->stop(); | |
597 | ||
598 | // Check that sampling stopped | |
599 | if (sampling_thread_.joinable()) | |
600 | sampling_thread_.join(); | |
601 | } | |
602 | ||
603 | void Session::register_view(shared_ptr<views::ViewBase> view) | |
604 | { | |
605 | if (views_.empty()) { | |
606 | main_view_ = view; | |
607 | } | |
608 | ||
609 | views_.push_back(view); | |
610 | ||
611 | // Add all device signals | |
612 | update_signals(); | |
613 | ||
614 | // Add all other signals | |
615 | unordered_set< shared_ptr<data::SignalBase> > view_signalbases = | |
616 | view->signalbases(); | |
617 | ||
618 | views::trace::View *trace_view = | |
619 | qobject_cast<views::trace::View*>(view.get()); | |
620 | ||
621 | if (trace_view) { | |
622 | for (shared_ptr<data::SignalBase> signalbase : signalbases_) { | |
623 | const int sb_exists = count_if( | |
624 | view_signalbases.cbegin(), view_signalbases.cend(), | |
625 | [&](const shared_ptr<data::SignalBase> &sb) { | |
626 | return sb == signalbase; | |
627 | }); | |
628 | // Add the signal to the view as it doesn't have it yet | |
629 | if (!sb_exists) | |
630 | switch (signalbase->type()) { | |
631 | case data::SignalBase::AnalogChannel: | |
632 | case data::SignalBase::LogicChannel: | |
633 | case data::SignalBase::DecodeChannel: | |
634 | #ifdef ENABLE_DECODE | |
635 | trace_view->add_decode_signal( | |
636 | dynamic_pointer_cast<data::DecodeSignal>(signalbase)); | |
637 | #endif | |
638 | break; | |
639 | case data::SignalBase::MathChannel: | |
640 | // TBD | |
641 | break; | |
642 | } | |
643 | } | |
644 | } | |
645 | ||
646 | signals_changed(); | |
647 | } | |
648 | ||
649 | void Session::deregister_view(shared_ptr<views::ViewBase> view) | |
650 | { | |
651 | views_.remove_if([&](shared_ptr<views::ViewBase> v) { return v == view; }); | |
652 | ||
653 | if (views_.empty()) { | |
654 | main_view_.reset(); | |
655 | ||
656 | // Without a view there can be no main bar | |
657 | main_bar_.reset(); | |
658 | } | |
659 | } | |
660 | ||
661 | bool Session::has_view(shared_ptr<views::ViewBase> view) | |
662 | { | |
663 | for (shared_ptr<views::ViewBase> v : views_) | |
664 | if (v == view) | |
665 | return true; | |
666 | ||
667 | return false; | |
668 | } | |
669 | ||
670 | double Session::get_samplerate() const | |
671 | { | |
672 | double samplerate = 0.0; | |
673 | ||
674 | for (const shared_ptr<pv::data::SignalData> d : all_signal_data_) { | |
675 | assert(d); | |
676 | const vector< shared_ptr<pv::data::Segment> > segments = | |
677 | d->segments(); | |
678 | for (const shared_ptr<pv::data::Segment> &s : segments) | |
679 | samplerate = max(samplerate, s->samplerate()); | |
680 | } | |
681 | // If there is no sample rate given we use samples as unit | |
682 | if (samplerate == 0.0) | |
683 | samplerate = 1.0; | |
684 | ||
685 | return samplerate; | |
686 | } | |
687 | ||
688 | uint32_t Session::get_segment_count() const | |
689 | { | |
690 | uint32_t value = 0; | |
691 | ||
692 | // Find the highest number of segments | |
693 | for (shared_ptr<data::SignalData> data : all_signal_data_) | |
694 | if (data->get_segment_count() > value) | |
695 | value = data->get_segment_count(); | |
696 | ||
697 | return value; | |
698 | } | |
699 | ||
700 | vector<util::Timestamp> Session::get_triggers(uint32_t segment_id) const | |
701 | { | |
702 | vector<util::Timestamp> result; | |
703 | ||
704 | for (pair<uint32_t, util::Timestamp> entry : trigger_list_) | |
705 | if (entry.first == segment_id) | |
706 | result.push_back(entry.second); | |
707 | ||
708 | return result; | |
709 | } | |
710 | ||
711 | const unordered_set< shared_ptr<data::SignalBase> > Session::signalbases() const | |
712 | { | |
713 | return signalbases_; | |
714 | } | |
715 | ||
716 | bool Session::all_segments_complete(uint32_t segment_id) const | |
717 | { | |
718 | bool all_complete = true; | |
719 | ||
720 | for (shared_ptr<data::SignalBase> base : signalbases_) | |
721 | if (!base->segment_is_complete(segment_id)) | |
722 | all_complete = false; | |
723 | ||
724 | return all_complete; | |
725 | } | |
726 | ||
727 | #ifdef ENABLE_DECODE | |
728 | shared_ptr<data::DecodeSignal> Session::add_decode_signal() | |
729 | { | |
730 | shared_ptr<data::DecodeSignal> signal; | |
731 | ||
732 | try { | |
733 | // Create the decode signal | |
734 | signal = make_shared<data::DecodeSignal>(*this); | |
735 | ||
736 | signalbases_.insert(signal); | |
737 | ||
738 | // Add the decode signal to all views | |
739 | for (shared_ptr<views::ViewBase> view : views_) | |
740 | view->add_decode_signal(signal); | |
741 | } catch (runtime_error& e) { | |
742 | remove_decode_signal(signal); | |
743 | return nullptr; | |
744 | } | |
745 | ||
746 | signals_changed(); | |
747 | ||
748 | return signal; | |
749 | } | |
750 | ||
751 | void Session::remove_decode_signal(shared_ptr<data::DecodeSignal> signal) | |
752 | { | |
753 | signalbases_.erase(signal); | |
754 | ||
755 | for (shared_ptr<views::ViewBase> view : views_) | |
756 | view->remove_decode_signal(signal); | |
757 | ||
758 | signals_changed(); | |
759 | } | |
760 | #endif | |
761 | ||
762 | void Session::set_capture_state(capture_state state) | |
763 | { | |
764 | bool changed; | |
765 | ||
766 | { | |
767 | lock_guard<mutex> lock(sampling_mutex_); | |
768 | changed = capture_state_ != state; | |
769 | capture_state_ = state; | |
770 | } | |
771 | ||
772 | if (changed) | |
773 | capture_state_changed(state); | |
774 | } | |
775 | ||
776 | void Session::update_signals() | |
777 | { | |
778 | if (!device_) { | |
779 | signalbases_.clear(); | |
780 | logic_data_.reset(); | |
781 | for (shared_ptr<views::ViewBase> view : views_) { | |
782 | view->clear_signals(); | |
783 | #ifdef ENABLE_DECODE | |
784 | view->clear_decode_signals(); | |
785 | #endif | |
786 | } | |
787 | return; | |
788 | } | |
789 | ||
790 | lock_guard<recursive_mutex> lock(data_mutex_); | |
791 | ||
792 | const shared_ptr<sigrok::Device> sr_dev = device_->device(); | |
793 | if (!sr_dev) { | |
794 | signalbases_.clear(); | |
795 | logic_data_.reset(); | |
796 | for (shared_ptr<views::ViewBase> view : views_) { | |
797 | view->clear_signals(); | |
798 | #ifdef ENABLE_DECODE | |
799 | view->clear_decode_signals(); | |
800 | #endif | |
801 | } | |
802 | return; | |
803 | } | |
804 | ||
805 | // Detect what data types we will receive | |
806 | auto channels = sr_dev->channels(); | |
807 | unsigned int logic_channel_count = count_if( | |
808 | channels.begin(), channels.end(), | |
809 | [] (shared_ptr<Channel> channel) { | |
810 | return channel->type() == sigrok::ChannelType::LOGIC; }); | |
811 | ||
812 | // Create data containers for the logic data segments | |
813 | { | |
814 | lock_guard<recursive_mutex> data_lock(data_mutex_); | |
815 | ||
816 | if (logic_channel_count == 0) { | |
817 | logic_data_.reset(); | |
818 | } else if (!logic_data_ || | |
819 | logic_data_->num_channels() != logic_channel_count) { | |
820 | logic_data_.reset(new data::Logic( | |
821 | logic_channel_count)); | |
822 | assert(logic_data_); | |
823 | } | |
824 | } | |
825 | ||
826 | // Make the signals list | |
827 | for (shared_ptr<views::ViewBase> viewbase : views_) { | |
828 | views::trace::View *trace_view = | |
829 | qobject_cast<views::trace::View*>(viewbase.get()); | |
830 | ||
831 | if (trace_view) { | |
832 | unordered_set< shared_ptr<views::trace::Signal> > | |
833 | prev_sigs(trace_view->signals()); | |
834 | trace_view->clear_signals(); | |
835 | ||
836 | for (auto channel : sr_dev->channels()) { | |
837 | shared_ptr<data::SignalBase> signalbase; | |
838 | shared_ptr<views::trace::Signal> signal; | |
839 | ||
840 | // Find the channel in the old signals | |
841 | const auto iter = find_if( | |
842 | prev_sigs.cbegin(), prev_sigs.cend(), | |
843 | [&](const shared_ptr<views::trace::Signal> &s) { | |
844 | return s->base()->channel() == channel; | |
845 | }); | |
846 | if (iter != prev_sigs.end()) { | |
847 | // Copy the signal from the old set to the new | |
848 | signal = *iter; | |
849 | trace_view->add_signal(signal); | |
850 | } else { | |
851 | // Find the signalbase for this channel if possible | |
852 | signalbase.reset(); | |
853 | for (const shared_ptr<data::SignalBase> b : signalbases_) | |
854 | if (b->channel() == channel) | |
855 | signalbase = b; | |
856 | ||
857 | switch(channel->type()->id()) { | |
858 | case SR_CHANNEL_LOGIC: | |
859 | if (!signalbase) { | |
860 | signalbase = make_shared<data::SignalBase>(channel, | |
861 | data::SignalBase::LogicChannel); | |
862 | signalbases_.insert(signalbase); | |
863 | ||
864 | all_signal_data_.insert(logic_data_); | |
865 | signalbase->set_data(logic_data_); | |
866 | ||
867 | connect(this, SIGNAL(capture_state_changed(int)), | |
868 | signalbase.get(), SLOT(on_capture_state_changed(int))); | |
869 | } | |
870 | ||
871 | signal = shared_ptr<views::trace::Signal>( | |
872 | new views::trace::LogicSignal(*this, | |
873 | device_, signalbase)); | |
874 | trace_view->add_signal(signal); | |
875 | break; | |
876 | ||
877 | case SR_CHANNEL_ANALOG: | |
878 | { | |
879 | if (!signalbase) { | |
880 | signalbase = make_shared<data::SignalBase>(channel, | |
881 | data::SignalBase::AnalogChannel); | |
882 | signalbases_.insert(signalbase); | |
883 | ||
884 | shared_ptr<data::Analog> data(new data::Analog()); | |
885 | all_signal_data_.insert(data); | |
886 | signalbase->set_data(data); | |
887 | ||
888 | connect(this, SIGNAL(capture_state_changed(int)), | |
889 | signalbase.get(), SLOT(on_capture_state_changed(int))); | |
890 | } | |
891 | ||
892 | signal = shared_ptr<views::trace::Signal>( | |
893 | new views::trace::AnalogSignal( | |
894 | *this, signalbase)); | |
895 | trace_view->add_signal(signal); | |
896 | break; | |
897 | } | |
898 | ||
899 | default: | |
900 | assert(false); | |
901 | break; | |
902 | } | |
903 | } | |
904 | } | |
905 | } | |
906 | } | |
907 | ||
908 | signals_changed(); | |
909 | } | |
910 | ||
911 | shared_ptr<data::SignalBase> Session::signalbase_from_channel( | |
912 | shared_ptr<sigrok::Channel> channel) const | |
913 | { | |
914 | for (shared_ptr<data::SignalBase> sig : signalbases_) { | |
915 | assert(sig); | |
916 | if (sig->channel() == channel) | |
917 | return sig; | |
918 | } | |
919 | return shared_ptr<data::SignalBase>(); | |
920 | } | |
921 | ||
922 | void Session::sample_thread_proc(function<void (const QString)> error_handler) | |
923 | { | |
924 | assert(error_handler); | |
925 | ||
926 | if (!device_) | |
927 | return; | |
928 | ||
929 | cur_samplerate_ = device_->read_config<uint64_t>(ConfigKey::SAMPLERATE); | |
930 | ||
931 | out_of_memory_ = false; | |
932 | ||
933 | { | |
934 | lock_guard<recursive_mutex> lock(data_mutex_); | |
935 | cur_logic_segment_.reset(); | |
936 | cur_analog_segments_.clear(); | |
937 | } | |
938 | highest_segment_id_ = -1; | |
939 | frame_began_ = false; | |
940 | ||
941 | try { | |
942 | device_->start(); | |
943 | } catch (Error& e) { | |
944 | error_handler(e.what()); | |
945 | return; | |
946 | } | |
947 | ||
948 | set_capture_state(device_->session()->trigger() ? | |
949 | AwaitingTrigger : Running); | |
950 | ||
951 | try { | |
952 | device_->run(); | |
953 | } catch (Error& e) { | |
954 | error_handler(e.what()); | |
955 | set_capture_state(Stopped); | |
956 | return; | |
957 | } | |
958 | ||
959 | set_capture_state(Stopped); | |
960 | ||
961 | // Confirm that SR_DF_END was received | |
962 | if (cur_logic_segment_) | |
963 | qDebug() << "WARNING: SR_DF_END was not received."; | |
964 | ||
965 | // Optimize memory usage | |
966 | free_unused_memory(); | |
967 | ||
968 | // We now have unsaved data unless we just "captured" from a file | |
969 | shared_ptr<devices::File> file_device = | |
970 | dynamic_pointer_cast<devices::File>(device_); | |
971 | ||
972 | if (!file_device) | |
973 | data_saved_ = false; | |
974 | ||
975 | if (out_of_memory_) | |
976 | error_handler(tr("Out of memory, acquisition stopped.")); | |
977 | } | |
978 | ||
979 | void Session::free_unused_memory() | |
980 | { | |
981 | for (shared_ptr<data::SignalData> data : all_signal_data_) { | |
982 | const vector< shared_ptr<data::Segment> > segments = data->segments(); | |
983 | ||
984 | for (shared_ptr<data::Segment> segment : segments) { | |
985 | segment->free_unused_memory(); | |
986 | } | |
987 | } | |
988 | } | |
989 | ||
990 | void Session::signal_new_segment() | |
991 | { | |
992 | int new_segment_id = 0; | |
993 | ||
994 | if ((cur_logic_segment_ != nullptr) || !cur_analog_segments_.empty()) { | |
995 | ||
996 | // Determine new frame/segment number, assuming that all | |
997 | // signals have the same number of frames/segments | |
998 | if (cur_logic_segment_) { | |
999 | new_segment_id = logic_data_->get_segment_count() - 1; | |
1000 | } else { | |
1001 | shared_ptr<sigrok::Channel> any_channel = | |
1002 | (*cur_analog_segments_.begin()).first; | |
1003 | ||
1004 | shared_ptr<data::SignalBase> base = signalbase_from_channel(any_channel); | |
1005 | assert(base); | |
1006 | ||
1007 | shared_ptr<data::Analog> data(base->analog_data()); | |
1008 | assert(data); | |
1009 | ||
1010 | new_segment_id = data->get_segment_count() - 1; | |
1011 | } | |
1012 | } | |
1013 | ||
1014 | if (new_segment_id > highest_segment_id_) { | |
1015 | highest_segment_id_ = new_segment_id; | |
1016 | new_segment(highest_segment_id_); | |
1017 | } | |
1018 | } | |
1019 | ||
1020 | void Session::signal_segment_completed() | |
1021 | { | |
1022 | int segment_id = 0; | |
1023 | ||
1024 | for (shared_ptr<data::SignalBase> signalbase : signalbases_) { | |
1025 | // We only care about analog and logic channels, not derived ones | |
1026 | if (signalbase->type() == data::SignalBase::AnalogChannel) { | |
1027 | segment_id = signalbase->analog_data()->get_segment_count() - 1; | |
1028 | break; | |
1029 | } | |
1030 | ||
1031 | if (signalbase->type() == data::SignalBase::LogicChannel) { | |
1032 | segment_id = signalbase->logic_data()->get_segment_count() - 1; | |
1033 | break; | |
1034 | } | |
1035 | } | |
1036 | ||
1037 | if (segment_id >= 0) | |
1038 | segment_completed(segment_id); | |
1039 | } | |
1040 | ||
1041 | void Session::feed_in_header() | |
1042 | { | |
1043 | // Nothing to do here for now | |
1044 | } | |
1045 | ||
1046 | void Session::feed_in_meta(shared_ptr<Meta> meta) | |
1047 | { | |
1048 | for (auto entry : meta->config()) { | |
1049 | switch (entry.first->id()) { | |
1050 | case SR_CONF_SAMPLERATE: | |
1051 | // We can't rely on the header to always contain the sample rate, | |
1052 | // so in case it's supplied via a meta packet, we use it. | |
1053 | if (!cur_samplerate_) | |
1054 | cur_samplerate_ = g_variant_get_uint64(entry.second.gobj()); | |
1055 | ||
1056 | /// @todo handle samplerate changes | |
1057 | break; | |
1058 | default: | |
1059 | // Unknown metadata is not an error. | |
1060 | break; | |
1061 | } | |
1062 | } | |
1063 | ||
1064 | signals_changed(); | |
1065 | } | |
1066 | ||
1067 | void Session::feed_in_trigger() | |
1068 | { | |
1069 | // The channel containing most samples should be most accurate | |
1070 | uint64_t sample_count = 0; | |
1071 | ||
1072 | { | |
1073 | for (const shared_ptr<pv::data::SignalData> d : all_signal_data_) { | |
1074 | assert(d); | |
1075 | uint64_t temp_count = 0; | |
1076 | ||
1077 | const vector< shared_ptr<pv::data::Segment> > segments = | |
1078 | d->segments(); | |
1079 | for (const shared_ptr<pv::data::Segment> &s : segments) | |
1080 | temp_count += s->get_sample_count(); | |
1081 | ||
1082 | if (temp_count > sample_count) | |
1083 | sample_count = temp_count; | |
1084 | } | |
1085 | } | |
1086 | ||
1087 | uint32_t segment_id = 0; // Default segment when no frames are used | |
1088 | ||
1089 | // If a frame began, we'd ideally be able to use the highest segment ID for | |
1090 | // the trigger. However, as new segments are only created when logic or | |
1091 | // analog data comes in, this doesn't work if the trigger appears right | |
1092 | // after the beginning of the frame, before any sample data. | |
1093 | // For this reason, we use highest segment ID + 1 if no sample data came in | |
1094 | // yet and the highest segment ID otherwise. | |
1095 | if (frame_began_) { | |
1096 | segment_id = highest_segment_id_; | |
1097 | if (!cur_logic_segment_ && (cur_analog_segments_.size() == 0)) | |
1098 | segment_id++; | |
1099 | } | |
1100 | ||
1101 | // TODO Create timestamp from segment start time + segment's current sample count | |
1102 | util::Timestamp timestamp = sample_count / get_samplerate(); | |
1103 | trigger_list_.emplace_back(segment_id, timestamp); | |
1104 | trigger_event(segment_id, timestamp); | |
1105 | } | |
1106 | ||
1107 | void Session::feed_in_frame_begin() | |
1108 | { | |
1109 | frame_began_ = true; | |
1110 | } | |
1111 | ||
1112 | void Session::feed_in_frame_end() | |
1113 | { | |
1114 | if (!frame_began_) | |
1115 | return; | |
1116 | ||
1117 | { | |
1118 | lock_guard<recursive_mutex> lock(data_mutex_); | |
1119 | ||
1120 | if (cur_logic_segment_) | |
1121 | cur_logic_segment_->set_complete(); | |
1122 | ||
1123 | for (auto entry : cur_analog_segments_) { | |
1124 | shared_ptr<data::AnalogSegment> segment = entry.second; | |
1125 | segment->set_complete(); | |
1126 | } | |
1127 | ||
1128 | cur_logic_segment_.reset(); | |
1129 | cur_analog_segments_.clear(); | |
1130 | } | |
1131 | ||
1132 | frame_began_ = false; | |
1133 | ||
1134 | signal_segment_completed(); | |
1135 | } | |
1136 | ||
1137 | void Session::feed_in_logic(shared_ptr<Logic> logic) | |
1138 | { | |
1139 | if (logic->data_length() == 0) { | |
1140 | qDebug() << "WARNING: Received logic packet with 0 samples."; | |
1141 | return; | |
1142 | } | |
1143 | ||
1144 | if (!cur_samplerate_) | |
1145 | cur_samplerate_ = device_->read_config<uint64_t>(ConfigKey::SAMPLERATE); | |
1146 | ||
1147 | lock_guard<recursive_mutex> lock(data_mutex_); | |
1148 | ||
1149 | if (!logic_data_) { | |
1150 | // The only reason logic_data_ would not have been created is | |
1151 | // if it was not possible to determine the signals when the | |
1152 | // device was created. | |
1153 | update_signals(); | |
1154 | } | |
1155 | ||
1156 | if (!cur_logic_segment_) { | |
1157 | // This could be the first packet after a trigger | |
1158 | set_capture_state(Running); | |
1159 | ||
1160 | // Create a new data segment | |
1161 | cur_logic_segment_ = make_shared<data::LogicSegment>( | |
1162 | *logic_data_, logic_data_->get_segment_count(), | |
1163 | logic->unit_size(), cur_samplerate_); | |
1164 | logic_data_->push_segment(cur_logic_segment_); | |
1165 | ||
1166 | signal_new_segment(); | |
1167 | } | |
1168 | ||
1169 | cur_logic_segment_->append_payload(logic); | |
1170 | ||
1171 | data_received(); | |
1172 | } | |
1173 | ||
1174 | void Session::feed_in_analog(shared_ptr<Analog> analog) | |
1175 | { | |
1176 | if (analog->num_samples() == 0) { | |
1177 | qDebug() << "WARNING: Received analog packet with 0 samples."; | |
1178 | return; | |
1179 | } | |
1180 | ||
1181 | if (!cur_samplerate_) | |
1182 | cur_samplerate_ = device_->read_config<uint64_t>(ConfigKey::SAMPLERATE); | |
1183 | ||
1184 | lock_guard<recursive_mutex> lock(data_mutex_); | |
1185 | ||
1186 | const vector<shared_ptr<Channel>> channels = analog->channels(); | |
1187 | const unsigned int channel_count = channels.size(); | |
1188 | const size_t sample_count = analog->num_samples() / channel_count; | |
1189 | bool sweep_beginning = false; | |
1190 | ||
1191 | unique_ptr<float[]> data(new float[analog->num_samples()]); | |
1192 | analog->get_data_as_float(data.get()); | |
1193 | ||
1194 | if (signalbases_.empty()) | |
1195 | update_signals(); | |
1196 | ||
1197 | float *channel_data = data.get(); | |
1198 | for (auto channel : channels) { | |
1199 | shared_ptr<data::AnalogSegment> segment; | |
1200 | ||
1201 | // Try to get the segment of the channel | |
1202 | const map< shared_ptr<Channel>, shared_ptr<data::AnalogSegment> >:: | |
1203 | iterator iter = cur_analog_segments_.find(channel); | |
1204 | if (iter != cur_analog_segments_.end()) | |
1205 | segment = (*iter).second; | |
1206 | else { | |
1207 | // If no segment was found, this means we haven't | |
1208 | // created one yet. i.e. this is the first packet | |
1209 | // in the sweep containing this segment. | |
1210 | sweep_beginning = true; | |
1211 | ||
1212 | // Find the analog data associated with the channel | |
1213 | shared_ptr<data::SignalBase> base = signalbase_from_channel(channel); | |
1214 | assert(base); | |
1215 | ||
1216 | shared_ptr<data::Analog> data(base->analog_data()); | |
1217 | assert(data); | |
1218 | ||
1219 | // Create a segment, keep it in the maps of channels | |
1220 | segment = make_shared<data::AnalogSegment>( | |
1221 | *data, data->get_segment_count(), cur_samplerate_); | |
1222 | cur_analog_segments_[channel] = segment; | |
1223 | ||
1224 | // Push the segment into the analog data. | |
1225 | data->push_segment(segment); | |
1226 | ||
1227 | signal_new_segment(); | |
1228 | } | |
1229 | ||
1230 | assert(segment); | |
1231 | ||
1232 | // Append the samples in the segment | |
1233 | segment->append_interleaved_samples(channel_data++, sample_count, | |
1234 | channel_count); | |
1235 | } | |
1236 | ||
1237 | if (sweep_beginning) { | |
1238 | // This could be the first packet after a trigger | |
1239 | set_capture_state(Running); | |
1240 | } | |
1241 | ||
1242 | data_received(); | |
1243 | } | |
1244 | ||
1245 | void Session::data_feed_in(shared_ptr<sigrok::Device> device, | |
1246 | shared_ptr<Packet> packet) | |
1247 | { | |
1248 | (void)device; | |
1249 | ||
1250 | assert(device); | |
1251 | assert(device == device_->device()); | |
1252 | assert(packet); | |
1253 | ||
1254 | switch (packet->type()->id()) { | |
1255 | case SR_DF_HEADER: | |
1256 | feed_in_header(); | |
1257 | break; | |
1258 | ||
1259 | case SR_DF_META: | |
1260 | feed_in_meta(dynamic_pointer_cast<Meta>(packet->payload())); | |
1261 | break; | |
1262 | ||
1263 | case SR_DF_TRIGGER: | |
1264 | feed_in_trigger(); | |
1265 | break; | |
1266 | ||
1267 | case SR_DF_LOGIC: | |
1268 | try { | |
1269 | feed_in_logic(dynamic_pointer_cast<Logic>(packet->payload())); | |
1270 | } catch (bad_alloc&) { | |
1271 | out_of_memory_ = true; | |
1272 | device_->stop(); | |
1273 | } | |
1274 | break; | |
1275 | ||
1276 | case SR_DF_ANALOG: | |
1277 | try { | |
1278 | feed_in_analog(dynamic_pointer_cast<Analog>(packet->payload())); | |
1279 | } catch (bad_alloc&) { | |
1280 | out_of_memory_ = true; | |
1281 | device_->stop(); | |
1282 | } | |
1283 | break; | |
1284 | ||
1285 | case SR_DF_FRAME_BEGIN: | |
1286 | feed_in_frame_begin(); | |
1287 | break; | |
1288 | ||
1289 | case SR_DF_FRAME_END: | |
1290 | feed_in_frame_end(); | |
1291 | break; | |
1292 | ||
1293 | case SR_DF_END: | |
1294 | // Strictly speaking, this is performed when a frame end marker was | |
1295 | // received, so there's no point doing this again. However, not all | |
1296 | // devices use frames, and for those devices, we need to do it here. | |
1297 | { | |
1298 | lock_guard<recursive_mutex> lock(data_mutex_); | |
1299 | ||
1300 | if (cur_logic_segment_) | |
1301 | cur_logic_segment_->set_complete(); | |
1302 | ||
1303 | for (auto entry : cur_analog_segments_) { | |
1304 | shared_ptr<data::AnalogSegment> segment = entry.second; | |
1305 | segment->set_complete(); | |
1306 | } | |
1307 | ||
1308 | cur_logic_segment_.reset(); | |
1309 | cur_analog_segments_.clear(); | |
1310 | } | |
1311 | break; | |
1312 | ||
1313 | default: | |
1314 | break; | |
1315 | } | |
1316 | } | |
1317 | ||
1318 | void Session::on_data_saved() | |
1319 | { | |
1320 | data_saved_ = true; | |
1321 | } | |
1322 | ||
1323 | } // namespace pv |