2 * This file is part of the PulseView project.
4 * Copyright (C) 2012-14 Joel Holdsworth <joel@airwebreathe.org.uk>
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.
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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef PULSEVIEW_PV_SIGSESSION_H
22 #define PULSEVIEW_PV_SIGSESSION_H
32 #include <boost/thread.hpp>
68 class SigSession : public QObject
80 SigSession(DeviceManager &device_manager);
84 DeviceManager& device_manager();
86 const DeviceManager& device_manager() const;
88 const std::shared_ptr<sigrok::Session>& session() const;
90 std::shared_ptr<sigrok::Device> device() const;
93 * Sets device instance that will be used in the next capture session.
95 void set_device(std::shared_ptr<sigrok::Device> device);
97 void set_file(const std::string &name);
99 void set_default_device();
101 capture_state get_capture_state() const;
103 void start_capture(std::function<void (const QString)> error_handler);
107 std::set< std::shared_ptr<data::SignalData> > get_data() const;
109 boost::shared_mutex& signals_mutex() const;
111 const std::vector< std::shared_ptr<view::Signal> >& signals() const;
114 bool add_decoder(srd_decoder *const dec);
116 std::vector< std::shared_ptr<view::DecodeTrace> >
117 get_decode_signals() const;
119 void remove_decode_signal(view::DecodeTrace *signal);
123 void set_capture_state(capture_state state);
125 void update_signals(std::shared_ptr<sigrok::Device> device);
127 std::shared_ptr<view::Signal> signal_from_channel(
128 std::shared_ptr<sigrok::Channel> channel) const;
130 void read_sample_rate(std::shared_ptr<sigrok::Device>);
133 void sample_thread_proc(std::shared_ptr<sigrok::Device> device,
134 std::function<void (const QString)> error_handler);
136 void feed_in_header(std::shared_ptr<sigrok::Device> device);
138 void feed_in_meta(std::shared_ptr<sigrok::Device> device,
139 std::shared_ptr<sigrok::Meta> meta);
141 void feed_in_frame_begin();
143 void feed_in_logic(std::shared_ptr<sigrok::Logic> logic);
145 void feed_in_analog(std::shared_ptr<sigrok::Analog> analog);
147 void data_feed_in(std::shared_ptr<sigrok::Device> device,
148 std::shared_ptr<sigrok::Packet> packet);
151 DeviceManager &device_manager_;
152 std::shared_ptr<sigrok::Session> session_;
155 * The device instance that will be used in the next capture session.
157 std::shared_ptr<sigrok::Device> device_;
159 std::vector< std::shared_ptr<view::DecodeTrace> > decode_traces_;
161 mutable std::mutex sampling_mutex_;
162 capture_state capture_state_;
164 mutable boost::shared_mutex signals_mutex_;
165 std::vector< std::shared_ptr<view::Signal> > signals_;
167 mutable std::mutex data_mutex_;
168 std::shared_ptr<data::Logic> logic_data_;
169 std::shared_ptr<data::LogicSnapshot> cur_logic_snapshot_;
170 std::map< std::shared_ptr<sigrok::Channel>, std::shared_ptr<data::AnalogSnapshot> >
171 cur_analog_snapshots_;
173 std::thread sampling_thread_;
176 void capture_state_changed(int state);
178 void signals_changed();
182 void data_received();
189 #endif // PULSEVIEW_PV_SIGSESSION_H