projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added pv::device::Device
[pulseview.git]
/
pv
/
sigsession.cpp
diff --git
a/pv/sigsession.cpp
b/pv/sigsession.cpp
index 8d22296c40e89e57da2ad24ec12aec88112c7be9..4469a3eef367071c44a545d3c3a1a8ae746742cc 100644
(file)
--- a/
pv/sigsession.cpp
+++ b/
pv/sigsession.cpp
@@
-25,6
+25,7
@@
#include "sigsession.h"
#include "devicemanager.h"
#include "sigsession.h"
#include "devicemanager.h"
+#include "device/device.h"
#include "data/analog.h"
#include "data/analogsnapshot.h"
#include "data/analog.h"
#include "data/analogsnapshot.h"
@@
-64,7
+65,6
@@
SigSession* SigSession::_session = NULL;
SigSession::SigSession(DeviceManager &device_manager) :
_device_manager(device_manager),
SigSession::SigSession(DeviceManager &device_manager) :
_device_manager(device_manager),
- _sdi(NULL),
_capture_state(Stopped)
{
// TODO: This should not be necessary
_capture_state(Stopped)
{
// TODO: This should not be necessary
@@
-75,41
+75,40
@@
SigSession::~SigSession()
{
stop_capture();
{
stop_capture();
- _sampling_thread.join();
+ if (_sampling_thread.joinable())
+ _sampling_thread.join();
- if (_sdi)
- _device_manager.release_device(_sdi);
- _sdi = NULL;
+ if (_dev_inst)
+ _device_manager.release_device(_dev_inst);
// TODO: This should not be necessary
_session = NULL;
}
// TODO: This should not be necessary
_session = NULL;
}
-s
truct sr_dev_inst*
SigSession::get_device() const
+s
hared_ptr<device::DevInst>
SigSession::get_device() const
{
{
- return _
sdi
;
+ return _
dev_inst
;
}
}
-void SigSession::set_device(s
truct sr_dev_inst *sdi
)
+void SigSession::set_device(s
hared_ptr<device::DevInst> dev_inst
)
{
// Ensure we are not capturing before setting the device
stop_capture();
{
// Ensure we are not capturing before setting the device
stop_capture();
- if (_
sdi
)
- _device_manager.release_device(_
sdi
);
- if (
sdi
)
- _device_manager.use_device(
sdi
, this);
- _
sdi = sdi
;
- update_signals(
sdi
);
+ if (_
dev_inst
)
+ _device_manager.release_device(_
dev_inst
);
+ if (
dev_inst
)
+ _device_manager.use_device(
dev_inst
, this);
+ _
dev_inst = dev_inst
;
+ update_signals(
dev_inst
);
}
}
-void SigSession::release_device(s
truct sr_dev_inst *sdi
)
+void SigSession::release_device(s
hared_ptr<device::DevInst> dev_inst
)
{
{
- (void)
sdi
;
+ (void)
dev_inst
;
assert(_capture_state == Stopped);
assert(_capture_state == Stopped);
- _sdi = NULL;
- update_signals(NULL);
+ _dev_inst = shared_ptr<device::DevInst>();
}
void SigSession::load_file(const string &name,
}
void SigSession::load_file(const string &name,
@@
-127,12
+126,13
@@
void SigSession::load_file(const string &name,
return;
}
return;
}
- sr_dev_inst *const sdi = (sr_dev_inst*)devlist->data;
+ shared_ptr<device::DevInst> dev_inst(
+ new device::Device((sr_dev_inst*)devlist->data));
g_slist_free(devlist);
_decode_traces.clear();
g_slist_free(devlist);
_decode_traces.clear();
- update_signals(
sdi
);
- read_sample_rate(
sdi
);
+ update_signals(
dev_inst
);
+ read_sample_rate(
dev_inst->dev_inst()
);
_sampling_thread = boost::thread(
&SigSession::load_session_thread_proc, this,
_sampling_thread = boost::thread(
&SigSession::load_session_thread_proc, this,
@@
-146,7
+146,8
@@
void SigSession::load_file(const string &name,
return;
_decode_traces.clear();
return;
_decode_traces.clear();
- update_signals(in->sdi);
+ update_signals(shared_ptr<device::DevInst>(
+ new device::Device(in->sdi)));
read_sample_rate(in->sdi);
_sampling_thread = boost::thread(
read_sample_rate(in->sdi);
_sampling_thread = boost::thread(
@@
-161,20
+162,21
@@
SigSession::capture_state SigSession::get_capture_state() const
return _capture_state;
}
return _capture_state;
}
-void SigSession::start_capture(uint64_t record_length,
- function<void (const QString)> error_handler)
+void SigSession::start_capture(function<void (const QString)> error_handler)
{
stop_capture();
// Check that a device instance has been selected.
{
stop_capture();
// Check that a device instance has been selected.
- if (!_
sdi
) {
+ if (!_
dev_inst
) {
qDebug() << "No device selected";
return;
}
qDebug() << "No device selected";
return;
}
+ assert(_dev_inst->dev_inst());
+
// Check that at least one probe is enabled
const GSList *l;
// Check that at least one probe is enabled
const GSList *l;
- for (l = _
sdi
->probes; l; l = l->next) {
+ for (l = _
dev_inst->dev_inst()
->probes; l; l = l->next) {
sr_probe *const probe = (sr_probe*)l->data;
assert(probe);
if (probe->enabled)
sr_probe *const probe = (sr_probe*)l->data;
assert(probe);
if (probe->enabled)
@@
-188,8
+190,8
@@
void SigSession::start_capture(uint64_t record_length,
// Begin the session
_sampling_thread = boost::thread(
// Begin the session
_sampling_thread = boost::thread(
- &SigSession::sample_thread_proc, this, _
sdi
,
-
record_length,
error_handler);
+ &SigSession::sample_thread_proc, this, _
dev_inst
,
+
error_handler);
}
void SigSession::stop_capture()
}
void SigSession::stop_capture()
@@
-200,7
+202,8
@@
void SigSession::stop_capture()
sr_session_stop();
// Check that sampling stopped
sr_session_stop();
// Check that sampling stopped
- _sampling_thread.join();
+ if (_sampling_thread.joinable())
+ _sampling_thread.join();
}
set< shared_ptr<data::SignalData> > SigSession::get_data() const
}
set< shared_ptr<data::SignalData> > SigSession::get_data() const
@@
-235,10
+238,15
@@
bool SigSession::add_decoder(srd_decoder *const dec)
decoder_stack = shared_ptr<data::DecoderStack>(
new data::DecoderStack(dec));
decoder_stack = shared_ptr<data::DecoderStack>(
new data::DecoderStack(dec));
- // Auto select the initial probes
+ // Make a list of all the probes
+ std::vector<const srd_probe*> all_probes;
for(const GSList *i = dec->probes; i; i = i->next)
for(const GSList *i = dec->probes; i; i = i->next)
- {
- const srd_probe *const probe = (const srd_probe*)i->data;
+ all_probes.push_back((const srd_probe*)i->data);
+ for(const GSList *i = dec->opt_probes; i; i = i->next)
+ all_probes.push_back((const srd_probe*)i->data);
+
+ // Auto select the initial probes
+ BOOST_FOREACH(const srd_probe *probe, all_probes)
BOOST_FOREACH(shared_ptr<view::Signal> s, _signals)
{
shared_ptr<view::LogicSignal> l =
BOOST_FOREACH(shared_ptr<view::Signal> s, _signals)
{
shared_ptr<view::LogicSignal> l =
@@
-248,7
+256,6
@@
bool SigSession::add_decoder(srd_decoder *const dec)
l->get_name().toLower()))
probes[probe] = l;
}
l->get_name().toLower()))
probes[probe] = l;
}
- }
assert(decoder_stack);
assert(!decoder_stack->stack().empty());
assert(decoder_stack);
assert(!decoder_stack->stack().empty());
@@
-380,8
+387,9
@@
sr_input* SigSession::load_input_file_format(const string &filename,
return in;
}
return in;
}
-void SigSession::update_signals(
const sr_dev_inst *const sdi
)
+void SigSession::update_signals(
shared_ptr<device::DevInst> dev_inst
)
{
{
+ assert(dev_inst);
assert(_capture_state == Stopped);
unsigned int logic_probe_count = 0;
assert(_capture_state == Stopped);
unsigned int logic_probe_count = 0;
@@
-390,8
+398,10
@@
void SigSession::update_signals(const sr_dev_inst *const sdi)
_decode_traces.clear();
// Detect what data types we will receive
_decode_traces.clear();
// Detect what data types we will receive
- if(sdi) {
- for (const GSList *l = sdi->probes; l; l = l->next) {
+ if(dev_inst) {
+ assert(dev_inst->dev_inst());
+ for (const GSList *l = dev_inst->dev_inst()->probes;
+ l; l = l->next) {
const sr_probe *const probe = (const sr_probe *)l->data;
if (!probe->enabled)
continue;
const sr_probe *const probe = (const sr_probe *)l->data;
if (!probe->enabled)
continue;
@@
-422,10
+432,12
@@
void SigSession::update_signals(const sr_dev_inst *const sdi)
_signals.clear();
_signals.clear();
- if(!
sdi
)
+ if(!
dev_inst
)
break;
break;
- for (const GSList *l = sdi->probes; l; l = l->next) {
+ assert(dev_inst->dev_inst());
+ for (const GSList *l = dev_inst->dev_inst()->probes;
+ l; l = l->next) {
shared_ptr<view::Signal> signal;
sr_probe *const probe = (sr_probe *)l->data;
assert(probe);
shared_ptr<view::Signal> signal;
sr_probe *const probe = (sr_probe *)l->data;
assert(probe);
@@
-433,8
+445,8
@@
void SigSession::update_signals(const sr_dev_inst *const sdi)
switch(probe->type) {
case SR_PROBE_LOGIC:
signal = shared_ptr<view::Signal>(
switch(probe->type) {
case SR_PROBE_LOGIC:
signal = shared_ptr<view::Signal>(
- new view::LogicSignal(
*this, probe
,
- _logic_data));
+ new view::LogicSignal(
dev_inst
,
+
probe,
_logic_data));
break;
case SR_PROBE_ANALOG:
break;
case SR_PROBE_ANALOG:
@@
-442,8
+454,8
@@
void SigSession::update_signals(const sr_dev_inst *const sdi)
shared_ptr<data::Analog> data(
new data::Analog());
signal = shared_ptr<view::Signal>(
shared_ptr<data::Analog> data(
new data::Analog());
signal = shared_ptr<view::Signal>(
- new view::AnalogSignal(
*this, probe
,
- data));
+ new view::AnalogSignal(
dev_inst
,
+
probe,
data));
break;
}
break;
}
@@
-463,8
+475,9
@@
void SigSession::update_signals(const sr_dev_inst *const sdi)
bool SigSession::is_trigger_enabled() const
{
bool SigSession::is_trigger_enabled() const
{
- assert(_sdi);
- for (const GSList *l = _sdi->probes; l; l = l->next) {
+ assert(_dev_inst);
+ assert(_dev_inst->dev_inst());
+ for (const GSList *l = _dev_inst->dev_inst()->probes; l; l = l->next) {
const sr_probe *const p = (const sr_probe *)l->data;
assert(p);
if (p->trigger && p->trigger[0] != '\0')
const sr_probe *const p = (const sr_probe *)l->data;
assert(p);
if (p->trigger && p->trigger[0] != '\0')
@@
-556,31
+569,22
@@
void SigSession::load_input_thread_proc(const string name,
delete in;
}
delete in;
}
-void SigSession::sample_thread_proc(struct sr_dev_inst *sdi,
- uint64_t record_length,
+void SigSession::sample_thread_proc(shared_ptr<device::DevInst> dev_inst,
function<void (const QString)> error_handler)
{
function<void (const QString)> error_handler)
{
- assert(sdi);
+ assert(dev_inst);
+ assert(dev_inst->dev_inst());
assert(error_handler);
sr_session_new();
sr_session_datafeed_callback_add(data_feed_in_proc, NULL);
assert(error_handler);
sr_session_new();
sr_session_datafeed_callback_add(data_feed_in_proc, NULL);
- if (sr_session_dev_add(
sdi
) != SR_OK) {
+ if (sr_session_dev_add(
dev_inst->dev_inst()
) != SR_OK) {
error_handler(tr("Failed to use device."));
sr_session_destroy();
return;
}
error_handler(tr("Failed to use device."));
sr_session_destroy();
return;
}
- // Set the sample limit
- if (sr_config_set(sdi, NULL, SR_CONF_LIMIT_SAMPLES,
- g_variant_new_uint64(record_length)) != SR_OK) {
- error_handler(tr("Failed to configure "
- "time-based sample limit."));
- sr_session_destroy();
- return;
- }
-
if (sr_session_start() != SR_OK) {
error_handler(tr("Failed to start session."));
return;
if (sr_session_start() != SR_OK) {
error_handler(tr("Failed to start session."));
return;
@@
-644,7
+648,7
@@
void SigSession::feed_in_logic(const sr_datafeed_logic &logic)
// Create a new data snapshot
_cur_logic_snapshot = shared_ptr<data::LogicSnapshot>(
// Create a new data snapshot
_cur_logic_snapshot = shared_ptr<data::LogicSnapshot>(
- new data::LogicSnapshot(logic));
+ new data::LogicSnapshot(logic
, _dev_inst->get_sample_limit()
));
_logic_data->push_snapshot(_cur_logic_snapshot);
}
else
_logic_data->push_snapshot(_cur_logic_snapshot);
}
else
@@
-686,7
+690,7
@@
void SigSession::feed_in_analog(const sr_datafeed_analog &analog)
// Create a snapshot, keep it in the maps of probes
snapshot = shared_ptr<data::AnalogSnapshot>(
// Create a snapshot, keep it in the maps of probes
snapshot = shared_ptr<data::AnalogSnapshot>(
- new data::AnalogSnapshot());
+ new data::AnalogSnapshot(
_dev_inst->get_sample_limit()
));
_cur_analog_snapshots[probe] = snapshot;
// Find the annalog data associated with the probe
_cur_analog_snapshots[probe] = snapshot;
// Find the annalog data associated with the probe