pv/dialogs/connect.cpp
pv/dialogs/storeprogress.cpp
pv/popups/deviceoptions.cpp
- pv/popups/probes.cpp
+ pv/popups/channels.cpp
pv/prop/bool.cpp
pv/prop/double.cpp
pv/prop/enum.cpp
pv/dialogs/about.h
pv/dialogs/connect.h
pv/dialogs/storeprogress.h
- pv/popups/probes.h
+ pv/popups/channels.h
pv/popups/deviceoptions.h
pv/prop/bool.h
pv/prop/double.h
const map<const srd_channel*, shared_ptr<view::LogicSignal> >&
Decoder::channels() const
{
- return _probes;
+ return _channels;
}
-void Decoder::set_probes(std::map<const srd_channel*,
- std::shared_ptr<view::LogicSignal> > probes)
+void Decoder::set_channels(std::map<const srd_channel*,
+ std::shared_ptr<view::LogicSignal> > channels)
{
- _probes = probes;
+ _channels = channels;
}
const std::map<std::string, GVariant*>& Decoder::options() const
_options[id] = value;
}
-bool Decoder::have_required_probes() const
+bool Decoder::have_required_channels() const
{
for (GSList *l = _decoder->channels; l; l = l->next) {
const srd_channel *const pdch = (const srd_channel*)l->data;
assert(pdch);
- if (_probes.find(pdch) == _probes.end())
+ if (_channels.find(pdch) == _channels.end())
return false;
}
set< shared_ptr<pv::data::Logic> > Decoder::get_data()
{
set< shared_ptr<pv::data::Logic> > data;
- for(auto i = _probes.cbegin(); i != _probes.cend(); i++) {
+ for(auto i = _channels.cbegin(); i != _channels.cend(); i++) {
shared_ptr<view::LogicSignal> signal((*i).second);
assert(signal);
data.insert(signal->logic_data());
if(!decoder_inst)
return NULL;
- // Setup the probes
- GHashTable *const probes = g_hash_table_new_full(g_str_hash,
+ // Setup the channels
+ GHashTable *const channels = g_hash_table_new_full(g_str_hash,
g_str_equal, g_free, (GDestroyNotify)g_variant_unref);
- for(auto i = _probes.cbegin(); i != _probes.cend(); i++)
+ for(auto i = _channels.cbegin(); i != _channels.cend(); i++)
{
shared_ptr<view::LogicSignal> signal((*i).second);
GVariant *const gvar = g_variant_new_int32(
- signal->probe()->index);
+ signal->channel()->index);
g_variant_ref_sink(gvar);
- g_hash_table_insert(probes, (*i).first->id, gvar);
+ g_hash_table_insert(channels, (*i).first->id, gvar);
}
- srd_inst_channel_set_all(decoder_inst, probes, unit_size);
+ srd_inst_channel_set_all(decoder_inst, channels, unit_size);
return decoder_inst;
}
const std::map<const srd_channel*,
std::shared_ptr<view::LogicSignal> >& channels() const;
- void set_probes(std::map<const srd_channel*,
- std::shared_ptr<view::LogicSignal> > probes);
+ void set_channels(std::map<const srd_channel*,
+ std::shared_ptr<view::LogicSignal> > channels);
const std::map<std::string, GVariant*>& options() const;
void set_option(const char *id, GVariant *value);
- bool have_required_probes() const;
+ bool have_required_channels() const;
srd_decoder_inst* create_decoder_inst(
srd_session *session, int unit_size) const;
bool _shown;
std::map<const srd_channel*, std::shared_ptr<pv::view::LogicSignal> >
- _probes;
+ _channels;
std::map<std::string, GVariant*> _options;
};
// Check that all decoders have the required channels
for (const shared_ptr<decode::Decoder> &dec : _stack)
- if (!dec->have_required_probes()) {
+ if (!dec->have_required_channels()) {
_error_message = tr("One or more required channels "
"have not been specified");
return;
namespace pv {
namespace data {
-Logic::Logic(unsigned int num_probes) :
+Logic::Logic(unsigned int num_channels) :
SignalData(),
- _num_probes(num_probes)
+ _num_channels(num_channels)
{
- assert(_num_probes > 0);
+ assert(_num_channels > 0);
}
-int Logic::get_num_probes() const
+int Logic::get_num_channels() const
{
- return _num_probes;
+ return _num_channels;
}
void Logic::push_snapshot(
class Logic : public SignalData
{
public:
- Logic(unsigned int num_probes);
+ Logic(unsigned int num_channels);
- int get_num_probes() const;
+ int get_num_channels() const;
void push_snapshot(
std::shared_ptr<LogicSnapshot> &snapshot);
uint64_t get_max_sample_count() const;
private:
- const unsigned int _num_probes;
+ const unsigned int _num_channels;
std::deque< std::shared_ptr<LogicSnapshot> > _snapshots;
};
return data;
}
-void DevInst::enable_probe(const sr_channel *probe, bool enable)
+void DevInst::enable_channel(const sr_channel *channel, bool enable)
{
assert(_owner);
sr_dev_inst *const sdi = dev_inst();
assert(sdi);
for (const GSList *p = sdi->channels; p; p = p->next)
- if (probe == p->data) {
- const_cast<sr_channel*>(probe)->enabled = enable;
+ if (channel == p->data) {
+ const_cast<sr_channel*>(channel)->enabled = enable;
config_changed();
return;
}
- // Probe was not found in the device
+ // Channel was not found in the device
assert(0);
}
GVariant* list_config(const sr_channel_group *group, int key);
- void enable_probe(const sr_channel *probe, bool enable = true);
+ void enable_channel(const sr_channel *channel, bool enable = true);
/**
* @brief Gets the sample limit from the driver.
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <map>
+
+#include <QCheckBox>
+#include <QFormLayout>
+#include <QGridLayout>
+#include <QLabel>
+
+#include "channels.h"
+
+#include <pv/device/devinst.h>
+#include <pv/prop/binding/deviceoptions.h>
+#include <pv/sigsession.h>
+#include <pv/view/signal.h>
+
+using namespace Qt;
+
+using std::map;
+using std::set;
+using std::shared_ptr;
+using std::vector;
+
+using pv::view::Signal;
+
+namespace pv {
+namespace popups {
+
+Channels::Channels(SigSession &session, QWidget *parent) :
+ Popup(parent),
+ _session(session),
+ _updating_channels(false),
+ _enable_all_channels(tr("Enable All"), this),
+ _disable_all_channels(tr("Disable All"), this),
+ _check_box_mapper(this)
+{
+ // Create the layout
+ setLayout(&_layout);
+
+ shared_ptr<device::DevInst> dev_inst = _session.get_device();
+ assert(dev_inst);
+ const sr_dev_inst *const sdi = dev_inst->dev_inst();
+ assert(sdi);
+
+ // Collect a set of signals
+ map<const sr_channel*, shared_ptr<Signal> > signal_map;
+ const vector< shared_ptr<Signal> > sigs = _session.get_signals();
+
+ for (const shared_ptr<Signal> &sig : sigs)
+ signal_map[sig->channel()] = sig;
+
+ // Populate channel groups
+ for (const GSList *g = sdi->channel_groups; g; g = g->next)
+ {
+ const sr_channel_group *const group =
+ (const sr_channel_group*)g->data;
+ assert(group);
+
+ // Make a set of signals and remove these signals from the
+ // signal map.
+ vector< shared_ptr<Signal> > group_sigs;
+ for (const GSList *p = group->channels; p; p = p->next)
+ {
+ const sr_channel *const channel = (const sr_channel*)p->data;
+ assert(channel);
+
+ const auto iter = signal_map.find(channel);
+
+ if (iter == signal_map.end())
+ break;
+
+ group_sigs.push_back((*iter).second);
+ signal_map.erase(iter);
+ }
+
+ populate_group(group, group_sigs);
+ }
+
+ // Make a vector of the remaining channels
+ vector< shared_ptr<Signal> > global_sigs;
+ for (const GSList *p = sdi->channels; p; p = p->next)
+ {
+ const sr_channel *const channel = (const sr_channel*)p->data;
+ assert(channel);
+
+ const map<const sr_channel*, shared_ptr<Signal> >::
+ const_iterator iter = signal_map.find(channel);
+ if (iter != signal_map.end())
+ global_sigs.push_back((*iter).second);
+ }
+
+ // Create a group
+ populate_group(NULL, global_sigs);
+
+ // Create the enable/disable all buttons
+ connect(&_enable_all_channels, SIGNAL(clicked()),
+ this, SLOT(enable_all_channels()));
+ connect(&_disable_all_channels, SIGNAL(clicked()),
+ this, SLOT(disable_all_channels()));
+
+ _enable_all_channels.setFlat(true);
+ _disable_all_channels.setFlat(true);
+
+ _buttons_bar.addWidget(&_enable_all_channels);
+ _buttons_bar.addWidget(&_disable_all_channels);
+ _buttons_bar.addStretch(1);
+
+ _layout.addRow(&_buttons_bar);
+
+ // Connect the check-box signal mapper
+ connect(&_check_box_mapper, SIGNAL(mapped(QWidget*)),
+ this, SLOT(on_channel_checked(QWidget*)));
+}
+
+void Channels::set_all_channels(bool set)
+{
+ _updating_channels = true;
+
+ for (map<QCheckBox*, shared_ptr<Signal> >::const_iterator i =
+ _check_box_signal_map.begin();
+ i != _check_box_signal_map.end(); i++)
+ {
+ const shared_ptr<Signal> sig = (*i).second;
+ assert(sig);
+
+ sig->enable(set);
+ (*i).first->setChecked(set);
+ }
+
+ _updating_channels = false;
+}
+
+void Channels::populate_group(const sr_channel_group *group,
+ const vector< shared_ptr<pv::view::Signal> > sigs)
+{
+ using pv::prop::binding::DeviceOptions;
+
+ // Only bind options if this is a group. We don't do it for general
+ // options, because these properties are shown in the device config
+ // popup.
+ shared_ptr<DeviceOptions> binding;
+ if (group)
+ binding = shared_ptr<DeviceOptions>(new DeviceOptions(
+ _session.get_device(), group));
+
+ // Create a title if the group is going to have any content
+ if ((!sigs.empty() || (binding && !binding->properties().empty())) &&
+ group && group->name)
+ _layout.addRow(new QLabel(
+ QString("<h3>%1</h3>").arg(group->name)));
+
+ // Create the channel group grid
+ QGridLayout *const channel_grid =
+ create_channel_group_grid(sigs);
+ _layout.addRow(channel_grid);
+
+ // Create the channel group options
+ if (binding)
+ {
+ binding->add_properties_to_form(&_layout, true);
+ _group_bindings.push_back(binding);
+ }
+}
+
+QGridLayout* Channels::create_channel_group_grid(
+ const vector< shared_ptr<pv::view::Signal> > sigs)
+{
+ int row = 0, col = 0;
+ QGridLayout *const grid = new QGridLayout();
+
+ for (const shared_ptr<pv::view::Signal>& sig : sigs)
+ {
+ assert(sig);
+
+ QCheckBox *const checkbox = new QCheckBox(sig->get_name());
+ _check_box_mapper.setMapping(checkbox, checkbox);
+ connect(checkbox, SIGNAL(toggled(bool)),
+ &_check_box_mapper, SLOT(map()));
+
+ grid->addWidget(checkbox, row, col);
+
+ _check_box_signal_map[checkbox] = sig;
+
+ if(++col >= 8)
+ col = 0, row++;
+ }
+
+ return grid;
+}
+
+void Channels::showEvent(QShowEvent *e)
+{
+ pv::widgets::Popup::showEvent(e);
+
+ _updating_channels = true;
+
+ for (map<QCheckBox*, shared_ptr<Signal> >::const_iterator i =
+ _check_box_signal_map.begin();
+ i != _check_box_signal_map.end(); i++)
+ {
+ const shared_ptr<Signal> sig = (*i).second;
+ assert(sig);
+
+ (*i).first->setChecked(sig->enabled());
+ }
+
+ _updating_channels = false;
+}
+
+void Channels::on_channel_checked(QWidget *widget)
+{
+ if (_updating_channels)
+ return;
+
+ QCheckBox *const check_box = (QCheckBox*)widget;
+ assert(check_box);
+
+ // Look up the signal of this check-box
+ map< QCheckBox*, shared_ptr<Signal> >::const_iterator iter =
+ _check_box_signal_map.find((QCheckBox*)check_box);
+ assert(iter != _check_box_signal_map.end());
+
+ const shared_ptr<pv::view::Signal> s = (*iter).second;
+ assert(s);
+
+ s->enable(check_box->isChecked());
+}
+
+void Channels::enable_all_channels()
+{
+ set_all_channels(true);
+}
+
+void Channels::disable_all_channels()
+{
+ set_all_channels(false);
+}
+
+} // popups
+} // pv
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef PULSEVIEW_PV_POPUPS_CHANNELS_H
+#define PULSEVIEW_PV_POPUPS_CHANNELS_H
+
+#include <map>
+#include <memory>
+#include <vector>
+
+#include <QFormLayout>
+#include <QHBoxLayout>
+#include <QPushButton>
+#include <QSignalMapper>
+
+#include <pv/widgets/popup.h>
+
+struct sr_channel_group;
+
+class QCheckBox;
+class QGridLayout;
+
+namespace pv {
+
+class SigSession;
+
+namespace prop {
+namespace binding {
+class DeviceOptions;
+}
+}
+
+namespace view {
+class Signal;
+}
+
+namespace popups {
+
+class Channels : public pv::widgets::Popup
+{
+ Q_OBJECT
+
+public:
+ Channels(SigSession &_session, QWidget *parent);
+
+private:
+ void set_all_channels(bool set);
+
+ void populate_group(const sr_channel_group *group,
+ const std::vector< std::shared_ptr<pv::view::Signal> > sigs);
+
+ QGridLayout* create_channel_group_grid(
+ const std::vector< std::shared_ptr<pv::view::Signal> > sigs);
+
+private:
+ void showEvent(QShowEvent *e);
+
+private Q_SLOTS:
+ void on_channel_checked(QWidget *widget);
+
+ void enable_all_channels();
+ void disable_all_channels();
+
+private:
+ pv::SigSession &_session;
+
+ QFormLayout _layout;
+
+ bool _updating_channels;
+
+ std::vector< std::shared_ptr<pv::prop::binding::DeviceOptions> >
+ _group_bindings;
+ std::map< QCheckBox*, std::shared_ptr<pv::view::Signal> >
+ _check_box_signal_map;
+
+ QHBoxLayout _buttons_bar;
+ QPushButton _enable_all_channels;
+ QPushButton _disable_all_channels;
+
+ QSignalMapper _check_box_mapper;
+};
+
+} // popups
+} // pv
+
+#endif // PULSEVIEW_PV_POPUPS_CHANNELS_H
+++ /dev/null
-/*
- * This file is part of the PulseView project.
- *
- * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <map>
-
-#include <QCheckBox>
-#include <QFormLayout>
-#include <QGridLayout>
-#include <QLabel>
-
-#include "probes.h"
-
-#include <pv/device/devinst.h>
-#include <pv/prop/binding/deviceoptions.h>
-#include <pv/sigsession.h>
-#include <pv/view/signal.h>
-
-using namespace Qt;
-
-using std::map;
-using std::set;
-using std::shared_ptr;
-using std::vector;
-
-using pv::view::Signal;
-
-namespace pv {
-namespace popups {
-
-Probes::Probes(SigSession &session, QWidget *parent) :
- Popup(parent),
- _session(session),
- _updating_probes(false),
- _enable_all_probes(tr("Enable All"), this),
- _disable_all_probes(tr("Disable All"), this),
- _check_box_mapper(this)
-{
- // Create the layout
- setLayout(&_layout);
-
- shared_ptr<device::DevInst> dev_inst = _session.get_device();
- assert(dev_inst);
- const sr_dev_inst *const sdi = dev_inst->dev_inst();
- assert(sdi);
-
- // Collect a set of signals
- map<const sr_channel*, shared_ptr<Signal> > signal_map;
- const vector< shared_ptr<Signal> > sigs = _session.get_signals();
-
- for (const shared_ptr<Signal> &sig : sigs)
- signal_map[sig->probe()] = sig;
-
- // Populate channel groups
- for (const GSList *g = sdi->channel_groups; g; g = g->next)
- {
- const sr_channel_group *const group =
- (const sr_channel_group*)g->data;
- assert(group);
-
- // Make a set of signals and remove these signals from the
- // signal map.
- vector< shared_ptr<Signal> > group_sigs;
- for (const GSList *p = group->channels; p; p = p->next)
- {
- const sr_channel *const probe = (const sr_channel*)p->data;
- assert(probe);
-
- const auto iter = signal_map.find(probe);
-
- if (iter == signal_map.end())
- break;
-
- group_sigs.push_back((*iter).second);
- signal_map.erase(iter);
- }
-
- populate_group(group, group_sigs);
- }
-
- // Make a vector of the remaining probes
- vector< shared_ptr<Signal> > global_sigs;
- for (const GSList *p = sdi->channels; p; p = p->next)
- {
- const sr_channel *const probe = (const sr_channel*)p->data;
- assert(probe);
-
- const map<const sr_channel*, shared_ptr<Signal> >::
- const_iterator iter = signal_map.find(probe);
- if (iter != signal_map.end())
- global_sigs.push_back((*iter).second);
- }
-
- // Create a group
- populate_group(NULL, global_sigs);
-
- // Create the enable/disable all buttons
- connect(&_enable_all_probes, SIGNAL(clicked()),
- this, SLOT(enable_all_probes()));
- connect(&_disable_all_probes, SIGNAL(clicked()),
- this, SLOT(disable_all_probes()));
-
- _enable_all_probes.setFlat(true);
- _disable_all_probes.setFlat(true);
-
- _buttons_bar.addWidget(&_enable_all_probes);
- _buttons_bar.addWidget(&_disable_all_probes);
- _buttons_bar.addStretch(1);
-
- _layout.addRow(&_buttons_bar);
-
- // Connect the check-box signal mapper
- connect(&_check_box_mapper, SIGNAL(mapped(QWidget*)),
- this, SLOT(on_probe_checked(QWidget*)));
-}
-
-void Probes::set_all_probes(bool set)
-{
- _updating_probes = true;
-
- for (map<QCheckBox*, shared_ptr<Signal> >::const_iterator i =
- _check_box_signal_map.begin();
- i != _check_box_signal_map.end(); i++)
- {
- const shared_ptr<Signal> sig = (*i).second;
- assert(sig);
-
- sig->enable(set);
- (*i).first->setChecked(set);
- }
-
- _updating_probes = false;
-}
-
-void Probes::populate_group(const sr_channel_group *group,
- const vector< shared_ptr<pv::view::Signal> > sigs)
-{
- using pv::prop::binding::DeviceOptions;
-
- // Only bind options if this is a group. We don't do it for general
- // options, because these properties are shown in the device config
- // popup.
- shared_ptr<DeviceOptions> binding;
- if (group)
- binding = shared_ptr<DeviceOptions>(new DeviceOptions(
- _session.get_device(), group));
-
- // Create a title if the group is going to have any content
- if ((!sigs.empty() || (binding && !binding->properties().empty())) &&
- group && group->name)
- _layout.addRow(new QLabel(
- QString("<h3>%1</h3>").arg(group->name)));
-
- // Create the channel group grid
- QGridLayout *const probe_grid =
- create_channel_group_grid(sigs);
- _layout.addRow(probe_grid);
-
- // Create the channel group options
- if (binding)
- {
- binding->add_properties_to_form(&_layout, true);
- _group_bindings.push_back(binding);
- }
-}
-
-QGridLayout* Probes::create_channel_group_grid(
- const vector< shared_ptr<pv::view::Signal> > sigs)
-{
- int row = 0, col = 0;
- QGridLayout *const grid = new QGridLayout();
-
- for (const shared_ptr<pv::view::Signal>& sig : sigs)
- {
- assert(sig);
-
- QCheckBox *const checkbox = new QCheckBox(sig->get_name());
- _check_box_mapper.setMapping(checkbox, checkbox);
- connect(checkbox, SIGNAL(toggled(bool)),
- &_check_box_mapper, SLOT(map()));
-
- grid->addWidget(checkbox, row, col);
-
- _check_box_signal_map[checkbox] = sig;
-
- if(++col >= 8)
- col = 0, row++;
- }
-
- return grid;
-}
-
-void Probes::showEvent(QShowEvent *e)
-{
- pv::widgets::Popup::showEvent(e);
-
- _updating_probes = true;
-
- for (map<QCheckBox*, shared_ptr<Signal> >::const_iterator i =
- _check_box_signal_map.begin();
- i != _check_box_signal_map.end(); i++)
- {
- const shared_ptr<Signal> sig = (*i).second;
- assert(sig);
-
- (*i).first->setChecked(sig->enabled());
- }
-
- _updating_probes = false;
-}
-
-void Probes::on_probe_checked(QWidget *widget)
-{
- if (_updating_probes)
- return;
-
- QCheckBox *const check_box = (QCheckBox*)widget;
- assert(check_box);
-
- // Look up the signal of this check-box
- map< QCheckBox*, shared_ptr<Signal> >::const_iterator iter =
- _check_box_signal_map.find((QCheckBox*)check_box);
- assert(iter != _check_box_signal_map.end());
-
- const shared_ptr<pv::view::Signal> s = (*iter).second;
- assert(s);
-
- s->enable(check_box->isChecked());
-}
-
-void Probes::enable_all_probes()
-{
- set_all_probes(true);
-}
-
-void Probes::disable_all_probes()
-{
- set_all_probes(false);
-}
-
-} // popups
-} // pv
+++ /dev/null
-/*
- * This file is part of the PulseView project.
- *
- * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef PULSEVIEW_PV_POPUPS_PROBES_H
-#define PULSEVIEW_PV_POPUPS_PROBES_H
-
-#include <map>
-#include <memory>
-#include <vector>
-
-#include <QFormLayout>
-#include <QHBoxLayout>
-#include <QPushButton>
-#include <QSignalMapper>
-
-#include <pv/widgets/popup.h>
-
-struct sr_channel_group;
-
-class QCheckBox;
-class QGridLayout;
-
-namespace pv {
-
-class SigSession;
-
-namespace prop {
-namespace binding {
-class DeviceOptions;
-}
-}
-
-namespace view {
-class Signal;
-}
-
-namespace popups {
-
-class Probes : public pv::widgets::Popup
-{
- Q_OBJECT
-
-public:
- Probes(SigSession &_session, QWidget *parent);
-
-private:
- void set_all_probes(bool set);
-
- void populate_group(const sr_channel_group *group,
- const std::vector< std::shared_ptr<pv::view::Signal> > sigs);
-
- QGridLayout* create_channel_group_grid(
- const std::vector< std::shared_ptr<pv::view::Signal> > sigs);
-
-private:
- void showEvent(QShowEvent *e);
-
-private Q_SLOTS:
- void on_probe_checked(QWidget *widget);
-
- void enable_all_probes();
- void disable_all_probes();
-
-private:
- pv::SigSession &_session;
-
- QFormLayout _layout;
-
- bool _updating_probes;
-
- std::vector< std::shared_ptr<pv::prop::binding::DeviceOptions> >
- _group_bindings;
- std::map< QCheckBox*, std::shared_ptr<pv::view::Signal> >
- _check_box_signal_map;
-
- QHBoxLayout _buttons_bar;
- QPushButton _enable_all_probes;
- QPushButton _disable_all_probes;
-
- QSignalMapper _check_box_mapper;
-};
-
-} // popups
-} // pv
-
-#endif // PULSEVIEW_PV_POPUPS_PROBES_H
assert(_dev_inst->dev_inst());
- // Check that at least one probe is enabled
+ // Check that at least one channel is enabled
const GSList *l;
for (l = _dev_inst->dev_inst()->channels; l; l = l->next) {
- sr_channel *const probe = (sr_channel*)l->data;
- assert(probe);
- if (probe->enabled)
+ sr_channel *const channel = (sr_channel*)l->data;
+ assert(channel);
+ if (channel->enabled)
break;
}
#ifdef ENABLE_DECODE
bool SigSession::add_decoder(srd_decoder *const dec)
{
- map<const srd_channel*, shared_ptr<view::LogicSignal> > probes;
+ map<const srd_channel*, shared_ptr<view::LogicSignal> > channels;
shared_ptr<data::DecoderStack> decoder_stack;
try
decoder_stack = shared_ptr<data::DecoderStack>(
new data::DecoderStack(*this, dec));
- // Make a list of all the probes
- std::vector<const srd_channel*> all_probes;
+ // Make a list of all the channels
+ std::vector<const srd_channel*> all_channels;
for(const GSList *i = dec->channels; i; i = i->next)
- all_probes.push_back((const srd_channel*)i->data);
+ all_channels.push_back((const srd_channel*)i->data);
for(const GSList *i = dec->opt_channels; i; i = i->next)
- all_probes.push_back((const srd_channel*)i->data);
+ all_channels.push_back((const srd_channel*)i->data);
- // Auto select the initial probes
- for (const srd_channel *pdch : all_probes)
+ // Auto select the initial channels
+ for (const srd_channel *pdch : all_channels)
for (shared_ptr<view::Signal> s : _signals)
{
shared_ptr<view::LogicSignal> l =
if (l && QString::fromUtf8(pdch->name).
toLower().contains(
l->get_name().toLower()))
- probes[pdch] = l;
+ channels[pdch] = l;
}
assert(decoder_stack);
assert(!decoder_stack->stack().empty());
assert(decoder_stack->stack().front());
- decoder_stack->stack().front()->set_probes(probes);
+ decoder_stack->stack().front()->set_channels(channels);
// Create the decode signal
shared_ptr<view::DecodeTrace> d(
assert(dev_inst);
assert(_capture_state == Stopped);
- unsigned int logic_probe_count = 0;
+ unsigned int logic_channel_count = 0;
// Clear the decode traces
_decode_traces.clear();
assert(dev_inst->dev_inst());
for (const GSList *l = dev_inst->dev_inst()->channels;
l; l = l->next) {
- const sr_channel *const probe = (const sr_channel *)l->data;
- if (!probe->enabled)
+ const sr_channel *const channel = (const sr_channel *)l->data;
+ if (!channel->enabled)
continue;
- switch(probe->type) {
+ switch(channel->type) {
case SR_CHANNEL_LOGIC:
- logic_probe_count++;
+ logic_channel_count++;
break;
}
}
lock_guard<mutex> data_lock(_data_mutex);
_logic_data.reset();
- if (logic_probe_count != 0) {
+ if (logic_channel_count != 0) {
_logic_data.reset(new data::Logic(
- logic_probe_count));
+ logic_channel_count));
assert(_logic_data);
}
}
for (const GSList *l = dev_inst->dev_inst()->channels;
l; l = l->next) {
shared_ptr<view::Signal> signal;
- sr_channel *const probe = (sr_channel *)l->data;
- assert(probe);
+ sr_channel *const channel = (sr_channel *)l->data;
+ assert(channel);
- switch(probe->type) {
+ switch(channel->type) {
case SR_CHANNEL_LOGIC:
signal = shared_ptr<view::Signal>(
new view::LogicSignal(dev_inst,
- probe, _logic_data));
+ channel, _logic_data));
break;
case SR_CHANNEL_ANALOG:
new data::Analog());
signal = shared_ptr<view::Signal>(
new view::AnalogSignal(dev_inst,
- probe, data));
+ channel, data));
break;
}
signals_changed();
}
-shared_ptr<view::Signal> SigSession::signal_from_probe(
- const sr_channel *probe) const
+shared_ptr<view::Signal> SigSession::signal_from_channel(
+ const sr_channel *channel) const
{
lock_guard<mutex> lock(_signals_mutex);
for (shared_ptr<view::Signal> sig : _signals) {
assert(sig);
- if (sig->probe() == probe)
+ if (sig->channel() == channel)
return sig;
}
return shared_ptr<view::Signal>();
{
lock_guard<mutex> lock(_data_mutex);
- const unsigned int probe_count = g_slist_length(analog.channels);
- const size_t sample_count = analog.num_samples / probe_count;
+ const unsigned int channel_count = g_slist_length(analog.channels);
+ const size_t sample_count = analog.num_samples / channel_count;
const float *data = analog.data;
bool sweep_beginning = false;
{
shared_ptr<data::AnalogSnapshot> snapshot;
- sr_channel *const probe = (sr_channel*)p->data;
- assert(probe);
+ sr_channel *const channel = (sr_channel*)p->data;
+ assert(channel);
- // Try to get the snapshot of the probe
+ // Try to get the snapshot of the channel
const map< const sr_channel*, shared_ptr<data::AnalogSnapshot> >::
- iterator iter = _cur_analog_snapshots.find(probe);
+ iterator iter = _cur_analog_snapshots.find(channel);
if (iter != _cur_analog_snapshots.end())
snapshot = (*iter).second;
else
// in the sweep containing this snapshot.
sweep_beginning = true;
- // Create a snapshot, keep it in the maps of probes
+ // Create a snapshot, keep it in the maps of channels
snapshot = shared_ptr<data::AnalogSnapshot>(
new data::AnalogSnapshot(_dev_inst->get_sample_limit()));
- _cur_analog_snapshots[probe] = snapshot;
+ _cur_analog_snapshots[channel] = snapshot;
- // Find the annalog data associated with the probe
+ // Find the annalog data associated with the channel
shared_ptr<view::AnalogSignal> sig =
dynamic_pointer_cast<view::AnalogSignal>(
- signal_from_probe(probe));
+ signal_from_channel(channel));
assert(sig);
shared_ptr<data::Analog> data(sig->analog_data());
// Append the samples in the snapshot
snapshot->append_interleaved_samples(data++, sample_count,
- probe_count);
+ channel_count);
}
if (sweep_beginning) {
void update_signals(std::shared_ptr<device::DevInst> dev_inst);
- std::shared_ptr<view::Signal> signal_from_probe(
- const sr_channel *probe) const;
+ std::shared_ptr<view::Signal> signal_from_channel(
+ const sr_channel *channel) const;
void read_sample_rate(const sr_dev_inst *const sdi);
const shared_ptr<data::LogicSnapshot> snapshot(snapshots.front());
assert(snapshot);
- // Make a list of probes
- char **const probes = new char*[sigs.size() + 1];
+ // Make a list of channels
+ char **const channels = new char*[sigs.size() + 1];
for (size_t i = 0; i < sigs.size(); i++) {
shared_ptr<view::Signal> sig(sigs[i]);
assert(sig);
- probes[i] = strdup(sig->get_name().toUtf8().constData());
+ channels[i] = strdup(sig->get_name().toUtf8().constData());
}
- probes[sigs.size()] = NULL;
+ channels[sigs.size()] = NULL;
// Begin storing
if (sr_session_save_init(SigSession::_sr_session, _file_name.c_str(),
- data->samplerate(), probes) != SR_OK) {
+ data->samplerate(), channels) != SR_OK) {
_error = tr("Error while saving.");
return false;
}
- // Delete the probes array
+ // Delete the channels array
for (size_t i = 0; i <= sigs.size(); i++)
- free(probes[i]);
- delete[] probes;
+ free(channels[i]);
+ delete[] channels;
_thread = std::thread(&StoreSession::store_proc, this, snapshot);
return true;
#include <pv/devicemanager.h>
#include <pv/device/devinst.h>
#include <pv/popups/deviceoptions.h>
-#include <pv/popups/probes.h>
+#include <pv/popups/channels.h>
#include <pv/util.h>
using std::map;
_updating_device_selector(false),
_configure_button(this),
_configure_button_action(NULL),
- _probes_button(this),
+ _channels_button(this),
_sample_count(" samples", this),
_sample_rate("Hz", this),
_updating_sample_rate(false),
_configure_button.setIcon(QIcon::fromTheme("configure",
QIcon(":/icons/configure.png")));
- _probes_button.setIcon(QIcon::fromTheme("probes",
- QIcon(":/icons/probes.svg")));
+ _channels_button.setIcon(QIcon::fromTheme("channels",
+ QIcon(":/icons/channels.svg")));
_run_stop_button.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
addWidget(&_device_selector);
_configure_button_action = addWidget(&_configure_button);
- addWidget(&_probes_button);
+ addWidget(&_channels_button);
addWidget(&_sample_count);
addWidget(&_sample_rate);
!opts->binding().properties().empty());
_configure_button.set_popup(opts);
- // Update the probes popup
- Probes *const probes = new Probes(_session, this);
- _probes_button.set_popup(probes);
+ // Update the channels popup
+ Channels *const channels = new Channels(_session, this);
+ _channels_button.set_popup(channels);
// Update supported options.
_sample_count_supported = false;
pv::widgets::PopupToolButton _configure_button;
QAction *_configure_button_action;
- pv::widgets::PopupToolButton _probes_button;
+ pv::widgets::PopupToolButton _channels_button;
pv::widgets::SweepTimingWidget _sample_count;
pv::widgets::SweepTimingWidget _sample_rate;
const float AnalogSignal::EnvelopeThreshold = 256.0f;
AnalogSignal::AnalogSignal(shared_ptr<pv::device::DevInst> dev_inst,
- const sr_channel *const probe, shared_ptr<data::Analog> data) :
- Signal(dev_inst, probe),
+ const sr_channel *const channel, shared_ptr<data::Analog> data) :
+ Signal(dev_inst, channel),
_data(data),
_scale(1.0f)
{
- _colour = SignalColours[probe->index % countof(SignalColours)];
+ _colour = SignalColours[channel->index % countof(SignalColours)];
}
AnalogSignal::~AnalogSignal()
void AnalogSignal::paint_back(QPainter &p, int left, int right)
{
- if (_probe->enabled)
+ if (_channel->enabled)
paint_axis(p, get_y(), left, right);
}
const double offset = _view->offset();
- if (!_probe->enabled)
+ if (!_channel->enabled)
return;
const deque< shared_ptr<pv::data::AnalogSnapshot> > &snapshots =
public:
AnalogSignal(std::shared_ptr<pv::device::DevInst> dev_inst,
- const sr_channel *const probe,
+ const sr_channel *const channel,
std::shared_ptr<pv::data::Analog> data);
virtual ~AnalogSignal();
// Add the decoder options
_bindings.clear();
- _probe_selectors.clear();
+ _channel_selectors.clear();
_decoder_forms.clear();
const list< shared_ptr<Decoder> >& stack = _decoder_stack->stack();
const list< shared_ptr<Decoder> > &stack = _decoder_stack->stack();
- // We get the logic data of the first probe in the list.
+ // We get the logic data of the first channel in the list.
// This works because we are currently assuming all
// LogicSignals have the same data/snapshot
for (const shared_ptr<Decoder> &dec : stack)
for(l = decoder->channels; l; l = l->next) {
const struct srd_channel *const pdch =
(struct srd_channel *)l->data;
- QComboBox *const combo = create_probe_selector(parent, dec, pdch);
+ QComboBox *const combo = create_channel_selector(parent, dec, pdch);
connect(combo, SIGNAL(currentIndexChanged(int)),
- this, SLOT(on_probe_selected(int)));
+ this, SLOT(on_channel_selected(int)));
decoder_form->addRow(tr("<b>%1</b> (%2) *")
.arg(QString::fromUtf8(pdch->name))
.arg(QString::fromUtf8(pdch->desc)), combo);
- const ProbeSelector s = {combo, dec, pdch};
- _probe_selectors.push_back(s);
+ const ChannelSelector s = {combo, dec, pdch};
+ _channel_selectors.push_back(s);
}
// Add the optional channels
for(l = decoder->opt_channels; l; l = l->next) {
const struct srd_channel *const pdch =
(struct srd_channel *)l->data;
- QComboBox *const combo = create_probe_selector(parent, dec, pdch);
+ QComboBox *const combo = create_channel_selector(parent, dec, pdch);
connect(combo, SIGNAL(currentIndexChanged(int)),
- this, SLOT(on_probe_selected(int)));
+ this, SLOT(on_channel_selected(int)));
decoder_form->addRow(tr("<b>%1</b> (%2)")
.arg(QString::fromUtf8(pdch->name))
.arg(QString::fromUtf8(pdch->desc)), combo);
- const ProbeSelector s = {combo, dec, pdch};
- _probe_selectors.push_back(s);
+ const ChannelSelector s = {combo, dec, pdch};
+ _channel_selectors.push_back(s);
}
// Add the options
_decoder_forms.push_back(group);
}
-QComboBox* DecodeTrace::create_probe_selector(
+QComboBox* DecodeTrace::create_channel_selector(
QWidget *parent, const shared_ptr<data::decode::Decoder> &dec,
const srd_channel *const pdch)
{
const vector< shared_ptr<Signal> > sigs = _session.get_signals();
assert(_decoder_stack);
- const auto probe_iter = dec->channels().find(pdch);
+ const auto channel_iter = dec->channels().find(pdch);
QComboBox *selector = new QComboBox(parent);
selector->addItem("-", qVariantFromValue((void*)NULL));
- if (probe_iter == dec->channels().end())
+ if (channel_iter == dec->channels().end())
selector->setCurrentIndex(0);
for(size_t i = 0; i < sigs.size(); i++) {
{
selector->addItem(s->get_name(),
qVariantFromValue((void*)s.get()));
- if ((*probe_iter).second == s)
+ if ((*channel_iter).second == s)
selector->setCurrentIndex(i + 1);
}
}
return selector;
}
-void DecodeTrace::commit_decoder_probes(shared_ptr<data::decode::Decoder> &dec)
+void DecodeTrace::commit_decoder_channels(shared_ptr<data::decode::Decoder> &dec)
{
assert(dec);
- map<const srd_channel*, shared_ptr<LogicSignal> > probe_map;
+ map<const srd_channel*, shared_ptr<LogicSignal> > channel_map;
const vector< shared_ptr<Signal> > sigs = _session.get_signals();
- for (const ProbeSelector &s : _probe_selectors)
+ for (const ChannelSelector &s : _channel_selectors)
{
if(s._decoder != dec)
break;
for (shared_ptr<Signal> sig : sigs)
if(sig.get() == selection) {
- probe_map[s._pdch] =
+ channel_map[s._pdch] =
dynamic_pointer_cast<LogicSignal>(sig);
break;
}
}
- dec->set_probes(probe_map);
+ dec->set_channels(channel_map);
}
-void DecodeTrace::commit_probes()
+void DecodeTrace::commit_channels()
{
assert(_decoder_stack);
for (shared_ptr<data::decode::Decoder> dec : _decoder_stack->stack())
- commit_decoder_probes(dec);
+ commit_decoder_channels(dec);
_decoder_stack->begin_decode();
}
_session.remove_decode_signal(this);
}
-void DecodeTrace::on_probe_selected(int)
+void DecodeTrace::on_channel_selected(int)
{
- commit_probes();
+ commit_channels();
}
void DecodeTrace::on_stack_decoder(srd_decoder *decoder)
Q_OBJECT
private:
- struct ProbeSelector
+ struct ChannelSelector
{
const QComboBox *_combo;
const std::shared_ptr<pv::data::decode::Decoder> _decoder;
std::shared_ptr<pv::data::decode::Decoder> &dec,
QWidget *parent, QFormLayout *form);
- QComboBox* create_probe_selector(QWidget *parent,
+ QComboBox* create_channel_selector(QWidget *parent,
const std::shared_ptr<pv::data::decode::Decoder> &dec,
const srd_channel *const pdch);
- void commit_decoder_probes(
+ void commit_decoder_channels(
std::shared_ptr<data::decode::Decoder> &dec);
- void commit_probes();
+ void commit_channels();
private Q_SLOTS:
void on_new_decode_data();
void on_delete();
- void on_probe_selected(int);
+ void on_channel_selected(int);
void on_stack_decoder(srd_decoder *decoder);
std::list< std::shared_ptr<pv::prop::binding::DecoderOptions> >
_bindings;
- std::list<ProbeSelector> _probe_selectors;
+ std::list<ChannelSelector> _channel_selectors;
std::vector<pv::widgets::DecoderGroupBox*> _decoder_forms;
std::vector<QString> _cur_row_headings;
};
LogicSignal::LogicSignal(shared_ptr<pv::device::DevInst> dev_inst,
- const sr_channel *const probe, shared_ptr<data::Logic> data) :
- Signal(dev_inst, probe),
+ const sr_channel *const channel, shared_ptr<data::Logic> data) :
+ Signal(dev_inst, channel),
_data(data),
_trigger_none(NULL),
_trigger_rising(NULL),
struct sr_trigger_match *match;
const GSList *l, *m;
- _colour = SignalColours[probe->index % countof(SignalColours)];
+ _colour = SignalColours[channel->index % countof(SignalColours)];
/* Populate this channel's trigger setting with whatever we
* find in the current session trigger, if anything. */
stage = (struct sr_trigger_stage *)l->data;
for (m = stage->matches; m && !_trigger_match; m = m->next) {
match = (struct sr_trigger_match *)m->data;
- if (match->channel == _probe)
+ if (match->channel == _channel)
_trigger_match = match->match;
}
}
void LogicSignal::paint_back(QPainter &p, int left, int right)
{
- if (_probe->enabled)
+ if (_channel->enabled)
paint_axis(p, get_y(), left, right);
}
vector< pair<int64_t, bool> > edges;
- assert(_probe);
+ assert(_channel);
assert(_data);
assert(right >= left);
const double offset = _view->offset();
- if (!_probe->enabled)
+ if (!_channel->enabled)
return;
const float high_offset = y - View::SignalHeight + 0.5f;
snapshot->get_subsampled_edges(edges,
min(max((int64_t)floor(start), (int64_t)0), last_sample),
min(max((int64_t)ceil(end), (int64_t)0), last_sample),
- samples_per_pixel / Oversampling, _probe->index);
+ samples_per_pixel / Oversampling, _channel->index);
assert(edges.size() >= 2);
// Paint the edges
public:
LogicSignal(std::shared_ptr<pv::device::DevInst> dev_inst,
- const sr_channel *const probe,
+ const sr_channel *const channel,
std::shared_ptr<pv::data::Logic> data);
virtual ~LogicSignal();
namespace pv {
namespace view {
-const char *const ProbeNames[] = {
+const char *const ChannelNames[] = {
"CLK",
"DATA",
"IN",
};
Signal::Signal(shared_ptr<pv::device::DevInst> dev_inst,
- const sr_channel *const probe) :
- Trace(probe->name),
+ const sr_channel *const channel) :
+ Trace(channel->name),
_dev_inst(dev_inst),
- _probe(probe),
+ _channel(channel),
_name_widget(NULL),
_updating_name_widget(false)
{
- assert(_probe);
+ assert(_channel);
}
void Signal::set_name(QString name)
bool Signal::enabled() const
{
- return _probe->enabled;
+ return _channel->enabled;
}
void Signal::enable(bool enable)
{
- _dev_inst->enable_probe(_probe, enable);
+ _dev_inst->enable_channel(_channel, enable);
visibility_changed();
}
-const sr_channel* Signal::probe() const
+const sr_channel* Signal::channel() const
{
- return _probe;
+ return _channel;
}
void Signal::populate_popup_form(QWidget *parent, QFormLayout *form)
_name_widget = new QComboBox(parent);
_name_widget->setEditable(true);
- for(unsigned int i = 0; i < countof(ProbeNames); i++)
- _name_widget->insertItem(i, ProbeNames[i]);
+ for(unsigned int i = 0; i < countof(ChannelNames); i++)
+ _name_widget->insertItem(i, ChannelNames[i]);
index = _name_widget->findText(_name, Qt::MatchExactly);
protected:
Signal(std::shared_ptr<pv::device::DevInst> dev_inst,
- const sr_channel *const probe);
+ const sr_channel *const channel);
public:
/**
void enable(bool enable = true);
- const sr_channel* probe() const;
+ const sr_channel* channel() const;
virtual void populate_popup_form(QWidget *parent, QFormLayout *form);
protected:
std::shared_ptr<pv::device::DevInst> _dev_inst;
- const sr_channel *const _probe;
+ const sr_channel *const _channel;
QComboBox *_name_widget;
bool _updating_name_widget;
const srd_decoder *const d = (srd_decoder*)l->data;
assert(d);
- const bool have_probes = (d->channels || d->opt_channels) != 0;
- if (first_level_decoder == have_probes) {
+ const bool have_channels = (d->channels || d->opt_channels) != 0;
+ if (first_level_decoder == have_channels) {
QAction *const action =
addAction(QString::fromUtf8(d->name));
action->setData(qVariantFromValue(l->data));
}
/*
- * This test checks the rendering of wide data (more than 8 probes)
+ * This test checks the rendering of wide data (more than 8 channels)
* Probe signals are either all-high, or all-low, but are interleaved such that
- * they would toggle during every sample if treated like 8 probes.
+ * they would toggle during every sample if treated like 8 channels.
* The packet contains a large number of samples, so the mipmap generation kicks
* in.
*