]>
Commit | Line | Data |
---|---|---|
f4e57597 SA |
1 | /* |
2 | * This file is part of the PulseView project. | |
3 | * | |
4 | * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk> | |
5 | * Copyright (C) 2016 Soeren Apel <soeren@apelpie.net> | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2 of the License, or | |
10 | * (at your option) any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
efdec55a | 18 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
f4e57597 SA |
19 | */ |
20 | ||
21 | #ifdef ENABLE_DECODE | |
22 | #include <libsigrokdecode/libsigrokdecode.h> | |
23 | #endif | |
24 | ||
25 | #include <libsigrokcxx/libsigrokcxx.hpp> | |
26 | ||
27 | #include "pv/session.hpp" | |
28 | #include "pv/util.hpp" | |
8c339741 | 29 | #include "pv/data/segment.hpp" |
f4e57597 SA |
30 | |
31 | using std::shared_ptr; | |
32 | ||
33 | namespace pv { | |
34 | namespace views { | |
35 | ||
5ed05b69 SA |
36 | const int ViewBase::MaxViewAutoUpdateRate = 25; // No more than 25 Hz |
37 | ||
143d322d | 38 | ViewBase::ViewBase(Session &session, bool is_main_view, QWidget *parent) : |
5a206446 | 39 | // Note: Place defaults in ViewBase::reset_view_state(), not here |
79926d3f | 40 | QWidget(parent), |
143d322d | 41 | session_(session), |
5a206446 | 42 | is_main_view_(is_main_view) |
f4e57597 SA |
43 | { |
44 | (void)parent; | |
45 | ||
46 | connect(&session_, SIGNAL(signals_changed()), | |
47 | this, SLOT(signals_changed())); | |
48 | connect(&session_, SIGNAL(capture_state_changed(int)), | |
49 | this, SLOT(capture_state_updated(int))); | |
4e86ec70 SA |
50 | connect(&session_, SIGNAL(new_segment(int)), |
51 | this, SLOT(on_new_segment(int))); | |
5ed05b69 SA |
52 | |
53 | connect(&delayed_view_updater_, SIGNAL(timeout()), | |
54 | this, SLOT(perform_delayed_view_update())); | |
55 | delayed_view_updater_.setSingleShot(true); | |
56 | delayed_view_updater_.setInterval(1000 / MaxViewAutoUpdateRate); | |
f4e57597 SA |
57 | } |
58 | ||
5a206446 SA |
59 | void ViewBase::reset_view_state() |
60 | { | |
5a206446 SA |
61 | current_segment_ = 0; |
62 | } | |
63 | ||
f4e57597 SA |
64 | Session& ViewBase::session() |
65 | { | |
66 | return session_; | |
67 | } | |
68 | ||
69 | const Session& ViewBase::session() const | |
70 | { | |
71 | return session_; | |
72 | } | |
73 | ||
74 | void ViewBase::clear_signals() | |
75 | { | |
76 | } | |
77 | ||
5ed05b69 SA |
78 | unordered_set< shared_ptr<data::SignalBase> > ViewBase::signalbases() const |
79 | { | |
80 | return signalbases_; | |
81 | } | |
82 | ||
83 | void ViewBase::clear_signalbases() | |
84 | { | |
f4ab4b5c | 85 | for (const shared_ptr<data::SignalBase>& signalbase : signalbases_) { |
5ed05b69 SA |
86 | disconnect(signalbase.get(), SIGNAL(samples_cleared()), |
87 | this, SLOT(on_data_updated())); | |
7f894d95 SA |
88 | disconnect(signalbase.get(), SIGNAL(samples_added(uint64_t, uint64_t, uint64_t)), |
89 | this, SLOT(on_samples_added(uint64_t, uint64_t, uint64_t))); | |
5ed05b69 SA |
90 | } |
91 | ||
92 | signalbases_.clear(); | |
93 | } | |
94 | ||
95 | void ViewBase::add_signalbase(const shared_ptr<data::SignalBase> signalbase) | |
96 | { | |
97 | signalbases_.insert(signalbase); | |
98 | ||
99 | connect(signalbase.get(), SIGNAL(samples_cleared()), | |
100 | this, SLOT(on_data_updated())); | |
7f894d95 SA |
101 | connect(signalbase.get(), SIGNAL(samples_added(uint64_t, uint64_t, uint64_t)), |
102 | this, SLOT(on_samples_added(uint64_t, uint64_t, uint64_t))); | |
5ed05b69 SA |
103 | } |
104 | ||
f4e57597 SA |
105 | #ifdef ENABLE_DECODE |
106 | void ViewBase::clear_decode_signals() | |
107 | { | |
108 | } | |
109 | ||
ad908057 | 110 | void ViewBase::add_decode_signal(shared_ptr<data::DecodeSignal> signal) |
f4e57597 | 111 | { |
ad908057 | 112 | (void)signal; |
f4e57597 SA |
113 | } |
114 | ||
ad908057 | 115 | void ViewBase::remove_decode_signal(shared_ptr<data::DecodeSignal> signal) |
f4e57597 | 116 | { |
ad908057 | 117 | (void)signal; |
f4e57597 SA |
118 | } |
119 | #endif | |
120 | ||
121 | void ViewBase::save_settings(QSettings &settings) const | |
122 | { | |
123 | (void)settings; | |
124 | } | |
125 | ||
126 | void ViewBase::restore_settings(QSettings &settings) | |
127 | { | |
128 | (void)settings; | |
129 | } | |
130 | ||
7ea2a4ff | 131 | void ViewBase::trigger_event(int segment_id, util::Timestamp location) |
f4e57597 | 132 | { |
7ea2a4ff | 133 | (void)segment_id; |
f4e57597 SA |
134 | (void)location; |
135 | } | |
136 | ||
137 | void ViewBase::signals_changed() | |
138 | { | |
139 | } | |
140 | ||
4e86ec70 SA |
141 | void ViewBase::on_new_segment(int new_segment_id) |
142 | { | |
143 | (void)new_segment_id; | |
144 | } | |
145 | ||
558ad6ce SA |
146 | void ViewBase::on_segment_completed(int new_segment_id) |
147 | { | |
148 | (void)new_segment_id; | |
149 | } | |
150 | ||
f4e57597 SA |
151 | void ViewBase::capture_state_updated(int state) |
152 | { | |
153 | (void)state; | |
154 | } | |
155 | ||
5ed05b69 SA |
156 | void ViewBase::perform_delayed_view_update() |
157 | { | |
158 | } | |
159 | ||
7f894d95 | 160 | void ViewBase::on_samples_added(uint64_t segment_id, uint64_t start_sample, |
8c339741 SA |
161 | uint64_t end_sample) |
162 | { | |
163 | (void)start_sample; | |
164 | (void)end_sample; | |
165 | ||
7f894d95 | 166 | if (segment_id != current_segment_) |
8c339741 SA |
167 | return; |
168 | ||
169 | if (!delayed_view_updater_.isActive()) | |
170 | delayed_view_updater_.start(); | |
171 | } | |
172 | ||
5ed05b69 | 173 | void ViewBase::on_data_updated() |
f4e57597 | 174 | { |
5ed05b69 SA |
175 | if (!delayed_view_updater_.isActive()) |
176 | delayed_view_updater_.start(); | |
f4e57597 SA |
177 | } |
178 | ||
870ea3db | 179 | } // namespace views |
f4e57597 | 180 | } // namespace pv |