]>
Commit | Line | Data |
---|---|---|
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 | |
18 | * along with this program; if not, see <http://www.gnu.org/licenses/>. | |
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" | |
29 | #include "pv/data/segment.hpp" | |
30 | ||
31 | using std::shared_ptr; | |
32 | ||
33 | namespace pv { | |
34 | namespace views { | |
35 | ||
36 | const int ViewBase::MaxViewAutoUpdateRate = 25; // No more than 25 Hz | |
37 | ||
38 | ViewBase::ViewBase(Session &session, bool is_main_view, QWidget *parent) : | |
39 | session_(session), | |
40 | is_main_view_(is_main_view), | |
41 | ruler_shift_(0), | |
42 | current_segment_(0) | |
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))); | |
50 | connect(&session_, SIGNAL(new_segment(int)), | |
51 | this, SLOT(on_new_segment(int))); | |
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); | |
57 | } | |
58 | ||
59 | Session& ViewBase::session() | |
60 | { | |
61 | return session_; | |
62 | } | |
63 | ||
64 | const Session& ViewBase::session() const | |
65 | { | |
66 | return session_; | |
67 | } | |
68 | ||
69 | void ViewBase::clear_signals() | |
70 | { | |
71 | } | |
72 | ||
73 | unordered_set< shared_ptr<data::SignalBase> > ViewBase::signalbases() const | |
74 | { | |
75 | return signalbases_; | |
76 | } | |
77 | ||
78 | void ViewBase::clear_signalbases() | |
79 | { | |
80 | for (shared_ptr<data::SignalBase> signalbase : signalbases_) { | |
81 | disconnect(signalbase.get(), SIGNAL(samples_cleared()), | |
82 | this, SLOT(on_data_updated())); | |
83 | disconnect(signalbase.get(), SIGNAL(samples_added(uint64_t, uint64_t, uint64_t)), | |
84 | this, SLOT(on_samples_added(uint64_t, uint64_t, uint64_t))); | |
85 | } | |
86 | ||
87 | signalbases_.clear(); | |
88 | } | |
89 | ||
90 | void ViewBase::add_signalbase(const shared_ptr<data::SignalBase> signalbase) | |
91 | { | |
92 | signalbases_.insert(signalbase); | |
93 | ||
94 | connect(signalbase.get(), SIGNAL(samples_cleared()), | |
95 | this, SLOT(on_data_updated())); | |
96 | connect(signalbase.get(), SIGNAL(samples_added(uint64_t, uint64_t, uint64_t)), | |
97 | this, SLOT(on_samples_added(uint64_t, uint64_t, uint64_t))); | |
98 | } | |
99 | ||
100 | #ifdef ENABLE_DECODE | |
101 | void ViewBase::clear_decode_signals() | |
102 | { | |
103 | } | |
104 | ||
105 | void ViewBase::add_decode_signal(shared_ptr<data::DecodeSignal> signal) | |
106 | { | |
107 | (void)signal; | |
108 | } | |
109 | ||
110 | void ViewBase::remove_decode_signal(shared_ptr<data::DecodeSignal> signal) | |
111 | { | |
112 | (void)signal; | |
113 | } | |
114 | #endif | |
115 | ||
116 | void ViewBase::save_settings(QSettings &settings) const | |
117 | { | |
118 | (void)settings; | |
119 | } | |
120 | ||
121 | void ViewBase::restore_settings(QSettings &settings) | |
122 | { | |
123 | (void)settings; | |
124 | } | |
125 | ||
126 | void ViewBase::trigger_event(int segment_id, util::Timestamp location) | |
127 | { | |
128 | (void)segment_id; | |
129 | (void)location; | |
130 | } | |
131 | ||
132 | void ViewBase::signals_changed() | |
133 | { | |
134 | } | |
135 | ||
136 | void ViewBase::on_new_segment(int new_segment_id) | |
137 | { | |
138 | (void)new_segment_id; | |
139 | } | |
140 | ||
141 | void ViewBase::on_segment_completed(int new_segment_id) | |
142 | { | |
143 | (void)new_segment_id; | |
144 | } | |
145 | ||
146 | void ViewBase::capture_state_updated(int state) | |
147 | { | |
148 | (void)state; | |
149 | } | |
150 | ||
151 | void ViewBase::perform_delayed_view_update() | |
152 | { | |
153 | } | |
154 | ||
155 | void ViewBase::on_samples_added(uint64_t segment_id, uint64_t start_sample, | |
156 | uint64_t end_sample) | |
157 | { | |
158 | (void)start_sample; | |
159 | (void)end_sample; | |
160 | ||
161 | if (segment_id != current_segment_) | |
162 | return; | |
163 | ||
164 | if (!delayed_view_updater_.isActive()) | |
165 | delayed_view_updater_.start(); | |
166 | } | |
167 | ||
168 | void ViewBase::on_data_updated() | |
169 | { | |
170 | if (!delayed_view_updater_.isActive()) | |
171 | delayed_view_updater_.start(); | |
172 | } | |
173 | ||
174 | } // namespace views | |
175 | } // namespace pv |