]> sigrok.org Git - pulseview.git/blame - pv/sigsession.h
Draw analog with a polyline rather than points
[pulseview.git] / pv / sigsession.h
CommitLineData
2953961c 1/*
b3f22de0 2 * This file is part of the PulseView project.
2953961c
JH
3 *
4 * Copyright (C) 2012 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, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
640d091b
UH
21#ifndef PULSEVIEW_PV_SIGSESSION_H
22#define PULSEVIEW_PV_SIGSESSION_H
2953961c 23
f2edb557 24#include <boost/function.hpp>
28a4c9c5 25#include <boost/shared_ptr.hpp>
2e2946fe 26#include <boost/thread.hpp>
28a4c9c5 27
28a4c9c5 28#include <string>
2e2946fe 29#include <utility>
e3f65ace 30#include <vector>
28a4c9c5 31
009e1503 32#include <QObject>
f2edb557 33#include <QString>
009e1503 34
2953961c 35#include <libsigrok/libsigrok.h>
2953961c 36
51e77110
JH
37namespace pv {
38
1b1ec774
JH
39namespace data {
40class Analog;
41class AnalogSnapshot;
42class Logic;
43class LogicSnapshot;
44}
8d634081
JH
45
46namespace view {
28a4c9c5 47class Signal;
8d634081 48}
2953961c 49
009e1503 50class SigSession : public QObject
2953961c 51{
009e1503
JH
52 Q_OBJECT
53
5b7cf66c
JH
54public:
55 enum capture_state {
56 Stopped,
57 Running
58 };
59
2953961c
JH
60public:
61 SigSession();
62
63 ~SigSession();
64
f2edb557
JH
65 void load_file(const std::string &name,
66 boost::function<void (const QString)> error_handler);
2953961c 67
5b7cf66c
JH
68 capture_state get_capture_state() const;
69
6745ffbb 70 void start_capture(struct sr_dev_inst* sdi,
f2edb557
JH
71 uint64_t record_length,
72 boost::function<void (const QString)> error_handler);
274d4f13 73
5b7cf66c
JH
74 void stop_capture();
75
3868e5fa 76 std::vector< boost::shared_ptr<view::Signal> >
e3f65ace
JH
77 get_signals();
78
1b1ec774 79 boost::shared_ptr<data::Logic> get_data();
adb4b10c 80
6ac96c2e
JH
81private:
82 void set_capture_state(capture_state state);
83
2953961c 84private:
f2edb557
JH
85 void load_thread_proc(const std::string name,
86 boost::function<void (const QString)> error_handler);
8a67bd9e 87
2e2946fe 88 void sample_thread_proc(struct sr_dev_inst *sdi,
f2edb557
JH
89 uint64_t record_length,
90 boost::function<void (const QString)> error_handler);
2e2946fe 91
eec446e1
JH
92 void feed_in_header(const sr_dev_inst *sdi);
93
be73bdfa
JH
94 void feed_in_meta(const sr_dev_inst *sdi,
95 const sr_datafeed_meta &meta);
aba1dd16 96
9c112671
JH
97 void feed_in_logic(const sr_datafeed_logic &logic);
98
aba1dd16
JH
99 void feed_in_analog(const sr_datafeed_analog &analog);
100
04abfae9 101 void data_feed_in(const struct sr_dev_inst *sdi,
bc5c1a99 102 const struct sr_datafeed_packet *packet);
2953961c 103
04abfae9 104 static void data_feed_in_proc(const struct sr_dev_inst *sdi,
bc5c1a99 105 const struct sr_datafeed_packet *packet);
2953961c
JH
106
107private:
949f8050 108 mutable boost::mutex _sampling_mutex;
5b7cf66c
JH
109 capture_state _capture_state;
110
3868e5fa 111 mutable boost::mutex _signals_mutex;
8d634081 112 std::vector< boost::shared_ptr<view::Signal> > _signals;
3868e5fa
JH
113
114 mutable boost::mutex _data_mutex;
1b1ec774
JH
115 boost::shared_ptr<data::Logic> _logic_data;
116 boost::shared_ptr<data::LogicSnapshot> _cur_logic_snapshot;
117 boost::shared_ptr<data::Analog> _analog_data;
118 boost::shared_ptr<data::AnalogSnapshot> _cur_analog_snapshot;
009e1503 119
2e2946fe
JH
120 std::auto_ptr<boost::thread> _sampling_thread;
121
009e1503 122signals:
6ac96c2e
JH
123 void capture_state_changed(int state);
124
69dd2b03
JH
125 void signals_changed();
126
04abfae9 127 void data_updated();
2953961c
JH
128
129private:
130 // TODO: This should not be necessary. Multiple concurrent
131 // sessions should should be supported and it should be
132 // possible to associate a pointer with a sr_session.
04abfae9 133 static SigSession *_session;
2953961c
JH
134};
135
51e77110
JH
136} // namespace pv
137
640d091b 138#endif // PULSEVIEW_PV_SIGSESSION_H